INMOST
A toolkit for distributed mathematical modeling
INMOST::Matrix< Var, storage_type > Class Template Reference

Class for linear algebra operations on dense matrices. More...

#include <inmost_dense.h>

Inheritance diagram for INMOST::Matrix< Var, storage_type >:
Collaboration diagram for INMOST::Matrix< Var, storage_type >:

Public Types

typedef AbstractMatrix< Var >::enumerator enumerator
 
- Public Types inherited from INMOST::AbstractMatrix< Var >
typedef AbstractMatrixReadOnly< Var >::enumerator enumerator
 
- Public Types inherited from INMOST::AbstractMatrixReadOnly< Var >
typedef unsigned enumerator
 

Public Member Functions

Var & operator[] (enumerator k)
 
const Var & operator[] (enumerator k) const
 
void RemoveRow (enumerator row)
 Erase single row. More...
 
void RemoveRows (enumerator first, enumerator last)
 Erase multiple rows. More...
 
void RemoveColumn (enumerator col)
 Erase single column. More...
 
void RemoveColumns (enumerator first, enumerator last)
 Erase multiple columns. More...
 
void RemoveSubset (enumerator firstrow, enumerator lastrow, enumerator firstcol, enumerator lastcol)
 Erase part of the matrix. More...
 
void Swap (AbstractMatrix< Var > &b)
 Exchange contents of two matrices.
 
 Matrix ()
 Construct empty matrix.
 
 Matrix (const Var *pspace, enumerator pn, enumerator pm)
 Construct the matrix from provided array and sizes. More...
 
 Matrix (const storage_type &pspace, enumerator pn, enumerator pm)
 Construct the matrix with the provided storage with known size. More...
 
 Matrix (const storage_type &pspace)
 Construct the matrix with the provided storage and unknown size. More...
 
 Matrix (enumerator pn, enumerator pm)
 Construct a matrix with provided sizes. More...
 
 Matrix (enumerator pn, enumerator pm, const Var &c)
 Construct a matrix with provided sizes and fills with value. More...
 
 Matrix (const Matrix &other)
 Copy matrix. More...
 
template<typename typeB >
 Matrix (const AbstractMatrixReadOnly< typeB > &other)
 Construct matrix from matrix of different type. More...
 
template<typename typeB >
 Matrix (const AbstractMatrix< typeB > &other)
 Construct matrix from matrix of different type. More...
 
 ~Matrix ()
 Delete matrix.
 
void Resize (enumerator nrows, enumerator mcols)
 Resize the matrix into different size. More...
 
Matrixoperator= (Matrix const &other)
 Assign matrix of the same type. More...
 
template<typename typeB >
Matrixoperator= (AbstractMatrixReadOnly< typeB > const &other)
 Assign matrix of another type. More...
 
template<typename typeB >
Matrixoperator= (AbstractMatrix< typeB > const &other)
 Assign matrix of another type. More...
 
__INLINE Var & operator() (enumerator i, enumerator j)
 Access element of the matrix by row and column indices. More...
 
__INLINE Var compute (enumerator i, enumerator j) const
 Access element of the matrix by row and column indices. More...
 
__INLINE const Var & get (enumerator i, enumerator j) const
 Access element of the matrix by row and column indices without right to change the element. More...
 
__INLINE Var * data ()
 Return raw pointer to matrix data, stored in row-wise format. More...
 
__INLINE const Var * data () const
 Return raw pointer to matrix data without right of change, stored in row-wise format. More...
 
__INLINE enumerator Rows () const
 Obtain number of rows. More...
 
__INLINE enumerator Cols () const
 Obtain number of columns. More...
 
__INLINE enumerator & Rows ()
 Obtain number of rows. More...
 
__INLINE enumerator & Cols ()
 Obtain number of rows. More...
 
Matrix< Var > JointDiagonalization (INMOST_DATA_REAL_TYPE threshold=1.0e-7)
 Joint diagonalization algorithm by Cardoso. More...
 
- Public Member Functions inherited from INMOST::AbstractMatrix< Var >
 AbstractMatrix ()
 Construct empty matrix.
 
AbstractMatrixoperator= (AbstractMatrix const &other)
 Assign matrix of the same type. More...
 
template<typename typeB >
AbstractMatrixoperator= (AbstractMatrixReadOnly< typeB > const &other)
 Assign matrix of another type. More...
 
AbstractMatrixoperator= (Var const &b)
 Assign value to all entries of the matrix. More...
 
void Zero ()
 Set all the elements of the matrix to zero.
 
template<typename typeB >
AbstractMatrixoperator-= (const AbstractMatrixReadOnly< typeB > &other)
 Subtract a matrix and store result in the current. More...
 
template<typename typeB >
AbstractMatrixoperator-= (const AbstractMatrix< typeB > &other)
 Subtract a matrix and store result in the current. More...
 
template<typename typeB >
AbstractMatrixoperator+= (const AbstractMatrixReadOnly< typeB > &other)
 Add a matrix and store result in the current. More...
 
template<typename typeB >
AbstractMatrixoperator+= (const AbstractMatrix< typeB > &other)
 Add a matrix and store result in the current. More...
 
template<typename typeB >
AbstractMatrixoperator*= (const AbstractMatrixReadOnly< typeB > &B)
 Multiply matrix with another matrix in-place. More...
 
template<typename typeB >
AbstractMatrixoperator*= (typeB coef)
 Multiply the matrix by the coefficient of the same type and store the result. More...
 
template<typename typeB >
AbstractMatrixoperator/= (typeB coef)
 Divide the matrix by the coefficient of the same type and store the result. More...
 
SubMatrix< Var > operator() (enumerator first_row, enumerator last_row, enumerator first_col, enumerator last_col)
 Extract submatrix of a matrix for in-place manipulation of elements. More...
 
BlockOfMatrix< Var > BlockOf (enumerator nrows, enumerator ncols, enumerator offset_row, enumerator offset_col)
 Define matrix as a part of a matrix of larger size with in-place manipulation of elements. More...
 
MatrixTranspose< Var > Transpose ()
 Transpose the current matrix with access to elements. More...
 
MatrixRepack< Var > Repack (enumerator rows, enumerator cols)
 Change representation of the matrix into matrix of another size. More...
 
MatrixConcatCols< Var > ConcatCols (AbstractMatrix< Var > &B)
 Concatenate B matrix as columns of current matrix. More...
 
MatrixConcatRows< Var > ConcatRows (AbstractMatrix< Var > &B)
 Concatenate B matrix as rows of current matrix. More...
 
bool CheckNans () const
 Check all matrix entries for not a number. More...
 
bool CheckInfs () const
 Check all matrix entries for infinity. More...
 
bool CheckNansInfs () const
 Check all matrix entries for not a number and infinity. More...
 
template<typename typeB >
Matrix< typename Promote< Var, typeB >::type > Transform (const AbstractMatrix< typeB > &other) const
 Transformation matrix from current vector to provided vector using shortest arc rotation. More...
 
template<typename typeB >
Matrix< typename Promote< Var, typeB >::type > Transform (const AbstractMatrixReadOnly< typeB > &other) const
 Transformation matrix from current vector to provided vector using shortest arc rotation. More...
 
template<typename typeB >
Matrix< typename Promote< Var, typeB >::type > CrossProduct (const AbstractMatrix< typeB > &other) const
 Cross-product operation for a vector. More...
 
template<typename typeB >
Matrix< typename Promote< Var, typeB >::type > CrossProduct (const AbstractMatrixReadOnly< typeB > &other) const
 Cross-product operation for a vector. More...
 
template<typename typeB >
Promote< Var, typeB >::type DotProduct (const AbstractMatrix< typeB > &other) const
 Computes dot product by summing up multiplication of entries with the same indices in the current and the provided matrix. More...
 
template<typename typeB >
Promote< Var, typeB >::type DotProduct (const AbstractMatrixReadOnly< typeB > &other) const
 Computes dot product by summing up multiplication of entries with the same indices in the current and the provided matrix. More...
 
template<typename typeB >
Promote< Var, typeB >::type operator^ (const AbstractMatrix< typeB > &other) const
 Computes dot product by summing up multiplication of entries with the same indices in the current and the provided matrix. More...
 
template<typename typeB >
Promote< Var, typeB >::type operator^ (const AbstractMatrixReadOnly< typeB > &other) const
 Computes dot product by summing up multiplication of entries with the same indices in the current and the provided matrix. More...
 
SelfPromote< Var >::type FrobeniusNorm () const
 Computes frobenious norm of the matrix. More...
 
Var MaxNorm () const
 Computes maximum absolute value of the matrix. More...
 
Var Trace () const
 Calculate sum of the diagonal elements of the matrix. More...
 
void Print (INMOST_DATA_REAL_TYPE threshold=1.0e-10, std::ostream &sout=std::cout) const
 Output matrix to screen. More...
 
bool isSymmetric (double eps=1.0e-7) const
 Check if the matrix is symmetric. More...
 
void MPT (INMOST_DATA_ENUM_TYPE *Perm, INMOST_DATA_REAL_TYPE *SL=NULL, INMOST_DATA_REAL_TYPE *SR=NULL) const
 Maximum product transversal. More...
 
__INLINE INMOST_DATA_ENUM_TYPE GetMatrixCount () const
 Retrieve number of indices of derivatives.
 
virtual ~AbstractMatrix ()
 Destructor.
 
template<typename typeB >
AbstractMatrix< Var > & operator-= (const AbstractMatrix< typeB > &other)
 
template<typename typeB >
AbstractMatrix< Var > & operator-= (const AbstractMatrixReadOnly< typeB > &other)
 
template<typename typeB >
AbstractMatrix< Var > & operator+= (const AbstractMatrix< typeB > &other)
 
template<typename typeB >
AbstractMatrix< Var > & operator+= (const AbstractMatrixReadOnly< typeB > &other)
 
template<typename typeB >
AbstractMatrix< Var > & operator*= (const AbstractMatrixReadOnly< typeB > &B)
 
template<typename typeB >
AbstractMatrix< Var > & operator*= (typeB coef)
 
template<typename typeB >
AbstractMatrix< Var > & operator/= (typeB coef)
 
- Public Member Functions inherited from INMOST::AbstractMatrixReadOnly< Var >
bool CheckNans () const
 Check all matrix entries for not a number. More...
 
bool CheckInfs () const
 Check all matrix entries for infinity. More...
 
bool CheckNansInfs () const
 Check all matrix entries for not a number and infinity. More...
 
Var Det () const
 Matrix determinant.
 
bool SVD (AbstractMatrix< Var > &U, AbstractMatrix< Var > &Sigma, AbstractMatrix< Var > &V, bool order_singular_values=true, bool nonnegative=true) const
 Singular value decomposition. More...
 
bool cSVD (AbstractMatrix< Var > &U, AbstractMatrix< Var > &Sigma, AbstractMatrix< Var > &V) const
 Singular value decomposition. More...
 
ConstMatrixTranspose< Var > Transpose () const
 Transpose current matrix. More...
 
ConstMatrixConjugateTranspose< Var > ConjugateTranspose () const
 Transpose and conjugate current matrix. More...
 
ConstMatrixConjugate< Var > Conjugate () const
 Conjugate current matrix. More...
 
template<typename typeB >
Matrix< typename Promote< Var, typeB >::type > CrossProduct (const AbstractMatrixReadOnly< typeB > &other) const
 Cross-product operation for a vector. More...
 
template<typename typeB >
Matrix< typename Promote< Var, typeB >::type > Transform (const AbstractMatrixReadOnly< typeB > &other) const
 Transformation matrix from current vector to provided vector using shortest arc rotation. More...
 
template<typename typeB >
MatrixDifference< Var, typeB > operator- (const AbstractMatrixReadOnly< typeB > &other) const
 Subtract a matrix. More...
 
template<typename typeB >
MatrixSum< Var, typeB > operator+ (const AbstractMatrixReadOnly< typeB > &other) const
 Add a matrix. More...
 
template<typename typeB >
MatrixMul< Var, typeB, typename Promote< Var, typeB >::type > operator* (const AbstractMatrixReadOnly< typeB > &other) const
 Multiply the matrix by another matrix. More...
 
MatrixUnaryMinus< Var > operator- () const
 Unary minus. Change sign of each element of the matrix.
 
template<typename typeB >
KroneckerProduct< Var, typeB > Kronecker (const AbstractMatrixReadOnly< typeB > &other) const
 Kronecker product, latex symbol \otimes. More...
 
Matrix< Var > Invert (int *ierr=NULL) const
 Inverts matrix using Crout-LU decomposition with full pivoting for maximum element. More...
 
Matrix< Var > CholeskyInvert (int *ierr=NULL) const
 Inverts symmetric positive-definite matrix using Cholesky decomposition.
 
template<typename typeB >
Matrix< typename Promote< Var, typeB >::type > Solve (const AbstractMatrixReadOnly< typeB > &B, int *ierr=NULL) const
 Finds X in A*X=B, where A and B are general matrices. More...
 
template<typename typeB >
Matrix< typename Promote< Var, typeB >::type > CholeskySolve (const AbstractMatrixReadOnly< typeB > &B, int *ierr=NULL) const
 Finds X in A*X=B, where A is a square symmetric positive definite matrix. More...
 
Var Trace () const
 Calculate sum of the diagonal elements of the matrix. More...
 
void Print (INMOST_DATA_REAL_TYPE threshold=1.0e-10, std::ostream &sout=std::cout) const
 Output matrix to screen. More...
 
bool isSymmetric (double eps=1.0e-7) const
 Check if the matrix is symmetric. More...
 
template<typename typeB >
Promote< Var, typeB >::type DotProduct (const AbstractMatrixReadOnly< typeB > &other) const
 Computes dot product by summing up multiplication of entries with the same indices in the current and the provided matrix. More...
 
template<typename typeB >
Promote< Var, typeB >::type operator^ (const AbstractMatrixReadOnly< typeB > &other) const
 Computes dot product by summing up multiplication of entries with the same indices in the current and the provided matrix. More...
 
SelfPromote< Var >::type FrobeniusNorm () const
 Computes frobenius norm of the matrix. More...
 
Var MaxNorm () const
 Computes maximum absolute value of the matrix. More...
 
Matrix< Var > PseudoInvert (INMOST_DATA_REAL_TYPE tol=0, int *ierr=NULL) const
 Calculates Moore-Penrose pseudo-inverse of the matrix. More...
 
Matrix< Var > Power (INMOST_DATA_REAL_TYPE n, int *ierr=NULL) const
 Calcuate A^n, where n is some real value. More...
 
Matrix< Var > Root (INMOST_DATA_ENUM_TYPE iter=25, INMOST_DATA_REAL_TYPE tol=1.0e-7, int *ierr=NULL) const
 Calculate square root of A matrix by Babylonian method. More...
 
template<typename typeB >
Matrix< typename Promote< Var, typeB >::type > PseudoSolve (const AbstractMatrixReadOnly< typeB > &B, INMOST_DATA_REAL_TYPE tol=0, int *ierr=NULL) const
 Solves the system of equations of the form A*X=B, with A and B matrices. More...
 
Matrix< Var > ExtractSubMatrix (enumerator ibeg, enumerator iend, enumerator jbeg, enumerator jend) const
 Extract submatrix of a matrix. More...
 
ConstMatrixRepack< Var > Repack (enumerator rows, enumerator cols) const
 Change representation of the matrix into matrix of another size. More...
 
ConstSubMatrix< Var > operator() (enumerator first_row, enumerator last_row, enumerator first_col, enumerator last_col) const
 Extract submatrix of a matrix for in-place manipulation of elements. More...
 
ConstBlockOfMatrix< Var > BlockOf (enumerator nrows, enumerator ncols, enumerator offset_row, enumerator offset_col) const
 Define matrix as a part of a matrix of larger size with in-place manipulation of elements. More...
 
template<typename typeB >
MatrixMulCoef< Var, typeB, typename Promote< Var, typeB >::type > operator* (const typeB &coef) const
 Multiply the matrix by a coefficient. More...
 
template<class A >
MatrixMulShellCoef< Var, shell_expression< A >, typename Promote< Var, variable >::type > operator* (shell_expression< A > const &coef) const
 Multiply the matrix by a coefficient. More...
 
template<typename typeB >
MatrixDivCoef< Var, typeB, typename Promote< Var, typeB >::type > operator/ (const typeB &coef) const
 Divide the matrix by a coefficient of a different type. More...
 
template<class A >
MatrixDivShellCoef< Var, shell_expression< A >, typename Promote< Var, variable >::type > operator/ (shell_expression< A > const &coef) const
 Divide the matrix by a coefficient of a different type. More...
 
template<typename typeB >
Matrix< typename Promote< Var, typeB >::type > operator/ (const AbstractMatrixReadOnly< typeB > &other) const
 Performs B^{-1}*A, multiplication by inverse matrix from left. More...
 
ConstMatrixConcatCols< Var > ConcatCols (const AbstractMatrixReadOnly< Var > &B) const
 Concatenate B matrix as columns of current matrix. More...
 
template<typename VarB >
ConstMatrixConcatCols2< Var, VarB, typename Promote< Var, VarB >::type > ConcatCols (const AbstractMatrixReadOnly< VarB > &B) const
 Concatenate B matrix as columns of current matrix. More...
 
ConstMatrixConcatRows< Var > ConcatRows (const AbstractMatrixReadOnly< Var > &B) const
 Concatenate B matrix as rows of current matrix. More...
 
template<typename VarB >
ConstMatrixConcatRows2< Var, VarB, typename Promote< Var, VarB >::type > ConcatRows (const AbstractMatrixReadOnly< VarB > &B) const
 Concatenate B matrix as rows of current matrix. More...
 
virtual ~AbstractMatrixReadOnly ()
 Destructor.
 
__INLINE Matrix< Promote< variable, variable >::type > CholeskySolve (const AbstractMatrixReadOnly< variable > &B, int *ierr) const
 
__INLINE Matrix< Promote< INMOST_DATA_REAL_TYPE, variable >::type > CholeskySolve (const AbstractMatrixReadOnly< variable > &B, int *ierr) const
 
__INLINE Matrix< Promote< variable, INMOST_DATA_REAL_TYPE >::type > CholeskySolve (const AbstractMatrixReadOnly< INMOST_DATA_REAL_TYPE > &B, int *ierr) const
 

Static Public Member Functions

static Matrix Make (enumerator pn, enumerator pm,...)
 Construct a matrix with provided elements. More...
 
static Matrix< Var > Permutation (const INMOST_DATA_ENUM_TYPE *Perm, enumerator size)
 Construct row permutation matrix from array of new positions for rows. More...
 
static Matrix< Var > FromTensor (const Var *K, enumerator size, enumerator matsize=3)
 Convert values in array into square matrix. More...
 
static Matrix< Var > FromVector (const Var *r, enumerator size)
 Create column-vector in matrix form from array. More...
 
static Matrix< Var > FromDiagonal (const Var *r, enumerator size)
 Create diagonal matrix from array. More...
 
static Matrix< Var > FromDiagonalInverse (const Var *r, enumerator size)
 Create diagonal matrix from array of values that have to be inversed. More...
 
static Matrix< Var > CrossProductMatrix (const Var vec[3])
 Cross-product matrix. More...
 
static MatrixUnit< Var > Unit (enumerator pn, const Var &c=1.0)
 Unit matrix. More...
 
static MatrixRow< Var > Row (enumerator pn, const Var &c=1.0)
 Matix with 1 row, Create a matrix of size 1 by pn and fills it with c. More...
 
static MatrixCol< Var > Col (enumerator pn, const Var &c=1.0)
 Matix with 1 column, Create a matrix of size pn by 1 and fills it with c. More...
 

Protected Attributes

storage_type space
 
enumerator n
 
enumerator m
 

Additional Inherited Members

- Static Protected Attributes inherited from INMOST::AbstractMatrixBase
static thread_private< Sparse::RowMergermerger
 

Detailed Description

template<typename Var, typename storage_type>
class INMOST::Matrix< Var, storage_type >

Class for linear algebra operations on dense matrices.

Matrix with n rows and m columns.

m | | n| | |_____|

Todo:
:
  1. expression templates for operations (???) how to for multiplication? efficient multiplication would require all the matrix elements to be precomputed. consider number 5 instead.
  2. (ok) template matrix type for AD variables
  3. (ok,test) template container type for data storage.
  4. (ok,test) option for wrapper container around provided data storage. (to perform matrix operations with existing data)
  5. consider multi-threaded stack to get space for matrices for local operations and returns.
  6. class SubMatrix for fortran-like access to matrix.
  7. Uniform implementation of algorithms for Matrix and Submatrix. to achieve: make abdstract class with abstract element access operator, make matrix and submatrix ancestors of that class

Definition at line 1433 of file inmost_dense.h.

Constructor & Destructor Documentation

◆ Matrix() [1/8]

template<typename Var , typename storage_type >
INMOST::Matrix< Var, storage_type >::Matrix ( const Var *  pspace,
enumerator  pn,
enumerator  pm 
)
inline

Construct the matrix from provided array and sizes.

Parameters
pspaceArray of elements of the matrix, stored in row-wise format.
pnNumber of rows.
pmNumber of columns.

Definition at line 1562 of file inmost_dense.h.

◆ Matrix() [2/8]

template<typename Var , typename storage_type >
INMOST::Matrix< Var, storage_type >::Matrix ( const storage_type &  pspace,
enumerator  pn,
enumerator  pm 
)
inline

Construct the matrix with the provided storage with known size.

Could be used to wrap existing array.

Warning
The size of the provided container is assumed to be pn*pm.
Parameters
pspaceStorage of elements of the matrix, stored in row-wise format.
pnNumber of rows.
pmNumber of columns.
Todo:
Do we need reference for pspace or just pspace?

Definition at line 1570 of file inmost_dense.h.

◆ Matrix() [3/8]

template<typename Var , typename storage_type >
INMOST::Matrix< Var, storage_type >::Matrix ( const storage_type &  pspace)
inline

Construct the matrix with the provided storage and unknown size.

Could be used to wrap existing array.

Warning
Have to call Resize afterwards.
Parameters
pspaceStorage of elements of the matrix, stored in row-wise format.
Todo:
Do we need reference for pspace or just pspace?

Definition at line 1576 of file inmost_dense.h.

◆ Matrix() [4/8]

template<typename Var , typename storage_type >
INMOST::Matrix< Var, storage_type >::Matrix ( enumerator  pn,
enumerator  pm 
)
inline

Construct a matrix with provided sizes.

Parameters
pnNumber of rows.
pmNumber of columns.
Warning
The matrix does not necessary have zero entries.

Definition at line 1581 of file inmost_dense.h.

◆ Matrix() [5/8]

template<typename Var , typename storage_type >
INMOST::Matrix< Var, storage_type >::Matrix ( enumerator  pn,
enumerator  pm,
const Var &  c 
)
inline

Construct a matrix with provided sizes and fills with value.

Parameters
pnNumber of rows.
pmNumber of columns.
cValue to fill the matrix.

Definition at line 1586 of file inmost_dense.h.

◆ Matrix() [6/8]

template<typename Var , typename storage_type >
INMOST::Matrix< Var, storage_type >::Matrix ( const Matrix< Var, storage_type > &  other)
inline

Copy matrix.

Parameters
otherAnother matrix of the same type.

Definition at line 1607 of file inmost_dense.h.

◆ Matrix() [7/8]

template<typename Var , typename storage_type >
template<typename typeB >
INMOST::Matrix< Var, storage_type >::Matrix ( const AbstractMatrixReadOnly< typeB > &  other)
inline

Construct matrix from matrix of different type.

Uses assign function declared in inmost_expression.h. Copies derivative information if possible.

Parameters
otherAnother matrix of different type.

Definition at line 1617 of file inmost_dense.h.

◆ Matrix() [8/8]

template<typename Var , typename storage_type >
template<typename typeB >
INMOST::Matrix< Var, storage_type >::Matrix ( const AbstractMatrix< typeB > &  other)
inline

Construct matrix from matrix of different type.

Uses assign function declared in inmost_expression.h. Copies derivative information if possible.

Parameters
otherAnother matrix of different type.

Definition at line 1628 of file inmost_dense.h.

Member Function Documentation

◆ Col()

template<typename Var , typename storage_type >
static MatrixCol<Var> INMOST::Matrix< Var, storage_type >::Col ( enumerator  pn,
const Var &  c = 1.0 
)
inlinestatic

Matix with 1 column, Create a matrix of size pn by 1 and fills it with c.

Parameters
pnNumber of rows.
cValue to fill the matrix.
Returns
Returns a matrix with 1 column.

Definition at line 1977 of file inmost_dense.h.

◆ Cols() [1/2]

template<typename Var , typename storage_type >
__INLINE enumerator& INMOST::Matrix< Var, storage_type >::Cols ( )
inline

Obtain number of rows.

Returns
Reference to number of columns.

Definition at line 1744 of file inmost_dense.h.

◆ Cols() [2/2]

template<typename Var , typename storage_type >
__INLINE enumerator INMOST::Matrix< Var, storage_type >::Cols ( ) const
inlinevirtual

Obtain number of columns.

Returns
Number of columns.

Implements INMOST::AbstractMatrixReadOnly< Var >.

Definition at line 1738 of file inmost_dense.h.

◆ compute()

template<typename Var , typename storage_type >
__INLINE Var INMOST::Matrix< Var, storage_type >::compute ( enumerator  i,
enumerator  j 
) const
inlinevirtual

Access element of the matrix by row and column indices.

Parameters
iColumn index.
jRow index.
Returns
Element copy.

Implements INMOST::AbstractMatrixReadOnly< Var >.

Definition at line 1707 of file inmost_dense.h.

◆ CrossProductMatrix()

template<typename Var , typename storage_type >
static Matrix<Var> INMOST::Matrix< Var, storage_type >::CrossProductMatrix ( const Var  vec[3])
inlinestatic

Cross-product matrix.

Converts an array of 3 elements representing a vector into matrix, helps replace a cross product of two vectors by multiplication of matrix and vector. For a x b equivalent is CrossProduct(a)*b.

Parameters
vecArray of elements representing a vector.
Returns
A matrix representing cross product.

Definition at line 1933 of file inmost_dense.h.

◆ data() [1/2]

template<typename Var , typename storage_type >
__INLINE Var* INMOST::Matrix< Var, storage_type >::data ( )
inline

Return raw pointer to matrix data, stored in row-wise format.

Returns
Pointer to data.

Definition at line 1728 of file inmost_dense.h.

◆ data() [2/2]

template<typename Var , typename storage_type >
__INLINE const Var* INMOST::Matrix< Var, storage_type >::data ( ) const
inline

Return raw pointer to matrix data without right of change, stored in row-wise format.

Returns
Pointer to constant data.

Definition at line 1732 of file inmost_dense.h.

◆ FromDiagonal()

template<typename Var , typename storage_type >
static Matrix<Var> INMOST::Matrix< Var, storage_type >::FromDiagonal ( const Var *  r,
enumerator  size 
)
inlinestatic

Create diagonal matrix from array.

Parameters
rArray of diagonal elements.
sizeSize of the matrix.
Returns
Matrix with diagonal defined by array, other elements are zero.

Definition at line 1909 of file inmost_dense.h.

◆ FromDiagonalInverse()

template<typename Var , typename storage_type >
static Matrix<Var> INMOST::Matrix< Var, storage_type >::FromDiagonalInverse ( const Var *  r,
enumerator  size 
)
inlinestatic

Create diagonal matrix from array of values that have to be inversed.

Parameters
rArray of diagonal elements.
sizeSize of the matrix.
Returns
Matrix with diagonal defined by inverse of array elements.

Definition at line 1920 of file inmost_dense.h.

◆ FromTensor()

template<typename Var , typename storage_type >
static Matrix<Var> INMOST::Matrix< Var, storage_type >::FromTensor ( const Var *  K,
enumerator  size,
enumerator  matsize = 3 
)
inlinestatic

Convert values in array into square matrix.

Supports the following representation, depending on the size of input array and size of side of final tensors' matrix:

representation | (array size, tensor size)

scalar | (1,1), (1,2), (1,3), (1,6)

diagonal | (2,2), (3,3), (6,6)

symmetric | (3,2), (6,3), (21,6)

full | (4,2), (9,3), (36,6)

For full matrix elements in array are enumerated row by row. For symmetric matrix elements in array are enumerated row by row starting from diagonal.

Parameters
KArray of elements to be converted into tensor.
sizeSize of the input array.
matsizeSize of the final tensor.
Returns
Matrix of the tensor of size matsize by matsize.

Definition at line 1783 of file inmost_dense.h.

◆ FromVector()

template<typename Var , typename storage_type >
static Matrix<Var> INMOST::Matrix< Var, storage_type >::FromVector ( const Var *  r,
enumerator  size 
)
inlinestatic

Create column-vector in matrix form from array.

Parameters
rArray of elements of the vector.
sizeSize of the vector.
Returns
Vector with contents of the array.

Definition at line 1901 of file inmost_dense.h.

◆ get()

template<typename Var , typename storage_type >
__INLINE const Var& INMOST::Matrix< Var, storage_type >::get ( enumerator  i,
enumerator  j 
) const
inlinevirtual

Access element of the matrix by row and column indices without right to change the element.

Parameters
iColumn index.
jRow index.
Returns
Reference to constant element.

Implements INMOST::AbstractMatrix< Var >.

Definition at line 1719 of file inmost_dense.h.

◆ JointDiagonalization()

template<typename Var , typename storage_type >
Matrix<Var> INMOST::Matrix< Var, storage_type >::JointDiagonalization ( INMOST_DATA_REAL_TYPE  threshold = 1.0e-7)
inline

Joint diagonalization algorithm by Cardoso.

Source http://perso.telecom-paristech.fr/~cardoso/Algo/Joint_Diag/joint_diag_r.m Current matrix should have size n by n*m And represent concatenation of m n by n matrices. Current matrix is replaced by diagonalized matrices. For correct result it is required that input matrices are exactly diagonalizable, otherwise the result may be approximate.

Parameters
thresholdOptional small number.
Returns
A unitary n by n matrix V used to diagonalize array of initial matrices. Current matrix is replaced by concatenation of V^T*A_i*V, a collection of diagonalized matrices.

Definition at line 1990 of file inmost_dense.h.

◆ Make()

template<typename Var , typename storage_type >
static Matrix INMOST::Matrix< Var, storage_type >::Make ( enumerator  pn,
enumerator  pm,
  ... 
)
inlinestatic

Construct a matrix with provided elements.

The elements are ordered row-wise.

Parameters
pnNumber of rows.
pmNumber of columns.

Definition at line 1591 of file inmost_dense.h.

◆ operator()()

template<typename Var , typename storage_type >
__INLINE Var& INMOST::Matrix< Var, storage_type >::operator() ( enumerator  i,
enumerator  j 
)
inlinevirtual

Access element of the matrix by row and column indices.

Parameters
iColumn index.
jRow index.
Returns
Reference to element.

Implements INMOST::AbstractMatrix< Var >.

Definition at line 1696 of file inmost_dense.h.

◆ operator=() [1/3]

template<typename Var , typename storage_type >
template<typename typeB >
Matrix& INMOST::Matrix< Var, storage_type >::operator= ( AbstractMatrix< typeB > const &  other)
inline

Assign matrix of another type.

Parameters
otherAnother matrix of different type.
Returns
Reference to matrix.

Definition at line 1681 of file inmost_dense.h.

◆ operator=() [2/3]

template<typename Var , typename storage_type >
template<typename typeB >
Matrix& INMOST::Matrix< Var, storage_type >::operator= ( AbstractMatrixReadOnly< typeB > const &  other)
inline

Assign matrix of another type.

Parameters
otherAnother matrix of different type.
Returns
Reference to matrix.

Definition at line 1666 of file inmost_dense.h.

◆ operator=() [3/3]

template<typename Var , typename storage_type >
Matrix& INMOST::Matrix< Var, storage_type >::operator= ( Matrix< Var, storage_type > const &  other)
inline

Assign matrix of the same type.

Parameters
otherAnother matrix of the same type.
Returns
Reference to matrix.

Definition at line 1649 of file inmost_dense.h.

◆ Permutation()

template<typename Var , typename storage_type >
static Matrix<Var> INMOST::Matrix< Var, storage_type >::Permutation ( const INMOST_DATA_ENUM_TYPE *  Perm,
enumerator  size 
)
inlinestatic

Construct row permutation matrix from array of new positions for rows.

Row permutation matrix multiplies matrix from left. Column permutation matrix is obtained by transposition and is multiplied from the right. Argument Perm is filled with the new position for rows, i.e. i-th row takes new position Perm[i]

Parameters
PermArray with new positions for rows.
sizeSize of the array and the resulting matrix.
Returns
Permutation matrix.

Definition at line 1754 of file inmost_dense.h.

◆ RemoveColumn()

template<typename Var , typename storage_type >
void INMOST::Matrix< Var, storage_type >::RemoveColumn ( enumerator  col)
inline

Erase single column.

Parameters
rowPosition of column, should be from 0 to Matrix::Cols()-1.

Definition at line 1480 of file inmost_dense.h.

◆ RemoveColumns()

template<typename Var , typename storage_type >
void INMOST::Matrix< Var, storage_type >::RemoveColumns ( enumerator  first,
enumerator  last 
)
inline

Erase multiple columns.

Assumes first <= last. If first == last, then no column is deleted.

Parameters
firstPosition of the first column, should be from 0 to Matrix::Cols()-1.
lastPosition behind the last column, should be from 0 to Matrix::Cols().
Todo:
check

Definition at line 1498 of file inmost_dense.h.

◆ RemoveRow()

template<typename Var , typename storage_type >
void INMOST::Matrix< Var, storage_type >::RemoveRow ( enumerator  row)
inline

Erase single row.

Parameters
rowPosition of row, should be from 0 to Matrix::Rows()-1.

Definition at line 1448 of file inmost_dense.h.

◆ RemoveRows()

template<typename Var , typename storage_type >
void INMOST::Matrix< Var, storage_type >::RemoveRows ( enumerator  first,
enumerator  last 
)
inline

Erase multiple rows.

Assumes first <= last. If first == last, then no row is deleted.

Parameters
firstPosition of the first row, should be from 0 to Matrix::Rows()-1.
lastPosition behind the last row, should be from 0 to Matrix::Rows().
Todo:
check

Definition at line 1464 of file inmost_dense.h.

◆ RemoveSubset()

template<typename Var , typename storage_type >
void INMOST::Matrix< Var, storage_type >::RemoveSubset ( enumerator  firstrow,
enumerator  lastrow,
enumerator  firstcol,
enumerator  lastcol 
)
inline

Erase part of the matrix.

Parameters
firstrowPosition of the first row, should be from 0 to Matrix::Rows()-1.
lastrowPosition behind the last row, should be from 0 to Matrix::Rows().
firstcolPosition of the first column, should be from 0 to Matrix::Cols()-1.
lastcolPosition behind the last column, should be from 0 to Matrix::Cols().

Definition at line 1519 of file inmost_dense.h.

◆ Resize()

template<typename Var , typename storage_type >
void INMOST::Matrix< Var, storage_type >::Resize ( enumerator  nrows,
enumerator  mcols 
)
inlinevirtual

Resize the matrix into different size.

Parameters
nrowsNew number of rows.
ncolsNew number of columns.

Implements INMOST::AbstractMatrix< Var >.

Definition at line 1639 of file inmost_dense.h.

◆ Row()

template<typename Var , typename storage_type >
static MatrixRow<Var> INMOST::Matrix< Var, storage_type >::Row ( enumerator  pn,
const Var &  c = 1.0 
)
inlinestatic

Matix with 1 row, Create a matrix of size 1 by pn and fills it with c.

Parameters
pnNumber of columns.
cValue to fill the matrix.
Returns
Returns a matrix with 1 row.

Definition at line 1970 of file inmost_dense.h.

◆ Rows() [1/2]

template<typename Var , typename storage_type >
__INLINE enumerator& INMOST::Matrix< Var, storage_type >::Rows ( )
inline

Obtain number of rows.

Returns
Reference to number of rows.

Definition at line 1741 of file inmost_dense.h.

◆ Rows() [2/2]

template<typename Var , typename storage_type >
__INLINE enumerator INMOST::Matrix< Var, storage_type >::Rows ( ) const
inlinevirtual

Obtain number of rows.

Returns
Number of rows.

Implements INMOST::AbstractMatrixReadOnly< Var >.

Definition at line 1735 of file inmost_dense.h.

◆ Unit()

template<typename Var , typename storage_type >
static MatrixUnit<Var> INMOST::Matrix< Var, storage_type >::Unit ( enumerator  pn,
const Var &  c = 1.0 
)
inlinestatic

Unit matrix.

Creates a square matrix of size pn by pn and fills the diagonal with c.

Parameters
pnNumber of rows and columns in the matrix.
cValue to put onto diagonal.
Returns
Returns a unit matrix.

Definition at line 1955 of file inmost_dense.h.


The documentation for this class was generated from the following files: