All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Modules | Classes
Matrices

Modules

 Dense Matrices
 
 Sparse Matrices
 

Classes

struct  blaze::Matrix< typename, bool >
 Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes within the Blaze library. It provides an abstraction from the actual type of the matrix, but enables a conversion back to this type via the 'Curiously Recurring Template Pattern' (CRTP). More...
 

Matrix global functions

template<typename MT , bool SO>
BLAZE_ALWAYS_INLINE size_t blaze::rows (const Matrix< MT, SO > &matrix)
 Returns the current number of rows of the matrix. More...
 
template<typename MT , bool SO>
BLAZE_ALWAYS_INLINE size_t blaze::columns (const Matrix< MT, SO > &matrix)
 Returns the current number of columns of the matrix. More...
 
template<typename MT , bool SO>
BLAZE_ALWAYS_INLINE size_t blaze::capacity (const Matrix< MT, SO > &matrix)
 Returns the maximum capacity of the matrix. More...
 
template<typename MT , bool SO>
BLAZE_ALWAYS_INLINE size_t blaze::capacity (const Matrix< MT, SO > &matrix, size_t i)
 Returns the current capacity of the specified row/column. More...
 
template<typename MT , bool SO>
BLAZE_ALWAYS_INLINE size_t blaze::nonZeros (const Matrix< MT, SO > &matrix)
 Returns the total number of non-zero elements in the matrix. More...
 
template<typename MT , bool SO>
BLAZE_ALWAYS_INLINE size_t blaze::nonZeros (const Matrix< MT, SO > &matrix, size_t i)
 Returns the number of non-zero elements in the specified row/column. More...
 
template<typename MT , bool SO>
BLAZE_ALWAYS_INLINE void blaze::resize (Matrix< MT, SO > &matrix, size_t m, size_t n, bool preserve)
 Changing the size of the matrix. More...
 
template<typename MT1 , bool SO1, typename MT2 , bool SO2>
BLAZE_ALWAYS_INLINE void blaze::assign (Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
 Default implementation of the assignment of a matrix to a matrix. More...
 
template<typename MT1 , bool SO1, typename MT2 , bool SO2>
BLAZE_ALWAYS_INLINE void blaze::addAssign (Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
 Default implementation of the addition assignment of a matrix to a matrix. More...
 
template<typename MT1 , bool SO1, typename MT2 , bool SO2>
BLAZE_ALWAYS_INLINE void blaze::subAssign (Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
 Default implementation of the subtraction assignment of a matrix to matrix. More...
 
template<typename MT1 , bool SO1, typename MT2 , bool SO2>
BLAZE_ALWAYS_INLINE void blaze::multAssign (Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
 Default implementation of the multiplication assignment of a matrix to a matrix. More...
 
template<typename MT , bool SO>
BLAZE_ALWAYS_INLINE bool blaze::isSquare (const Matrix< MT, SO > &matrix)
 Checks if the given matrix is a square matrix. More...
 
template<typename MT1 , bool SO1, typename MT2 , bool SO2>
BLAZE_ALWAYS_INLINE bool blaze::isSame (const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b)
 Returns whether the two given matrices represent the same observable state. More...
 

Matrix operators

template<typename MT , bool SO>
std::ostream & blaze::operator<< (std::ostream &os, const Matrix< MT, SO > &m)
 Global output operator for dense and sparse matrices. More...
 

Detailed Description

Function Documentation

template<typename MT1 , bool SO1, typename MT2 , bool SO2>
BLAZE_ALWAYS_INLINE void blaze::addAssign ( Matrix< MT1, SO1 > &  lhs,
const Matrix< MT2, SO2 > &  rhs 
)

Default implementation of the addition assignment of a matrix to a matrix.

Parameters
lhsThe target left-hand side matrix.
rhsThe right-hand side matrix to be added.
Returns
void

This function implements the default addition assignment of a matrix to a matrix.
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename MT1 , bool SO1, typename MT2 , bool SO2>
BLAZE_ALWAYS_INLINE void blaze::assign ( Matrix< MT1, SO1 > &  lhs,
const Matrix< MT2, SO2 > &  rhs 
)

Default implementation of the assignment of a matrix to a matrix.

Parameters
lhsThe target left-hand side matrix.
rhsThe right-hand side matrix to be assigned.
Returns
void

This function implements the default assignment of a matrix to a matrix.
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename MT , bool SO>
BLAZE_ALWAYS_INLINE size_t blaze::capacity ( const Matrix< MT, SO > &  matrix)

Returns the maximum capacity of the matrix.

Parameters
matrixThe given matrix.
Returns
The capacity of the matrix.
template<typename MT , bool SO>
BLAZE_ALWAYS_INLINE size_t blaze::capacity ( const Matrix< MT, SO > &  matrix,
size_t  i 
)

Returns the current capacity of the specified row/column.

Parameters
matrixThe given matrix.
iThe index of the row/column.
Returns
The current capacity of row/column i.

This function returns the current capacity of the specified row/column. In case the storage order is set to rowMajor the function returns the capacity of row i, in case the storage flag is set to columnMajor the function returns the capacity of column i.

template<typename MT , bool SO>
BLAZE_ALWAYS_INLINE size_t blaze::columns ( const Matrix< MT, SO > &  matrix)

Returns the current number of columns of the matrix.

Parameters
matrixThe given matrix.
Returns
The number of columns of the matrix.
template<typename MT1 , bool SO1, typename MT2 , bool SO2>
BLAZE_ALWAYS_INLINE bool blaze::isSame ( const Matrix< MT1, SO1 > &  a,
const Matrix< MT2, SO2 > &  b 
)

Returns whether the two given matrices represent the same observable state.

Parameters
aThe first matrix to be tested for its state.
bThe second matrix to be tested for its state.
Returns
true in case the two matrices share a state, false otherwise.

The isSame function provides an abstract interface for testing if the two given matrices represent the same observable state. This happens for instance in case a and b refer to the same matrix or in case a and b are aliases for the same matrix. In case both matrices represent the same observable state, the function returns true, other it returns false.

typedef blaze::DynamicMatrix<int> MatrixType;
typedef blaze::DenseSubmatrix<MatrixType> SubmatrixType;
MatrixType mat1( 4UL, 5UL ); // Setup of a 4x5 dynamic matrix
MatrixType mat2( 4UL, 5UL ); // Setup of a second 4x5 dynamic matrix
SubmatrixType sub1 = submatrix( mat1, 0UL, 0UL, 4UL, 5UL ); // Submatrix fully covering mat1
SubmatrixType sub2 = submatrix( mat1, 1UL, 1UL, 2UL, 3UL ); // Submatrix partially covering mat1
SubmatrixType sub3 = submatrix( mat1, 1UL, 1UL, 2UL, 3UL ); // Submatrix partially covering mat1
isSame( mat1, mat1 ); // returns true since both objects refer to the same matrix
isSame( mat1, mat2 ); // returns false since mat1 and mat2 are two different matrices
isSame( mat1, sub1 ); // returns true since sub1 represents the same observable state as mat1
isSame( mat1, sub3 ); // returns false since sub3 only covers part of mat1
isSame( sub2, sub3 ); // returns true since sub1 and sub2 refer to exactly the same part of mat1
isSame( sub1, sub3 ); // returns false since sub1 and sub3 refer to different parts of mat1
template<typename MT , bool SO>
BLAZE_ALWAYS_INLINE bool blaze::isSquare ( const Matrix< MT, SO > &  matrix)

Checks if the given matrix is a square matrix.

Parameters
matrixThe matrix to be checked.
Returns
true if the matrix is a square matrix, false if not.

This function checks if the number of rows and columns of the given matrix are equal. If they are, the function returns true, otherwise it returns false.

template<typename MT1 , bool SO1, typename MT2 , bool SO2>
BLAZE_ALWAYS_INLINE void blaze::multAssign ( Matrix< MT1, SO1 > &  lhs,
const Matrix< MT2, SO2 > &  rhs 
)

Default implementation of the multiplication assignment of a matrix to a matrix.

Parameters
lhsThe target left-hand side matrix.
rhsThe right-hand side matrix to be multiplied.
Returns
void

This function implements the default multiplication assignment of a matrix to a matrix.
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename MT , bool SO>
BLAZE_ALWAYS_INLINE size_t blaze::nonZeros ( const Matrix< MT, SO > &  matrix)

Returns the total number of non-zero elements in the matrix.

Parameters
matrixThe given matrix.
Returns
The number of non-zero elements in the dense matrix.
template<typename MT , bool SO>
BLAZE_ALWAYS_INLINE size_t blaze::nonZeros ( const Matrix< MT, SO > &  matrix,
size_t  i 
)

Returns the number of non-zero elements in the specified row/column.

Parameters
matrixThe given matrix.
iThe index of the row/column.
Returns
The number of non-zero elements of row/column i.

This function returns the current number of non-zero elements in the specified row/column. In case the storage order is set to rowMajor the function returns the number of non-zero elements in row i, in case the storage flag is set to columnMajor the function returns the number of non-zero elements in column i.

template<typename MT , bool SO>
std::ostream & blaze::operator<< ( std::ostream &  os,
const Matrix< MT, SO > &  m 
)
inline

Global output operator for dense and sparse matrices.

Parameters
osReference to the output stream.
mReference to a constant matrix object.
Returns
Reference to the output stream.
template<typename MT , bool SO>
BLAZE_ALWAYS_INLINE void blaze::resize ( Matrix< MT, SO > &  matrix,
size_t  m,
size_t  n,
bool  preserve 
)

Changing the size of the matrix.

Parameters
matrixThe given matrix to be resized.
mThe new number of rows of the matrix.
nThe new number of columns of the matrix.
preservetrue if the old values of the matrix should be preserved, false if not.
Returns
void
Exceptions
std::invalid_argumentInvalid resize arguments for square matrix.
std::invalid_argumentMatrix cannot be resized.

This function provides a unified interface to resize dense and sparse matrices. In contrast to the resize() member function, which is only available on resizable matrix types, this function can be used on both resizable and non-resizable matrices. In case the given matrix of type MT is resizable (i.e. provides a resize function) the type-specific resize() member function is called. Depending on the type MT, this may result in the allocation of new dynamic memory and the invalidation of existing views (submatrices, rows, columns, ...). Note that in case the matrix is a compile time square matrix (as for instance the blaze::SymmetricMatrix adaptor, ...) the specified number of rows must be identical to the number of columns. Otherwise a std::invalid_argument exception is thrown. If the matrix type MT is non-resizable (i.e. does not provide a resize() function) and if the specified number of rows and columns is not identical to the current number of rows and columns of the matrix, a std::invalid_argument exception is thrown.

resize( A, 5UL, 2UL ); // OK: regular resize operation
resize( B, 4UL, 4UL ); // OK: Number of rows and columns is identical
resize( B, 3UL, 5UL ); // Error: Invalid arguments for square matrix!
resize( C, 3UL, 3UL ); // OK: No resize necessary
resize( C, 5UL, 2UL ); // Error: Matrix cannot be resized!
template<typename MT , bool SO>
BLAZE_ALWAYS_INLINE size_t blaze::rows ( const Matrix< MT, SO > &  matrix)

Returns the current number of rows of the matrix.

Parameters
matrixThe given matrix.
Returns
The number of rows of the matrix.
template<typename MT1 , bool SO1, typename MT2 , bool SO2>
BLAZE_ALWAYS_INLINE void blaze::subAssign ( Matrix< MT1, SO1 > &  lhs,
const Matrix< MT2, SO2 > &  rhs 
)

Default implementation of the subtraction assignment of a matrix to matrix.

Parameters
lhsThe target left-hand side matrix.
rhsThe right-hand side matrix to be subtracted.
Returns
void

This function implements the default subtraction assignment of a matrix to a matrix.
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.