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::SparseSubmatrix< typename, bool, bool > Class Template Reference

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

#include <SparseSubmatrix.h>

Inherits blaze::SparseMatrix< SparseSubmatrix< MT, AF, SO >, SO >, and blaze::Submatrix.

Classes

class  SubmatrixElement
 Access proxy for a specific element of the sparse submatrix. More...
 
class  SubmatrixIterator
 Iterator over the elements of the sparse submatrix. More...
 

Public Types

enum  { smpAssignable = MT::smpAssignable }
 Compilation switch for the expression template assignment strategy.
 
typedef SparseSubmatrix< MT,
AF, SO > 
This
 Type of this SparseSubmatrix 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 MT::ReturnType ReturnType
 Return type for expression template evaluations.
 
typedef const SparseSubmatrixCompositeType
 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 SubmatrixIterator
< const MT, typename
MT::ConstIterator > 
ConstIterator
 Iterator over constant elements.
 
typedef SelectType< useConst,
ConstIterator,
SubmatrixIterator< MT,
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>
SparseSubmatrix< MT, AF, SO > & operator= (const DenseMatrix< MT2, SO2 > &rhs)
 Assignment operator for dense matrices. More...
 
template<typename MT2 , bool SO2>
SparseSubmatrix< MT, AF, SO > & operator= (const SparseMatrix< MT2, SO2 > &rhs)
 Assignment operator for different sparse matrices. More...
 
template<typename MT2 , bool SO2>
SparseSubmatrix< 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>
SparseSubmatrix< 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>
SparseSubmatrix< 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 >
, SparseSubmatrix< MT, AF, SO >
>::Type & 
operator*= (Other rhs)
 Multiplication assignment operator for the multiplication between a sparse submatrix and a scalar value ( $ A*=s $). More...
 
template<typename Other >
EnableIf< IsNumeric< Other >
, SparseSubmatrix< MT, AF, SO >
>::Type & 
operator/= (Other rhs)
 Division assignment operator for the division of a sparse submatrix by a scalar value ( $ A/=s $). More...
 
template<typename Other >
SparseSubmatrix< MT, AF, SO > & scale (Other scalar)
 Scaling of the sparse submatrix by the scalar value scalar ( $ A=B*s $). More...
 
MatrixTypeoperator~ ()
 Conversion operator for non-constant matrices. More...
 
const MatrixTypeoperator~ () const
 Conversion operator for constant matrices. More...
 
Constructors
 SparseSubmatrix (Operand matrix, size_t row, size_t column, size_t m, size_t n)
 The constructor for SparseSubmatrix. More...
 
Data access functions
Reference operator() (size_t i, size_t j)
 2D-access to the sparse submatrix elements. More...
 
ConstReference operator() (size_t i, size_t j) const
 2D-access to the sparse 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
SparseSubmatrixoperator= (const SparseSubmatrix &rhs)
 Copy assignment operator for SparseSubmatrix. More...
 
template<typename MT2 , bool SO2>
SparseSubmatrixoperator= (const DenseMatrix< MT2, SO2 > &rhs)
 
template<typename MT2 , bool SO2>
SparseSubmatrixoperator= (const SparseMatrix< MT2, SO2 > &rhs)
 
template<typename MT2 , bool SO2>
SparseSubmatrixoperator+= (const Matrix< MT2, SO2 > &rhs)
 
template<typename MT2 , bool SO2>
SparseSubmatrixoperator-= (const Matrix< MT2, SO2 > &rhs)
 
template<typename MT2 , bool SO2>
SparseSubmatrixoperator*= (const Matrix< MT2, SO2 > &rhs)
 
template<typename Other >
EnableIf< IsNumeric< Other >
, SparseSubmatrix >::Type & 
operator*= (Other rhs)
 
template<typename Other >
EnableIf< IsNumeric< Other >
, SparseSubmatrix >::Type & 
operator/= (Other rhs)
 
Utility functions
size_t rows () const
 Returns the number of rows of the sparse submatrix. More...
 
size_t columns () const
 Returns the number of columns of the sparse submatrix. More...
 
size_t capacity () const
 Returns the maximum capacity of the sparse 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 sparse 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...
 
Iterator insert (size_t i, size_t j, const ElementType &value)
 Inserting an element into the sparse submatrix. More...
 
void erase (size_t i, size_t j)
 Erasing an element from the sparse submatrix. More...
 
Iterator erase (size_t i, Iterator pos)
 Erasing an element from the sparse submatrix. More...
 
Iterator erase (size_t i, Iterator first, Iterator last)
 Erasing a range of elements from the sparse submatrix. More...
 
void reserve (size_t nonzeros)
 Setting the minimum capacity of the sparse submatrix. More...
 
void reserve (size_t i, size_t nonzeros)
 Setting the minimum capacity of a specific row/column of the sparse submatrix. More...
 
void trim ()
 Removing all excessive capacity from all rows/columns. More...
 
void trim (size_t i)
 Removing all excessive capacity of a specific row/column of the sparse matrix. More...
 
SparseSubmatrixtranspose ()
 Transposing the submatrix. More...
 
template<typename Other >
SparseSubmatrixscale (Other scalar)
 
Lookup functions
Iterator find (size_t i, size_t j)
 Searches for a specific submatrix element. More...
 
ConstIterator find (size_t i, size_t j) const
 Searches for a specific submatrix element. More...
 
Iterator lowerBound (size_t i, size_t j)
 Returns an iterator to the first index not less then the given index. More...
 
ConstIterator lowerBound (size_t i, size_t j) const
 Returns an iterator to the first index not less then the given index. More...
 
Iterator upperBound (size_t i, size_t j)
 Returns an iterator to the first index greater then the given index. More...
 
ConstIterator upperBound (size_t i, size_t j) const
 Returns an iterator to the first index greater then the given index. More...
 
Low-level utility functions
void append (size_t i, size_t j, const ElementType &value, bool check=false)
 Appending an element to the specified row/column of the sparse submatrix. More...
 
void finalize (size_t i)
 Finalizing the element insertion of a row/column. More...
 
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 Other >
bool isAliased (const Other *alias) const
 Returns whether the submatrix is aliased with the given address alias. More...
 
bool canSMPAssign () const
 Returns whether the submatrix can be used in SMP assignments. More...
 
template<typename MT2 , bool SO2>
void assign (const DenseMatrix< MT2, SO2 > &rhs)
 Default implementation of the assignment of a dense matrix. More...
 
template<typename MT2 >
void assign (const SparseMatrix< MT2, false > &rhs)
 Default implementation of the assignment of a row-major sparse matrix. More...
 
template<typename MT2 >
void assign (const SparseMatrix< MT2, true > &rhs)
 Default implementation of the assignment of a column-major sparse matrix. More...
 
template<typename MT2 , bool SO2>
void addAssign (const DenseMatrix< MT2, SO2 > &rhs)
 Default implementation of the addition assignment of a dense matrix. More...
 
template<typename MT2 , bool SO2>
void addAssign (const SparseMatrix< MT2, SO2 > &rhs)
 Default implementation of the addition assignment of a sparse matrix. More...
 
template<typename MT2 , bool SO2>
void subAssign (const DenseMatrix< MT2, SO2 > &rhs)
 Default implementation of the subtraction assignment of a dense matrix. More...
 
template<typename MT2 , bool SO2>
void subAssign (const SparseMatrix< MT2, SO2 > &rhs)
 Default implementation of the subtraction assignment of a 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.
 

Private Attributes

Member variables
Operand matrix_
 The sparse 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.
 

Detailed Description

template<typename, bool, bool>
class blaze::SparseSubmatrix< typename, bool, bool >

View on a specific submatrix of a sparse matrix.

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

template< typename MT, bool AF, bool SO >


Setup of Sparse Submatrices

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

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

This view can be treated as any other sparse 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 sparse matrix primitive on the left-hand side of an assignment or to grant read-access to a specific submatrix of a sparse matrix primitive or expression on the right-hand side of an assignment. The following example demonstrates this in detail:

SparseMatrixType A, B;
DenseMatrixType C;
// ... Resizing and initialization
// Creating a sparse submatrix of size 8x4, starting in row 0 and column 2
// Setting the submatrix of A to a 8x4 submatrix of B
sm = submatrix( B, 0UL, 0UL, 8UL, 4UL );
// Copying the dense 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 sparse submatrix can be used like any other sparse matrix. For instance, the elements of the sparse 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::SparseSubmatrix<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::SparseSubmatrix<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->value() = ...; // OK: Write access to the value of the non-zero element.
... = it->value(); // OK: Read access to the value of the non-zero element.
it->index() = ...; // Compilation error: The index of a non-zero element cannot be changed.
... = it->index(); // OK: Read access to the index of the sparse element.
}
// 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->value() = ...; // Compilation error: Assignment to the value via a ConstIterator is invalid.
... = it->value(); // OK: Read access to the value of the non-zero element.
it->index() = ...; // Compilation error: The index of a non-zero element cannot be changed.
... = it->index(); // OK: Read access to the index of the sparse element.
}


Element Insertion

Inserting/accessing elements in a sparse submatrix can be done by several alternative functions. The following example demonstrates all options:

MatrixType A( 256UL, 512UL ); // Non-initialized matrix of size 256x512
typedef blaze::SparseSubmatrix<MatrixType> SubmatrixType;
SubmatrixType sm = submatrix( A, 10UL, 10UL, 16UL, 16UL ); // View on a 16x16 submatrix of A
// The function call operator provides access to all possible elements of the sparse submatrix,
// including the zero elements. In case the subscript operator is used to access an element
// that is currently not stored in the sparse submatrix, the element is inserted into the
// submatrix.
sm(2,4) = 2.0;
// An alternative for inserting elements into the submatrix is the \c insert() function. However,
// it inserts the element only in case the element is not already contained in the submatrix.
sm.insert( 2UL, 6UL, 3.7 );
// Just as in the case of sparse matrices, elements can also be inserted via the \c append()
// function. In case of submatrices, \c append() also requires that the appended element's
// index is strictly larger than the currently largest non-zero index in the according row
// or column of the submatrix and that the according row's or column's capacity is large enough
// to hold the new element. Note however that due to the nature of a submatrix, which may be an
// alias to the middle of a sparse matrix, the \c append() function does not work as efficiently
// for a submatrix as it does for a matrix.
sm.reserve( 2UL, 10UL );
sm.append( 2UL, 10UL, -2.1 );


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::SparseSubmatrix<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 SparseSubmatrix 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:

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

SparseMatrixType A;
// ... Resizing and initialization
// Identical creations of an unaligned submatrix of size 8x8, starting in row 0 and column 0
blaze::SparseSubmatrix<SparseMatrixType> sm1 = submatrix ( A, 0UL, 0UL, 8UL, 8UL );
blaze::SparseSubmatrix<SparseMatrixType> sm2 = submatrix<unaligned>( A, 0UL, 0UL, 8UL, 8UL );
blaze::SparseSubmatrix<SparseMatrixType,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::SparseSubmatrix<SparseMatrixType,aligned> sv = submatrix<aligned>( A, 0UL, 0UL, 8UL, 8UL );

In contrast to dense submatrices, which pose several additional alignment restrictions based on the used element type, sparse submatrices at this time don't pose any additional restrictions. Therefore aligned and unaligned sparse submatrices are truly fully identical. Note however that this is not true for dense submatrices (see the DenseSubmatrix class description)!


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 sparse matrix:

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

Member Enumeration Documentation

template<typename , bool , bool >
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 sparse matrix of type MT is const qualified, useConst will be set to 1 and the sparse submatrix will return references and iterators to const. Otherwise useConst will be set to 0 and the sparse submatrix will offer write access to the sparse matrix elements both via the function call operator and iterators.

Constructor & Destructor Documentation

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

The constructor for SparseSubmatrix.

Parameters
matrixThe sparse matrix containing the submatrix.
rowThe index of the first row of the submatrix in the given sparse matrix.
columnThe index of the first column of the submatrix in the given sparse 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 sparse matrix) a std::invalid_argument exception is thrown.

Member Function Documentation

template<typename MT , bool AF, bool SO>
template<typename MT2 , bool SO2>
void blaze::SparseSubmatrix< MT, AF, SO >::addAssign ( const DenseMatrix< MT2, SO2 > &  rhs)
inline

Default implementation of the addition assignment of a 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 , bool SO2>
void blaze::SparseSubmatrix< MT, AF, SO >::addAssign ( const SparseMatrix< MT2, SO2 > &  rhs)
inline

Default implementation of the addition assignment of a 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>
void blaze::SparseSubmatrix< MT, AF, SO >::append ( size_t  i,
size_t  j,
const ElementType value,
bool  check = false 
)
inline

Appending an element to the specified row/column of the sparse submatrix.

Parameters
iThe row index of the new element. The index has to be in the range $[0..M-1]$.
jThe column index of the new element. The index has to be in the range $[0..N-1]$.
valueThe value of the element to be appended.
checktrue if the new value should be checked for default values, false if not.
Returns
void

This function provides a very efficient way to fill a sparse submatrix with elements. It appends a new element to the end of the specified row/column without any additional memory allocation. Therefore it is strictly necessary to keep the following preconditions in mind:

  • the index of the new element must be strictly larger than the largest index of non-zero elements in the specified row/column of the sparse submatrix
  • the current number of non-zero elements in the submatrix must be smaller than the capacity of the matrix

Ignoring these preconditions might result in undefined behavior! The optional check parameter specifies whether the new value should be tested for a default value. If the new value is a default value (for instance 0 in case of an integral element type) the value is not appended. Per default the values are not tested.

In combination with the reserve() and the finalize() function, append() provides the most efficient way to add new elements to a sparse submatrix:

typedef blaze::SparseSubmatrix<MatrixType> SubmatrixType;
MatrixType A( 42, 54 );
SubmatrixType B = submatrix( A, 10, 10, 4, 3 );
B.reserve( 3 ); // Reserving enough space for 3 non-zero elements
B.append( 0, 1, 1 ); // Appending the value 1 in row 0 with column index 1
B.finalize( 0 ); // Finalizing row 0
B.append( 1, 1, 2 ); // Appending the value 2 in row 1 with column index 1
B.finalize( 1 ); // Finalizing row 1
B.append( 2, 0, 3 ); // Appending the value 3 in row 2 with column index 0
B.finalize( 2 ); // Finalizing row 2

Note: Although append() does not allocate new memory, it still invalidates all iterators returned by the end() functions!

template<typename MT , bool AF, bool SO>
template<typename MT2 , bool SO2>
void blaze::SparseSubmatrix< MT, AF, SO >::assign ( const DenseMatrix< MT2, SO2 > &  rhs)
inline

Default implementation of the assignment of a 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::SparseSubmatrix< MT, AF, SO >::assign ( const SparseMatrix< MT2, false > &  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::SparseSubmatrix< MT, AF, SO >::assign ( const SparseMatrix< MT2, true > &  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, bool SO>
SparseSubmatrix< MT, AF, SO >::Iterator blaze::SparseSubmatrix< 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>
SparseSubmatrix< MT, AF, SO >::ConstIterator blaze::SparseSubmatrix< 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::SparseSubmatrix< 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>
bool blaze::SparseSubmatrix< 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 matrix).

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

Returns the maximum capacity of the sparse submatrix.

Returns
The capacity of the sparse submatrix.
template<typename MT , bool AF, bool SO>
size_t blaze::SparseSubmatrix< 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>
SparseSubmatrix< MT, AF, SO >::ConstIterator blaze::SparseSubmatrix< 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>
SparseSubmatrix< MT, AF, SO >::ConstIterator blaze::SparseSubmatrix< 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::SparseSubmatrix< MT, AF, SO >::columns ( ) const
inline

Returns the number of columns of the sparse submatrix.

Returns
The number of columns of the sparse submatrix.
template<typename MT , bool AF, bool SO>
SparseSubmatrix< MT, AF, SO >::Iterator blaze::SparseSubmatrix< 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>
SparseSubmatrix< MT, AF, SO >::ConstIterator blaze::SparseSubmatrix< 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>
void blaze::SparseSubmatrix< MT, AF, SO >::erase ( size_t  i,
size_t  j 
)
inline

Erasing an element from the sparse submatrix.

Parameters
iThe row index of the element to be erased. The index has to be in the range $[0..M-1]$.
jThe column index of the element to be erased. The index has to be in the range $[0..N-1]$.
Returns
void

This function erases an element from the sparse submatrix.

template<typename MT , bool AF, bool SO>
SparseSubmatrix< MT, AF, SO >::Iterator blaze::SparseSubmatrix< MT, AF, SO >::erase ( size_t  i,
Iterator  pos 
)
inline

Erasing an element from the sparse submatrix.

Parameters
iThe row/column index of the element to be erased. The index has to be in the range $[0..M-1]$.
posIterator to the element to be erased.
Returns
Iterator to the element after the erased element.

This function erases an element from the sparse submatrix. In case the storage order is set to rowMajor the function erases an element from row i, in case the storage flag is set to columnMajor the function erases an element from column i.

template<typename MT , bool AF, bool SO>
SparseSubmatrix< MT, AF, SO >::Iterator blaze::SparseSubmatrix< MT, AF, SO >::erase ( size_t  i,
Iterator  first,
Iterator  last 
)
inline

Erasing a range of elements from the sparse submatrix.

Parameters
iThe row/column index of the element to be erased. The index has to be in the range $[0..M-1]$.
firstIterator to first element to be erased.
lastIterator just past the last element to be erased.
Returns
Iterator to the element after the erased element.

This function erases a range of element from the sparse submatrix. In case the storage order is set to rowMajor the function erases a range of elements element from row i, in case the storage flag is set to columnMajor the function erases a range of elements from column i.

template<typename MT , bool AF, bool SO>
void blaze::SparseSubmatrix< MT, AF, SO >::finalize ( size_t  i)
inline

Finalizing the element insertion of a row/column.

Parameters
iThe index of the row/column to be finalized $[0..M-1]$.
Returns
void

This function is part of the low-level interface to efficiently fill a submatrix with elements. After completion of row/column i via the append() function, this function can be called to finalize row/column i and prepare the next row/column for insertion process via append().

Note: Although finalize() does not allocate new memory, it still invalidates all iterators returned by the end() functions!

template<typename MT , bool AF, bool SO>
SparseSubmatrix< MT, AF, SO >::Iterator blaze::SparseSubmatrix< MT, AF, SO >::find ( size_t  i,
size_t  j 
)
inline

Searches for a specific submatrix element.

Parameters
iThe row index of the search element. The index has to be in the range $[0..M-1]$.
jThe column index of the search element. The index has to be in the range $[0..N-1]$.
Returns
Iterator to the element in case the index is found, end() iterator otherwise.

This function can be used to check whether a specific element is contained in the sparse submatrix. It specifically searches for the element with row index i and column index j. In case the element is found, the function returns an row/column iterator to the element. Otherwise an iterator just past the last non-zero element of row i or column j (the end() iterator) is returned. Note that the returned sparse submatrix iterator is subject to invalidation due to inserting operations via the function call operator or the insert() function!

template<typename MT , bool AF, bool SO>
SparseSubmatrix< MT, AF, SO >::ConstIterator blaze::SparseSubmatrix< MT, AF, SO >::find ( size_t  i,
size_t  j 
) const
inline

Searches for a specific submatrix element.

Parameters
iThe row index of the search element. The index has to be in the range $[0..M-1]$.
jThe column index of the search element. The index has to be in the range $[0..N-1]$.
Returns
Iterator to the element in case the index is found, end() iterator otherwise.

This function can be used to check whether a specific element is contained in the sparse submatrix. It specifically searches for the element with row index i and column index j. In case the element is found, the function returns an row/column iterator to the element. Otherwise an iterator just past the last non-zero element of row i or column j (the end() iterator) is returned. Note that the returned sparse submatrix iterator is subject to invalidation due to inserting operations via the function call operator or the insert() function!

template<typename MT , bool AF, bool SO>
SparseSubmatrix< MT, AF, SO >::Iterator blaze::SparseSubmatrix< MT, AF, SO >::insert ( size_t  i,
size_t  j,
const ElementType value 
)

Inserting an element into the sparse submatrix.

Parameters
iThe row index of the new element. The index has to be in the range $[0..M-1]$.
jThe column index of the new element. The index has to be in the range $[0..N-1]$.
valueThe value of the element to be inserted.
Returns
Iterator to the newly inserted element.
Exceptions
std::invalid_argumentInvalid sparse submatrix access index.

This function inserts a new element into the sparse submatrix. However, duplicate elements are not allowed. In case the sparse submatrix already contains an element with row index i and column index j, a std::invalid_argument exception is thrown.

template<typename MT , bool AF, bool SO>
template<typename Other >
bool blaze::SparseSubmatrix< 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 conAlias() function this function is not allowed to use compile time expressions to optimize the evaluation.

template<typename MT , bool AF, bool SO>
SparseSubmatrix< MT, AF, SO >::Iterator blaze::SparseSubmatrix< MT, AF, SO >::lowerBound ( size_t  i,
size_t  j 
)
inline

Returns an iterator to the first index not less then the given index.

Parameters
iThe row index of the search element. The index has to be in the range $[0..M-1]$.
jThe column index of the search element. The index has to be in the range $[0..N-1]$.
Returns
Iterator to the first index not less then the given index, end() iterator otherwise.

In case of a row-major submatrix, this function returns a row iterator to the first element with an index not less then the given column index. In case of a column-major submatrix, the function returns a column iterator to the first element with an index not less then the given row index. In combination with the upperBound() function this function can be used to create a pair of iterators specifying a range of indices. Note that the returned submatrix iterator is subject to invalidation due to inserting operations via the function call operator or the insert() function!

template<typename MT , bool AF, bool SO>
SparseSubmatrix< MT, AF, SO >::ConstIterator blaze::SparseSubmatrix< MT, AF, SO >::lowerBound ( size_t  i,
size_t  j 
) const
inline

Returns an iterator to the first index not less then the given index.

Parameters
iThe row index of the search element. The index has to be in the range $[0..M-1]$.
jThe column index of the search element. The index has to be in the range $[0..N-1]$.
Returns
Iterator to the first index not less then the given index, end() iterator otherwise.

In case of a row-major submatrix, this function returns a row iterator to the first element with an index not less then the given column index. In case of a column-major submatrix, the function returns a column iterator to the first element with an index not less then the given row index. In combination with the upperBound() function this function can be used to create a pair of iterators specifying a range of indices. Note that the returned submatrix iterator is subject to invalidation due to inserting operations via the function call operator or the insert() function!

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

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

Returns
The number of non-zero elements in the sparse submatrix.
template<typename MT , bool AF, bool SO>
size_t blaze::SparseSubmatrix< 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>
SparseSubmatrix< MT, AF, SO >::Reference blaze::SparseSubmatrix< MT, AF, SO >::operator() ( size_t  i,
size_t  j 
)
inline

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

2D-access to the sparse 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 , bool , bool >
template<typename MT2 , bool SO2>
SparseSubmatrix<MT,AF,SO>& blaze::SparseSubmatrix< typename, bool, bool >::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 sparse submatrix.
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 , bool , bool >
template<typename Other >
EnableIf< IsNumeric<Other>, SparseSubmatrix<MT,AF,SO> >::Type& blaze::SparseSubmatrix< typename, bool, bool >::operator*= ( Other  rhs)
inline

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

Parameters
rhsThe right-hand side scalar value for the multiplication.
Returns
Reference to the sparse submatrix.
template<typename , bool , bool >
template<typename MT2 , bool SO2>
SparseSubmatrix<MT,AF,SO>& blaze::SparseSubmatrix< typename, bool, bool >::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 sparse submatrix.
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 , bool , bool >
template<typename MT2 , bool SO2>
SparseSubmatrix<MT,AF,SO>& blaze::SparseSubmatrix< typename, bool, bool >::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 sparse submatrix.
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 , bool , bool >
template<typename Other >
EnableIf< IsNumeric<Other>, SparseSubmatrix<MT,AF,SO> >::Type& blaze::SparseSubmatrix< typename, bool, bool >::operator/= ( Other  rhs)
inline

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

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

Copy assignment operator for SparseSubmatrix.

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

The sparse submatrix is initialized as a copy of the given sparse submatrix. In case the current sizes of the two submatrices don't match, a std::invalid_argument exception is thrown.

template<typename , bool , bool >
template<typename MT2 , bool SO2>
SparseSubmatrix<MT,AF,SO>& blaze::SparseSubmatrix< typename, bool, bool >::operator= ( const DenseMatrix< MT2, SO2 > &  rhs)
inline

Assignment operator for dense matrices.

Parameters
rhsDense matrix to be assigned.
Returns
Reference to the assigned submatrix.
Exceptions
std::invalid_argumentMatrix sizes do not match.

The sparse submatrix is initialized as a copy of the given dense matrix. In case the current sizes of the two matrices don't match, a std::invalid_argument exception is thrown.

template<typename , bool , bool >
template<typename MT2 , bool SO2>
SparseSubmatrix<MT,AF,SO>& blaze::SparseSubmatrix< typename, bool, bool >::operator= ( const SparseMatrix< MT2, SO2 > &  rhs)
inline

Assignment operator for different sparse matrices.

Parameters
rhsSparse matrix to be assigned.
Returns
Reference to the assigned submatrix.
Exceptions
std::invalid_argumentMatrix sizes do not match.

The sparse submatrix is initialized as a copy of the given sparse matrix. In case the current sizes of the two matrices don't match, a std::invalid_argument exception is thrown.

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

Conversion operator for non-constant matrices.

Returns
Reference of the actual type of the matrix.
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>
void blaze::SparseSubmatrix< MT, AF, SO >::reserve ( size_t  nonzeros)
inline

Setting the minimum capacity of the sparse submatrix.

Parameters
nonzerosThe new minimum capacity of the sparse submatrix.
Returns
void

This function increases the capacity of the sparse submatrix to at least nonzeros elements. The current values of the submatrix elements and the individual capacities of the submatrix rows are preserved.

template<typename MT , bool AF, bool SO>
void blaze::SparseSubmatrix< MT, AF, SO >::reserve ( size_t  i,
size_t  nonzeros 
)

Setting the minimum capacity of a specific row/column of the sparse submatrix.

Parameters
iThe row/column index of the new element $[0..M-1]$ or $[0..N-1]$.
nonzerosThe new minimum capacity of the specified row/column.
Returns
void

This function increases the capacity of row/column i of the sparse submatrix to at least nonzeros elements, but not beyond the current number of columns/rows, respectively. The current values of the sparse submatrix and all other individual row/column capacities are preserved. In case the storage order is set to rowMajor, the function reserves capacity for row i and the index has to be in the range $[0..M-1]$. In case the storage order is set to columnMajor, the function reserves capacity for column i and the index has to be in the range $[0..N-1]$.

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

Reset to the default initial values.

Returns
void
template<typename MT , bool AF, bool SO>
void blaze::SparseSubmatrix< 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::SparseSubmatrix< MT, AF, SO >::rows ( ) const
inline

Returns the number of rows of the sparse submatrix.

Returns
The number of rows of the sparse submatrix.
template<typename , bool , bool >
template<typename Other >
SparseSubmatrix<MT,AF,SO>& blaze::SparseSubmatrix< typename, bool, bool >::scale ( Other  scalar)
inline

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

Parameters
scalarThe scalar value for the submatrix scaling.
Returns
Reference to the sparse submatrix.
template<typename MT , bool AF, bool SO>
template<typename MT2 , bool SO2>
void blaze::SparseSubmatrix< MT, AF, SO >::subAssign ( const DenseMatrix< MT2, SO2 > &  rhs)
inline

Default implementation of the subtraction assignment of a 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 , bool SO2>
void blaze::SparseSubmatrix< MT, AF, SO >::subAssign ( const SparseMatrix< MT2, SO2 > &  rhs)
inline

Default implementation of the subtraction assignment of a 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>
SparseSubmatrix< MT, AF, SO > & blaze::SparseSubmatrix< 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 sparse 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.

template<typename MT , bool AF, bool SO>
void blaze::SparseSubmatrix< MT, AF, SO >::trim ( )
inline

Removing all excessive capacity from all rows/columns.

Returns
void

The trim() function can be used to reverse the effect of all row/column-specific reserve() calls. The function removes all excessive capacity from all rows (in case of a rowMajor matrix) or columns (in case of a columnMajor matrix). Note that this function does not remove the overall capacity but only reduces the capacity per row/column.

template<typename MT , bool AF, bool SO>
void blaze::SparseSubmatrix< MT, AF, SO >::trim ( size_t  i)
inline

Removing all excessive capacity of a specific row/column of the sparse matrix.

Parameters
iThe index of the row/column to be trimmed ( $[0..M-1]$ or $[0..N-1]$).
Returns
void

This function can be used to reverse the effect of a row/column-specific reserve() call. It removes all excessive capacity from the specified row (in case of a rowMajor matrix) or column (in case of a columnMajor matrix). The excessive capacity is assigned to the subsequent row/column.

template<typename MT , bool AF, bool SO>
SparseSubmatrix< MT, AF, SO >::Iterator blaze::SparseSubmatrix< MT, AF, SO >::upperBound ( size_t  i,
size_t  j 
)
inline

Returns an iterator to the first index greater then the given index.

Parameters
iThe row index of the search element. The index has to be in the range $[0..M-1]$.
jThe column index of the search element. The index has to be in the range $[0..N-1]$.
Returns
Iterator to the first index greater then the given index, end() iterator otherwise.

In case of a row-major submatrix, this function returns a row iterator to the first element with an index greater then the given column index. In case of a column-major submatrix, the function returns a column iterator to the first element with an index greater then the given row index. In combination with the upperBound() function this function can be used to create a pair of iterators specifying a range of indices. Note that the returned submatrix iterator is subject to invalidation due to inserting operations via the function call operator or the insert() function!

template<typename MT , bool AF, bool SO>
SparseSubmatrix< MT, AF, SO >::ConstIterator blaze::SparseSubmatrix< MT, AF, SO >::upperBound ( size_t  i,
size_t  j 
) const
inline

Returns an iterator to the first index greater then the given index.

Parameters
iThe row index of the search element. The index has to be in the range $[0..M-1]$.
jThe column index of the search element. The index has to be in the range $[0..N-1]$.
Returns
Iterator to the first index greater then the given index, end() iterator otherwise.

In case of a row-major submatrix, this function returns a row iterator to the first element with an index greater then the given column index. In case of a column-major submatrix, the function returns a column iterator to the first element with an index greater then the given row index. In combination with the upperBound() function this function can be used to create a pair of iterators specifying a range of indices. Note that the returned submatrix iterator is subject to invalidation due to inserting operations via the function call operator or the insert() function!


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