Belos Package Browser (Single Doxygen Collection) Development
Public Member Functions | Private Member Functions | Private Attributes
MyMultiVec< ScalarType > Class Template Reference

Simple example of a user's defined Belos::MultiVec class. More...

#include <MyMultiVec.hpp>

Inheritance diagram for MyMultiVec< ScalarType >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 MyMultiVec (const int Length, const int NumberVecs)
 Constructor for a NumberVecs vectors of length Length.
 MyMultiVec (const int Length, const std::vector< ScalarType * > &rhs)
 Constructor with already allocated memory.
 MyMultiVec (const MyMultiVec &rhs)
 Copy constructor, performs a deep copy.
 ~MyMultiVec ()
 Destructor.
MyMultiVecClone (const int NumberVecs) const
 Returns a clone of the current std::vector.
MyMultiVecCloneCopy () const
 Creates a new Belos::MultiVec and copies contents of *this into the new std::vector (deep copy).
MyMultiVecCloneCopy (const std::vector< int > &index) const
 Returns a clone copy of specified vectors.
MyMultiVecCloneViewNonConst (const std::vector< int > &index)
 Returns a view of current std::vector (shallow copy)
const MyMultiVecCloneView (const std::vector< int > &index) const
 Returns a view of current std::vector (shallow copy), const version.
int GetVecLength () const
 Obtain the std::vector length of *this multivector block.
int GetNumberVecs () const
 Obtain the number of vectors in *this multivector block.
void MvTimesMatAddMv (const ScalarType alpha, const Belos::MultiVec< ScalarType > &A, const Teuchos::SerialDenseMatrix< int, ScalarType > &B, const ScalarType beta)
 Update *this with alpha * A * B + beta * (*this).
void MvAddMv (const ScalarType alpha, const Belos::MultiVec< ScalarType > &A, const ScalarType beta, const Belos::MultiVec< ScalarType > &B)
 Replace *this with alpha * A + beta * B.
void MvScale (const ScalarType alpha)
 Scale each element of the vectors in *this with alpha.
void MvScale (const std::vector< ScalarType > &alpha)
 Scale each element of the i-th vector in *this with alpha[i].
void MvTransMv (const ScalarType alpha, const Belos::MultiVec< ScalarType > &A, Teuchos::SerialDenseMatrix< int, ScalarType > &B) const
 Compute a dense matrix B through the matrix-matrix multiply alpha * A^T * (*this).
void MvDot (const Belos::MultiVec< ScalarType > &A, std::vector< ScalarType > &b) const
 Compute a std::vector b where the components are the individual dot-products, i.e.b[i] = A[i]^T*this[i] where A[i] is the i-th column of A.
void MvNorm (std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec, Belos::NormType type=Belos::TwoNorm) const
 Compute the 2-norm of each individual std::vector of *this. Upon return, normvec[i] holds the 2-norm of the i-th std::vector of *this.
void SetBlock (const Belos::MultiVec< ScalarType > &A, const std::vector< int > &index)
 Copy the vectors in A to a set of vectors in *this. The numvecs vectors in A are copied to a subset of vectors in *this indicated by the indices given in index.
void MvRandom ()
 Replace the vectors in *this with random vectors.
void MvInit (const ScalarType alpha)
 Replace each element of the vectors in *this with alpha.
void MvPrint (std::ostream &os) const
 Print the *this multivector.
ScalarType & operator() (const int i, const int j)
const ScalarType & operator() (const int i, const int j) const
ScalarType * operator[] (int v)
ScalarType * operator[] (int v) const

Private Member Functions

void Check ()

Private Attributes

const int Length_
 Length of the vectors.
const int NumberVecs_
 Number of multi-vectors.
std::vector< ScalarType * > data_
 Pointers to the storage of the vectors.
std::vector< bool > ownership_
 If true, then this object owns the vectors and must free them in dtor.

Detailed Description

template<class ScalarType>
class MyMultiVec< ScalarType >

Simple example of a user's defined Belos::MultiVec class.

This is a simple, single processor example of user's defined MultiVec-derived class. The class is templated with ScalarType; possible choices are, for example, "float", "double", or "std::complex<double>".

Author:
Oscar Chinallato (ETHZ/ICOS) and Marzio Sala (ETHZ/COLAB)
Date:
Last modified on 01-Nov-05

Definition at line 62 of file MyMultiVec.hpp.


Constructor & Destructor Documentation

template<class ScalarType>
MyMultiVec< ScalarType >::MyMultiVec ( const int  Length,
const int  NumberVecs 
) [inline]

Constructor for a NumberVecs vectors of length Length.

Definition at line 67 of file MyMultiVec.hpp.

template<class ScalarType>
MyMultiVec< ScalarType >::MyMultiVec ( const int  Length,
const std::vector< ScalarType * > &  rhs 
) [inline]

Constructor with already allocated memory.

Definition at line 88 of file MyMultiVec.hpp.

template<class ScalarType>
MyMultiVec< ScalarType >::MyMultiVec ( const MyMultiVec< ScalarType > &  rhs) [inline]

Copy constructor, performs a deep copy.

Definition at line 107 of file MyMultiVec.hpp.

template<class ScalarType>
MyMultiVec< ScalarType >::~MyMultiVec ( ) [inline]

Destructor.

Definition at line 130 of file MyMultiVec.hpp.


Member Function Documentation

template<class ScalarType>
MyMultiVec* MyMultiVec< ScalarType >::Clone ( const int  NumberVecs) const [inline, virtual]

Returns a clone of the current std::vector.

Implements Belos::MultiVec< ScalarType >.

Definition at line 138 of file MyMultiVec.hpp.

template<class ScalarType>
MyMultiVec* MyMultiVec< ScalarType >::CloneCopy ( ) const [inline, virtual]

Creates a new Belos::MultiVec and copies contents of *this into the new std::vector (deep copy).

Returns:
Pointer to the new multivector

Implements Belos::MultiVec< ScalarType >.

Definition at line 151 of file MyMultiVec.hpp.

template<class ScalarType>
MyMultiVec* MyMultiVec< ScalarType >::CloneCopy ( const std::vector< int > &  index) const [inline, virtual]

Returns a clone copy of specified vectors.

Implements Belos::MultiVec< ScalarType >.

Definition at line 157 of file MyMultiVec.hpp.

template<class ScalarType>
MyMultiVec* MyMultiVec< ScalarType >::CloneViewNonConst ( const std::vector< int > &  index) [inline, virtual]

Returns a view of current std::vector (shallow copy)

Implements Belos::MultiVec< ScalarType >.

Definition at line 172 of file MyMultiVec.hpp.

template<class ScalarType>
const MyMultiVec* MyMultiVec< ScalarType >::CloneView ( const std::vector< int > &  index) const [inline, virtual]

Returns a view of current std::vector (shallow copy), const version.

Implements Belos::MultiVec< ScalarType >.

Definition at line 184 of file MyMultiVec.hpp.

template<class ScalarType>
int MyMultiVec< ScalarType >::GetVecLength ( ) const [inline, virtual]

Obtain the std::vector length of *this multivector block.

Implements Belos::MultiVec< ScalarType >.

Definition at line 195 of file MyMultiVec.hpp.

template<class ScalarType>
int MyMultiVec< ScalarType >::GetNumberVecs ( ) const [inline, virtual]

Obtain the number of vectors in *this multivector block.

Implements Belos::MultiVec< ScalarType >.

Definition at line 200 of file MyMultiVec.hpp.

template<class ScalarType>
void MyMultiVec< ScalarType >::MvTimesMatAddMv ( const ScalarType  alpha,
const Belos::MultiVec< ScalarType > &  A,
const Teuchos::SerialDenseMatrix< int, ScalarType > &  B,
const ScalarType  beta 
) [inline, virtual]

Update *this with alpha * A * B + beta * (*this).

Implements Belos::MultiVec< ScalarType >.

Definition at line 206 of file MyMultiVec.hpp.

template<class ScalarType>
void MyMultiVec< ScalarType >::MvAddMv ( const ScalarType  alpha,
const Belos::MultiVec< ScalarType > &  A,
const ScalarType  beta,
const Belos::MultiVec< ScalarType > &  B 
) [inline, virtual]

Replace *this with alpha * A + beta * B.

Implements Belos::MultiVec< ScalarType >.

Definition at line 259 of file MyMultiVec.hpp.

template<class ScalarType>
void MyMultiVec< ScalarType >::MvScale ( const ScalarType  alpha) [inline, virtual]

Scale each element of the vectors in *this with alpha.

Implements Belos::MultiVec< ScalarType >.

Definition at line 284 of file MyMultiVec.hpp.

template<class ScalarType>
void MyMultiVec< ScalarType >::MvScale ( const std::vector< ScalarType > &  alpha) [inline, virtual]

Scale each element of the i-th vector in *this with alpha[i].

Implements Belos::MultiVec< ScalarType >.

Definition at line 294 of file MyMultiVec.hpp.

template<class ScalarType>
void MyMultiVec< ScalarType >::MvTransMv ( const ScalarType  alpha,
const Belos::MultiVec< ScalarType > &  A,
Teuchos::SerialDenseMatrix< int, ScalarType > &  B 
) const [inline, virtual]

Compute a dense matrix B through the matrix-matrix multiply alpha * A^T * (*this).

Implements Belos::MultiVec< ScalarType >.

Definition at line 305 of file MyMultiVec.hpp.

template<class ScalarType>
void MyMultiVec< ScalarType >::MvDot ( const Belos::MultiVec< ScalarType > &  A,
std::vector< ScalarType > &  b 
) const [inline, virtual]

Compute a std::vector b where the components are the individual dot-products, i.e.b[i] = A[i]^T*this[i] where A[i] is the i-th column of A.

Implements Belos::MultiVec< ScalarType >.

Definition at line 329 of file MyMultiVec.hpp.

template<class ScalarType>
void MyMultiVec< ScalarType >::MvNorm ( std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &  normvec,
Belos::NormType  type = Belos::TwoNorm 
) const [inline, virtual]

Compute the 2-norm of each individual std::vector of *this. Upon return, normvec[i] holds the 2-norm of the i-th std::vector of *this.

Implements Belos::MultiVec< ScalarType >.

Definition at line 349 of file MyMultiVec.hpp.

template<class ScalarType>
void MyMultiVec< ScalarType >::SetBlock ( const Belos::MultiVec< ScalarType > &  A,
const std::vector< int > &  index 
) [inline, virtual]

Copy the vectors in A to a set of vectors in *this. The numvecs vectors in A are copied to a subset of vectors in *this indicated by the indices given in index.

Implements Belos::MultiVec< ScalarType >.

Definition at line 370 of file MyMultiVec.hpp.

template<class ScalarType>
void MyMultiVec< ScalarType >::MvRandom ( ) [inline, virtual]

Replace the vectors in *this with random vectors.

Implements Belos::MultiVec< ScalarType >.

Definition at line 388 of file MyMultiVec.hpp.

template<class ScalarType>
void MyMultiVec< ScalarType >::MvInit ( const ScalarType  alpha) [inline, virtual]

Replace each element of the vectors in *this with alpha.

Implements Belos::MultiVec< ScalarType >.

Definition at line 398 of file MyMultiVec.hpp.

template<class ScalarType>
void MyMultiVec< ScalarType >::MvPrint ( std::ostream &  os) const [inline, virtual]

Print the *this multivector.

Implements Belos::MultiVec< ScalarType >.

Definition at line 407 of file MyMultiVec.hpp.

template<class ScalarType>
ScalarType& MyMultiVec< ScalarType >::operator() ( const int  i,
const int  j 
) [inline]

Definition at line 421 of file MyMultiVec.hpp.

template<class ScalarType>
const ScalarType& MyMultiVec< ScalarType >::operator() ( const int  i,
const int  j 
) const [inline]

Definition at line 429 of file MyMultiVec.hpp.

template<class ScalarType>
ScalarType* MyMultiVec< ScalarType >::operator[] ( int  v) [inline]

Definition at line 437 of file MyMultiVec.hpp.

template<class ScalarType>
ScalarType* MyMultiVec< ScalarType >::operator[] ( int  v) const [inline]

Definition at line 443 of file MyMultiVec.hpp.

template<class ScalarType>
void MyMultiVec< ScalarType >::Check ( ) [inline, private]

Definition at line 449 of file MyMultiVec.hpp.


Member Data Documentation

template<class ScalarType>
const int MyMultiVec< ScalarType >::Length_ [private]

Length of the vectors.

Definition at line 459 of file MyMultiVec.hpp.

template<class ScalarType>
const int MyMultiVec< ScalarType >::NumberVecs_ [private]

Number of multi-vectors.

Definition at line 461 of file MyMultiVec.hpp.

template<class ScalarType>
std::vector<ScalarType*> MyMultiVec< ScalarType >::data_ [private]

Pointers to the storage of the vectors.

Definition at line 463 of file MyMultiVec.hpp.

template<class ScalarType>
std::vector<bool> MyMultiVec< ScalarType >::ownership_ [private]

If true, then this object owns the vectors and must free them in dtor.

Definition at line 465 of file MyMultiVec.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines