Class xlifepp::MultiVec#
-
template<class ScalarType>
class MultiVec#
-
Inheritance diagram for xlifepp::MultiVec:
Collaboration diagram for xlifepp::MultiVec:
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
numvecscolumns.- Returns:
-
Pointer to the new multivector with uninitialized values.
-
virtual MultiVec<ScalarType> *cloneCopy() const = 0#
-
Create a new MultiVec and copy contents of
*thisinto 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
*thisinto the new vector (deep copy).The copied vectors from
*thisare indicated by theindex.size()indices inindex.- 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
numvecsvectors shallow copied from*thisare indicated by the indices given inindex.- 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
numvecsvectors shallow copied from*thisare indicated by the indices given inindex.- Returns:
-
Pointer to the new multivector
Dimension information methods
Update methods
-
virtual void mvTimesMatAddMv(ScalarType alpha, const MultiVec<ScalarType> &A, const MatrixEigenDense<ScalarType> &B, ScalarType beta) = 0#
-
Update
*thiswithalpha*A*B+beta* (*this).
-
virtual void mvAddMv(ScalarType alpha, const MultiVec<ScalarType> &A, ScalarType beta, const MultiVec<ScalarType> &B) = 0#
-
Replace
*thiswithalpha*A+beta*B.
-
virtual void mvScale(ScalarType alpha) = 0#
-
Scale each element of the vectors in
*thiswithalpha.
-
virtual void mvScale(const std::vector<ScalarType> &alpha) = 0#
-
Scale each element of the
i-th vector in*thiswithalpha[i].
-
virtual void mvTransMv(ScalarType alpha, const MultiVec<ScalarType> &A, MatrixEigenDense<ScalarType> &B) const = 0#
-
Compute a dense matrix
Bthrough the matrix-matrix multiplyalpha*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
bwhose entries are the individual dot-products. That is,b[i] = A[i]^H * (*this)[i]whereA[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-thvector of*this.
Initialization methods
-
virtual void setBlock(const MultiVec<ScalarType> &A, const std::vector<int> &index) = 0#
-
Copy the vectors in
Ato a set of vectors in*this.The
numvecsvectors inAare copied to a subset of vectors in*thisindicated by the indices given inindex.
-
virtual void mvRandom() = 0#
-
Fill all the vectors in
*thiswith random numbers.
-
virtual void mvInit(ScalarType alpha) = 0#
-
Replace each element of the vectors in
*thiswithalpha.
Print method
-
virtual void mvPrint(std::ostream &os) const = 0#
-
Print
*thismultivector to theosoutput stream.
-
virtual std::vector<ScalarType> *operator[](int v) = 0#
-
Print
*thismultivector to theosoutput stream.
-
virtual std::vector<ScalarType> *operator[](int v) const = 0#
-
Print
*thismultivector to theosoutput stream.
-
virtual ScalarType &operator()(const int i, const int j) = 0#
-
Print
*thismultivector to theosoutput stream.
-
virtual const ScalarType &operator()(const int i, const int j) const = 0#
-
Print
*thismultivector to theosoutput stream.
-
virtual void mvLoadFromFile(const char *f) = 0#
-
Print
*thismultivector to theosoutput stream.