Belos Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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]

Public Member Functions

 MyMultiVec (const ptrdiff_t Length, const int NumberVecs)
 Constructor for a NumberVecs vectors of length Length. More...
 
 MyMultiVec (const ptrdiff_t Length, const std::vector< ScalarType * > &rhs)
 Constructor with already allocated memory. More...
 
 MyMultiVec (const MyMultiVec &rhs)
 Copy constructor, performs a deep copy. More...
 
 ~MyMultiVec ()
 Destructor. More...
 
MyMultiVecClone (const int NumberVecs) const
 Returns a clone of the current std::vector. More...
 
MyMultiVecCloneCopy () const
 Create a new MultiVec and copy contents of *this into it (deep copy). More...
 
MyMultiVecCloneCopy (const std::vector< int > &index) const
 Returns a clone copy of specified vectors. More...
 
MyMultiVecCloneViewNonConst (const std::vector< int > &index)
 Returns a view of current std::vector (shallow copy) More...
 
const MyMultiVecCloneView (const std::vector< int > &index) const
 Returns a view of current std::vector (shallow copy), const version. More...
 
ptrdiff_t GetGlobalLength () const
 The number of rows in the multivector. More...
 
int GetNumberVecs () const
 The number of vectors (i.e., columns) in the multivector. More...
 
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). More...
 
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. More...
 
void MvScale (const ScalarType alpha)
 Scale each element of the vectors in *this with alpha. More...
 
void MvScale (const std::vector< ScalarType > &alpha)
 Scale each element of the i-th vector in *this with alpha[i]. More...
 
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). More...
 
void MvDot (const Belos::MultiVec< ScalarType > &A, std::vector< ScalarType > &b) const
 Compute the dot product of each column of *this with the corresponding column of A. More...
 
void MvNorm (std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec, Belos::NormType type=Belos::TwoNorm) const
 Compute the norm of each vector in *this. More...
 
void SetBlock (const Belos::MultiVec< ScalarType > &A, const std::vector< int > &index)
 Copy the vectors in A to a set of vectors in *this. More...
 
void MvRandom ()
 Fill all the vectors in *this with random numbers. More...
 
void MvInit (const ScalarType alpha)
 Replace each element of the vectors in *this with alpha. More...
 
void MvPrint (std::ostream &os) const
 Print *this multivector to the os output stream. More...
 
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
 
- Public Member Functions inherited from Belos::MultiVec< ScalarType >
 MultiVec ()
 Default constructor. More...
 
virtual ~MultiVec ()
 Destructor (virtual for memory safety of derived classes). More...
 

Private Member Functions

void Check ()
 

Private Attributes

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

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 65 of file MyMultiVec.hpp.

Constructor & Destructor Documentation

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

Constructor for a NumberVecs vectors of length Length.

Definition at line 70 of file MyMultiVec.hpp.

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

Constructor with already allocated memory.

Definition at line 90 of file MyMultiVec.hpp.

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

Copy constructor, performs a deep copy.

Definition at line 108 of file MyMultiVec.hpp.

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

Destructor.

Definition at line 131 of file MyMultiVec.hpp.

Member Function Documentation

template<class ScalarType>
MyMultiVec* MyMultiVec< ScalarType >::Clone ( const int  NumberVecs) const
inlinevirtual

Returns a clone of the current std::vector.

Implements Belos::MultiVec< ScalarType >.

Definition at line 139 of file MyMultiVec.hpp.

template<class ScalarType>
MyMultiVec* MyMultiVec< ScalarType >::CloneCopy ( ) const
inlinevirtual

Create a new MultiVec and copy contents of *this into it (deep copy).

Returns
Pointer to the new multivector

Implements Belos::MultiVec< ScalarType >.

Definition at line 152 of file MyMultiVec.hpp.

template<class ScalarType>
MyMultiVec* MyMultiVec< ScalarType >::CloneCopy ( const std::vector< int > &  index) const
inlinevirtual

Returns a clone copy of specified vectors.

Implements Belos::MultiVec< ScalarType >.

Definition at line 158 of file MyMultiVec.hpp.

template<class ScalarType>
MyMultiVec* MyMultiVec< ScalarType >::CloneViewNonConst ( const std::vector< int > &  index)
inlinevirtual

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

Implements Belos::MultiVec< ScalarType >.

Definition at line 173 of file MyMultiVec.hpp.

template<class ScalarType>
const MyMultiVec* MyMultiVec< ScalarType >::CloneView ( const std::vector< int > &  index) const
inlinevirtual

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

Implements Belos::MultiVec< ScalarType >.

Definition at line 185 of file MyMultiVec.hpp.

template<class ScalarType>
ptrdiff_t MyMultiVec< ScalarType >::GetGlobalLength ( ) const
inlinevirtual

The number of rows in the multivector.

Implements Belos::MultiVec< ScalarType >.

Definition at line 197 of file MyMultiVec.hpp.

template<class ScalarType>
int MyMultiVec< ScalarType >::GetNumberVecs ( ) const
inlinevirtual

The number of vectors (i.e., columns) in the multivector.

Implements Belos::MultiVec< ScalarType >.

Definition at line 202 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 
)
inlinevirtual

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

Implements Belos::MultiVec< ScalarType >.

Definition at line 208 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 
)
inlinevirtual

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)
inlinevirtual

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

Implements Belos::MultiVec< ScalarType >.

Definition at line 282 of file MyMultiVec.hpp.

template<class ScalarType>
void MyMultiVec< ScalarType >::MvScale ( const std::vector< ScalarType > &  alpha)
inlinevirtual

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

Implements Belos::MultiVec< ScalarType >.

Definition at line 292 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
inlinevirtual

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

Implements Belos::MultiVec< ScalarType >.

Definition at line 303 of file MyMultiVec.hpp.

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

Compute the dot product of each column of *this with the corresponding column of A.

Compute a vector b whose entries are the individual dot-products. That is, b[i] = A[i]^H * (*this)[i] where A[i] is the i-th column of A.

Implements Belos::MultiVec< ScalarType >.

Definition at line 327 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
inlinevirtual

Compute the norm of each vector in *this.

Parameters
normvec[out] On output, normvec[i] holds the norm of the i-th vector of *this.
type[in] The type of norm to compute. The 2-norm is the default.

Implements Belos::MultiVec< ScalarType >.

Definition at line 347 of file MyMultiVec.hpp.

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

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 368 of file MyMultiVec.hpp.

template<class ScalarType>
void MyMultiVec< ScalarType >::MvRandom ( )
inlinevirtual

Fill all the vectors in *this with random numbers.

Implements Belos::MultiVec< ScalarType >.

Definition at line 386 of file MyMultiVec.hpp.

template<class ScalarType>
void MyMultiVec< ScalarType >::MvInit ( const ScalarType  alpha)
inlinevirtual

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
inlinevirtual

Print *this multivector to the os output stream.

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 ( )
inlineprivate

Definition at line 449 of file MyMultiVec.hpp.

Member Data Documentation

template<class ScalarType>
const ptrdiff_t 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: