Multidimensional matrix
-
class CDenseMDMatrix
Multidimensional matrix in dense format.
Public Functions
-
CDenseMDMatrix()
Basic constructor. Creates an empty matrix.
-
CDenseMDMatrix(const std::vector<unsigned> &_vTypes, const std::vector<unsigned> &_vClasses)
Constructor creating a matrix with the given types and number of classes.
- Parameters
_vTypes – Distribution types.
_vClasses – Numbers of classes of distributions.
-
bool SetDimensions(unsigned _nType, unsigned _nClasses)
Sets new dimensions set with erasing of old data.
Type is one of the EDistrTypes.
- Parameters
_nType – Distribution type.
_nClasses – Number of classes.
- Returns
Error flag.
-
bool SetDimensions(unsigned _nType1, unsigned _nClasses1, unsigned _nType2, unsigned _nClasses2)
Sets new dimensions set with erasing of old data.
Types are types of the EDistrTypes.
- Parameters
_nType1 – Fisrt distribution type.
_nClasses1 – Number of classes of first distribution.
_nType2 – Second distribution type.
_nClasses2 – Number of classes of second distribution.
- Returns
Error flag.
-
bool SetDimensions(unsigned _nType1, unsigned _nClasses1, unsigned _nType2, unsigned _nClasses2, unsigned _nType3, unsigned _nClasses3)
Sets new dimensions set with erasing of old data.
Types are one of the EDistrTypes.
- Parameters
_nType1 – First distribution type.
_nClasses1 – Number of classes of first distribution.
_nType2 – Second distribution type.
_nClasses2 – Number of classes of second distribution.
_nType3 – Third distribution type.
_nClasses3 – Number of classes of third distribution.
- Returns
Error flag.
-
bool SetDimensions(const std::vector<unsigned> &_vTypes, const std::vector<unsigned> &_vClasses)
Sets new dimensions set with erasing of old data.
Types is the vector of EDistrTypes.
- Parameters
_vTypes – Distribution types.
_vClasses – Numbers of classes of distributions.
- Returns
Error flag.
-
std::vector<unsigned> GetDimensions() const
Returns vector with all current defined dimensions types.
- Returns
Vector of defined dimensions types.
-
std::vector<unsigned> GetClasses() const
Returns vector with current numbers of classes.
- Returns
Vector of defined classes.
-
size_t GetDimensionsNumber() const
Returns current number of dimensions.
- Returns
Number of defined dimensions
-
void Clear()
Clears all data and information about dimensions.
-
void ClearData()
Clears all data in the matrix by setting all values to 0.
Dimensions set won’t be erased.
-
const double *GetDataPtr() const
Returns const pointer to data.
- Returns
Const pointer to data.
-
double *GetDataPtr()
Returns pointer to data.
- Returns
Pointer to data.
-
size_t GetDataLength() const
Returns length of the plain data array.
- Returns
Total data length.
-
double GetValue(unsigned _nDim, unsigned _nCoord) const
Returns value by specified dimension and coordinate with possible reducing of dimensions set.
Returns -1 on error.
- Parameters
_nDim – Target dimension.
_nCoord – Coordinate.
- Returns
Value by specified dimension and coordinate.
-
double GetValue(unsigned _nDim1, unsigned _nCoord1, unsigned _nDim2, unsigned _nCoord2) const
Returns value by specified dimensions and coordinates with possible reducing of dimensions set.
Returns -1 on error.
- Parameters
_nDim1 – First dimension.
_nCoord1 – First coordinate.
_nDim2 – Second dimension.
_nCoord2 – Second coordinate.
- Returns
Value by specified dimensions and coordinates.
-
double GetValue(unsigned _nDim1, unsigned _nCoord1, unsigned _nDim2, unsigned _nCoord2, unsigned _nDim3, unsigned _nCoord3) const
Returns value by specified dimensions and coordinates with possible reducing of dimensions set.
Returns -1 on error.
- Parameters
_nDim1 – First dimension.
_nCoord1 – First coordinate.
_nDim2 – Second dimension.
_nCoord2 – Second coordinate.
_nDim3 – Third dimension.
_nCoord3 – Third coordinate.
- Returns
Value by specified dimensions and coordinates.
-
double GetValue(const std::vector<unsigned> &_vCoords) const
Returns value by specified coordinates according to the full defined set of dimensions.
Returns -1 on error.
- Parameters
_vCoords – Coordinates.
- Returns
Value by specified coordinates.
-
double GetValue(const std::vector<unsigned> &_vDims, const std::vector<unsigned> &_vCoords) const
Returns value by specified coordinates and dimensions sequence.
Dimensions set can be reduced. Returns -1 on error.
- Parameters
_vDims – Dimensions.
_vCoords – Coordinates.
- Returns
Value by specified dimensions and coordinates sequence.
-
std::vector<double> GetVectorValue(unsigned _nDim) const
Returns vector of values according to specified dimension with possible reducing of dimensions set.
- Parameters
_nDim – Target dimension.
- Returns
Vector of values according to specified dimension.
-
bool GetVectorValue(unsigned _nDim, std::vector<double> &_vResult) const
Returns vector of values according to specified dimension with possible reducing of dimensions set.
- Parameters
_nDim – Target dimension.
_vResult – Vector of values according to specified dimension.
- Returns
Error flag.
-
bool GetVectorValue(unsigned _nDim1, unsigned _nCoord1, unsigned _nDim2, std::vector<double> &_vResult) const
Returns vector of values according to specified dimensions and coordinates with possible reducing of dimensions set.
- Parameters
_nDim1 – First dimension.
_nCoord1 – First coordinate.
_nDim2 – Second dimension.
_vResult – Vector of values according to specified dimensions and coordinates.
- Returns
Error flag.
-
bool GetVectorValue(unsigned _nDim1, unsigned _nCoord1, unsigned _nDim2, unsigned _nCoord2, unsigned _nDim3, std::vector<double> &_vResult) const
Returns vector of values according to specified dimensions and coordinates with possible reducing of dimensions set.
- Parameters
_nDim1 – First dimension.
_nCoord1 – First coordinate.
_nDim2 – Second dimension.
_nCoord2 – Second coordinate.
_nDim3 – Third dimension.
_vResult – Vector of values according to specified dimensions and coordinates.
- Returns
Error flag.
-
std::vector<double> GetVectorValue(unsigned _nDim1, unsigned _nCoord1, unsigned _nDim2, unsigned _nCoord2, unsigned _nDim3) const
Returns vector of values according to specified dimensions and coordinates with possible reducing of dimensions set.
- Parameters
_nDim1 – First dimension.
_nCoord1 – First coordinate.
_nDim2 – Second dimension.
_nCoord2 – Second coordinate.
_nDim3 – Third dimension.
- Returns
Vector of values according to specified dimensions and coordinates.
-
bool GetVectorValue(const std::vector<unsigned> &_vCoords, std::vector<double> &_vResult) const
Returns vector of values by specified coordinates according to a full defined dimensions set.
- Parameters
_vCoords – Coordinates.
_vResult – Vector of values by specified coordinates.
- Returns
Error flag.
-
bool GetVectorValue(const std::vector<unsigned> &_vDims, const std::vector<unsigned> &_vCoords, std::vector<double> &_vResult) const
Returns vector of values according to specified dimensions and coordinates.
Dimensions set can be reduced.
- Parameters
_vDims – Dimensions.
_vCoords – Coordinates.
_vResult – Vector of values according to specified dimensions and coordinates.
- Returns
Error flag.
-
std::vector<double> GetVectorValue(const std::vector<unsigned> &_vDims, const std::vector<unsigned> &_vCoords) const
Returns vector of values according to specified dimensions and coordinates. Dimensions set can be reduced.
- Parameters
_vDims – Dimensions.
_vCoords – Coordinates.
- Returns
Vector of values according to specified dimensions and coordinates.
-
bool SetValue(unsigned _nCoord, double _dValue)
Sets value in 1D-matrix by specified coordinate.
Sets value only if the number of dimensions is the same as in the matrix.
- Parameters
_nCoord – Coordinate.
_dValue – New value.
- Returns
Error flag.
-
bool SetValue(unsigned _nDim1, unsigned _nCoord1, unsigned _nCoord2, double _dValue)
Sets value in 2D-matrix by specified dimensions and coordinates.
Sets value only if the number of dimensions is the same as in the matrix.
- Parameters
_nDim1 – First dimension.
_nCoord1 – First coordinate.
_nCoord2 – Second coordinate.
_dValue – New value.
- Returns
Error flag.
-
bool SetValue(unsigned _nDim1, unsigned _nCoord1, unsigned _nDim2, unsigned _nCoord2, unsigned _nCoord3, double _dValue)
Sets value in 3D-matrix by specified dimensions and coordinates.
Sets value only if the number of dimensions is the same as in the matrix.
- Parameters
_nDim1 – First dimension.
_nCoord1 – First coordinate.
_nDim2 – Second dimension.
_nCoord2 – Second coordinate.
_nCoord3 – Third coordinate.
_dValue – New value.
- Returns
Error flag.
-
bool SetValue(const std::vector<unsigned> &_vCoords, double _dValue)
Sets value by specified coordinates according to the full defined set of dimensions.
Sets value only if the number of dimensions is the same as in the matrix.
- Parameters
_vCoords – Coordinates.
_dValue – New value.
- Returns
Error flag.
-
bool SetValue(const std::vector<unsigned> &_vDims, const std::vector<unsigned> &_vCoords, double _dValue)
Sets value by specified coordinates and dimensions sequence.
Sets value only if the number of dimensions is the same as in the matrix.
- Parameters
_vDims – Dimensions.
_vCoords – Coordinates.
_dValue – New value.
- Returns
Error flag.
-
bool SetVectorValue(const std::vector<double> &_vValue)
Sets vector of values in 1D-matrix.
- Parameters
_vValue – New values.
- Returns
Error flag.
-
bool SetVectorValue(unsigned _nDim, unsigned _nCoord, const std::vector<double> &_vValue)
Sets vector of values according to specified dimensions and coordinates in 2D-matrix.
- Parameters
_nDim – Target dimension.
_nCoord – Coordinate.
_vValue – New values.
- Returns
Error flag.
-
bool SetVectorValue(unsigned _nDim1, unsigned _nCoord1, unsigned _nDim2, unsigned _nCoord2, const std::vector<double> &_vValue)
Sets vector of values according to specified dimensions and coordinates in 3D-matrix.
- Parameters
_nDim1 – First dimension.
_nCoord1 – First coordinate.
_nDim2 – Second dimension.
_nCoord2 – Second coordinate.
_vValue – New values.
- Returns
Error flag.
-
bool SetVectorValue(const std::vector<unsigned> &_vCoords, const std::vector<double> &_vValue)
Sets vector of values by specified coordinates according to a full defined dimensions set.
Sets values only if the number of coordinates is one less than number of dimensions in the matrix.
- Parameters
_vCoords – Coordinates.
_vValue – New values.
- Returns
Whether an error has occurred.
- Returns
Error flag.
-
bool SetVectorValue(const std::vector<unsigned> &_vDims, const std::vector<unsigned> &_vCoords, const std::vector<double> &_vValue)
Sets vector of values according to specified dimensions and coordinates.
Sets values only if the number of dimensions is one less than in the matrix.
- Parameters
_vDims – Dimensions.
_vCoords – Coordinates.
_vValue – New values.
- Returns
Error flag.
-
bool IsNormalized()
Checks if the matrix is normalized.
- Returns
Whether the matrix is normalized.
-
void Normalize()
Normalizes the matrix so that the sum of all elements equals to 1.
-
CDenseMDMatrix operator+(const CDenseMDMatrix &_matrix)
Adds matrix with the same dimensions.
If dimensions are not the same, than the empty matrix will be returned.
- Parameters
_matrix – Other matrix.
-
CDenseMDMatrix operator-(const CDenseMDMatrix &_matrix)
Subtracts matrix with the same dimensions.
If dimensions are not the same, than the empty matrix will be returned.
- Parameters
_matrix – Other matrix.
-
CDenseMDMatrix operator*(double _dFactor)
Multiplication of the matrix by a coefficient.
- Parameters
_dFactor – Coefficient.
-
CDenseMDMatrix()