1 #ifndef SM_PackedBlockGeneralMatrix_H
2 #define SM_PackedBlockGeneralMatrix_H
5 #include "SM_PackedBlockMatrix.h"
16 template<
typename T,tUCInt P>
36 std::valarray<T> mBlocksValues;
97 mem+=mBlocksValues.size()*
sizeof(T);
105 inline static CORE_UniquePointer<SelfClass>
New() {
106 return CORE_UniquePointer<SelfClass>(
new SelfClass(),
119 memset(&mBlocksValues[0],0,mBlocksValues.size()*
sizeof(T));
125 virtual void setSize(
const tIndex& nRowBlocks,
const tIndex& nColBlocks)
final {
130 if (s!=mBlocksValues.size()) {
132 mBlocksValues.resize(s);
133 memset(&mBlocksValues[0],0,
sizeof(T)*s);
134 }
catch (std::exception& e) {
136 "SM_PackedBlockGeneralMatrix::setSize("+std::to_string(nRowBlocks)+
","+std::to_string(nColBlocks)+
")",
137 "not enough size to allocate "+std::to_string(s)+
" elements for matrix : memory size needed: "+std::to_string((
sizeof(T)*s)/(1024*1024*1024))+
" Go");
148 virtual void setValue(
const tIndex& i,
const tIndex& j,
const T& v)
final {
157 virtual const T&
getValue(
const tIndex& i,
const tIndex& j)
const final {
165 virtual T&
getValue(
const tIndex& i,
const tIndex& j)
final {
174 return mBlocksValues;
180 return mBlocksValues;
229 std::stringstream ret;
232 ret<<
"blocks values:"<<functions_array::toString(mBlocksValues)<<
"\n";
238 #include "SM_PackedBlockGeneralMatrix.hpp"
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:17
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:113
This class described a matrix by packed symmetric block of size NxP in a row storage.
Definition: SM_PackedBlockGeneralMatrix.h:17
static CORE_UniquePointer< SelfClass > New()
build a new instance of the operator
Definition: SM_PackedBlockGeneralMatrix.h:105
virtual void reset() final
reset the values
Definition: SM_PackedBlockGeneralMatrix.h:118
virtual ~SM_PackedBlockGeneralMatrix(void)
destroy
Definition: SM_PackedBlockGeneralMatrix.h:60
virtual const T & getValue(const tIndex &i, const tIndex &j) const final
get values at row i and column j for reading
Definition: SM_PackedBlockGeneralMatrix.h:157
virtual void vectorProduct(const T *vX, T *vY) const
vector product
Definition: SM_PackedBlockGeneralMatrix.hpp:5
virtual void setSize(const tIndex &nRowBlocks, const tIndex &nColBlocks) final
set the number or rows & columns of the blocks matrix
Definition: SM_PackedBlockGeneralMatrix.h:125
T & operator()(tIndex i, tIndex j)
get values at row i and column j for writing
Definition: SM_PackedBlockGeneralMatrix.h:205
SM_PackedBlockGeneralMatrix(void)
create a matrix of size 0
Definition: SM_PackedBlockGeneralMatrix.h:53
const std::valarray< T > & getBlocksValues() const
get the values of superior blocks of the matrix
Definition: SM_PackedBlockGeneralMatrix.h:179
virtual T & getValue(const tIndex &i, const tIndex &j) final
get values at row i and column j for writing
Definition: SM_PackedBlockGeneralMatrix.h:165
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_PackedBlockGeneralMatrix.h:83
virtual void setValue(const tIndex &i, const tIndex &j, const T &v) final
set values at row i and column j
Definition: SM_PackedBlockGeneralMatrix.h:148
const T & operator()(tIndex i, tIndex j) const
get values at row i and column j for reading
Definition: SM_PackedBlockGeneralMatrix.h:193
std::valarray< T > & getBlocksValues()
get the values of superior blocks of the matrix
Definition: SM_PackedBlockGeneralMatrix.h:173
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_PackedBlockGeneralMatrix.h:95
virtual tString toString() const override
return string representaton of the operator
Definition: SM_PackedBlockGeneralMatrix.h:228
This class described a matrix by packed block of size in a row storage.
Definition: SM_PackedBlockMatrix.h:18
virtual tString toString() const override
return string representaton of the operator
Definition: SM_PackedBlockMatrix.h:236
const tInteger & getColumnBlocksNumber() const
get the number of column blocks
Definition: SM_PackedBlockMatrix.h:124
virtual void setSize(const tInteger &nRowBlocks, const tInteger &nColBlocks)
set the number or rows & columns of the blocks matrix
Definition: SM_PackedBlockMatrix.h:112
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_PackedBlockMatrix.h:94
static tIndex GetPackedIndex(const tIndex &i, const tIndex &j)
return the pack index of size Q in a column storage
Definition: SM_PackedBlockMatrix.h:165