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

Reference to a specific row of a sparse matrix.The SparseRow template represents a reference to a specific row of a sparse matrix primitive. The type of the sparse matrix is specified via the first template parameter: More...

#include <SparseRow.h>

Inherits blaze::SparseVector< SparseRow< MT, SO >, true >, and blaze::View.

Public Types

typedef SparseRow< MT, SO > This
 Type of this SparseRow instance.
 
typedef RowTrait< MT >::Type ResultType
 Result type for expression template evaluations.
 
typedef ResultType::TransposeType TransposeType
 Transpose type for expression template evaluations.
 
typedef MT::ElementType ElementType
 Type of the row elements.
 
typedef MT::ReturnType ReturnType
 Return type for expression template evaluations.
 
typedef const SparseRowCompositeType
 Data type for composite expression templates.
 
typedef MT::ConstReference ConstReference
 Reference to a constant row value.
 
typedef SelectType< useConst,
ConstReference, typename
MT::Reference >::Type 
Reference
 Reference to a non-constant row value.
 
typedef MT::ConstIterator ConstIterator
 Iterator over constant elements.
 
typedef SelectType< useConst,
ConstIterator, typename
MT::Iterator >::Type 
Iterator
 Iterator over non-constant elements.
 
typedef VT VectorType
 Type of the vector.
 

Public Member Functions

template<typename VT >
SparseRow< MT, SO > & operator= (const DenseVector< VT, true > &rhs)
 Assignment operator for different dense vectors. More...
 
template<typename VT >
SparseRow< MT, SO > & operator= (const SparseVector< VT, true > &rhs)
 Assignment operator for different sparse vectors. More...
 
template<typename VT >
SparseRow< MT, SO > & operator+= (const Vector< VT, true > &rhs)
 Addition assignment operator for the addition of a vector ( $ \vec{a}+=\vec{b} $). More...
 
template<typename VT >
SparseRow< MT, SO > & operator-= (const Vector< VT, true > &rhs)
 Subtraction assignment operator for the subtraction of a vector ( $ \vec{a}-=\vec{b} $). More...
 
template<typename VT >
SparseRow< MT, SO > & operator*= (const Vector< VT, true > &rhs)
 Multiplication assignment operator for the multiplication of a vector ( $ \vec{a}*=\vec{b} $). More...
 
template<typename Other >
EnableIf< IsNumeric< Other >
, SparseRow< MT, SO > >::Type & 
operator*= (Other rhs)
 Multiplication assignment operator for the multiplication between a sparse row and a scalar value ( $ \vec{a}*=s $). More...
 
template<typename Other >
EnableIf< IsNumeric< Other >
, SparseRow< MT, SO > >::Type & 
operator/= (Other rhs)
 Division assignment operator for the division of a sparse row by a scalar value ( $ \vec{a}/=s $). More...
 
template<typename Other >
SparseRow< MT, SO > & scale (Other scalar)
 Scaling of the sparse row by the scalar value scalar ( $ \vec{a}=\vec{b}*s $). More...
 
VectorTypeoperator~ ()
 Conversion operator for non-constant vectors. More...
 
const VectorTypeoperator~ () const
 Conversion operator for constant vectors. More...
 
Constructors
 SparseRow (MT &matrix, size_t index)
 The constructor for SparseRow. More...
 
Data access functions
Reference operator[] (size_t index)
 Subscript operator for the direct access to the row elements. More...
 
ConstReference operator[] (size_t index) const
 Subscript operator for the direct access to the row elements. More...
 
Iterator begin ()
 Returns an iterator to the first element of the row. More...
 
ConstIterator begin () const
 Returns an iterator to the first element of the row. More...
 
ConstIterator cbegin () const
 Returns an iterator to the first element of the row. More...
 
Iterator end ()
 Returns an iterator just past the last element of the row. More...
 
ConstIterator end () const
 Returns an iterator just past the last element of the row. More...
 
ConstIterator cend () const
 Returns an iterator just past the last element of the row. More...
 
Assignment operators
SparseRowoperator= (const SparseRow &rhs)
 Copy assignment operator for SparseRow. More...
 
template<typename VT >
SparseRowoperator= (const DenseVector< VT, true > &rhs)
 
template<typename VT >
SparseRowoperator= (const SparseVector< VT, true > &rhs)
 
template<typename VT >
SparseRowoperator+= (const Vector< VT, true > &rhs)
 
template<typename VT >
SparseRowoperator-= (const Vector< VT, true > &rhs)
 
template<typename VT >
SparseRowoperator*= (const Vector< VT, true > &rhs)
 
template<typename Other >
EnableIf< IsNumeric< Other >
, SparseRow >::Type & 
operator*= (Other rhs)
 
template<typename Other >
EnableIf< IsNumeric< Other >
, SparseRow >::Type & 
operator/= (Other rhs)
 
Lookup functions
Iterator find (size_t index)
 Searches for a specific row element. More...
 
ConstIterator find (size_t index) const
 Searches for a specific row element. More...
 
Iterator lowerBound (size_t index)
 Returns an iterator to the first index not less then the given index. More...
 
ConstIterator lowerBound (size_t index) const
 Returns an iterator to the first index not less then the given index. More...
 
Iterator upperBound (size_t index)
 Returns an iterator to the first index greater then the given index. More...
 
ConstIterator upperBound (size_t index) const
 Returns an iterator to the first index greater then the given index. More...
 
Low-level utility functions
void append (size_t index, const ElementType &value, bool check=false)
 Appending an element to the sparse row. More...
 
Expression template evaluation functions
template<typename Other >
bool canAlias (const Other *alias) const
 Returns whether the sparse row can alias with the given address alias. More...
 
template<typename Other >
bool isAliased (const Other *alias) const
 Returns whether the sparse row is aliased with the given address alias. More...
 
template<typename VT >
void assign (const DenseVector< VT, true > &rhs)
 Default implementation of the assignment of a dense vector. More...
 
template<typename VT >
void assign (const SparseVector< VT, true > &rhs)
 Default implementation of the assignment of a sparse vector. More...
 
template<typename VT >
void addAssign (const DenseVector< VT, true > &rhs)
 Default implementation of the addition assignment of a dense vector. More...
 
template<typename VT >
void addAssign (const SparseVector< VT, true > &rhs)
 Default implementation of the addition assignment of a sparse vector. More...
 
template<typename VT >
void subAssign (const DenseVector< VT, true > &rhs)
 Default implementation of the subtraction assignment of a dense vector. More...
 
template<typename VT >
void subAssign (const SparseVector< VT, true > &rhs)
 Default implementation of the subtraction assignment of a sparse vector. 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 row.
 
const size_t row_
 The index of the row in the matrix.
 

Utility functions

size_t size () const
 Returns the current size/dimension of the sparse row. More...
 
size_t capacity () const
 Returns the maximum capacity of the sparse row. More...
 
size_t nonZeros () const
 Returns the number of non-zero elements in the row. More...
 
void reset ()
 Reset to the default initial values. More...
 
Iterator insert (size_t index, const ElementType &value)
 Inserting an element into the sparse row. More...
 
void erase (size_t index)
 Erasing an element from the sparse row. More...
 
Iterator erase (Iterator pos)
 Erasing an element from the sparse row. More...
 
Iterator erase (Iterator first, Iterator last)
 Erasing a range of elements from the sparse row. More...
 
void reserve (size_t n)
 Setting the minimum capacity of the sparse row. More...
 
template<typename Other >
SparseRowscale (Other scalar)
 
size_t extendCapacity () const
 Calculating a new sparse row capacity. More...
 

Detailed Description

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

Reference to a specific row of a sparse matrix.

The SparseRow template represents a reference to a specific row of a sparse matrix primitive. The type of the sparse matrix is specified via the first template parameter:

template< typename MT, bool SO >
class SparseRow;


Setup of Sparse Rows

A reference to a sparse row can be created very conveniently via the row() function. This reference can be treated as any other row vector, i.e. it can be assigned to, it can be copied from, and it can be used in arithmetic operations. The reference can also be used on both sides of an assignment: The row can either be used as an alias to grant write access to a specific row of a matrix primitive on the left-hand side of an assignment or to grant read-access to a specific row of a matrix primitive or expression on the right-hand side of an assignment. The following example demonstrates this in detail:

DenseVectorType x;
SparseVectorType y;
SparseMatrixType A, B;
// ... Resizing and initialization
// Setting the 2nd row of matrix A to x
row2 = x;
// Setting the 3rd row of matrix B to y
row( B, 3UL ) = y;
// Setting x to the 1st row of matrix B
x = row( B, 1UL );
// Setting y to the 4th row of the result of the matrix multiplication
y = row( A * B, 4UL );


Element access

A sparse row can be used like any other row vector. For instance, the elements of the sparse row can be directly accessed with the subscript operator.

MatrixType A;
// ... Resizing and initialization
// Creating a view on the 4th row of matrix A
// Setting the 1st element of the sparse row, which corresponds
// to the 1st element in the 4th row of matrix A
row4[1] = 2.0;

The numbering of the row elements is

\[\left(\begin{array}{*{5}{c}} 0 & 1 & 2 & \cdots & N-1 \\ \end{array}\right),\]

where N is the number of columns of the referenced matrix. Alternatively, the elements of a row can be traversed via iterators. Just as with vectors, in case of non-const rows, begin() and end() return an Iterator, which allows a manipulation of the non-zero values, in case of constant rows a ConstIterator is returned:

MatrixType A( 128UL, 256UL );
// ... Resizing and initialization
// Creating a reference to the 31st row of matrix A
RowType row31 = row( A, 31UL );
for( RowType::Iterator it=row31.begin(); it!=row31.end(); ++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.
}
for( RowType::ConstIterator it=row31.begin(); it!=row31.end(); ++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 row can be done by several alternative functions. The following example demonstrates all options:

MatrixType A( 10UL, 100UL ); // Non-initialized 10x100 matrix
RowType row0( row( A, 0UL ) ); // Reference to the 0th row of A
// The subscript operator provides access to all possible elements of the sparse row,
// including the zero elements. In case the subscript operator is used to access an element
// that is currently not stored in the sparse row, the element is inserted into the row.
row0[42] = 2.0;
// An alternative for inserting elements into the row is the insert() function. However,
// it inserts the element only in case the element is not already contained in the row.
row0.insert( 50UL, 3.7 );
// A very efficient way to add new elements to a sparse row is the append() function.
// Note that append() requires that the appended element's index is strictly larger than
// the currently largest non-zero index of the row and that the row's capacity is large
// enough to hold the new element.
row0.reserve( 10UL );
row0.append( 51UL, -2.1 );


Common Operations

The current number of row elements can be obtained via the size() function, the current capacity via the capacity() function, and the number of non-zero elements via the nonZeros() function. However, since rows are references to specific rows of a matrix, several operations are not possible on views, such as resizing and swapping:

MatrixType A( 42UL, 42UL );
// ... Resizing and initialization
// Creating a reference to the 2nd row of matrix A
RowType row2 = row( A, 2UL );
row2.size(); // Returns the number of elements in the row
row2.capacity(); // Returns the capacity of the row
row2.nonZeros(); // Returns the number of non-zero elements contained in the row
row2.resize( 84UL ); // Compilation error: Cannot resize a single row of a matrix
RowType row3 = row( A, 3UL );
swap( row2, row3 ); // Compilation error: Swap operation not allowed


Arithmetic Operations

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

a[1] = 2.0;
MatrixType A( 3UL, 2UL ); // Non-initialized 3x2 matrix
RowType row0( row( A, 0UL ) ); // Reference to the 0th row of A
row0[0] = 0.0; // Manual initialization of the 0th row of A
row0[1] = 0.0;
row( A, 1UL ) = a; // Sparse vector initialization of the 1st row of A
row( A, 2UL ) = c; // Dense vector initialization of the 2nd row of A
b = row0 + a; // Sparse vector/sparse vector addition
b = c + row( A, 1UL ); // Dense vector/sparse vector addition
b = row0 * row( A, 2UL ); // Component-wise vector multiplication
row( A, 1UL ) *= 2.0; // In-place scaling of the 1st row
b = row( A, 1UL ) * 2.0; // Scaling of the 1st row
b = 2.0 * row( A, 1UL ); // Scaling of the 1st row
row( A, 2UL ) += a; // Addition assignment
row( A, 2UL ) -= c; // Subtraction assignment
row( A, 2UL ) *= row( A, 0UL ); // Multiplication assignment
double scalar = row( A, 1UL ) * trans( c ); // Scalar/dot/inner product between two vectors
A = trans( c ) * row( A, 1UL ); // Outer product between two vectors


Sparse Row on a Column-Major Matrix

It is especially noteworthy that row views can be created for both row-major and column-major matrices. Whereas the interface of a row-major matrix only allows to traverse a row directly and the interface of a column-major matrix only allows to traverse a column, via views it is also possible to traverse a row of a column-major matrix. For instance:

MatrixType A( 64UL, 32UL );
// ... Resizing and initialization
// Creating a reference to the 1st row of a column-major matrix A
RowType row1 = row( A, 1UL );
for( RowType::Iterator it=row1.begin(); it!=row1.end(); ++it ) {
// ...
}

However, please note that creating a row view on a matrix stored in a column-major fashion can result in a considerable performance decrease in comparison to a row view on a matrix with row-major storage format. This is due to the non-contiguous storage of the matrix elements. Therefore care has to be taken in the choice of the most suitable storage order:

// Setup of two column-major matrices
// ... Resizing and initialization
// The computation of the 15th row of the multiplication between A and B ...
// ... is essentially the same as the following computation, which multiplies
// the 15th row of the column-major matrix A with B.

Although Blaze performs the resulting vector/matrix multiplication as efficiently as possible using a row-major storage order for matrix A would result in a more efficient evaluation.

Member Enumeration Documentation

template<typename , 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 row will return references and iterators to const. Otherwise useConst will be set to 0 and the sparse row will offer write access to the sparse matrix elements both via the subscript operator and iterators.

Constructor & Destructor Documentation

template<typename MT , bool SO>
blaze::SparseRow< MT, SO >::SparseRow ( MT &  matrix,
size_t  index 
)
inlineexplicit

The constructor for SparseRow.

Parameters
matrixThe matrix containing the row.
indexThe index of the row.
Exceptions
std::invalid_argumentInvalid row access index.

Member Function Documentation

template<typename MT , bool SO>
template<typename VT >
void blaze::SparseRow< MT, SO >::addAssign ( const DenseVector< VT, true > &  rhs)
inline

Default implementation of the addition assignment of a dense vector.

Parameters
rhsThe right-hand side dense vector 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 SO>
template<typename VT >
void blaze::SparseRow< MT, SO >::addAssign ( const SparseVector< VT, true > &  rhs)
inline

Default implementation of the addition assignment of a sparse vector.

Parameters
rhsThe right-hand side sparse vector 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 SO>
void blaze::SparseRow< MT, SO >::append ( size_t  index,
const ElementType value,
bool  check = false 
)
inline

Appending an element to the sparse row.

Parameters
indexThe index of the new element. The index must be smaller than the number of matrix columns.
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 row with elements. It appends a new element to the end of the sparse row without any 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 sparse row
  • the current number of non-zero elements must be smaller than the capacity of the row

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.

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

template<typename MT , bool SO>
template<typename VT >
void blaze::SparseRow< MT, SO >::assign ( const DenseVector< VT, true > &  rhs)
inline

Default implementation of the assignment of a dense vector.

Parameters
rhsThe right-hand side dense vector 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 SO>
template<typename VT >
void blaze::SparseRow< MT, SO >::assign ( const SparseVector< VT, true > &  rhs)
inline

Default implementation of the assignment of a sparse vector.

Parameters
rhsThe right-hand side sparse vector 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 SO>
SparseRow< MT, SO >::Iterator blaze::SparseRow< MT, SO >::begin ( )
inline

Returns an iterator to the first element of the row.

Returns
Iterator to the first element of the row.

This function returns an iterator to the first element of the row.

template<typename MT , bool SO>
SparseRow< MT, SO >::ConstIterator blaze::SparseRow< MT, SO >::begin ( ) const
inline

Returns an iterator to the first element of the row.

Returns
Iterator to the first element of the row.

This function returns an iterator to the first element of the row.

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

Returns whether the sparse row can alias with the given address alias.

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

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

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

Returns the maximum capacity of the sparse row.

Returns
The capacity of the sparse row.
template<typename MT , bool SO>
SparseRow< MT, SO >::ConstIterator blaze::SparseRow< MT, SO >::cbegin ( ) const
inline

Returns an iterator to the first element of the row.

Returns
Iterator to the first element of the row.

This function returns an iterator to the first element of the row.

template<typename MT , bool SO>
SparseRow< MT, SO >::ConstIterator blaze::SparseRow< MT, SO >::cend ( ) const
inline

Returns an iterator just past the last element of the row.

Returns
Iterator just past the last element of the row.

This function returns an iterator just past the last element of the row.

template<typename MT , bool SO>
SparseRow< MT, SO >::Iterator blaze::SparseRow< MT, SO >::end ( )
inline

Returns an iterator just past the last element of the row.

Returns
Iterator just past the last element of the row.

This function returns an iterator just past the last element of the row.

template<typename MT , bool SO>
SparseRow< MT, SO >::ConstIterator blaze::SparseRow< MT, SO >::end ( ) const
inline

Returns an iterator just past the last element of the row.

Returns
Iterator just past the last element of the row.

This function returns an iterator just past the last element of the row.

template<typename MT , bool SO>
void blaze::SparseRow< MT, SO >::erase ( size_t  index)
inline

Erasing an element from the sparse row.

Parameters
indexThe 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 row.

template<typename MT , bool SO>
SparseRow< MT, SO >::Iterator blaze::SparseRow< MT, SO >::erase ( Iterator  pos)
inline

Erasing an element from the sparse row.

Parameters
posIterator to the element to be erased.
Returns
void

This function erases an element from the sparse row.

template<typename MT , bool SO>
SparseRow< MT, SO >::Iterator blaze::SparseRow< MT, SO >::erase ( Iterator  first,
Iterator  last 
)
inline

Erasing a range of elements from the sparse row.

Parameters
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 elements from the sparse row.

template<typename MT , bool SO>
size_t blaze::SparseRow< MT, SO >::extendCapacity ( ) const
inlineprivate

Calculating a new sparse row capacity.

Returns
The new sparse row capacity.

This function calculates a new row capacity based on the current capacity of the sparse row. Note that the new capacity is restricted to the interval $[7..size]$.

template<typename MT , bool SO>
SparseRow< MT, SO >::Iterator blaze::SparseRow< MT, SO >::find ( size_t  index)
inline

Searches for a specific row element.

Parameters
indexThe 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 row. It specifically searches for the element with index index. In case the element is found, the function returns an iterator to the element. Otherwise an iterator just past the last non-zero element of the sparse row (the end() iterator) is returned. Note that the returned sparse row iterator is subject to invalidation due to inserting operations via the subscript operator or the insert() function!

template<typename MT , bool SO>
SparseRow< MT, SO >::ConstIterator blaze::SparseRow< MT, SO >::find ( size_t  index) const
inline

Searches for a specific row element.

Parameters
indexThe 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 row. It specifically searches for the element with index index. In case the element is found, the function returns an iterator to the element. Otherwise an iterator just past the last non-zero element of the sparse row (the end() iterator) is returned. Note that the returned sparse row iterator is subject to invalidation due to inserting operations via the subscript operator or the insert() function!

template<typename MT , bool SO>
SparseRow< MT, SO >::Iterator blaze::SparseRow< MT, SO >::insert ( size_t  index,
const ElementType value 
)
inline

Inserting an element into the sparse row.

Parameters
indexThe 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
Reference to the inserted value.
Exceptions
std::invalid_argumentInvalid sparse row access index.

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

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

Returns whether the sparse row is aliased with the given address alias.

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

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

template<typename MT , bool SO>
SparseRow< MT, SO >::Iterator blaze::SparseRow< MT, SO >::lowerBound ( size_t  index)
inline

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

Parameters
indexThe 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.

This function returns an iterator to the first element with an index not less then the given 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 sparse row iterator is subject to invalidation due to inserting operations via the subscript operator or the insert() function!

template<typename MT , bool SO>
SparseRow< MT, SO >::ConstIterator blaze::SparseRow< MT, SO >::lowerBound ( size_t  index) const
inline

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

Parameters
indexThe 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.

This function returns an iterator to the first element with an index not less then the given 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 sparse row iterator is subject to invalidation due to inserting operations via the subscript operator or the insert() function!

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

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

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

Note that the number of non-zero elements is always less than or equal to the current number of columns of the matrix containing the row.

template<typename , bool >
template<typename VT >
SparseRow<MT,SO>& blaze::SparseRow< typename, bool >::operator*= ( const Vector< VT, true > &  rhs)
inline

Multiplication assignment operator for the multiplication of a vector ( $ \vec{a}*=\vec{b} $).

Parameters
rhsThe right-hand side vector to be multiplied with the sparse row.
Returns
Reference to the sparse row.
Exceptions
std::invalid_argumentVector sizes do not match.

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

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

Multiplication assignment operator for the multiplication between a sparse row and a scalar value ( $ \vec{a}*=s $).

Parameters
rhsThe right-hand side scalar value for the multiplication.
Returns
Reference to the sparse row.

This operator can only be used for built-in data types. Additionally, the elements of the sparse row must support the multiplication assignment operator for the given scalar built-in data type.

template<typename , bool >
template<typename VT >
SparseRow<MT,SO>& blaze::SparseRow< typename, bool >::operator+= ( const Vector< VT, true > &  rhs)
inline

Addition assignment operator for the addition of a vector ( $ \vec{a}+=\vec{b} $).

Parameters
rhsThe right-hand side vector to be added to the sparse row.
Returns
Reference to the sparse row.
Exceptions
std::invalid_argumentVector sizes do not match.

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

template<typename , bool >
template<typename VT >
SparseRow<MT,SO>& blaze::SparseRow< typename, bool >::operator-= ( const Vector< VT, true > &  rhs)
inline

Subtraction assignment operator for the subtraction of a vector ( $ \vec{a}-=\vec{b} $).

Parameters
rhsThe right-hand side vector to be subtracted from the sparse row.
Returns
Reference to the sparse row.
Exceptions
std::invalid_argumentVector sizes do not match.

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

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

Division assignment operator for the division of a sparse row by a scalar value ( $ \vec{a}/=s $).

Parameters
rhsThe right-hand side scalar value for the division.
Returns
Reference to the sparse row.

This operator can only be used for built-in data types. Additionally, the elements of the sparse row must either support the multiplication assignment operator for the given floating point data type or the division assignment operator for the given integral data type.

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

Copy assignment operator for SparseRow.

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

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

template<typename , bool >
template<typename VT >
SparseRow<MT,SO>& blaze::SparseRow< typename, bool >::operator= ( const DenseVector< VT, true > &  rhs)
inline

Assignment operator for different dense vectors.

Parameters
rhsDense vector to be assigned.
Returns
Reference to the assigned row.
Exceptions
std::invalid_argumentVector sizes do not match.

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

template<typename , bool >
template<typename VT >
SparseRow<MT,SO>& blaze::SparseRow< typename, bool >::operator= ( const SparseVector< VT, true > &  rhs)
inline

Assignment operator for different sparse vectors.

Parameters
rhsSparse vector to be assigned.
Returns
Reference to the assigned row.
Exceptions
std::invalid_argumentVector sizes do not match.

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

template<typename MT , bool SO>
SparseRow< MT, SO >::Reference blaze::SparseRow< MT, SO >::operator[] ( size_t  index)
inline

Subscript operator for the direct access to the row elements.

Parameters
indexAccess index. The index must be smaller than the number of matrix columns.
Returns
Reference to the accessed value.
template<typename MT , bool SO>
SparseRow< MT, SO >::ConstReference blaze::SparseRow< MT, SO >::operator[] ( size_t  index) const
inline

Subscript operator for the direct access to the row elements.

Parameters
indexAccess index. The index must be smaller than the number of matrix columns.
Returns
Reference to the accessed value.
VectorType& blaze::Vector< typename, bool >::operator~ ( )
inlineinherited

Conversion operator for non-constant vectors.

Returns
Reference of the actual type of the vector.
const VectorType& blaze::Vector< typename, bool >::operator~ ( ) const
inlineinherited

Conversion operator for constant vectors.

Returns
Const reference of the actual type of the vector.
template<typename MT , bool SO>
void blaze::SparseRow< MT, SO >::reserve ( size_t  n)
inline

Setting the minimum capacity of the sparse row.

Parameters
nThe new minimum capacity of the sparse row.
Returns
void

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

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

Reset to the default initial values.

Returns
void
template<typename , bool >
template<typename Other >
SparseRow<MT,SO>& blaze::SparseRow< typename, bool >::scale ( Other  scalar)
inline

Scaling of the sparse row by the scalar value scalar ( $ \vec{a}=\vec{b}*s $).

Parameters
scalarThe scalar value for the row scaling.
Returns
Reference to the sparse row.
template<typename MT , bool SO>
size_t blaze::SparseRow< MT, SO >::size ( ) const
inline

Returns the current size/dimension of the sparse row.

Returns
The size of the sparse row.
template<typename MT , bool SO>
template<typename VT >
void blaze::SparseRow< MT, SO >::subAssign ( const DenseVector< VT, true > &  rhs)
inline

Default implementation of the subtraction assignment of a dense vector.

Parameters
rhsThe right-hand side dense vector 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 SO>
template<typename VT >
void blaze::SparseRow< MT, SO >::subAssign ( const SparseVector< VT, true > &  rhs)
inline

Default implementation of the subtraction assignment of a sparse vector.

Parameters
rhsThe right-hand side sparse vector 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 SO>
SparseRow< MT, SO >::Iterator blaze::SparseRow< MT, SO >::upperBound ( size_t  index)
inline

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

Parameters
indexThe 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.

This function returns an iterator to the first element with an index greater then the given 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 sparse row iterator is subject to invalidation due to inserting operations via the subscript operator or the insert() function!

template<typename MT , bool SO>
SparseRow< MT, SO >::ConstIterator blaze::SparseRow< MT, SO >::upperBound ( size_t  index) const
inline

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

Parameters
indexThe 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.

This function returns an iterator to the first element with an index greater then the given 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 sparse row iterator is subject to invalidation due to inserting operations via the subscript operator or the insert() function!


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