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

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

#include <SparseColumn.h>

Inherits blaze::SparseVector< SparseColumn< MT, SO, SF >, false >, and blaze::Column.

Public Types

enum  { smpAssignable = 0 }
 Compilation switch for the expression template assignment strategy.
 
typedef SparseColumn< MT, SO, SF > This
 Type of this SparseColumn instance.
 
typedef ColumnTrait< 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 column elements.
 
typedef MT::ReturnType ReturnType
 Return type for expression template evaluations.
 
typedef const SparseColumnCompositeType
 Data type for composite expression templates.
 
typedef MT::ConstReference ConstReference
 Reference to a constant column value.
 
typedef SelectType< useConst,
ConstReference, typename
MT::Reference >::Type 
Reference
 Reference to a non-constant column 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 >
SparseColumn< MT, SO, SF > & operator= (const DenseVector< VT, false > &rhs)
 Assignment operator for different dense vectors. More...
 
template<typename VT >
SparseColumn< MT, SO, SF > & operator= (const SparseVector< VT, false > &rhs)
 Assignment operator for different sparse vectors. More...
 
template<typename VT >
SparseColumn< MT, SO, SF > & operator+= (const Vector< VT, false > &rhs)
 Addition assignment operator for the addition of a vector ( $ \vec{a}+=\vec{b} $). More...
 
template<typename VT >
SparseColumn< MT, SO, SF > & operator-= (const Vector< VT, false > &rhs)
 Subtraction assignment operator for the subtraction of a vector ( $ \vec{a}-=\vec{b} $). More...
 
template<typename VT >
SparseColumn< MT, SO, SF > & operator*= (const Vector< VT, false > &rhs)
 Multiplication assignment operator for the multiplication of a vector ( $ \vec{a}*=\vec{b} $). More...
 
template<typename Other >
EnableIf< IsNumeric< Other >
, SparseColumn< MT, SO, SF >
>::Type & 
operator*= (Other rhs)
 Multiplication assignment operator for the multiplication between a sparse column and a scalar value ( $ \vec{a}*=s $). More...
 
template<typename Other >
EnableIf< IsNumeric< Other >
, SparseColumn< MT, SO, SF >
>::Type & 
operator/= (Other rhs)
 Division assignment operator for the division of a sparse column by a scalar value ( $ \vec{a}/=s $). More...
 
template<typename Other >
SparseColumn< MT, SO, SF > & scale (const Other &scalar)
 Scaling of the sparse column by the scalar value scalar ( $ \vec{a}=\vec{b}*s $). More...
 
BLAZE_ALWAYS_INLINE VectorTypeoperator~ ()
 Conversion operator for non-constant vectors. More...
 
BLAZE_ALWAYS_INLINE const
VectorType
operator~ () const
 Conversion operator for constant vectors. More...
 
Constructors
 SparseColumn (MT &matrix, size_t index)
 The constructor for SparseColumn. More...
 
Data access functions
Reference operator[] (size_t index)
 Subscript operator for the direct access to the column elements. More...
 
ConstReference operator[] (size_t index) const
 Subscript operator for the direct access to the column elements. More...
 
Iterator begin ()
 Returns an iterator to the first element of the column. More...
 
ConstIterator begin () const
 Returns an iterator to the first element of the column. More...
 
ConstIterator cbegin () const
 Returns an iterator to the first element of the column. More...
 
Iterator end ()
 Returns an iterator just past the last element of the column. More...
 
ConstIterator end () const
 Returns an iterator just past the last element of the column. More...
 
ConstIterator cend () const
 Returns an iterator just past the last element of the column. More...
 
Assignment operators
SparseColumnoperator= (const SparseColumn &rhs)
 Copy assignment operator for SparseColumn. More...
 
template<typename VT >
SparseColumnoperator= (const DenseVector< VT, false > &rhs)
 
template<typename VT >
SparseColumnoperator= (const SparseVector< VT, false > &rhs)
 
template<typename VT >
SparseColumnoperator+= (const Vector< VT, false > &rhs)
 
template<typename VT >
SparseColumnoperator-= (const Vector< VT, false > &rhs)
 
template<typename VT >
SparseColumnoperator*= (const Vector< VT, false > &rhs)
 
template<typename Other >
EnableIf< IsNumeric< Other >
, SparseColumn >::Type & 
operator*= (Other rhs)
 
template<typename Other >
EnableIf< IsNumeric< Other >
, SparseColumn >::Type & 
operator/= (Other rhs)
 
Lookup functions
Iterator find (size_t index)
 Searches for a specific column element. More...
 
ConstIterator find (size_t index) const
 Searches for a specific column 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 column. More...
 
Expression template evaluation functions
template<typename Other >
bool canAlias (const Other *alias) const
 Returns whether the sparse column can alias with the given address alias. More...
 
template<typename Other >
bool isAliased (const Other *alias) const
 Returns whether the sparse column is aliased with the given address alias. More...
 
template<typename VT >
void assign (const DenseVector< VT, false > &rhs)
 Default implementation of the assignment of a dense vector. More...
 
template<typename VT >
void assign (const SparseVector< VT, false > &rhs)
 Default implementation of the assignment of a sparse vector. More...
 
template<typename VT >
void addAssign (const DenseVector< VT, false > &rhs)
 Default implementation of the addition assignment of a dense vector. More...
 
template<typename VT >
void addAssign (const SparseVector< VT, false > &rhs)
 Default implementation of the addition assignment of a sparse vector. More...
 
template<typename VT >
void subAssign (const DenseVector< VT, false > &rhs)
 Default implementation of the subtraction assignment of a dense vector. More...
 
template<typename VT >
void subAssign (const SparseVector< VT, false > &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 column.
 
const size_t col_
 The index of the column in the matrix.
 

Utility functions

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

Detailed Description

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

Reference to a specific column of a sparse matrix.

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

template< typename MT, bool SO >


Setup of Sparse Columns

A reference to a sparse column can be created very conveniently via the column() function. This reference can be treated as any other column 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 column can either be used as an alias to grant write access to a specific column of a matrix primitive on the left-hand side of an assignment or to grant read-access to a specific column 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 column of matrix A to x
col2 = x;
// Setting the 3rd column of matrix B to y
column( B, 3UL ) = y;
// Setting x to the 1st column of matrix B
x = column( B, 1UL );
// Setting y to the 4th column of the result of the matrix multiplication
y = column( A * B, 4UL );


Element access

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

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

The numbering of the column elements is

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

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

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

MatrixType A( 100UL, 10UL ); // Non-initialized 100x10 matrix
ColumnType col0( column( A, 0UL ) ); // Reference to the 0th column of A
// The subscript operator provides access to all possible elements of the sparse column,
// including the zero elements. In case the subscript operator is used to access an element
// that is currently not stored in the sparse column, the element is inserted into the column.
col0[42] = 2.0;
// The second operation for inserting elements is the set() function. In case the element
// is not contained in the column it is inserted into the column, if it is already contained
// in the column its value is modified.
col0.set( 45UL, -1.2 );
// An alternative for inserting elements into the column is the insert() function. However,
// it inserts the element only in case the element is not already contained in the column.
col0.insert( 50UL, 3.7 );
// A very efficient way to add new elements to a sparse column 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 column and that the column's capacity is
// large enough to hold the new element.
col0.reserve( 10UL );
col0.append( 51UL, -2.1 );


Common Operations

The current number of column 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 columns are references to specific columns 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 column of matrix A
ColumnType col2 = column( A, 2UL );
col2.size(); // Returns the number of elements in the column
col2.capacity(); // Returns the capacity of the column
col2.nonZeros(); // Returns the number of non-zero elements contained in the column
col2.resize( 84UL ); // Compilation error: Cannot resize a single column of a matrix
ColumnType col3 = column( A, 3UL );
swap( col2, col3 ); // Compilation error: Swap operation not allowed


Arithmetic Operations

The following example gives an impression of the use of SparseColumn 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( 2UL, 3UL ); // Non-initialized 2x3 matrix
ColumnType col0( column( A, 0UL ) ); // Reference to the 0th column of A
col0[0] = 0.0; // Manual initialization of the 0th column of A
col0[1] = 0.0;
column( A, 1UL ) = a; // Sparse vector initialization of the 1st column of A
column( A, 2UL ) = c; // Dense vector initialization of the 2nd column of A
b = col0 + a; // Sparse vector/sparse vector addition
b = c + column( A, 1UL ); // Dense vector/sparse vector addition
b = col0 * column( A, 2UL ); // Component-wise vector multiplication
column( A, 1UL ) *= 2.0; // In-place scaling of the 1st column
b = column( A, 1UL ) * 2.0; // Scaling of the 1st column
b = 2.0 * column( A, 1UL ); // Scaling of the 1st column
column( A, 2UL ) += a; // Addition assignment
column( A, 2UL ) -= c; // Subtraction assignment
column( A, 2UL ) *= column( A, 0UL ); // Multiplication assignment
double scalar = trans( c ) * column( A, 1UL ); // Scalar/dot/inner product between two vectors
A = column( A, 1UL ) * trans( c ); // Outer product between two vectors


Sparse Column on a Row-Major Matrix

It is especially noteworthy that column 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 column of a row-major matrix. For instance:

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

However, please note that creating a column view on a matrix stored in a row-major fashion can result in a considerable performance decrease in comparison to a column view on a matrix with column-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 row-major matrices
// ... Resizing and initialization
// The computation of the 15th column of the multiplication between A and B ...
// ... is essentially the same as the following computation, which multiplies
// A with the 15th column of the row-major matrix B.

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

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

Constructor & Destructor Documentation

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

The constructor for SparseColumn.

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

Member Function Documentation

template<typename MT , bool SO, bool SF>
template<typename VT >
void blaze::SparseColumn< MT, SO, SF >::addAssign ( const DenseVector< VT, false > &  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, bool SF>
template<typename VT >
void blaze::SparseColumn< MT, SO, SF >::addAssign ( const SparseVector< VT, false > &  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, bool SF>
void blaze::SparseColumn< MT, SO, SF >::append ( size_t  index,
const ElementType value,
bool  check = false 
)
inline

Appending an element to the sparse column.

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

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, bool SF>
template<typename VT >
void blaze::SparseColumn< MT, SO, SF >::assign ( const DenseVector< VT, false > &  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, bool SF>
template<typename VT >
void blaze::SparseColumn< MT, SO, SF >::assign ( const SparseVector< VT, false > &  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, bool SF>
SparseColumn< MT, SO, SF >::Iterator blaze::SparseColumn< MT, SO, SF >::begin ( )
inline

Returns an iterator to the first element of the column.

Returns
Iterator to the first element of the column.

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

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

Returns an iterator to the first element of the column.

Returns
Iterator to the first element of the column.

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

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

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

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

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

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

Returns the maximum capacity of the sparse column.

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

Returns an iterator to the first element of the column.

Returns
Iterator to the first element of the column.

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

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

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

Returns
Iterator just past the last element of the column.

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

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

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

Returns
Iterator just past the last element of the column.

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

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

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

Returns
Iterator just past the last element of the column.

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

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

Erasing an element from the sparse column.

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 column.

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

Erasing an element from the sparse column.

Parameters
posIterator to the element to be erased.
Returns
void

This function erases an element from the sparse column.

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

Erasing a range of elements from the sparse column.

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 column.

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

Calculating a new sparse column capacity.

Returns
The new sparse column capacity.

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

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

Searches for a specific column 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 column. 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 column (the end() iterator) is returned. Note that the returned sparse column iterator is subject to invalidation due to inserting operations via the subscript operator or the insert() function!

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

Searches for a specific column 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 column. 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 column (the end() iterator) is returned. Note that the returned sparse column iterator is subject to invalidation due to inserting operations via the subscript operator or the insert() function!

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

Inserting an element into the sparse column.

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 column access index.

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

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

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

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

This function returns whether the given address is aliased with the sparse column. 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, bool SF>
SparseColumn< MT, SO, SF >::Iterator blaze::SparseColumn< MT, SO, SF >::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 column iterator is subject to invalidation due to inserting operations via the subscript operator or the insert() function!

template<typename MT , bool SO, bool SF>
SparseColumn< MT, SO, SF >::ConstIterator blaze::SparseColumn< MT, SO, SF >::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 column iterator is subject to invalidation due to inserting operations via the subscript operator or the insert() function!

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

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

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

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

template<typename , bool , bool >
template<typename VT >
SparseColumn<MT,SO,SF>& blaze::SparseColumn< typename, bool, bool >::operator*= ( const Vector< VT, false > &  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 column.
Returns
Reference to the sparse column.
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 , bool >
template<typename Other >
EnableIf< IsNumeric<Other>, SparseColumn<MT,SO,SF> >::Type& blaze::SparseColumn< typename, bool, bool >::operator*= ( Other  rhs)
inline

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

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

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

template<typename , bool , bool >
template<typename VT >
SparseColumn<MT,SO,SF>& blaze::SparseColumn< typename, bool, bool >::operator+= ( const Vector< VT, false > &  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 column.
Returns
Reference to the sparse column.
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 , bool >
template<typename VT >
SparseColumn<MT,SO,SF>& blaze::SparseColumn< typename, bool, bool >::operator-= ( const Vector< VT, false > &  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 column.
Returns
Reference to the sparse column.
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 , bool >
template<typename Other >
EnableIf< IsNumeric<Other>, SparseColumn<MT,SO,SF> >::Type& blaze::SparseColumn< typename, bool, bool >::operator/= ( Other  rhs)
inline

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

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

This operator can only be used for built-in data types. Additionally, the elements of the sparse column 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, bool SF>
SparseColumn< MT, SO, SF > & blaze::SparseColumn< MT, SO, SF >::operator= ( const SparseColumn< typename, bool, bool > &  rhs)
inline

Copy assignment operator for SparseColumn.

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

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

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

Assignment operator for different dense vectors.

Parameters
rhsDense vector to be assigned.
Returns
Reference to the assigned column.
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 , bool >
template<typename VT >
SparseColumn<MT,SO,SF>& blaze::SparseColumn< typename, bool, bool >::operator= ( const SparseVector< VT, false > &  rhs)
inline

Assignment operator for different sparse vectors.

Parameters
rhsSparse vector to be assigned.
Returns
Reference to the assigned column.
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, bool SF>
SparseColumn< MT, SO, SF >::Reference blaze::SparseColumn< MT, SO, SF >::operator[] ( size_t  index)
inline

Subscript operator for the direct access to the column elements.

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

Subscript operator for the direct access to the column elements.

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

Conversion operator for non-constant vectors.

Returns
Reference of the actual type of the vector.
BLAZE_ALWAYS_INLINE 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, bool SF>
void blaze::SparseColumn< MT, SO, SF >::reserve ( size_t  n)
inline

Setting the minimum capacity of the sparse column.

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

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

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

Reset to the default initial values.

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

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

Parameters
scalarThe scalar value for the column scaling.
Returns
Reference to the sparse column.
template<typename MT , bool SO, bool SF>
SparseColumn< MT, SO, SF >::Iterator blaze::SparseColumn< MT, SO, SF >::set ( size_t  index,
const ElementType value 
)
inline

Setting an element of the sparse column.

Parameters
indexThe index of the element. The index has to be in the range $[0..N-1]$.
valueThe value of the element to be set.
Returns
Reference to the set value.

This function sets the value of an element of the sparse column. In case the sparse column already contains an element with index index its value is modified, else a new element with the given value is inserted.

template<typename MT , bool SO, bool SF>
size_t blaze::SparseColumn< MT, SO, SF >::size ( ) const
inline

Returns the current size/dimension of the sparse column.

Returns
The size of the sparse column.
template<typename MT , bool SO, bool SF>
template<typename VT >
void blaze::SparseColumn< MT, SO, SF >::subAssign ( const DenseVector< VT, false > &  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, bool SF>
template<typename VT >
void blaze::SparseColumn< MT, SO, SF >::subAssign ( const SparseVector< VT, false > &  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, bool SF>
SparseColumn< MT, SO, SF >::Iterator blaze::SparseColumn< MT, SO, SF >::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 column iterator is subject to invalidation due to inserting operations via the subscript operator or the insert() function!

template<typename MT , bool SO, bool SF>
SparseColumn< MT, SO, SF >::ConstIterator blaze::SparseColumn< MT, SO, SF >::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 column 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: