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
 Create a new MultiVec and copy contents of *this into it (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
 The number of rows in the multivector.
int GetNumberVecs () const
 The number of vectors (i.e., columns) in the multivector.
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 the dot product of each column of *this with the corresponding column of A.
void MvNorm (std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec, Belos::NormType type=Belos::TwoNorm) const
 Compute the norm of each vector in *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.
void MvRandom ()
 Fill all the vectors in *this with random numbers.
void MvInit (const ScalarType alpha)
 Replace each element of the vectors in *this with alpha.
void MvPrint (std::ostream &os) const
 Print *this multivector to the os output stream.
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]

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 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]

The number of rows in the multivector.

Implements Belos::MultiVec< ScalarType >.

Definition at line 195 of file MyMultiVec.hpp.

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

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

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 258 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 281 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 291 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 302 of file MyMultiVec.hpp.

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

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 326 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 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 346 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 367 of file MyMultiVec.hpp.

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

Fill all the vectors in *this with random numbers.

Implements Belos::MultiVec< ScalarType >.

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

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

Print *this multivector to the os output stream.

Implements Belos::MultiVec< ScalarType >.

Definition at line 404 of file MyMultiVec.hpp.

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

Definition at line 418 of file MyMultiVec.hpp.

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

Definition at line 426 of file MyMultiVec.hpp.

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

Definition at line 434 of file MyMultiVec.hpp.

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

Definition at line 440 of file MyMultiVec.hpp.

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

Definition at line 446 of file MyMultiVec.hpp.


Member Data Documentation

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

Length of the vectors.

Definition at line 456 of file MyMultiVec.hpp.

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

Number of multi-vectors.

Definition at line 458 of file MyMultiVec.hpp.

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

Pointers to the storage of the vectors.

Definition at line 460 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 462 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