2#include "Base/Headers/Buffer.hpp"
4#include <Eigen/StdVector>
17 template <
class MatrixType>
18 class SparseBlockMatrixDiagonal
25 int cols()
const {
return _blockIndices && (*_blockIndices).size() ? (*_blockIndices).last() : 0;}
27 int rows()
const {
return _blockIndices && (*_blockIndices).size() ? (*_blockIndices).last() : 0;}
33 SparseBlockMatrixDiagonal(
const Buffer<int>&
blockIndices) :
38 inline int dimOfBlock(
int r)
const {
return r ? (*_blockIndices)[r] - (*_blockIndices)[r-1] : (*_blockIndices)[0] ; }
41 inline int baseOfBlock(
int r)
const {
return r ? (*_blockIndices)[r-1] : 0 ; }
44 const DiagonalVector&
diagonal()
const {
return _diagonal;}
45 DiagonalVector&
diagonal() {
return _diagonal;}
50 void multiply(g_type*& dest,
const g_type* src)
const
54 dest=
new g_type[destSize];
55 memset(dest,0, destSize*
sizeof(g_type));
59 Eigen::Map<Eigen::VectorX<g_type>> destVec(dest, destSize);
60 Eigen::Map<const Eigen::VectorX<g_type>> srcVec(src,
rows());
63# pragma omp parallel for default (shared) schedule(dynamic, 10)
65 for (
int i=0; i < static_cast<int>(_diagonal.size()); ++i){
67 int srcOffset = destOffset;
70 internal::axpy(A, srcVec, srcOffset, destVec, destOffset);
76 DiagonalVector _diagonal;
The equivelent of std::vector but with a bit more control.
Sparse matrix which uses blocks on the diagonal.
int rows() const
rows of the matrix
int cols() const
columns of the matrix
const DiagonalVector & diagonal() const
the block matrices per block-column
int baseOfBlock(int r) const
where does the row /col at block-row / block-column r starts?
const Buffer< int > * _blockIndices
vector of the indices of the blocks along the diagonal
const Buffer< int > & blockIndices() const
indices of the row blocks
MatrixType SparseMatrixBlock
this is the type of the elementary block, it is an Eigen::Matrix.
int dimOfBlock(int r) const
how many rows/cols does the block at block-row / block-column r has?
Internal helper functions for block-wise matrix-vector products (axpy and atxpy).
The primary namespace for the NDEVR SDK.