24 #ifndef _GEMA_MATRIX_SET_H_ 25 #define _GEMA_MATRIX_SET_H_ 32 #include <QStringList> 43 bool init(
int maxNodes,
int numMatrices, ...);
44 bool adjustSizes(
int maxNodes);
47 void prepareSet(
int nnodes);
50 bool containsType(
int type)
const {
return (index(type) >= 0 && _typeEnabled[type]); }
57 assert(type >= 0 && type < _nTypes);
58 if(enabled == _typeEnabled[type])
60 _typeEnabled[type] = enabled;
61 _nEnabled += (enabled ? 1 : -1);
77 assert(index(type) >= 0);
78 _symmetric.localBuffer()[index(type)] = symmetric;
85 void setFilled(
int type,
bool filled) { assert(index(type) >= 0); _filled.localBuffer()[index(type)] = filled; }
91 bool symmetric(
int type)
const { assert(index(type) >= 0);
return _symmetric.localBuffer()[index(type)]; }
93 bool filledSymmetric()
const;
99 bool filled(
int type)
const { assert(index(type) >= 0);
return _filled.localBuffer()[index(type)]; }
102 int index(
int type)
const { assert(type >= 0 && type < _nTypes);
return _typeIndex[type]; }
105 int typeFromIndex(
int index)
const { assert(index >= 0 && index < _nMatrices);
return _indexType[index]; }
110 assert(type >= 0 && type < _nTypes);
111 return type < _typeNames.size() ? _typeNames.at(type) :
"";
118 const GmMatrix&
matrixFromIndex(
int index)
const { assert(index >= 0 && index < _nMatrices);
return _matrices.localBuffer()[index]; }
123 bool symmetricFromIndex(
int index)
const { assert(index >= 0 && index < _nMatrices);
return _symmetric.localBuffer()[index]; }
128 bool filledFromIndex(
int index)
const { assert(index >= 0 && index < _nMatrices);
return _filled.localBuffer()[index]; }
131 bool initTypes(
int numMatrices, va_list typeList);
GmTLBuffer< bool, true > _filled
Vector stating, for each matrix, if it was filled by the user or not.
Definition: gmMatrixSet.h:145
int numMatrices() const
Return the number of matrices stored in this set.
Definition: gmMatrixSet.h:115
int * _indexType
Reverse index for finding the type from the matrix index.
Definition: gmMatrixSet.h:135
GmTLBuffer< double, true > _matrixMemory
Memory used to hold data for the set matrices.
Definition: gmMatrixSet.h:142
Definition: gmMatrixSet.h:37
GmTLBuffer< GmMatrix, true > _matrices
Vector with matrices prepared by prepareSet()
Definition: gmMatrixSet.h:143
QString typeName(int type) const
Returns a name associated to the given type from the list supplied in the constructor.
Definition: gmMatrixSet.h:108
void fill(GmMatrix &m, const double *data, int nlin, int ncol)
Copy the contents of data to matrix m. If m size is different from nlin, ncol the matrix is resized....
Definition: gmMatrixUtils.h:51
bool symmetric(int type) const
Returns true if the matrix from the current thread, identified by its type, was marked symmetric (def...
Definition: gmMatrixSet.h:91
Declaration of the GmTLBuffer class.
int index(int type) const
Returns the index inside the set of the supplied type (-1 if the type doesn't belong to the set).
Definition: gmMatrixSet.h:102
Declaration of the GmMatrix class.
int numEnabledTypes() const
Returns the number of enabled types in the matrix set.
Definition: gmMatrixSet.h:65
void setTypeEnabled(int type, bool enabled)
Enables or disables a type in the set. Disabled types do NOT return matrices in calls to matrix() or ...
Definition: gmMatrixSet.h:55
bool filled(int type) const
Returns true if the matrix from the current thread, identified by its type, was marked as filled (def...
Definition: gmMatrixSet.h:99
int _nEnabled
The number of enabled matrices in _typeEnabled.
Definition: gmMatrixSet.h:137
void setFilled(int type, bool filled)
Marks a matrix, identified by its type in the set, as filled or unfilled. IMPORTANT: The supplied typ...
Definition: gmMatrixSet.h:85
#define GMC_API_EXPORT
Macro for controling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_LI...
Definition: gmCoreConfig.h:35
int * _typeIndex
An index mapping matrix types to its position within the set.
Definition: gmMatrixSet.h:134
const GmMatrix & matrixFromIndex(int index) const
Returns a matrix, tied to the current thread, identified by its index in the set.
Definition: gmMatrixSet.h:118
int _nTypes
The number of existing matrix types.
Definition: gmMatrixSet.h:133
bool * _typeEnabled
A vector stating if the type is enabled or not.
Definition: gmMatrixSet.h:136
bool filledFromIndex(int index) const
Returns true if the matrix tied to the current thread, indentified by its index, was marked as filled...
Definition: gmMatrixSet.h:128
int _nMatrices
The number of matrices stored in this set.
Definition: gmMatrixSet.h:140
int _maxNodes
The maximum dimension of a matrix (maximum number of element nodes)
Definition: gmMatrixSet.h:141
GmTLBuffer< bool, true > _symmetric
Vector stating, for each matrix, if it is symmetric or not.
Definition: gmMatrixSet.h:144
void setSymmetric(int type, bool symmetric)
Marks a matrix, identified by its type in the set, as symmetric or unsymmetric. IMPORTANT: The suppli...
Definition: gmMatrixSet.h:75
arma::mat GmMatrix
The basic type for a GeMA matrix object. Currently based on an Armadillo matrix.
Definition: gmMatrix.h:38
bool symmetricFromIndex(int index) const
Returns true if the matrix tied to the current thread, and indentified by its index,...
Definition: gmMatrixSet.h:123
bool containsType(int type) const
Returns true if the matrix set contains a matrix of the requested type AND the type is enabled.
Definition: gmMatrixSet.h:50
int typeFromIndex(int index) const
Given a matrix index, returns its type.
Definition: gmMatrixSet.h:105
QStringList _typeNames
Optional names for matrix types.
Definition: gmMatrixSet.h:138