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 33 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 38 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 58 of file MyMultiVec.hpp.

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

Copy constructor, performs a deep copy.

Definition at line 76 of file MyMultiVec.hpp.

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

Destructor.

Definition at line 99 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 107 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 120 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 126 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 141 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 153 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 165 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 170 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 176 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 227 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 250 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 260 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 271 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 295 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 315 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 336 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 354 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 366 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 375 of file MyMultiVec.hpp.

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

Definition at line 389 of file MyMultiVec.hpp.

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

Definition at line 397 of file MyMultiVec.hpp.

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

Definition at line 405 of file MyMultiVec.hpp.

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

Definition at line 411 of file MyMultiVec.hpp.

template<class ScalarType>
void MyMultiVec< ScalarType >::Check ( )
inlineprivate

Definition at line 417 of file MyMultiVec.hpp.

Member Data Documentation

template<class ScalarType>
const ptrdiff_t MyMultiVec< ScalarType >::Length_
private

Length of the vectors.

Definition at line 427 of file MyMultiVec.hpp.

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

Number of multi-vectors.

Definition at line 429 of file MyMultiVec.hpp.

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

Pointers to the storage of the vectors.

Definition at line 431 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 433 of file MyMultiVec.hpp.


The documentation for this class was generated from the following file: