Class xlifepp::MultiVec#
-
template<class ScalarType>
class MultiVec#
-
Inheritence 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
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 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
numvecs
vectors shallow copied from*this
are 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
numvecs
vectors shallow copied from*this
are 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
*this
withalpha
*A
*B
+beta
* (*this
).
-
virtual void mvAddMv(ScalarType alpha, const MultiVec<ScalarType> &A, ScalarType beta, const MultiVec<ScalarType> &B) = 0#
-
Replace
*this
withalpha
*A
+beta
*B
.
-
virtual void mvScale(ScalarType alpha) = 0#
-
Scale each element of the vectors in
*this
withalpha
.
-
virtual void mvScale(const std::vector<ScalarType> &alpha) = 0#
-
Scale each element of the
i
-th vector in*this
withalpha[i]
.
-
virtual void mvTransMv(ScalarType alpha, const MultiVec<ScalarType> &A, MatrixEigenDense<ScalarType> &B) const = 0#
-
Compute a dense matrix
B
through 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
b
whose 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-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 inA
are copied to a subset of vectors in*this
indicated by the indices given inindex
.
-
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
withalpha
.
Print method
-
virtual void mvPrint(std::ostream &os) const = 0#
-
Print
*this
multivector to theos
output stream.
-
virtual std::vector<ScalarType> *operator[](int v) = 0#
-
Print
*this
multivector to theos
output stream.
-
virtual std::vector<ScalarType> *operator[](int v) const = 0#
-
Print
*this
multivector to theos
output stream.
-
virtual ScalarType &operator()(const int i, const int j) = 0#
-
Print
*this
multivector to theos
output stream.
-
virtual const ScalarType &operator()(const int i, const int j) const = 0#
-
Print
*this
multivector to theos
output stream.
-
virtual void mvLoadFromFile(const char *f) = 0#
-
Print
*this
multivector to theos
output stream.