All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Private Types | List of all members
blaze::DynamicMatrix< Type, SO > Class Template Reference

Efficient implementation of a dynamic $ M \times N $ matrix.The DynamicMatrix class template is the representation of an arbitrary sized matrix with $ M \cdot N $ dynamically allocated elements of arbitrary type. The type of the elements and the storage order of the matrix can be specified via the two template parameters: More...

#include <DynamicMatrix.h>

Inherits blaze::DenseMatrix< DynamicMatrix< Type, SO >, SO >.

Public Types

enum  { vectorizable = IsVectorizable<Type>::value }
 Compilation flag for intrinsic optimization. More...
 
enum  { canAlias = 0 }
 Compilation flag for the detection of aliasing effects. More...
 
typedef DynamicMatrix< Type, SO > This
 Type of this DynamicMatrix instance.
 
typedef This ResultType
 Result type for expression template evaluations.
 
typedef DynamicMatrix< Type,!SO > OppositeType
 Result type with opposite storage order for expression template evaluations.
 
typedef DynamicMatrix< Type,!SO > TransposeType
 Transpose type for expression template evaluations.
 
typedef Type ElementType
 Type of the matrix elements.
 
typedef const Type & ReturnType
 Return type for expression template evaluations.
 
typedef IT::Type IntrinsicType
 Intrinsic type of the matrix elements.
 
typedef const ThisCompositeType
 Data type for composite expression templates.
 
typedef Type & Reference
 Reference to a non-constant matrix value.
 
typedef const Type & ConstReference
 Reference to a constant matrix value.
 
typedef Type * Iterator
 Iterator over non-constant elements.
 
typedef const Type * ConstIterator
 Iterator over constant elements.
 
typedef MT MatrixType
 Type of the matrix.
 

Public Member Functions

MatrixTypeoperator~ ()
 Conversion operator for non-constant matrices.
 
const MatrixTypeoperator~ () const
 Conversion operator for constant matrices.
 
Constructors
 DynamicMatrix ()
 The default constructor for DynamicMatrix.
 
 DynamicMatrix (size_t m, size_t n)
 Constructor for a matrix of size $ m \times n $. No element initialization is performed!
 
 DynamicMatrix (size_t m, size_t n, Type init)
 Constructor for a homogenous initialization of all $ m \times n $ matrix elements.
 
 DynamicMatrix (const DynamicMatrix &m)
 The copy constructor for DynamicMatrix.
 
template<typename MT , bool SO2>
 DynamicMatrix (const Matrix< MT, SO2 > &m)
 Conversion constructor from different matrices.
 
template<typename Other , size_t M, size_t N>
 DynamicMatrix (const Other(&rhs)[M][N])
 Array initialization of all matrix elements.
 
Destructor
 ~DynamicMatrix ()
 The destructor for DynamicMatrix.
 
Data access functions
Reference operator() (size_t i, size_t j)
 2D-access to the matrix elements.
 
ConstReference operator() (size_t i, size_t j) const
 2D-access to the matrix elements.
 
Type * data ()
 Low-level data access to the matrix elements.
 
const Type * data () const
 Low-level data access to the matrix elements.
 
Iterator begin (size_t i)
 Returns an iterator to the first element of row/column i.
 
ConstIterator begin (size_t i) const
 Returns an iterator to the first element of row/column i.
 
ConstIterator cbegin (size_t i) const
 Returns an iterator to the first element of row/column i.
 
Iterator end (size_t i)
 Returns an iterator just past the last element of row/column i.
 
ConstIterator end (size_t i) const
 Returns an iterator just past the last element of row/column i.
 
ConstIterator cend (size_t i) const
 Returns an iterator just past the last element of row/column i.
 
Assignment operators
template<typename Other , size_t M, size_t N>
DynamicMatrixoperator= (const Other(&rhs)[M][N])
 Array assignment to all matrix elements.
 
DynamicMatrixoperator= (Type set)
 Homogenous assignment to all matrix elements.
 
DynamicMatrixoperator= (const DynamicMatrix &set)
 Copy assignment operator for DynamicMatrix.
 
template<typename MT , bool SO2>
DynamicMatrixoperator= (const Matrix< MT, SO2 > &rhs)
 Assignment operator for different matrices.
 
template<typename MT , bool SO2>
DynamicMatrixoperator+= (const Matrix< MT, SO2 > &rhs)
 Addition assignment operator for the addition of a matrix ( $ A+=B $).
 
template<typename MT , bool SO2>
DynamicMatrixoperator-= (const Matrix< MT, SO2 > &rhs)
 Subtraction assignment operator for the subtraction of a matrix ( $ A-=B $).
 
template<typename MT , bool SO2>
DynamicMatrixoperator*= (const Matrix< MT, SO2 > &rhs)
 Multiplication assignment operator for the multiplication of a matrix ( $ A*=B $).
 
template<typename Other >
EnableIf< IsNumeric< Other >
, DynamicMatrix >::Type & 
operator*= (Other rhs)
 Multiplication assignment operator for the multiplication between a matrix and a scalar value ( $ A*=s $).
 
template<typename Other >
EnableIf< IsNumeric< Other >
, DynamicMatrix >::Type & 
operator/= (Other rhs)
 Division assignment operator for the division of a matrix by a scalar value ( $ A/=s $).
 
Expression template evaluation functions
template<typename Other >
bool isAliased (const Other *alias) const
 Returns whether the matrix is aliased with the given address alias.
 
IntrinsicType get (size_t i, size_t j) const
 Access to the intrinsic elements of the matrix.
 
template<typename MT >
DisableIf< VectorizedAssign
< MT > >::Type 
assign (const DenseMatrix< MT, SO > &rhs)
 Default implementation of the assignment of a row-major dense matrix.
 
template<typename MT >
EnableIf< VectorizedAssign< MT >
>::Type 
assign (const DenseMatrix< MT, SO > &rhs)
 
template<typename MT >
void assign (const DenseMatrix< MT,!SO > &rhs)
 Default implementation of the assignment of a column-major dense matrix.
 
template<typename MT >
void assign (const SparseMatrix< MT, SO > &rhs)
 Default implementation of the assignment of a row-major sparse matrix.
 
template<typename MT >
void assign (const SparseMatrix< MT,!SO > &rhs)
 Default implementation of the assignment of a column-major sparse matrix.
 
template<typename MT >
DisableIf< VectorizedAddAssign
< MT > >::Type 
addAssign (const DenseMatrix< MT, SO > &rhs)
 Default implementation of the addition assignment of a row-major dense matrix.
 
template<typename MT >
EnableIf< VectorizedAddAssign
< MT > >::Type 
addAssign (const DenseMatrix< MT, SO > &rhs)
 
template<typename MT >
void addAssign (const DenseMatrix< MT,!SO > &rhs)
 Default implementation of the addition assignment of a column-major dense matrix.
 
template<typename MT >
void addAssign (const SparseMatrix< MT, SO > &rhs)
 Default implementation of the addition assignment of a row-major sparse matrix.
 
template<typename MT >
void addAssign (const SparseMatrix< MT,!SO > &rhs)
 Default implementation of the addition assignment of a column-major sparse matrix.
 
template<typename MT >
DisableIf< VectorizedSubAssign
< MT > >::Type 
subAssign (const DenseMatrix< MT, SO > &rhs)
 Default implementation of the subtraction assignment of a row-major dense matrix.
 
template<typename MT >
EnableIf< VectorizedSubAssign
< MT > >::Type 
subAssign (const DenseMatrix< MT, SO > &rhs)
 
template<typename MT >
void subAssign (const DenseMatrix< MT,!SO > &rhs)
 Default implementation of the subtraction assignment of a column-major dense matrix.
 
template<typename MT >
void subAssign (const SparseMatrix< MT, SO > &rhs)
 Default implementation of the subtraction assignment of a row-major sparse matrix.
 
template<typename MT >
void subAssign (const SparseMatrix< MT,!SO > &rhs)
 Default implementation of the subtraction assignment of a column-major sparse matrix.
 

Private Types

typedef IntrinsicTrait< Type > IT
 Intrinsic trait for the matrix element type.
 

Private Attributes

Member variables
size_t m_
 The current number of rows of the matrix.
 
size_t n_
 The current number of columns of the matrix.
 
size_t nn_
 The alignment adjusted number of columns.
 
size_t capacity_
 The maximum capacity of the matrix.
 
Type *BLAZE_RESTRICT v_
 The dynamically allocated matrix elements.
 

Utility functions

size_t rows () const
 Returns the current number of rows of the matrix.
 
size_t columns () const
 Returns the current number of columns of the matrix.
 
size_t spacing () const
 Returns the spacing between the beginning of two rows.
 
size_t capacity () const
 Returns the maximum capacity of the matrix.
 
size_t nonZeros () const
 Returns the total number of non-zero elements in the matrix.
 
size_t nonZeros (size_t i) const
 Returns the number of non-zero elements in the specified row.
 
void reset ()
 Reset to the default initial values.
 
void clear ()
 Clearing the $ M \times N $ matrix.
 
void resize (size_t m, size_t n, bool preserve=true)
 Changing the size of the matrix.
 
void extend (size_t m, size_t n, bool preserve=true)
 Extending the size of the matrix.
 
void reserve (size_t elements)
 Setting the minimum capacity of the matrix.
 
DynamicMatrixtranspose ()
 Transposing the matrix.
 
DynamicMatrixinvert ()
 Inverting the matrix.
 
bool isDiagonal () const
 Checks if the matrix is diagonal.
 
bool isSymmetric () const
 Checks if the matrix is symmetric.
 
template<typename Other >
DynamicMatrixscale (Other scalar)
 Scaling of the matrix by the scalar value scalar ( $ A=B*s $).
 
void swap (DynamicMatrix &m)
 Swapping the contents of two matrices.
 
size_t adjustColumns (size_t minColumns) const
 Adjusting the number columns of the matrix according to its data type Type.
 

Detailed Description

template<typename Type, bool SO = defaultStorageOrder>
class blaze::DynamicMatrix< Type, SO >

Efficient implementation of a dynamic $ M \times N $ matrix.

The DynamicMatrix class template is the representation of an arbitrary sized matrix with $ M \cdot N $ dynamically allocated elements of arbitrary type. The type of the elements and the storage order of the matrix can be specified via the two template parameters:

template< typename Type, bool SO >

Depending on the storage order, the matrix elements are either stored in a row-wise fashion or in a column-wise fashion. Given the 2x3 matrix

\[\left(\begin{array}{*{3}{c}} 1 & 2 & 3 \\ 4 & 5 & 6 \\ \end{array}\right)\]


in case of row-major order the elements are stored in the order

\[\left(\begin{array}{*{6}{c}} 1 & 2 & 3 & 4 & 5 & 6. \\ \end{array}\right)\]

In case of column-major order the elements are stored in the order

\[\left(\begin{array}{*{6}{c}} 1 & 4 & 2 & 5 & 3 & 6. \\ \end{array}\right)\]

The use of DynamicMatrix is very natural and intuitive. All operations (addition, subtraction, multiplication, scaling, ...) can be performed on all possible combination of row-major and column-major dense and sparse matrices with fitting element types. The following example gives an impression of the use of DynamicMatrix:

DynamicMatrix<double,rowMajor> A( 2, 3 ); // Default constructed, non-initialized, row-major 2x3 matrix
A(0,0) = 1.0; A(0,1) = 2.0; A(0,2) = 3.0; // Initialization of the first row
A(1,0) = 4.0; A(1,1) = 5.0; A(1,2) = 6.0; // Initialization of the second row
DynamicMatrix<float,columnMajor> B( 2, 3 ); // Default constructed column-major single precision 2x3 matrix
B(0,0) = 1.0; B(0,1) = 3.0; B(0,2) = 5.0; // Initialization of the first row
B(1,0) = 2.0; B(1,1) = 4.0; B(1,2) = 6.0; // Initialization of the second row
CompressedMatrix<float> C( 2, 3 ); // Empty row-major sparse single precision matrix
DynamicMatrix<float> D( 3, 2, 4.0F ); // Directly, homogeneously initialized single precision 3x2 matrix
DynamicMatrix<double,rowMajor> E( A ); // Creation of a new row-major matrix as a copy of A
DynamicMatrix<double,columnMajor> F; // Creation of a default column-major matrix
E = A + B; // Matrix addition and assignment to a row-major matrix
E = A - C; // Matrix subtraction and assignment to a column-major matrix
F = A * D; // Matrix multiplication between two matrices of different element types
A *= 2.0; // In-place scaling of matrix A
E = 2.0 * B; // Scaling of matrix B
F = D * 2.0; // Scaling of matrix D
E += A - B; // Addition assignment
E -= A + C; // Subtraction assignment
F *= A * D; // Multiplication assignment

Member Enumeration Documentation

template<typename Type, bool SO = defaultStorageOrder>
anonymous enum

Compilation flag for intrinsic optimization.

The vectorizable compilation flag indicates whether expressions the matrix is involved in can be optimized via intrinsics. In case the element type of the matrix is a vectorizable data type, the vectorizable compilation flag is set to true, otherwise it is set to false.

template<typename Type, bool SO = defaultStorageOrder>
anonymous enum

Compilation flag for the detection of aliasing effects.

This compilation switch indicates whether this type potentially causes compuation errors due to aliasing effects. In case the type can cause aliasing effects, the canAlias switch is set to true, otherwise it is set to false.

Constructor & Destructor Documentation

template<typename Type , bool SO>
blaze::DynamicMatrix< Type, SO >::DynamicMatrix ( size_t  m,
size_t  n 
)
inlineexplicit

Constructor for a matrix of size $ m \times n $. No element initialization is performed!

Parameters
mThe number of rows of the matrix.
nThe number of columns of the matrix.

Note: This constructor is only responsible to allocate the required dynamic memory. No element initialization is performed!

template<typename Type, bool SO>
blaze::DynamicMatrix< Type, SO >::DynamicMatrix ( size_t  m,
size_t  n,
Type  init 
)
inlineexplicit

Constructor for a homogenous initialization of all $ m \times n $ matrix elements.

Parameters
mThe number of rows of the matrix.
nThe number of columns of the matrix.
initThe initial value of the matrix elements.

All matrix elements are initialized with the specified value.

template<typename Type, bool SO>
blaze::DynamicMatrix< Type, SO >::DynamicMatrix ( const DynamicMatrix< Type, SO > &  m)
inline

The copy constructor for DynamicMatrix.

Parameters
mMatrix to be copied.

The copy constructor is explicitly defined due to the required dynamic memory management and in order to enable/facilitate NRV optimization.

template<typename Type , bool SO>
template<typename MT , bool SO2>
blaze::DynamicMatrix< Type, SO >::DynamicMatrix ( const Matrix< MT, SO2 > &  m)
inline

Conversion constructor from different matrices.

Parameters
mMatrix to be copied.
template<typename Type , bool SO>
template<typename Other , size_t M, size_t N>
blaze::DynamicMatrix< Type, SO >::DynamicMatrix ( const Other(&)  rhs[M][N])
inline

Array initialization of all matrix elements.

Parameters
rhs$ M \times N $ dimensional array for the initialization.
Returns
Reference to the assigned matrix.

This constructor offers the option to directly initialize the elements of the matrix:

const real init[3][3] = { { 1, 2, 3 },
{ 4, 5 },
{ 7, 8, 9 } };

The matrix is sized accoring to the size of the array and initialized with the given values. Missing values are initialized with zero (as e.g. the value 6 in the example).

Member Function Documentation

template<typename Type , bool SO>
template<typename MT >
EnableIf< typename DynamicMatrix< Type, SO >::BLAZE_TEMPLATE VectorizedAddAssign< MT > >::Type blaze::DynamicMatrix< Type, SO >::addAssign ( const DenseMatrix< MT, SO > &  rhs)
inline

Default implementation of the addition assignment of a row-major dense matrix.

Intrinsic optimized implementation of the addition assignment of a row-major dense matrix.

Parameters
rhsThe right-hand side dense matrix to be added.
Returns
void

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 Type , bool SO>
template<typename MT >
void blaze::DynamicMatrix< Type, SO >::addAssign ( const DenseMatrix< MT,!SO > &  rhs)
inline

Default implementation of the addition assignment of a column-major dense matrix.

Parameters
rhsThe right-hand side dense matrix to be added.
Returns
void

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 Type , bool SO>
template<typename MT >
void blaze::DynamicMatrix< Type, SO >::addAssign ( const SparseMatrix< MT, SO > &  rhs)
inline

Default implementation of the addition assignment of a row-major sparse matrix.

Parameters
rhsThe right-hand side sparse matrix to be added.
Returns
void

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 Type , bool SO>
template<typename MT >
void blaze::DynamicMatrix< Type, SO >::addAssign ( const SparseMatrix< MT,!SO > &  rhs)
inline

Default implementation of the addition assignment of a column-major sparse matrix.

Parameters
rhsThe right-hand side sparse matrix to be added.
Returns
void

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 Type , bool SO>
size_t blaze::DynamicMatrix< Type, SO >::adjustColumns ( size_t  minColumns) const
inlineprivate

Adjusting the number columns of the matrix according to its data type Type.

Parameters
minColumnsThe minimum necessary number of columns.
Returns
The adjusted number of columns.
template<typename Type , bool SO>
template<typename MT >
EnableIf< typename DynamicMatrix< Type, SO >::BLAZE_TEMPLATE VectorizedAssign< MT > >::Type blaze::DynamicMatrix< Type, SO >::assign ( const DenseMatrix< MT, SO > &  rhs)
inline

Default implementation of the assignment of a row-major dense matrix.

Intrinsic optimized implementation of the assignment of a row-major dense matrix.

Parameters
rhsThe right-hand side dense matrix to be assigned.
Returns
void

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 Type , bool SO>
template<typename MT >
void blaze::DynamicMatrix< Type, SO >::assign ( const DenseMatrix< MT,!SO > &  rhs)
inline

Default implementation of the assignment of a column-major dense matrix.

Parameters
rhsThe right-hand side dense matrix to be assigned.
Returns
void

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 Type , bool SO>
template<typename MT >
void blaze::DynamicMatrix< Type, SO >::assign ( const SparseMatrix< MT, SO > &  rhs)
inline

Default implementation of the assignment of a row-major sparse matrix.

Parameters
rhsThe right-hand side sparse matrix to be assigned.
Returns
void

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 Type , bool SO>
template<typename MT >
void blaze::DynamicMatrix< Type, SO >::assign ( const SparseMatrix< MT,!SO > &  rhs)
inline

Default implementation of the assignment of a column-major sparse matrix.

Parameters
rhsThe right-hand side sparse matrix to be assigned.
Returns
void

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 Type , bool SO>
DynamicMatrix< Type, SO >::Iterator blaze::DynamicMatrix< Type, SO >::begin ( size_t  i)
inline

Returns an iterator to the first element of row/column i.

Parameters
iThe row/column index.
Returns
Iterator to the first element of row/column i.

This function returns a row/column iterator to the first element of row/column i. In case the storage order is set to rowMajor the function returns an iterator to the first element of row i, in case the storage flag is set to columnMajor the function returns an iterator to the first element of column i.

template<typename Type , bool SO>
DynamicMatrix< Type, SO >::ConstIterator blaze::DynamicMatrix< Type, SO >::begin ( size_t  i) const
inline

Returns an iterator to the first element of row/column i.

Parameters
iThe row/column index.
Returns
Iterator to the first element of row/column i.

This function returns a row/column iterator to the first element of row/column i. In case the storage order is set to rowMajor the function returns an iterator to the first element of row i, in case the storage flag is set to columnMajor the function returns an iterator to the first element of column i.

template<typename Type , bool SO>
size_t blaze::DynamicMatrix< Type, SO >::capacity ( ) const
inline

Returns the maximum capacity of the matrix.

Returns
The capacity of the matrix.
template<typename Type , bool SO>
DynamicMatrix< Type, SO >::ConstIterator blaze::DynamicMatrix< Type, SO >::cbegin ( size_t  i) const
inline

Returns an iterator to the first element of row/column i.

Parameters
iThe row/column index.
Returns
Iterator to the first element of row/column i.

This function returns a row/column iterator to the first element of row/column i. In case the storage order is set to rowMajor the function returns an iterator to the first element of row i, in case the storage flag is set to columnMajor the function returns an iterator to the first element of column i.

template<typename Type , bool SO>
DynamicMatrix< Type, SO >::ConstIterator blaze::DynamicMatrix< Type, SO >::cend ( size_t  i) const
inline

Returns an iterator just past the last element of row/column i.

Parameters
iThe row/column index.
Returns
Iterator just past the last element of row/column i.

This function returns an row/column iterator just past the last element of row/column i. In case the storage order is set to rowMajor the function returns an iterator just past the last element of row i, in case the storage flag is set to columnMajor the function returns an iterator just past the last element of column i.

template<typename Type , bool SO>
void blaze::DynamicMatrix< Type, SO >::clear ( )
inline

Clearing the $ M \times N $ matrix.

Returns
void

After the clear() function, the size of the matrix is 0.

template<typename Type , bool SO>
size_t blaze::DynamicMatrix< Type, SO >::columns ( ) const
inline

Returns the current number of columns of the matrix.

Returns
The number of columns of the matrix.
template<typename Type , bool SO>
Type * blaze::DynamicMatrix< Type, SO >::data ( )
inline

Low-level data access to the matrix elements.

Returns
Pointer to the internal element storage.
template<typename Type , bool SO>
const Type * blaze::DynamicMatrix< Type, SO >::data ( ) const
inline

Low-level data access to the matrix elements.

Returns
Pointer to the internal element storage.
template<typename Type , bool SO>
DynamicMatrix< Type, SO >::Iterator blaze::DynamicMatrix< Type, SO >::end ( size_t  i)
inline

Returns an iterator just past the last element of row/column i.

Parameters
iThe row/column index.
Returns
Iterator just past the last element of row/column i.

This function returns an row/column iterator just past the last element of row/column i. In case the storage order is set to rowMajor the function returns an iterator just past the last element of row i, in case the storage flag is set to columnMajor the function returns an iterator just past the last element of column i.

template<typename Type , bool SO>
DynamicMatrix< Type, SO >::ConstIterator blaze::DynamicMatrix< Type, SO >::end ( size_t  i) const
inline

Returns an iterator just past the last element of row/column i.

Parameters
iThe row/column index.
Returns
Iterator just past the last element of row/column i.

This function returns an row/column iterator just past the last element of row/column i. In case the storage order is set to rowMajor the function returns an iterator just past the last element of row i, in case the storage flag is set to columnMajor the function returns an iterator just past the last element of column i.

template<typename Type , bool SO>
void blaze::DynamicMatrix< Type, SO >::extend ( size_t  m,
size_t  n,
bool  preserve = true 
)
inline

Extending the size of the matrix.

Parameters
mNumber of additional rows.
nNumber of additional columns.
preservetrue if the old values of the matrix should be preserved, false if not.
Returns
void

This function increases the matrix size by m rows and n columns. During this operation, new dynamic memory may be allocated in case the capacity of the matrix is too small. Therefore this function potentially changes all matrix elements. In order to preserve the old matrix values, the preserve flag can be set to true. However, new matrix elements are not initialized!

template<typename Type , bool SO>
DynamicMatrix< Type, SO >::IntrinsicType blaze::DynamicMatrix< Type, SO >::get ( size_t  i,
size_t  j 
) const
inline

Access to the intrinsic elements of the matrix.

Parameters
iAccess index for the row. The index has to be in the range [0..M-1].
jAccess index for the column. The index has to be in the range [0..N-1].
Returns
Reference to the accessed values.

This function offers a direct access to the intrinsic elements of the matrix. It 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.

template<typename Type , bool SO>
DynamicMatrix< Type, SO > & blaze::DynamicMatrix< Type, SO >::invert ( )
inline

Inverting the matrix.

Returns
Reference to the inverted matrix.

Note: This function is only defined for matrices of floating point type. The attempt to use this function with matrices of integral data types will result in a compile time error.

template<typename Type , bool SO>
template<typename Other >
bool blaze::DynamicMatrix< Type, SO >::isAliased ( const Other *  alias) const
inline

Returns whether the matrix is aliased with the given address alias.

Parameters
aliasThe alias to be checked.
Returns
true in case the alias corresponds to this matrix, false if not.
template<typename Type , bool SO>
bool blaze::DynamicMatrix< Type, SO >::isDiagonal ( ) const
inline

Checks if the matrix is diagonal.

Returns
true if the matrix is diagonal, false if not.

This function tests whether the matrix is diagonal, i.e. if the non-diagonal elements are default elements. In case of integral or floating point data types, a diagonal matrix has the form

\[\left(\begin{array}{*{5}{c}} aa & 0 & 0 & \cdots & 0 \\ 0 & bb & 0 & \cdots & 0 \\ 0 & 0 & cc & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & 0 \\ 0 & 0 & 0 & 0 & mn \\ \end{array}\right)\]

template<typename Type , bool SO>
bool blaze::DynamicMatrix< Type, SO >::isSymmetric ( ) const
inline

Checks if the matrix is symmetric.

Returns
true if the matrix is symmetric, false if not.
template<typename Type , bool SO>
size_t blaze::DynamicMatrix< Type, SO >::nonZeros ( ) const
inline

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

Returns
The number of non-zero elements in the dense matrix.
template<typename Type , bool SO>
size_t blaze::DynamicMatrix< Type, SO >::nonZeros ( size_t  i) const
inline

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

Parameters
iThe index of the row.
Returns
The number of non-zero elements of row i.
template<typename Type , bool SO>
DynamicMatrix< Type, SO >::Reference blaze::DynamicMatrix< Type, SO >::operator() ( size_t  i,
size_t  j 
)
inline

2D-access to the matrix elements.

Parameters
iAccess index for the row. The index has to be in the range $[0..M-1]$.
jAccess index for the column. The index has to be in the range $[0..N-1]$.
Returns
Reference to the accessed value.
template<typename Type , bool SO>
DynamicMatrix< Type, SO >::ConstReference blaze::DynamicMatrix< Type, SO >::operator() ( size_t  i,
size_t  j 
) const
inline

2D-access to the matrix elements.

Parameters
iAccess index for the row. The index has to be in the range $[0..M-1]$.
jAccess index for the column. The index has to be in the range $[0..N-1]$.
Returns
Reference to the accessed value.
template<typename Type , bool SO>
template<typename MT , bool SO2>
DynamicMatrix< Type, SO > & blaze::DynamicMatrix< Type, SO >::operator*= ( const Matrix< MT, SO2 > &  rhs)
inline

Multiplication assignment operator for the multiplication of a matrix ( $ A*=B $).

Parameters
rhsThe right-hand side matrix for the multiplication.
Returns
Reference to the matrix.
Exceptions
std::invalid_argumentMatrix sizes do not match.

In case the current sizes of the two given matrices don't match, a std::invalid_argument is thrown.

template<typename Type , bool SO>
template<typename Other >
EnableIf< IsNumeric< Other >, DynamicMatrix< Type, SO > >::Type & blaze::DynamicMatrix< Type, SO >::operator*= ( Other  rhs)
inline

Multiplication assignment operator for the multiplication between a matrix and a scalar value ( $ A*=s $).

Parameters
rhsThe right-hand side scalar value for the multiplication.
Returns
Reference to the matrix.
template<typename Type , bool SO>
template<typename MT , bool SO2>
DynamicMatrix< Type, SO > & blaze::DynamicMatrix< Type, SO >::operator+= ( const Matrix< MT, SO2 > &  rhs)
inline

Addition assignment operator for the addition of a matrix ( $ A+=B $).

Parameters
rhsThe right-hand side matrix to be added to the matrix.
Returns
Reference to the matrix.
Exceptions
std::invalid_argumentMatrix sizes do not match.

In case the current sizes of the two matrices don't match, a std::invalid_argument exception is thrown.

template<typename Type , bool SO>
template<typename MT , bool SO2>
DynamicMatrix< Type, SO > & blaze::DynamicMatrix< Type, SO >::operator-= ( const Matrix< MT, SO2 > &  rhs)
inline

Subtraction assignment operator for the subtraction of a matrix ( $ A-=B $).

Parameters
rhsThe right-hand side matrix to be subtracted from the matrix.
Returns
Reference to the matrix.
Exceptions
std::invalid_argumentMatrix sizes do not match.

In case the current sizes of the two matrices don't match, a std::invalid_argument exception is thrown.

template<typename Type , bool SO>
template<typename Other >
EnableIf< IsNumeric< Other >, DynamicMatrix< Type, SO > >::Type & blaze::DynamicMatrix< Type, SO >::operator/= ( Other  rhs)
inline

Division assignment operator for the division of a matrix by a scalar value ( $ A/=s $).

Parameters
rhsThe right-hand side scalar value for the division.
Returns
Reference to the matrix.
template<typename Type , bool SO>
template<typename Other , size_t M, size_t N>
DynamicMatrix< Type, SO > & blaze::DynamicMatrix< Type, SO >::operator= ( const Other(&)  rhs[M][N])
inline

Array assignment to all matrix elements.

Parameters
rhs$ M \times N $ dimensional array for the assignment.
Returns
Reference to the assigned matrix.

This assignment operator offers the option to directly set all elements of the matrix:

const real init[3][3] = { { 1, 2, 3 },
{ 4, 5 },
{ 7, 8, 9 } };
A = init;

The matrix is resized accoring to the size of the array and initialized with the given values. Missing values are initialized with zero (as e.g. the value 6 in the example).

template<typename Type, bool SO>
DynamicMatrix< Type, SO > & blaze::DynamicMatrix< Type, SO >::operator= ( Type  rhs)
inline

Homogenous assignment to all matrix elements.

Parameters
rhsScalar value to be assigned to all matrix elements.
Returns
Reference to the assigned matrix.
template<typename Type, bool SO>
DynamicMatrix< Type, SO > & blaze::DynamicMatrix< Type, SO >::operator= ( const DynamicMatrix< Type, SO > &  rhs)
inline

Copy assignment operator for DynamicMatrix.

Parameters
rhsMatrix to be copied.
Returns
Reference to the assigned matrix.

The matrix is resized according to the given $ M \times N $ matrix and initialized as a copy of this matrix.

template<typename Type , bool SO>
template<typename MT , bool SO2>
DynamicMatrix< Type, SO > & blaze::DynamicMatrix< Type, SO >::operator= ( const Matrix< MT, SO2 > &  rhs)
inline

Assignment operator for different matrices.

Parameters
rhsMatrix to be copied.
Returns
Reference to the assigned matrix.

The matrix is resized according to the given $ M \times N $ matrix and initialized as a copy of this matrix.

template<typename MT, bool SO>
MatrixType& blaze::Matrix< MT, SO >::operator~ ( )
inlineinherited

Conversion operator for non-constant matrices.

Returns
Reference of the actual type of the matrix.
template<typename MT, bool SO>
const MatrixType& blaze::Matrix< MT, SO >::operator~ ( ) const
inlineinherited

Conversion operator for constant matrices.

Returns
Constant reference of the actual type of the matrix.
template<typename Type , bool SO>
void blaze::DynamicMatrix< Type, SO >::reserve ( size_t  elements)
inline

Setting the minimum capacity of the matrix.

Parameters
elementsThe new minimum capacity of the sparse matrix.
Returns
void

This function increases the capacity of the sparse matrix to at least elements elements. The current values of the matrix elements are preserved.

template<typename Type , bool SO>
void blaze::DynamicMatrix< Type, SO >::reset ( )
inline

Reset to the default initial values.

Returns
void
template<typename Type , bool SO>
void blaze::DynamicMatrix< Type, SO >::resize ( size_t  m,
size_t  n,
bool  preserve = true 
)

Changing the size of the matrix.

Parameters
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

This function resizes the matrix using the given size to $ m \times n $. During this operation, new dynamic memory may be allocated in case the capacity of the matrix is too small. Therefore this function potentially changes all matrix elements. In order to preserve the old matrix values, the preserve flag can be set to true. However, new matrix elements are not initialized!
The following example illustrates the resize operation of a $ 2 \times 4 $ matrix to a $ 4 \times 2 $ matrix. The new, uninitialized elements are marked with x:

\[ \left(\begin{array}{*{4}{c}} 1 & 2 & 3 & 4 \\ 5 & 6 & 7 & 8 \\ \end{array}\right) \Longrightarrow \left(\begin{array}{*{2}{c}} 1 & 2 \\ 5 & 6 \\ x & x \\ x & x \\ \end{array}\right) \]

template<typename Type , bool SO>
size_t blaze::DynamicMatrix< Type, SO >::rows ( ) const
inline

Returns the current number of rows of the matrix.

Returns
The number of rows of the matrix.
template<typename Type , bool SO>
template<typename Other >
DynamicMatrix< Type, SO > & blaze::DynamicMatrix< Type, SO >::scale ( Other  scalar)
inline

Scaling of the matrix by the scalar value scalar ( $ A=B*s $).

Parameters
scalarThe scalar value for the matrix scaling.
Returns
Reference to the matrix.
template<typename Type , bool SO>
size_t blaze::DynamicMatrix< Type, SO >::spacing ( ) const
inline

Returns the spacing between the beginning of two rows.

Returns
The spacing between the beginning of two rows.

This function returns the spacing between the beginning of two rows, i.e. the total number of elements of a row.

template<typename Type , bool SO>
template<typename MT >
EnableIf< typename DynamicMatrix< Type, SO >::BLAZE_TEMPLATE VectorizedSubAssign< MT > >::Type blaze::DynamicMatrix< Type, SO >::subAssign ( const DenseMatrix< MT, SO > &  rhs)
inline

Default implementation of the subtraction assignment of a row-major dense matrix.

Intrinsic optimized implementation of the subtraction assignment of a row-major dense matrix.

Parameters
rhsThe right-hand side dense matrix to be subtracted.
Returns
void

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 Type , bool SO>
template<typename MT >
void blaze::DynamicMatrix< Type, SO >::subAssign ( const DenseMatrix< MT,!SO > &  rhs)
inline

Default implementation of the subtraction assignment of a column-major dense matrix.

Parameters
rhsThe right-hand side dense matrix to be subtracted.
Returns
void

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 Type , bool SO>
template<typename MT >
void blaze::DynamicMatrix< Type, SO >::subAssign ( const SparseMatrix< MT, SO > &  rhs)
inline

Default implementation of the subtraction assignment of a row-major sparse matrix.

Parameters
rhsThe right-hand side sparse matrix to be subtracted.
Returns
void

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 Type , bool SO>
template<typename MT >
void blaze::DynamicMatrix< Type, SO >::subAssign ( const SparseMatrix< MT,!SO > &  rhs)
inline

Default implementation of the subtraction assignment of a column-major sparse matrix.

Parameters
rhsThe right-hand side sparse matrix to be subtracted.
Returns
void

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 Type , bool SO>
void blaze::DynamicMatrix< Type, SO >::swap ( DynamicMatrix< Type, SO > &  m)
inline

Swapping the contents of two matrices.

Parameters
mThe matrix to be swapped.
Returns
void
Exceptions
no-throwguarantee.
template<typename Type , bool SO>
DynamicMatrix< Type, SO > & blaze::DynamicMatrix< Type, SO >::transpose ( )
inline

Transposing the matrix.

Returns
Reference to the transposed matrix.

Member Data Documentation

template<typename Type, bool SO = defaultStorageOrder>
Type* BLAZE_RESTRICT blaze::DynamicMatrix< Type, SO >::v_
private

The dynamically allocated matrix elements.

Access to the matrix elements is gained via the subscript or function call operator. In case of row-major order the memory layout of the elements is

\[\left(\begin{array}{*{5}{c}} 0 & 1 & 2 & \cdots & N-1 \\ N & N+1 & N+2 & \cdots & 2 \cdot N-1 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ M \cdot N-N & M \cdot N-N+1 & M \cdot N-N+2 & \cdots & M \cdot N-1 \\ \end{array}\right)\]

.


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