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

View on a specific submatrix of a dense matrix.The DenseSubmatrix template represents a view on a specific submatrix of a dense matrix primitive. The type of the dense matrix is specified via the first template parameter: More...

#include <DenseSubmatrix.h>

Inherits blaze::DenseMatrix< DenseSubmatrix< MT, AF, SO >, SO >, and blaze::Submatrix.

Classes

class  SubmatrixIterator
 Iterator over the elements of the sparse submatrix. More...
 

Public Types

enum  { vectorizable = MT::vectorizable }
 Compilation switch for the expression template evaluation strategy.
 
enum  { smpAssignable = MT::smpAssignable }
 Compilation switch for the expression template assignment strategy.
 
typedef DenseSubmatrix< MT, AF,
SO > 
This
 Type of this DenseSubmatrix instance.
 
typedef SubmatrixTrait< MT >::Type ResultType
 Result type for expression template evaluations.
 
typedef ResultType::OppositeType OppositeType
 Result type with opposite storage order for expression template evaluations.
 
typedef ResultType::TransposeType TransposeType
 Transpose type for expression template evaluations.
 
typedef MT::ElementType ElementType
 Type of the submatrix elements.
 
typedef IT::Type IntrinsicType
 Intrinsic type of the submatrix elements.
 
typedef MT::ReturnType ReturnType
 Return type for expression template evaluations.
 
typedef const DenseSubmatrixCompositeType
 Data type for composite expression templates.
 
typedef MT::ConstReference ConstReference
 Reference to a constant submatrix value.
 
typedef SelectType< useConst,
ConstReference, typename
MT::Reference >::Type 
Reference
 Reference to a non-constant submatrix value.
 
typedef const ElementTypeConstPointer
 Pointer to a constant submatrix value.
 
typedef SelectType< useConst,
ConstPointer, ElementType * >
::Type 
Pointer
 Pointer to a non-constant submatrix value.
 
typedef SubmatrixIterator
< typename MT::ConstIterator > 
ConstIterator
 Iterator over constant elements.
 
typedef SelectType< useConst,
ConstIterator,
SubmatrixIterator< typename
MT::Iterator > >::Type 
Iterator
 Iterator over non-constant elements.
 
typedef MT MatrixType
 Type of the matrix.
 

Public Member Functions

template<typename MT2 , bool SO2>
DenseSubmatrix< MT, AF, SO > & operator= (const Matrix< MT2, SO2 > &rhs)
 Assignment operator for different matrices. More...
 
template<typename MT2 , bool SO2>
DenseSubmatrix< MT, AF, SO > & operator+= (const Matrix< MT2, SO2 > &rhs)
 Addition assignment operator for the addition of a matrix ( $ A+=B $). More...
 
template<typename MT2 , bool SO2>
DenseSubmatrix< MT, AF, SO > & operator-= (const Matrix< MT2, SO2 > &rhs)
 Subtraction assignment operator for the subtraction of a matrix ( $ A-=B $). More...
 
template<typename MT2 , bool SO2>
DenseSubmatrix< MT, AF, SO > & operator*= (const Matrix< MT2, SO2 > &rhs)
 Multiplication assignment operator for the multiplication of a matrix ( $ A*=B $). More...
 
template<typename Other >
EnableIf< IsNumeric< Other >
, DenseSubmatrix< MT, AF, SO >
>::Type & 
operator*= (Other rhs)
 Multiplication assignment operator for the multiplication between a dense submatrix and a scalar value ( $ A*=s $). More...
 
template<typename Other >
EnableIf< IsNumeric< Other >
, DenseSubmatrix< MT, AF, SO >
>::Type & 
operator/= (Other rhs)
 Division assignment operator for the division of a dense submatrix by a scalar value ( $ A/=s $). More...
 
template<typename Other >
DenseSubmatrix< MT, AF, SO > & scale (const Other &scalar)
 Scaling of the dense submatrix by the scalar value scalar ( $ A=B*s $). More...
 
template<typename MT2 >
DisableIf< typename
DenseSubmatrix< MT, AF, SO >
::BLAZE_TEMPLATE
VectorizedAssign< MT2 >
>::Type 
assign (const DenseMatrix< MT2, SO > &rhs)
 Default implementation of the assignment of a row-major dense matrix. More...
 
template<typename MT2 >
EnableIf< typename
DenseSubmatrix< MT, AF, SO >
::BLAZE_TEMPLATE
VectorizedAssign< MT2 >
>::Type 
assign (const DenseMatrix< MT2, SO > &rhs)
 Intrinsic optimized implementation of the assignment of a row-major dense matrix. More...
 
template<typename MT2 >
DisableIf< typename
DenseSubmatrix< MT, AF, SO >
::BLAZE_TEMPLATE
VectorizedAddAssign< MT2 >
>::Type 
addAssign (const DenseMatrix< MT2, SO > &rhs)
 Default implementation of the addition assignment of a row-major dense matrix. More...
 
template<typename MT2 >
EnableIf< typename
DenseSubmatrix< MT, AF, SO >
::BLAZE_TEMPLATE
VectorizedAddAssign< MT2 >
>::Type 
addAssign (const DenseMatrix< MT2, SO > &rhs)
 Intrinsic optimized implementation of the addition assignment of a row-major dense matrix. More...
 
template<typename MT2 >
DisableIf< typename
DenseSubmatrix< MT, AF, SO >
::BLAZE_TEMPLATE
VectorizedSubAssign< MT2 >
>::Type 
subAssign (const DenseMatrix< MT2, SO > &rhs)
 Default implementation of the subtraction assignment of a row-major dense matrix. More...
 
template<typename MT2 >
EnableIf< typename
DenseSubmatrix< MT, AF, SO >
::BLAZE_TEMPLATE
VectorizedSubAssign< MT2 >
>::Type 
subAssign (const DenseMatrix< MT2, SO > &rhs)
 Intrinsic optimized implementation of the subtraction assignment of a row-major dense matrix. More...
 
BLAZE_ALWAYS_INLINE MatrixTypeoperator~ ()
 Conversion operator for non-constant matrices. More...
 
BLAZE_ALWAYS_INLINE const
MatrixType
operator~ () const
 Conversion operator for constant matrices. More...
 
Constructors
 DenseSubmatrix (Operand matrix, size_t row, size_t column, size_t m, size_t n)
 The constructor for DenseSubmatrix. More...
 
Data access functions
Reference operator() (size_t i, size_t j)
 2D-access to the dense submatrix elements. More...
 
ConstReference operator() (size_t i, size_t j) const
 2D-access to the dense submatrix elements. More...
 
Pointer data ()
 Low-level data access to the submatrix elements. More...
 
ConstPointer data () const
 Low-level data access to the submatrix elements. More...
 
Iterator begin (size_t i)
 Returns an iterator to the first non-zero element of row/column i. More...
 
ConstIterator begin (size_t i) const
 Returns an iterator to the first non-zero element of row/column i. More...
 
ConstIterator cbegin (size_t i) const
 Returns an iterator to the first non-zero element of row/column i. More...
 
Iterator end (size_t i)
 Returns an iterator just past the last non-zero element of row/column i. More...
 
ConstIterator end (size_t i) const
 Returns an iterator just past the last non-zero element of row/column i. More...
 
ConstIterator cend (size_t i) const
 Returns an iterator just past the last non-zero element of row/column i. More...
 
Assignment operators
DenseSubmatrixoperator= (const ElementType &rhs)
 Homogenous assignment to all submatrix elements. More...
 
DenseSubmatrixoperator= (const DenseSubmatrix &rhs)
 Copy assignment operator for DenseSubmatrix. More...
 
template<typename MT2 , bool SO2>
DenseSubmatrixoperator= (const Matrix< MT2, SO2 > &rhs)
 
template<typename MT2 , bool SO2>
DenseSubmatrixoperator+= (const Matrix< MT2, SO2 > &rhs)
 
template<typename MT2 , bool SO2>
DenseSubmatrixoperator-= (const Matrix< MT2, SO2 > &rhs)
 
template<typename MT2 , bool SO2>
DenseSubmatrixoperator*= (const Matrix< MT2, SO2 > &rhs)
 
template<typename Other >
EnableIf< IsNumeric< Other >
, DenseSubmatrix >::Type & 
operator*= (Other rhs)
 
template<typename Other >
EnableIf< IsNumeric< Other >
, DenseSubmatrix >::Type & 
operator/= (Other rhs)
 
Expression template evaluation functions
template<typename Other >
bool canAlias (const Other *alias) const
 Returns whether the submatrix can alias with the given address alias. More...
 
template<typename MT2 , bool AF2, bool SO2>
bool canAlias (const DenseSubmatrix< MT2, AF2, SO2 > *alias) const
 Returns whether the submatrix can alias with the given dense submatrix alias. More...
 
template<typename Other >
bool isAliased (const Other *alias) const
 Returns whether the submatrix is aliased with the given address alias. More...
 
template<typename MT2 , bool AF2, bool SO2>
bool isAliased (const DenseSubmatrix< MT2, AF2, SO2 > *alias) const
 Returns whether the submatrix is aliased with the given dense submatrix alias. More...
 
bool isAligned () const
 Returns whether the submatrix is properly aligned in memory. More...
 
bool canSMPAssign () const
 Returns whether the submatrix can be used in SMP assignments. More...
 
IntrinsicType load (size_t i, size_t j) const
 Aligned load of an intrinsic element of the submatrix. More...
 
IntrinsicType loadu (size_t i, size_t j) const
 Unaligned load of an intrinsic element of the submatrix. More...
 
void store (size_t i, size_t j, const IntrinsicType &value)
 Aligned store of an intrinsic element of the submatrix. More...
 
void storeu (size_t i, size_t j, const IntrinsicType &value)
 Unaligned store of an intrinsic element of the submatrix. More...
 
void stream (size_t i, size_t j, const IntrinsicType &value)
 Aligned, non-temporal store of an intrinsic element of the submatrix. More...
 
template<typename MT2 >
DisableIf< VectorizedAssign
< MT2 > >::Type 
assign (const DenseMatrix< MT2, SO > &rhs)
 
template<typename MT2 >
EnableIf< VectorizedAssign
< MT2 > >::Type 
assign (const DenseMatrix< MT2, SO > &rhs)
 
template<typename MT2 >
void assign (const DenseMatrix< MT2,!SO > &rhs)
 Default implementation of the assignment of a column-major dense matrix. More...
 
template<typename MT2 >
void assign (const SparseMatrix< MT2, SO > &rhs)
 Default implementation of the assignment of a row-major sparse matrix. More...
 
template<typename MT2 >
void assign (const SparseMatrix< MT2,!SO > &rhs)
 Default implementation of the assignment of a column-major sparse matrix. More...
 
template<typename MT2 >
DisableIf< VectorizedAddAssign
< MT2 > >::Type 
addAssign (const DenseMatrix< MT2, SO > &rhs)
 
template<typename MT2 >
EnableIf< VectorizedAddAssign
< MT2 > >::Type 
addAssign (const DenseMatrix< MT2, SO > &rhs)
 
template<typename MT2 >
void addAssign (const DenseMatrix< MT2,!SO > &rhs)
 Default implementation of the addition assignment of a column-major dense matrix. More...
 
template<typename MT2 >
void addAssign (const SparseMatrix< MT2, SO > &rhs)
 Default implementation of the addition assignment of a row-major sparse matrix. More...
 
template<typename MT2 >
void addAssign (const SparseMatrix< MT2,!SO > &rhs)
 Default implementation of the addition assignment of a column-major sparse matrix. More...
 
template<typename MT2 >
DisableIf< VectorizedSubAssign
< MT2 > >::Type 
subAssign (const DenseMatrix< MT2, SO > &rhs)
 
template<typename MT2 >
EnableIf< VectorizedSubAssign
< MT2 > >::Type 
subAssign (const DenseMatrix< MT2, SO > &rhs)
 
template<typename MT2 >
void subAssign (const DenseMatrix< MT2,!SO > &rhs)
 Default implementation of the subtraction assignment of a column-major dense matrix. More...
 
template<typename MT2 >
void subAssign (const SparseMatrix< MT2, SO > &rhs)
 Default implementation of the subtraction assignment of a row-major sparse matrix. More...
 
template<typename MT2 >
void subAssign (const SparseMatrix< MT2,!SO > &rhs)
 Default implementation of the subtraction assignment of a column-major sparse matrix. More...
 

Private Types

enum  { useConst = IsConst<MT>::value }
 Compilation switch for the non-const reference and iterator types. More...
 
typedef SelectType
< IsExpression< MT >::value,
MT, MT & >::Type 
Operand
 Composite data type of the dense matrix expression.
 
typedef IntrinsicTrait
< typename MT::ElementType > 
IT
 Intrinsic trait for the matrix element type.
 

Private Attributes

Member variables
Operand matrix_
 The dense matrix containing the submatrix.
 
const size_t row_
 The first row of the submatrix.
 
const size_t column_
 The first column of the submatrix.
 
const size_t m_
 The number of rows of the submatrix.
 
const size_t n_
 The number of columns of the submatrix.
 
const size_t rest_
 The number of remaining elements in an unaligned intrinsic operation.
 
const size_t final_
 The final index for unaligned intrinsic operations. More...
 
const bool isAligned_
 Memory alignment flag. More...
 

Utility functions

size_t rows () const
 Returns the number of rows of the dense submatrix. More...
 
size_t columns () const
 Returns the number of columns of the dense submatrix. More...
 
size_t spacing () const
 Returns the spacing between the beginning of two rows/columns. More...
 
size_t capacity () const
 Returns the maximum capacity of the dense submatrix. More...
 
size_t capacity (size_t i) const
 Returns the current capacity of the specified row/column. More...
 
size_t nonZeros () const
 Returns the number of non-zero elements in the dense submatrix. More...
 
size_t nonZeros (size_t i) const
 Returns the number of non-zero elements in the specified row/column. More...
 
void reset ()
 Reset to the default initial values. More...
 
void reset (size_t i)
 Reset the specified row/column to the default initial values. More...
 
DenseSubmatrixtranspose ()
 Transposing the submatrix. More...
 
template<typename Other >
DenseSubmatrixscale (const Other &scalar)
 
bool hasOverlap () const
 Checking whether there exists an overlap in the context of a symmetric matrix. More...
 
template<typename MT2 , bool SO2>
bool preservesSymmetry (const Matrix< MT2, SO2 > &rhs) const
 Checking whether the given matrix would violate the symmetry of the underlying matrix. More...
 

Detailed Description

template<typename MT, bool AF = unaligned, bool SO = IsColumnMajorMatrix<MT>::value>
class blaze::DenseSubmatrix< MT, AF, SO >

View on a specific submatrix of a dense matrix.

The DenseSubmatrix template represents a view on a specific submatrix of a dense matrix primitive. The type of the dense matrix is specified via the first template parameter:

template< typename MT, bool AF, bool SO >


Setup of Dense Submatrices

A view on a dense submatrix can be created very conveniently via the submatrix() function:

DenseMatrixType A;
// ... Resizing and initialization
// Creating a dense submatrix of size 8x16, starting in row 0 and column 4
blaze::DenseSubmatrix<DenseMatrixType> sm = submatrix( A, 0UL, 4UL, 8UL, 16UL );

This view can be treated as any other dense matrix, i.e. it can be assigned to, it can be copied from, and it can be used in arithmetic operations. The view can also be used on both sides of an assignment: The submatrix can either be used as an alias to grant write access to a specific submatrix of a dense matrix primitive on the left-hand side of an assignment or to grant read-access to a specific submatrix of a dense matrix primitive or expression on the right-hand side of an assignment. The following example demonstrates this in detail:

DenseMatrixType A, B;
SparseMatrixType C;
// ... Resizing and initialization
// Creating a dense submatrix of size 8x4, starting in row 0 and column 2
blaze::DenseSubmatrix<DenseMatrixType> sm = submatrix( A, 0UL, 2UL, 8UL, 4UL );
// Setting the submatrix of A to a 8x4 submatrix of B
sm = submatrix( B, 0UL, 0UL, 8UL, 4UL );
// Copying the sparse matrix C into another 8x4 submatrix of A
submatrix( A, 8UL, 2UL, 8UL, 4UL ) = C;
// Assigning part of the result of a matrix addition to the first submatrix
sm = submatrix( B + C, 0UL, 0UL, 8UL, 4UL );


Element access

A dense submatrix can be used like any other dense matrix. For instance, the elements of the dense submatrix can be directly accessed with the function call operator:

MatrixType A;
// ... Resizing and initialization
// Creating a 8x8 submatrix, starting from position (4,4)
blaze::DenseSubmatrix<MatrixType> sm = submatrix( A, 4UL, 4UL, 8UL, 8UL );
// Setting the element (0,0) of the submatrix, which corresponds to
// the element at position (4,4) in matrix A
sm(0,0) = 2.0;

Alternatively, the elements of a submatrix can be traversed via (const) iterators. Just as with matrices, in case of non-const submatrices, begin() and end() return an Iterator, which allows a manipulation of the non-zero values, in case of constant submatrices a ConstIterator is returned:

typedef blaze::DenseSubmatrix<MatrixType> SubmatrixType;
MatrixType A( 256UL, 512UL );
// ... Resizing and initialization
// Creating a reference to a specific submatrix of matrix A
SubmatrixType sm = submatrix( A, 16UL, 16UL, 64UL, 128UL );
// Traversing the elements of the 0th row via iterators to non-const elements
for( SubmatrixType::Iterator it=sm.begin(0); it!=sm.end(0); ++it ) {
*it = ...; // OK: Write access to the dense submatrix value.
... = *it; // OK: Read access to the dense submatrix value.
}
// Traversing the elements of the 1st row via iterators to const elements
for( SubmatrixType::ConstIterator it=sm.begin(1); it!=sm.end(1); ++it ) {
*it = ...; // Compilation error: Assignment to the value via a ConstIterator is invalid.
... = *it; // OK: Read access to the dense submatrix value.
}


Common Operations

The current size of the matrix, i.e. the number of rows or columns can be obtained via the rows() and columns() functions, the current total capacity via the capacity() function, and the number of non-zero elements via the nonZeros() function. However, since submatrices are views on a specific submatrix of a matrix, several operations are not possible on views, such as resizing and swapping:

typedef blaze::DenseSubmatrix<MatrixType> SubmatrixType;
MatrixType A;
// ... Resizing and initialization
// Creating a view on the a 8x12 submatrix of matrix A
SubmatrixType sm = submatrix( A, 0UL, 0UL, 8UL, 12UL );
sm.rows(); // Returns the number of rows of the submatrix
sm.columns(); // Returns the number of columns of the submatrix
sm.capacity(); // Returns the capacity of the submatrix
sm.nonZeros(); // Returns the number of non-zero elements contained in the submatrix
sm.resize( 10UL, 8UL ); // Compilation error: Cannot resize a submatrix of a matrix
SubmatrixType sm2 = submatrix( A, 8UL, 0UL, 12UL, 8UL );
swap( sm, sm2 ); // Compilation error: Swap operation not allowed


Arithmetic Operations

The following example gives an impression of the use of DenseSubmatrix within arithmetic operations. All operations (addition, subtraction, multiplication, scaling, ...) can be performed on all possible combinations of dense and sparse matrices with fitting element types:

DenseMatrixType D1, D2, D3;
SparseMatrixType S1, S2;
SparseVectorType a, b;
// ... Resizing and initialization
typedef DenseSubmatrix<DenseMatrixType> SubmatrixType;
SubmatrixType sm = submatrix( D1, 0UL, 0UL, 8UL, 8UL ); // View on the 8x8 submatrix of matrix D1
// starting from row 0 and column 0
submatrix( D1, 0UL, 8UL, 8UL, 8UL ) = D2; // Dense matrix initialization of the 8x8 submatrix
// starting in row 0 and column 8
sm = S1; // Sparse matrix initialization of the second 8x8 submatrix
D3 = sm + D2; // Dense matrix/dense matrix addition
S2 = S1 - submatrix( D1, 8UL, 0UL, 8UL, 8UL ); // Sparse matrix/dense matrix subtraction
D2 = sm * submatrix( D1, 8UL, 8UL, 8UL, 8UL ); // Dense matrix/dense matrix multiplication
submatrix( D1, 8UL, 0UL, 8UL, 8UL ) *= 2.0; // In-place scaling of a submatrix of D1
D2 = submatrix( D1, 8UL, 8UL, 8UL, 8UL ) * 2.0; // Scaling of the a submatrix of D1
D2 = 2.0 * sm; // Scaling of the a submatrix of D1
submatrix( D1, 0UL, 8UL, 8UL, 8UL ) += D2; // Addition assignment
submatrix( D1, 8UL, 0UL, 8UL, 8UL ) -= S1; // Subtraction assignment
submatrix( D1, 8UL, 8UL, 8UL, 8UL ) *= sm; // Multiplication assignment
a = submatrix( D1, 4UL, 4UL, 8UL, 8UL ) * b; // Dense matrix/sparse vector multiplication


Aligned Submatrices

Usually submatrices can be defined anywhere within a matrix. They may start at any position and may have an arbitrary extension (only restricted by the extension of the underlying matrix). However, in contrast to matrices themselves, which are always properly aligned in memory and therefore can provide maximum performance, this means that submatrices in general have to be considered to be unaligned. This can be made explicit by the blaze::unaligned flag:

DenseMatrixType A;
// ... Resizing and initialization
// Identical creations of an unaligned submatrix of size 8x8, starting in row 0 and column 0
blaze::DenseSubmatrix<DenseMatrixType> sm1 = submatrix ( A, 0UL, 0UL, 8UL, 8UL );
blaze::DenseSubmatrix<DenseMatrixType> sm2 = submatrix<unaligned>( A, 0UL, 0UL, 8UL, 8UL );
blaze::DenseSubmatrix<DenseMatrixType,unaligned> sm4 = submatrix<unaligned>( A, 0UL, 0UL, 8UL, 8UL );

All of these calls to the submatrix() function are identical. Whether the alignment flag is explicitly specified or not, it always returns an unaligned submatrix. Whereas this may provide full flexibility in the creation of submatrices, this might result in performance restrictions (even in case the specified submatrix could be aligned). However, it is also possible to create aligned submatrices. Aligned submatrices are identical to unaligned submatrices in all aspects, except that they may pose additional alignment restrictions and therefore have less flexibility during creation, but don't suffer from performance penalties and provide the same performance as the underlying matrix. Aligned submatrices are created by explicitly specifying the blaze::aligned flag:

// Creating an aligned submatrix of size 8x8, starting in row 0 and column 0
blaze::DenseSubmatrix<DenseMatrixType,aligned> sv = submatrix<aligned>( A, 0UL, 0UL, 8UL, 8UL );

The alignment restrictions refer to system dependent address restrictions for the used element type and the available vectorization mode (SSE, AVX, ...). The following source code gives some examples for a double precision dense matrix, assuming that AVX is available, which packs 4 double values into an intrinsic vector:

MatrixType D( 13UL, 17UL );
// ... Resizing and initialization
// OK: Starts at position (0,0) and the number of rows and columns are a multiple of 4
SubmatrixType dsm1 = submatrix<aligned>( D, 0UL, 0UL, 8UL, 12UL );
// OK: First row and column and the number of rows and columns are all a multiple of 4
SubmatrixType dsm2 = submatrix<aligned>( D, 4UL, 12UL, 8UL, 16UL );
// OK: First row and column are a multiple of 4 and the submatrix includes the last row and column
SubmatrixType dsm3 = submatrix<aligned>( D, 4UL, 0UL, 9UL, 17UL );
// Error: First row is not a multiple of 4
SubmatrixType dsm4 = submatrix<aligned>( D, 2UL, 4UL, 12UL, 12UL );
// Error: First column is not a multiple of 4
SubmatrixType dsm5 = submatrix<aligned>( D, 0UL, 2UL, 8UL, 8UL );
// Error: The number of rows is not a multiple of 4 and the submatrix does not include the last row
SubmatrixType dsm6 = submatrix<aligned>( D, 0UL, 0UL, 7UL, 8UL );
// Error: The number of columns is not a multiple of 4 and the submatrix does not include the last column
SubmatrixType dsm6 = submatrix<aligned>( D, 0UL, 0UL, 8UL, 11UL );


Submatrix on Submatrix

It is also possible to create a submatrix view on another submatrix. In this context it is important to remember that the type returned by the submatrix() function is the same type as the type of the given submatrix, since the view on a submatrix is just another view on the underlying dense matrix:

typedef blaze::DenseSubmatrix<MatrixType> SubmatrixType;
MatrixType D1;
// ... Resizing and initialization
// Creating a submatrix view on the dense matrix D1
SubmatrixType sm1 = submatrix( D1, 4UL, 4UL, 8UL, 16UL );
// Creating a submatrix view on the dense submatrix sm1
SubmatrixType sm2 = submatrix( sm1, 1UL, 1UL, 4UL, 8UL );


Submatrix on Symmetric Matrices

Submatrices can also be created on symmetric matrices (see the SymmetricMatrix class template):

typedef SymmetricMatrix< DynamicMatrix<int> > SymmetricDynamicType;
typedef DenseSubmatrix< SymmetricDynamicType > SubmatrixType;
// Setup of a 16x16 symmetric matrix
SymmetricDynamicType A( 16UL );
// Creating a dense submatrix of size 8x12, starting in row 2 and column 4
SubmatrixType sm = submatrix( A, 2UL, 4UL, 8UL, 12UL );

It is important to note, however, that (compound) assignments to such submatrices have a special restriction: The symmetry of the underlying symmetric matrix must not be broken! Since the modification of element $ a_{ij} $ of a symmetric matrix also modifies the element $ a_{ji} $, the matrix to be assigned must be structured such that the symmetry of the symmetric matrix is preserved. Otherwise a std::invalid_argument exception is thrown:

// Setup of two default 4x4 symmetric matrices
SymmetricMatrix< DynamicMatrix<int> > A1( 4 ), A2( 4 );
// Setup of the 3x2 dynamic matrix
//
// ( 0 9 )
// B = ( 9 8 )
// ( 0 7 )
//
DynamicMatrix<int> B( 3UL, 2UL );
B(0,0) = 1;
B(0,1) = 2;
B(1,0) = 3;
B(1,1) = 4;
B(2,1) = 5;
B(2,2) = 6;
// OK: Assigning B to a submatrix of A1 such that the symmetry can be preserved
//
// ( 0 0 1 2 )
// A1 = ( 0 0 3 4 )
// ( 1 3 5 6 )
// ( 2 4 6 0 )
//
submatrix( A1, 0UL, 2UL, 3UL, 2UL ) = B; // OK
// Error: Assigning B to a submatrix of A2 such that the symmetry cannot be preserved!
// The elements marked with X cannot be assigned unambiguously!
//
// ( 0 1 2 0 )
// A2 = ( 1 3 X 0 )
// ( 2 X 6 0 )
// ( 0 0 0 0 )
//
submatrix( A2, 0UL, 1UL, 3UL, 2UL ) = B; // Assignment throws an exception!

Member Enumeration Documentation

template<typename MT, bool AF = unaligned, bool SO = IsColumnMajorMatrix<MT>::value>
anonymous enum
private

Compilation switch for the non-const reference and iterator types.

The useConst compile time constant expression represents a compilation switch for the non-const reference and iterator types. In case the given dense matrix of type MT is const qualified, useConst will be set to 1 and the dense submatrix will return references and iterators to const. Otherwise useConst will be set to 0 and the dense submatrix will offer write access to the dense matrix elements both via the function call operator and iterators.

Constructor & Destructor Documentation

template<typename MT , bool AF, bool SO>
blaze::DenseSubmatrix< MT, AF, SO >::DenseSubmatrix ( Operand  matrix,
size_t  row,
size_t  column,
size_t  m,
size_t  n 
)
inlineexplicit

The constructor for DenseSubmatrix.

Parameters
matrixThe dense matrix containing the submatrix.
rowThe index of the first row of the submatrix in the given dense matrix.
columnThe index of the first column of the submatrix in the given dense matrix.
mThe number of rows of the submatrix.
nThe number of columns of the submatrix.
Exceptions
std::invalid_argumentInvalid submatrix specification.

In case the submatrix is not properly specified (i.e. if the specified submatrix is not contained in the given dense matrix) a std::invalid_argument exception is thrown.

Member Function Documentation

template<typename MT , bool AF, bool SO>
template<typename MT2 >
void blaze::DenseSubmatrix< MT, AF, SO >::addAssign ( const DenseMatrix< MT2,!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 MT , bool AF, bool SO>
template<typename MT2 >
void blaze::DenseSubmatrix< MT, AF, SO >::addAssign ( const SparseMatrix< MT2, 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 MT , bool AF, bool SO>
template<typename MT2 >
void blaze::DenseSubmatrix< MT, AF, SO >::addAssign ( const SparseMatrix< MT2,!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 MT, bool AF = unaligned, bool SO = IsColumnMajorMatrix<MT>::value>
template<typename MT2 >
DisableIf< typename DenseSubmatrix<MT,AF,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type blaze::DenseSubmatrix< MT, AF, SO >::addAssign ( const DenseMatrix< MT2, SO > &  rhs)
inline

Default 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 MT, bool AF = unaligned, bool SO = IsColumnMajorMatrix<MT>::value>
template<typename MT2 >
EnableIf< typename DenseSubmatrix<MT,AF,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type blaze::DenseSubmatrix< MT, AF, SO >::addAssign ( const DenseMatrix< MT2, SO > &  rhs)
inline

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 MT , bool AF, bool SO>
template<typename MT2 >
void blaze::DenseSubmatrix< MT, AF, SO >::assign ( const DenseMatrix< MT2,!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 MT , bool AF, bool SO>
template<typename MT2 >
void blaze::DenseSubmatrix< MT, AF, SO >::assign ( const SparseMatrix< MT2, 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 MT , bool AF, bool SO>
template<typename MT2 >
void blaze::DenseSubmatrix< MT, AF, SO >::assign ( const SparseMatrix< MT2,!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 MT, bool AF = unaligned, bool SO = IsColumnMajorMatrix<MT>::value>
template<typename MT2 >
DisableIf< typename DenseSubmatrix<MT,AF,SO>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type blaze::DenseSubmatrix< MT, AF, SO >::assign ( const DenseMatrix< MT2, SO > &  rhs)
inline

Default 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 MT, bool AF = unaligned, bool SO = IsColumnMajorMatrix<MT>::value>
template<typename MT2 >
EnableIf< typename DenseSubmatrix<MT,AF,SO>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type blaze::DenseSubmatrix< MT, AF, SO >::assign ( const DenseMatrix< MT2, SO > &  rhs)
inline

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

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

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

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

template<typename MT , bool AF, bool SO>
DenseSubmatrix< MT, AF, SO >::ConstIterator blaze::DenseSubmatrix< MT, AF, SO >::begin ( size_t  i) const
inline

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

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

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

template<typename MT , bool AF, bool SO>
template<typename Other >
bool blaze::DenseSubmatrix< MT, AF, SO >::canAlias ( const Other *  alias) const
inline

Returns whether the submatrix can alias with the given address alias.

Parameters
aliasThe alias to be checked.
Returns
true in case the alias corresponds to this submatrix, false if not.

This function returns whether the given address can alias with the submatrix. In contrast to the isAliased() function this function is allowed to use compile time expressions to optimize the evaluation.

template<typename MT , bool AF, bool SO>
template<typename MT2 , bool AF2, bool SO2>
bool blaze::DenseSubmatrix< MT, AF, SO >::canAlias ( const DenseSubmatrix< MT2, AF2, SO2 > *  alias) const
inline

Returns whether the submatrix can alias with the given dense submatrix alias.

Parameters
aliasThe alias to be checked.
Returns
true in case the alias corresponds to this submatrix, false if not.

This function returns whether the given address can alias with the submatrix. In contrast to the isAliased() function this function is allowed to use compile time expressions to optimize the evaluation.

template<typename MT , bool AF, bool SO>
bool blaze::DenseSubmatrix< MT, AF, SO >::canSMPAssign ( ) const
inline

Returns whether the submatrix can be used in SMP assignments.

Returns
true in case the submatrix can be used in SMP assignments, false if not.

This function returns whether the submatrix can be used in SMP assignments. In contrast to the smpAssignable member enumeration, which is based solely on compile time information, this function additionally provides runtime information (as for instance the current number of rows and/or columns of the submatrix).

template<typename MT , bool AF, bool SO>
size_t blaze::DenseSubmatrix< MT, AF, SO >::capacity ( ) const
inline

Returns the maximum capacity of the dense submatrix.

Returns
The capacity of the dense submatrix.
template<typename MT , bool AF, bool SO>
size_t blaze::DenseSubmatrix< MT, AF, SO >::capacity ( size_t  i) const
inline

Returns the current capacity of the specified row/column.

Parameters
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 AF, bool SO>
DenseSubmatrix< MT, AF, SO >::ConstIterator blaze::DenseSubmatrix< MT, AF, SO >::cbegin ( size_t  i) const
inline

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

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

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

template<typename MT , bool AF, bool SO>
DenseSubmatrix< MT, AF, SO >::ConstIterator blaze::DenseSubmatrix< MT, AF, SO >::cend ( size_t  i) const
inline

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

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

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

template<typename MT , bool AF, bool SO>
size_t blaze::DenseSubmatrix< MT, AF, SO >::columns ( ) const
inline

Returns the number of columns of the dense submatrix.

Returns
The number of columns of the dense submatrix.
template<typename MT , bool AF, bool SO>
DenseSubmatrix< MT, AF, SO >::Pointer blaze::DenseSubmatrix< MT, AF, SO >::data ( )
inline

Low-level data access to the submatrix elements.

Returns
Pointer to the internal element storage.

This function returns a pointer to the internal storage of the dense submatrix. Note that you can NOT assume that all matrix elements lie adjacent to each other! The dense submatrix may use techniques such as padding to improve the alignment of the data.

template<typename MT , bool AF, bool SO>
DenseSubmatrix< MT, AF, SO >::ConstPointer blaze::DenseSubmatrix< MT, AF, SO >::data ( ) const
inline

Low-level data access to the submatrix elements.

Returns
Pointer to the internal element storage.

This function returns a pointer to the internal storage of the dense submatrix. Note that you can NOT assume that all matrix elements lie adjacent to each other! The dense submatrix may use techniques such as padding to improve the alignment of the data.

template<typename MT , bool AF, bool SO>
DenseSubmatrix< MT, AF, SO >::Iterator blaze::DenseSubmatrix< MT, AF, SO >::end ( size_t  i)
inline

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

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

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

template<typename MT , bool AF, bool SO>
DenseSubmatrix< MT, AF, SO >::ConstIterator blaze::DenseSubmatrix< MT, AF, SO >::end ( size_t  i) const
inline

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

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

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

template<typename MT , bool AF, bool SO>
bool blaze::DenseSubmatrix< MT, AF, SO >::hasOverlap ( ) const
inlineprivate

Checking whether there exists an overlap in the context of a symmetric matrix.

Returns
true in case an overlap exists, false if not.

This function checks if in the context of a symmetric matrix the submatrix has an overlap with its counterpart. In case an overlap exists, the function return true, otherwise it returns false.

template<typename MT , bool AF, bool SO>
template<typename Other >
bool blaze::DenseSubmatrix< MT, AF, SO >::isAliased ( const Other *  alias) const
inline

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

Parameters
aliasThe alias to be checked.
Returns
true in case the alias corresponds to this submatrix, false if not.

This function returns whether the given address is aliased with the submatrix. In contrast to the canAlias() function this function is not allowed to use compile time expressions to optimize the evaluation.

template<typename MT , bool AF, bool SO>
template<typename MT2 , bool AF2, bool SO2>
bool blaze::DenseSubmatrix< MT, AF, SO >::isAliased ( const DenseSubmatrix< MT2, AF2, SO2 > *  alias) const
inline

Returns whether the submatrix is aliased with the given dense submatrix alias.

Parameters
aliasThe alias to be checked.
Returns
true in case the alias corresponds to this submatrix, false if not.

This function returns whether the given address is aliased with the submatrix. In contrast to the canAlias() function this function is not allowed to use compile time expressions to optimize the evaluation.

template<typename MT , bool AF, bool SO>
bool blaze::DenseSubmatrix< MT, AF, SO >::isAligned ( ) const
inline

Returns whether the submatrix is properly aligned in memory.

Returns
true in case the submatrix is aligned, false if not.

This function returns whether the submatrix is guaranteed to be properly aligned in memory, i.e. whether the beginning and the end of each row/column of the submatrix are guaranteed to conform to the alignment restrictions of the underlying element type.

template<typename MT , bool AF, bool SO>
DenseSubmatrix< MT, AF, SO >::IntrinsicType blaze::DenseSubmatrix< MT, AF, SO >::load ( size_t  i,
size_t  j 
) const
inline

Aligned load of an intrinsic element of the submatrix.

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
The loaded intrinsic element.

This function performs an aligned load of a specific intrinsic element of the dense submatrix. The row index must be smaller than the number of rows and the column index must be smaller than the number of columns. Additionally, the column index (in case of a row-major matrix) or the row index (in case of a column-major matrix) must be a multiple of the number of values inside the intrinsic element. 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.

template<typename MT , bool AF, bool SO>
DenseSubmatrix< MT, AF, SO >::IntrinsicType blaze::DenseSubmatrix< MT, AF, SO >::loadu ( size_t  i,
size_t  j 
) const
inline

Unaligned load of an intrinsic element of the submatrix.

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
The loaded intrinsic element.

This function performs an unaligned load of a specific intrinsic element of the dense submatrix. The row index must be smaller than the number of rows and the column index must be smaller than the number of columns. Additionally, the column index (in case of a row-major matrix) or the row index (in case of a column-major matrix) must be a multiple of the number of values inside the intrinsic element. 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.

template<typename MT , bool AF, bool SO>
size_t blaze::DenseSubmatrix< MT, AF, SO >::nonZeros ( ) const
inline

Returns the number of non-zero elements in the dense submatrix.

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

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

Parameters
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 AF, bool SO>
DenseSubmatrix< MT, AF, SO >::Reference blaze::DenseSubmatrix< MT, AF, SO >::operator() ( size_t  i,
size_t  j 
)
inline

2D-access to the dense submatrix 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 MT , bool AF, bool SO>
DenseSubmatrix< MT, AF, SO >::ConstReference blaze::DenseSubmatrix< MT, AF, SO >::operator() ( size_t  i,
size_t  j 
) const
inline

2D-access to the dense submatrix 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 MT, bool AF = unaligned, bool SO = IsColumnMajorMatrix<MT>::value>
template<typename MT2 , bool SO2>
DenseSubmatrix<MT,AF,SO>& blaze::DenseSubmatrix< MT, AF, SO >::operator*= ( const Matrix< MT2, 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 dense submatrix.
Exceptions
std::invalid_argumentMatrix sizes do not match.
std::invalid_argumentInvalid assignment to symmetric matrix.

In case the current sizes of the two matrices don't match, a std::invalid_argument exception is thrown. Also, if the underlying matrix MT is a symmetric matrix and the assignment would violate its symmetry, a std::invalid_argument exception is thrown.

template<typename MT, bool AF = unaligned, bool SO = IsColumnMajorMatrix<MT>::value>
template<typename Other >
EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,AF,SO> >::Type& blaze::DenseSubmatrix< MT, AF, SO >::operator*= ( Other  rhs)
inline

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

Parameters
rhsThe right-hand side scalar value for the multiplication.
Returns
Reference to the dense submatrix.
template<typename MT, bool AF = unaligned, bool SO = IsColumnMajorMatrix<MT>::value>
template<typename MT2 , bool SO2>
DenseSubmatrix<MT,AF,SO>& blaze::DenseSubmatrix< MT, AF, SO >::operator+= ( const Matrix< MT2, 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 submatrix.
Returns
Reference to the dense submatrix.
Exceptions
std::invalid_argumentMatrix sizes do not match.
std::invalid_argumentInvalid assignment to symmetric matrix.

In case the current sizes of the two matrices don't match, a std::invalid_argument exception is thrown. Also, if the underlying matrix MT is a symmetric matrix and the assignment would violate its symmetry, a std::invalid_argument exception is thrown.

template<typename MT, bool AF = unaligned, bool SO = IsColumnMajorMatrix<MT>::value>
template<typename MT2 , bool SO2>
DenseSubmatrix<MT,AF,SO>& blaze::DenseSubmatrix< MT, AF, SO >::operator-= ( const Matrix< MT2, 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 submatrix.
Returns
Reference to the dense submatrix.
Exceptions
std::invalid_argumentMatrix sizes do not match.
std::invalid_argumentInvalid assignment to symmetric matrix.

In case the current sizes of the two matrices don't match, a std::invalid_argument exception is thrown. Also, if the underlying matrix MT is a symmetric matrix and the assignment would violate its symmetry, a std::invalid_argument exception is thrown.

template<typename MT, bool AF = unaligned, bool SO = IsColumnMajorMatrix<MT>::value>
template<typename Other >
EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,AF,SO> >::Type& blaze::DenseSubmatrix< MT, AF, SO >::operator/= ( Other  rhs)
inline

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

Parameters
rhsThe right-hand side scalar value for the division.
Returns
Reference to the dense submatrix.
template<typename MT , bool AF, bool SO>
DenseSubmatrix< MT, AF, SO > & blaze::DenseSubmatrix< MT, AF, SO >::operator= ( const ElementType rhs)
inline

Homogenous assignment to all submatrix elements.

Parameters
rhsScalar value to be assigned to all submatrix elements.
Returns
Reference to the assigned submatrix.

This function homogeneously assigns the given value to all dense matrix elements.

template<typename MT , bool AF, bool SO>
DenseSubmatrix< MT, AF, SO > & blaze::DenseSubmatrix< MT, AF, SO >::operator= ( const DenseSubmatrix< MT, AF, SO > &  rhs)
inline

Copy assignment operator for DenseSubmatrix.

Parameters
rhsSparse submatrix to be copied.
Returns
Reference to the assigned submatrix.
Exceptions
std::invalid_argumentSubmatrix sizes do not match.
std::invalid_argumentInvalid assignment to symmetric matrix.

The dense submatrix is initialized as a copy of the given dense submatrix. In case the current sizes of the two submatrices don't match, a std::invalid_argument exception is thrown. Also, if the underlying matrix MT is a symmetric matrix and the assignment would violate its symmetry, a std::invalid_argument exception is thrown.

template<typename MT, bool AF = unaligned, bool SO = IsColumnMajorMatrix<MT>::value>
template<typename MT2 , bool SO2>
DenseSubmatrix<MT,AF,SO>& blaze::DenseSubmatrix< MT, AF, SO >::operator= ( const Matrix< MT2, SO2 > &  rhs)
inline

Assignment operator for different matrices.

Parameters
rhsMatrix to be assigned.
Returns
Reference to the assigned submatrix.
Exceptions
std::invalid_argumentMatrix sizes do not match.
std::invalid_argumentInvalid assignment to symmetric matrix.

The dense submatrix is initialized as a copy of the given dense submatrix. In case the current sizes of the two matrices don't match, a std::invalid_argument exception is thrown. Also, if the underlying matrix MT is a symmetric matrix and the assignment would violate its symmetry, a std::invalid_argument exception is thrown.

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

Conversion operator for non-constant matrices.

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

Conversion operator for constant matrices.

Returns
Constant reference of the actual type of the matrix.
template<typename MT , bool AF, bool SO>
template<typename MT2 , bool SO2>
bool blaze::DenseSubmatrix< MT, AF, SO >::preservesSymmetry ( const Matrix< MT2, SO2 > &  rhs) const
inlineprivate

Checking whether the given matrix would violate the symmetry of the underlying matrix.

Parameters
rhsThe matrix to be assigned.
Returns
true in case the symmetry is preserved, false if not.

This function checks if the symmetry of the underlying symmetric matrix of type MT would be violated by an assignment of the given matrix rhs. In case the symmetry invariant is preserved, the function returns true. Otherwise it returns false.

template<typename MT , bool AF, bool SO>
void blaze::DenseSubmatrix< MT, AF, SO >::reset ( )
inline

Reset to the default initial values.

Returns
void
template<typename MT , bool AF, bool SO>
void blaze::DenseSubmatrix< MT, AF, SO >::reset ( size_t  i)
inline

Reset the specified row/column to the default initial values.

Parameters
iThe index of the row/column.
Returns
void

This function resets the values in the specified row/column to their default value. In case the storage order is set to rowMajor the function resets the values in row i, in case the storage order is set to columnMajor the function resets the values in column i. Note that the capacity of the row/column remains unchanged.

template<typename MT , bool AF, bool SO>
size_t blaze::DenseSubmatrix< MT, AF, SO >::rows ( ) const
inline

Returns the number of rows of the dense submatrix.

Returns
The number of rows of the dense submatrix.
template<typename MT, bool AF = unaligned, bool SO = IsColumnMajorMatrix<MT>::value>
template<typename Other >
DenseSubmatrix<MT,AF,SO>& blaze::DenseSubmatrix< MT, AF, SO >::scale ( const Other &  scalar)
inline

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

Parameters
scalarThe scalar value for the submatrix scaling.
Returns
Reference to the dense submatrix.
template<typename MT , bool AF, bool SO>
size_t blaze::DenseSubmatrix< MT, AF, SO >::spacing ( ) const
inline

Returns the spacing between the beginning of two rows/columns.

Returns
The spacing between the beginning of two rows/columns.

This function returns the spacing between the beginning of two rows/columns, i.e. the total number of elements of a row/column. In case the storage order is set to rowMajor the function returns the spacing between two rows, in case the storage flag is set to columnMajor the function returns the spacing between two columns.

template<typename MT , bool AF, bool SO>
void blaze::DenseSubmatrix< MT, AF, SO >::store ( size_t  i,
size_t  j,
const IntrinsicType value 
)
inline

Aligned store of an intrinsic element of the submatrix.

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].
valueThe intrinsic element to be stored.
Returns
void

This function performs an aligned store of a specific intrinsic element of the dense submatrix. The row index must be smaller than the number of rows and the column index must be smaller than the number of columns. Additionally, the column index (in case of a row-major matrix) or the row index (in case of a column-major matrix) must be a multiple of the number of values inside the intrinsic element. 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.

template<typename MT , bool AF, bool SO>
void blaze::DenseSubmatrix< MT, AF, SO >::storeu ( size_t  i,
size_t  j,
const IntrinsicType value 
)
inline

Unaligned store of an intrinsic element of the submatrix.

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].
valueThe intrinsic element to be stored.
Returns
void

This function performs an unaligned store of a specific intrinsic element of the dense submatrix. The row index must be smaller than the number of rows and the column index must be smaller than the number of columns. Additionally, the column index (in case of a row-major matrix) or the row index (in case of a column-major matrix) must be a multiple of the number of values inside the intrinsic element. 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.

template<typename MT , bool AF, bool SO>
void blaze::DenseSubmatrix< MT, AF, SO >::stream ( size_t  i,
size_t  j,
const IntrinsicType value 
)
inline

Aligned, non-temporal store of an intrinsic element of the submatrix.

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].
valueThe intrinsic element to be stored.
Returns
void

This function performs an aligned, non-temporal store of a specific intrinsic element of the dense submatrix. The row index must be smaller than the number of rows and the column index must be smaller than the number of columns. Additionally, the column index (in case of a row-major matrix) or the row index (in case of a column-major matrix) must be a multiple of the number of values inside the intrinsic element. 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.

template<typename MT , bool AF, bool SO>
template<typename MT2 >
void blaze::DenseSubmatrix< MT, AF, SO >::subAssign ( const DenseMatrix< MT2,!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 MT , bool AF, bool SO>
template<typename MT2 >
void blaze::DenseSubmatrix< MT, AF, SO >::subAssign ( const SparseMatrix< MT2, 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 MT , bool AF, bool SO>
template<typename MT2 >
void blaze::DenseSubmatrix< MT, AF, SO >::subAssign ( const SparseMatrix< MT2,!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 MT, bool AF = unaligned, bool SO = IsColumnMajorMatrix<MT>::value>
template<typename MT2 >
DisableIf< typename DenseSubmatrix<MT,AF,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type blaze::DenseSubmatrix< MT, AF, SO >::subAssign ( const DenseMatrix< MT2, SO > &  rhs)
inline

Default 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 MT, bool AF = unaligned, bool SO = IsColumnMajorMatrix<MT>::value>
template<typename MT2 >
EnableIf< typename DenseSubmatrix<MT,AF,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type blaze::DenseSubmatrix< MT, AF, SO >::subAssign ( const DenseMatrix< MT2, SO > &  rhs)
inline

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 MT , bool AF, bool SO>
DenseSubmatrix< MT, AF, SO > & blaze::DenseSubmatrix< MT, AF, SO >::transpose ( )
inline

Transposing the submatrix.

Returns
Reference to the transposed submatrix.
Exceptions
std::runtime_errorInvalid transpose of a non-quadratic submatrix.

This function transposes the dense submatrix in-place. Note that this function can only be used for quadratic submatrices, i.e. if the number of rows is equal to the number of columns. The attempt to transpose a non-quadratic submatrix results in a std::runtime_error exception.

Member Data Documentation

template<typename MT, bool AF = unaligned, bool SO = IsColumnMajorMatrix<MT>::value>
const size_t blaze::DenseSubmatrix< MT, AF, SO >::final_
private

The final index for unaligned intrinsic operations.

In case the submatrix is not fully aligned and the submatrix is involved in a vectorized operation, the final index indicates at which index a special treatment for the remaining elements is required.

template<typename MT, bool AF = unaligned, bool SO = IsColumnMajorMatrix<MT>::value>
const bool blaze::DenseSubmatrix< MT, AF, SO >::isAligned_
private

Memory alignment flag.

The alignment flag indicates whether the submatrix is fully aligned. In case the submatrix is fully aligned, no special handling has to be used for the last elements of the submatrix in a vectorized operation. In order to be aligned, the following conditions must hold for the submatrix:

  • The first element of each row/column must be aligned
  • The submatrix must be at the end of the given matrix or
  • The number of rows/columns of the submatrix must be a multiple of the number of values per intrinsic element.

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