Class xlifepp::MultiVec#

template<class ScalarType>
class MultiVec#

Inheritence diagram for xlifepp::MultiVec:

digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "1" [label="xlifepp::MultiVec< ScalarType >" tooltip="xlifepp::MultiVec< ScalarType >" fillcolor="#BFBFBF"] "2" [label="xlifepp::MultiVecAdapter< ScalarType >" tooltip="xlifepp::MultiVecAdapter< ScalarType >"] "2" -> "1" [dir=forward tooltip="public-inheritance"] }

Collaboration diagram for xlifepp::MultiVec:

digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "1" [label="xlifepp::MultiVec< ScalarType >" tooltip="xlifepp::MultiVec< ScalarType >" fillcolor="#BFBFBF"] }

Interface for multivectors used by xlifepp’s linear solvers.

By using the pointer to each vector in MultiVecAdapter, we can create objects which share a same view of memory (share same storage, like Storage in library LargeMatrix) However, these implementation aren’t counted for parallel programming and maybe we need to change them in the future to make the class work with MPI?

xlifepp accesses multivectors through a traits interface called MultiVecTraits. If you want to use xlifepp with your own multivector class MV, you may either specialize MultiVecTraits for MV, or you may wrap MV in your own class that implements MultiVec. Specializing MultiVecTraits works via compile-time polymorphism, whereas implementing the MultiVec interface works via run-time polymorphism. You may pick whichever option you like. However, specializing MultiVecTraits is the preferred method. This is because xlifepp’s linear solvers always use a specialization of MultiVecTraits to access multivector operations. They only use MultiVec through a specialization of the MultiVecTraits traits class, which is implemented below in this header file.

If you want your multivector class (or a wrapper thereof) to implement the MultiVec interface, you should inherit from MultiVec<ScalarType>, where ScalarType is the type of entries in the multivector. For example, a multivector with entries of type double would inherit from MultiVec<double>.

Template Parameters:

ScalarType – The type of entries of the multivector.

Subclassed by xlifepp::MultiVecAdapter< ScalarType >

Constructor/Destructor

inline MultiVec()#

Default constructor.

inline virtual ~MultiVec()#

Destructor (virtual for memory safety of derived classes).

Creation methods

virtual MultiVec<ScalarType> *clone(const dimen_t numvecs) const = 0#

Create a new MultiVec with numvecs columns.

Returns:

Pointer to the new multivector with uninitialized values.

virtual MultiVec<ScalarType> *cloneCopy() const = 0#

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

Returns:

Pointer to the new multivector

virtual MultiVec<ScalarType> *cloneCopy(const std::vector<int> &index) const = 0#

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

The copied vectors from *this are indicated by the index.size() indices in index.

Returns:

Pointer to the new multivector

virtual MultiVec<ScalarType> *cloneViewNonConst(const std::vector<int> &index) = 0#

Creates a new MultiVec that shares the selected contents of *this.

The index of the numvecs vectors shallow copied from *this are indicated by the indices given in index.

Returns:

Pointer to the new multivector

virtual const MultiVec<ScalarType> *cloneView(const std::vector<int> &index) const = 0#

Creates a new MultiVec that shares the selected contents of *this.

The index of the numvecs vectors shallow copied from *this are indicated by the indices given in index.

Returns:

Pointer to the new multivector

Dimension information methods

virtual number_t getVecLength() const = 0#

The number of rows in the multivector.

virtual dimen_t getNumberVecs() const = 0#

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

Update methods

virtual void mvTimesMatAddMv(ScalarType alpha, const MultiVec<ScalarType> &A, const MatrixEigenDense<ScalarType> &B, ScalarType beta) = 0#

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

virtual void mvAddMv(ScalarType alpha, const MultiVec<ScalarType> &A, ScalarType beta, const MultiVec<ScalarType> &B) = 0#

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

virtual void mvScale(ScalarType alpha) = 0#

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

virtual void mvScale(const std::vector<ScalarType> &alpha) = 0#

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

virtual void mvTransMv(ScalarType alpha, const MultiVec<ScalarType> &A, MatrixEigenDense<ScalarType> &B) const = 0#

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

virtual void mvDot(const MultiVec<ScalarType> &A, std::vector<ScalarType> &b) const = 0#

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.

Norm method

virtual void mvNorm(std::vector<typename NumTraits<ScalarType>::RealScalar> &normvec) const = 0#

Compute the 2-norm of each vector in *this.

Parameters:

normvec – [out] On output, normvec[i] holds the 2-norm of the i-th vector of *this.

Initialization methods

virtual void setBlock(const MultiVec<ScalarType> &A, const std::vector<int> &index) = 0#

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.

virtual void mvRandom() = 0#

Fill all the vectors in *this with random numbers.

virtual void mvInit(ScalarType alpha) = 0#

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

Print method

virtual void mvPrint(std::ostream &os) const = 0#

Print *this multivector to the os output stream.

virtual std::vector<ScalarType> *operator[](int v) = 0#

Print *this multivector to the os output stream.

virtual std::vector<ScalarType> *operator[](int v) const = 0#

Print *this multivector to the os output stream.

virtual ScalarType &operator()(const int i, const int j) = 0#

Print *this multivector to the os output stream.

virtual const ScalarType &operator()(const int i, const int j) const = 0#

Print *this multivector to the os output stream.

virtual void mvLoadFromFile(const char *f) = 0#

Print *this multivector to the os output stream.