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

View on a specific subvector of a sparse vector.The SparseSubvector template represents a view on a specific subvector of a sparse vector primitive. The type of the sparse vector is specified via the first template parameter: More...

#include <SparseSubvector.h>

Inherits blaze::SparseVector< SparseSubvector< VT, AF, TF >, TF >, and blaze::Subvector.

Classes

class  SubvectorElement
 Access proxy for a specific element of the sparse subvector. More...
 
class  SubvectorIterator
 Iterator over the elements of the sparse subvector. More...
 

Public Types

enum  { smpAssignable = VT::smpAssignable }
 Compilation switch for the expression template assignment strategy.
 
typedef SparseSubvector< VT,
AF, TF > 
This
 Type of this SparseSubvector instance.
 
typedef SubvectorTrait< VT >::Type ResultType
 Result type for expression template evaluations.
 
typedef ResultType::TransposeType TransposeType
 Transpose type for expression template evaluations.
 
typedef VT::ElementType ElementType
 Type of the subvector elements.
 
typedef VT::ReturnType ReturnType
 Return type for expression template evaluations.
 
typedef const SparseSubvectorCompositeType
 Data type for composite expression templates.
 
typedef VT::ConstReference ConstReference
 Reference to a constant subvector value.
 
typedef SelectType< useConst,
ConstReference, typename
VT::Reference >::Type 
Reference
 Reference to a non-constant subvector value.
 
typedef SubvectorIterator
< const VT, typename
VT::ConstIterator > 
ConstIterator
 Iterator over constant elements.
 
typedef SelectType< useConst,
ConstIterator,
SubvectorIterator< VT,
typename VT::Iterator >
>::Type 
Iterator
 Iterator over non-constant elements.
 
typedef VT VectorType
 Type of the vector.
 

Public Member Functions

template<typename VT2 >
SparseSubvector< VT, AF, TF > & operator= (const DenseVector< VT2, TF > &rhs)
 Assignment operator for dense vectors. More...
 
template<typename VT2 >
SparseSubvector< VT, AF, TF > & operator= (const SparseVector< VT2, TF > &rhs)
 Assignment operator for different sparse vectors. More...
 
template<typename VT2 >
SparseSubvector< VT, AF, TF > & operator+= (const Vector< VT2, TF > &rhs)
 Addition assignment operator for the addition of a vector ( $ \vec{a}+=\vec{b} $). More...
 
template<typename VT2 >
SparseSubvector< VT, AF, TF > & operator-= (const Vector< VT2, TF > &rhs)
 Subtraction assignment operator for the subtraction of a vector ( $ \vec{a}-=\vec{b} $). More...
 
template<typename VT2 >
SparseSubvector< VT, AF, TF > & operator*= (const Vector< VT2, TF > &rhs)
 Multiplication assignment operator for the multiplication of a vector ( $ \vec{a}*=\vec{b} $). More...
 
template<typename Other >
EnableIf< IsNumeric< Other >
, SparseSubvector< VT, AF, TF >
>::Type & 
operator*= (Other rhs)
 Multiplication assignment operator for the multiplication between a sparse subvector and a scalar value ( $ \vec{a}*=s $). More...
 
template<typename Other >
EnableIf< IsNumeric< Other >
, SparseSubvector< VT, AF, TF >
>::Type & 
operator/= (Other rhs)
 Division assignment operator for the division of a sparse subvector by a scalar value ( $ \vec{a}/=s $). More...
 
template<typename Other >
SparseSubvector< VT, AF, TF > & scale (Other scalar)
 Scaling of the sparse subvector 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
 SparseSubvector (Operand vector, size_t index, size_t n)
 The constructor for SparseSubvector. More...
 
Data access functions
Reference operator[] (size_t index)
 Subscript operator for the direct access to the subvector elements. More...
 
ConstReference operator[] (size_t index) const
 Subscript operator for the direct access to the subvector elements. More...
 
Iterator begin ()
 Returns an iterator to the first element of the subvector. More...
 
ConstIterator begin () const
 Returns an iterator to the first element of the subvector. More...
 
ConstIterator cbegin () const
 Returns an iterator to the first element of the subvector. More...
 
Iterator end ()
 Returns an iterator just past the last element of the subvector. More...
 
ConstIterator end () const
 Returns an iterator just past the last element of the subvector. More...
 
ConstIterator cend () const
 Returns an iterator just past the last element of the subvector. More...
 
Assignment operators
SparseSubvectoroperator= (const SparseSubvector &rhs)
 Copy assignment operator for SparseSubvector. More...
 
template<typename VT2 >
SparseSubvectoroperator= (const DenseVector< VT2, TF > &rhs)
 
template<typename VT2 >
SparseSubvectoroperator= (const SparseVector< VT2, TF > &rhs)
 
template<typename VT2 >
SparseSubvectoroperator+= (const Vector< VT2, TF > &rhs)
 
template<typename VT2 >
SparseSubvectoroperator-= (const Vector< VT2, TF > &rhs)
 
template<typename VT2 >
SparseSubvectoroperator*= (const Vector< VT2, TF > &rhs)
 
template<typename Other >
EnableIf< IsNumeric< Other >
, SparseSubvector >::Type & 
operator*= (Other rhs)
 
template<typename Other >
EnableIf< IsNumeric< Other >
, SparseSubvector >::Type & 
operator/= (Other rhs)
 
Utility functions
size_t size () const
 Returns the size/dimension of the sparse subvector. More...
 
size_t capacity () const
 Returns the maximum capacity of the sparse subvector. More...
 
size_t nonZeros () const
 Returns the number of non-zero elements in the subvector. More...
 
void reset ()
 Reset to the default initial values. More...
 
Iterator insert (size_t index, const ElementType &value)
 Inserting an element into the sparse subvector. More...
 
void erase (size_t index)
 Erasing an element from the sparse subvector. More...
 
Iterator erase (Iterator pos)
 Erasing an element from the sparse subvector. More...
 
Iterator erase (Iterator first, Iterator last)
 Erasing a range of elements from the sparse subvector. More...
 
void reserve (size_t n)
 Setting the minimum capacity of the sparse subvector. More...
 
template<typename Other >
SparseSubvectorscale (Other scalar)
 
Lookup functions
Iterator find (size_t index)
 Searches for a specific subvector element. More...
 
ConstIterator find (size_t index) const
 Searches for a specific subvector 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 subvector. More...
 
Expression template evaluation functions
template<typename Other >
bool canAlias (const Other *alias) const
 Returns whether the sparse subvector can alias with the given address alias. More...
 
template<typename Other >
bool isAliased (const Other *alias) const
 Returns whether the sparse subvector is aliased with the given address alias. More...
 
bool canSMPAssign () const
 Returns whether the subvector can be used in SMP assignments. More...
 
template<typename VT2 >
void assign (const DenseVector< VT2, TF > &rhs)
 Default implementation of the assignment of a dense vector. More...
 
template<typename VT2 >
void assign (const SparseVector< VT2, TF > &rhs)
 Default implementation of the assignment of a sparse vector. More...
 
template<typename VT2 >
void addAssign (const DenseVector< VT2, TF > &rhs)
 Default implementation of the addition assignment of a dense vector. More...
 
template<typename VT2 >
void addAssign (const SparseVector< VT2, TF > &rhs)
 Default implementation of the addition assignment of a sparse vector. More...
 
template<typename VT2 >
void subAssign (const DenseVector< VT2, TF > &rhs)
 Default implementation of the subtraction assignment of a dense vector. More...
 
template<typename VT2 >
void subAssign (const SparseVector< VT2, TF > &rhs)
 Default implementation of the subtraction assignment of a sparse vector. More...
 

Private Types

enum  { useConst = IsConst<VT>::value }
 Compilation switch for the non-const reference and iterator types. More...
 
typedef SelectType
< IsExpression< VT >::value,
VT, VT & >::Type 
Operand
 Composite data type of the sparse vector expression.
 

Private Attributes

Member variables
Operand vector_
 The sparse vector containing the subvector.
 
const size_t offset_
 The offset of the subvector within the sparse vector.
 
const size_t size_
 The size of the subvector.
 

Detailed Description

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

View on a specific subvector of a sparse vector.

The SparseSubvector template represents a view on a specific subvector of a sparse vector primitive. The type of the sparse vector is specified via the first template parameter:

template< typename VT, bool AF, bool TF >


Setup of Sparse Subvectors

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

SparseVectorType x;
// ... Resizing and initialization
// Create a subvector from index 8 with a size of 16 (i.e. in the range [8..23])

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

DenseVectorType x;
SparseVectorType y;
SparseMatrixType A;
// ... Resizing and initialization
// Create a subvector from index 0UL with a size of 10 (i.e. in the range [0..9])
// Setting the first ten elements of y to the 2nd row of matrix A
sv = row( A, 2UL );
// Setting the second ten elements of y to x
subvector( y, 10UL, 10UL ) = x;
// Setting the 3rd row of A to a subvector of y
row( A, 3UL ) = subvector( y, 3UL, 10UL );
// Setting y to a subvector of the result of the addition between x and the 1st row of A
y = subvector( x + row( A, 1UL ), 2UL, 5UL )


Element access

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

VectorType v;
// ... Resizing and initialization
// Creating an 8-dimensional subvector, starting from index 4
// Setting the 1st element of the subvector, which corresponds to
// the element at index 5 in vector v
sv[1] = 2.0;

The numbering of the subvector elements is

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

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

typedef blaze::SparseSubvector<VectorType> SubvectorType;
VectorType v( 256UL );
// ... Resizing and initialization
// Creating a reference to a specific subvector of vector v
SubvectorType sv = subvector( v, 16UL, 64UL );
for( SubvectorType::Iterator it=sv.begin(); it!=sv.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( SubvectorType::ConstIterator it=sv.begin(); it!=sv.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 subvector can be done by several alternative functions. The following example demonstrates all options:

VectorType v( 256UL ); // Non-initialized vector of size 256
typedef blaze::SparseSubvector<VectorType> SubvectorType;
SubvectorType sv( subvector( v, 10UL, 60UL ) ); // View on the range [10..69] of v
// The subscript operator provides access to all possible elements of the sparse subvector,
// including the zero elements. In case the subscript operator is used to access an element
// that is currently not stored in the sparse subvector, the element is inserted into the
// subvector.
sv[42] = 2.0;
// An alternative for inserting elements into the subvector is the insert() function. However,
// it inserts the element only in case the element is not already contained in the subvector.
sv.insert( 50UL, 3.7 );
// Just as in case of vectors, elements can also be inserted via the append() function. In
// case of subvectors, append() also requires that the appended element's index is strictly
// larger than the currently largest non-zero index of the subvector and that the subvector's
// capacity is large enough to hold the new element. Note however that due to the nature of
// a subvector, which may be an alias to the middle of a sparse vector, the append() function
// does not work as efficiently for a subvector as it does for a vector.
sv.reserve( 10UL );
sv.append( 51UL, -2.1 );


Common Operations

The current number of subvector 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 subvector are views on a specific subvector of a vector, several operations are not possible on views, such as resizing and swapping:

typedef blaze::SparseSubvector<VectorType> SubvectorType;
VectorType v( 42UL );
// ... Resizing and initialization
// Creating a view on the range [5..15] of vector v
SubvectorType sv = subvector( v, 5UL, 10UL );
sv.size(); // Returns the number of elements in the subvector
sv.capacity(); // Returns the capacity of the subvector
sv.nonZeros(); // Returns the number of non-zero elements contained in the subvector
sv.resize( 84UL ); // Compilation error: Cannot resize a subvector of a vector
SubvectorType sv2 = subvector( v, 15UL, 10UL );
swap( sv, sv2 ); // Compilation error: Swap operation not allowed


Arithmetic Operations

The following example gives an impression of the use of SparseSubvector 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:

SparseVectorType s1, s2, s3;
DenseVectorType d1, d2;
// ... Resizing and initialization
SparseMatrixType A;
SubvectorType sv( subvector( s1, 0UL, 10UL ) ); // View on the range [0..9] of vector s1
sv = s2; // Sparse vector initialization of the range [0..9]
subvector( s1, 10UL, 10UL ) = d1; // Dense vector initialization of the range [10..19]
s3 = sv + s2; // Sparse vector/sparse vector addition
d2 = d1 + subvector( s1, 10UL, 10UL ); // Dense vector/sparse vector addition
s2 = sv * subvector( s1, 20UL, 10UL ); // Component-wise vector multiplication
subvector( s1, 3UL, 4UL ) *= 2.0; // In-place scaling of the range [3..6]
s2 = subvector( s1, 7UL, 3UL ) * 2.0; // Scaling of the range [7..9]
s2 = 2.0 * subvector( s1, 7UL, 3UL ); // Scaling of the range [7..9]
subvector( s1, 0UL , 10UL ) += s2; // Addition assignment
subvector( s1, 10UL, 10UL ) -= d2; // Subtraction assignment
subvector( s1, 20UL, 10UL ) *= sv; // Multiplication assignment
double scalar = subvector( s1, 5UL, 10UL ) * trans( d1 ); // Scalar/dot/inner product between two vectors
A = trans( d1 ) * subvector( s1, 4UL, 16UL ); // Outer product between two vectors


Aligned Subvectors

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

SparseVectorType x;
// ... Resizing and initialization
// Identical creations of an unaligned subvector in the range [8..23]
blaze::SparseSubvector<SparseVectorType> sv2 = subvector<unaligned>( x, 8UL, 16UL );
blaze::SparseSubvector<SparseVectorType,unaligned> sv4 = subvector<unaligned>( x, 8UL, 16UL );

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

// Creating an aligned subvector in the range [8..23]
blaze::SparseSubvector<SparseVectorType,aligned> sv = subvector<aligned>( x, 8UL, 16UL );

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


Subvectors on Subvectors

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

typedef blaze::SparseSubvector<VectorType> SubvectorType;
VectorType s1;
// ... Resizing and initialization
// Creating a subvector view on the sparse vector s1
SubvectorType sv1 = subvector( s1, 5UL, 10UL );
// Creating a subvector view on the sparse subvector sv1
SubvectorType sv2 = subvector( sv1, 1UL, 5UL );

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 vector of type VT is const qualified, useConst will be set to 1 and the sparse subvector will return references and iterators to const. Otherwise useConst will be set to 0 and the sparse subvector will offer write access to the sparse vector elements both via the subscript operator and iterators.

Constructor & Destructor Documentation

template<typename VT , bool AF, bool TF>
blaze::SparseSubvector< VT, AF, TF >::SparseSubvector ( Operand  vector,
size_t  index,
size_t  n 
)
inlineexplicit

The constructor for SparseSubvector.

Parameters
vectorThe sparse vector containing the subvector.
indexThe index of the first element of the subvector.
nThe size of the subvector.
Exceptions
std::invalid_argumentInvalid subvector specification.

In case the subvector is not properly specified (i.e. if the specified first index is larger than the size of the given vector or the subvector is specified beyond the size of the vector) a std::invalid_argument exception is thrown.

Member Function Documentation

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

Appending an element to the sparse subvector.

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 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 subvector with elements. It appends a new element to the end of the sparse subvector 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 subvector
  • the current number of non-zero elements must be smaller than the capacity of the subvector

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 VT , bool AF, bool TF>
template<typename VT2 >
void blaze::SparseSubvector< VT, AF, TF >::assign ( const DenseVector< VT2, TF > &  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 VT , bool AF, bool TF>
template<typename VT2 >
void blaze::SparseSubvector< VT, AF, TF >::assign ( const SparseVector< VT2, TF > &  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 VT , bool AF, bool TF>
SparseSubvector< VT, AF, TF >::Iterator blaze::SparseSubvector< VT, AF, TF >::begin ( )
inline

Returns an iterator to the first element of the subvector.

Returns
Iterator to the first element of the subvector.

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

template<typename VT , bool AF, bool TF>
SparseSubvector< VT, AF, TF >::ConstIterator blaze::SparseSubvector< VT, AF, TF >::begin ( ) const
inline

Returns an iterator to the first element of the subvector.

Returns
Iterator to the first element of the subvector.

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

template<typename VT , bool AF, bool TF>
template<typename Other >
bool blaze::SparseSubvector< VT, AF, TF >::canAlias ( const Other *  alias) const
inline

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

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

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

template<typename VT , bool AF, bool TF>
bool blaze::SparseSubvector< VT, AF, TF >::canSMPAssign ( ) const
inline

Returns whether the subvector can be used in SMP assignments.

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

This function returns whether the subvector 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 size of the vector).

template<typename VT , bool AF, bool TF>
size_t blaze::SparseSubvector< VT, AF, TF >::capacity ( ) const
inline

Returns the maximum capacity of the sparse subvector.

Returns
The capacity of the sparse subvector.
template<typename VT , bool AF, bool TF>
SparseSubvector< VT, AF, TF >::ConstIterator blaze::SparseSubvector< VT, AF, TF >::cbegin ( ) const
inline

Returns an iterator to the first element of the subvector.

Returns
Iterator to the first element of the subvector.

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

template<typename VT , bool AF, bool TF>
SparseSubvector< VT, AF, TF >::ConstIterator blaze::SparseSubvector< VT, AF, TF >::cend ( ) const
inline

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

Returns
Iterator just past the last element of the subvector.

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

template<typename VT , bool AF, bool TF>
SparseSubvector< VT, AF, TF >::Iterator blaze::SparseSubvector< VT, AF, TF >::end ( )
inline

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

Returns
Iterator just past the last element of the subvector.

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

template<typename VT , bool AF, bool TF>
SparseSubvector< VT, AF, TF >::ConstIterator blaze::SparseSubvector< VT, AF, TF >::end ( ) const
inline

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

Returns
Iterator just past the last element of the subvector.

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

template<typename VT , bool AF, bool TF>
void blaze::SparseSubvector< VT, AF, TF >::erase ( size_t  index)
inline

Erasing an element from the sparse subvector.

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

template<typename VT , bool AF, bool TF>
SparseSubvector< VT, AF, TF >::Iterator blaze::SparseSubvector< VT, AF, TF >::erase ( Iterator  pos)
inline

Erasing an element from the sparse subvector.

Parameters
posIterator to the element to be erased.
Returns
void

This function erases an element from the sparse subvector.

template<typename VT , bool AF, bool TF>
SparseSubvector< VT, AF, TF >::Iterator blaze::SparseSubvector< VT, AF, TF >::erase ( Iterator  first,
Iterator  last 
)
inline

Erasing a range of elements from the sparse subvector.

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

template<typename VT , bool AF, bool TF>
SparseSubvector< VT, AF, TF >::Iterator blaze::SparseSubvector< VT, AF, TF >::find ( size_t  index)
inline

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

template<typename VT , bool AF, bool TF>
SparseSubvector< VT, AF, TF >::ConstIterator blaze::SparseSubvector< VT, AF, TF >::find ( size_t  index) const
inline

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

template<typename VT , bool AF, bool TF>
SparseSubvector< VT, AF, TF >::Iterator blaze::SparseSubvector< VT, AF, TF >::insert ( size_t  index,
const ElementType value 
)
inline

Inserting an element into the sparse subvector.

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

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

template<typename VT , bool AF, bool TF>
template<typename Other >
bool blaze::SparseSubvector< VT, AF, TF >::isAliased ( const Other *  alias) const
inline

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

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

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

template<typename VT , bool AF, bool TF>
SparseSubvector< VT, AF, TF >::Iterator blaze::SparseSubvector< VT, AF, TF >::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 subvector iterator is subject to invalidation due to inserting operations via the subscript operator or the insert() function!

template<typename VT , bool AF, bool TF>
SparseSubvector< VT, AF, TF >::ConstIterator blaze::SparseSubvector< VT, AF, TF >::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 subvector iterator is subject to invalidation due to inserting operations via the subscript operator or the insert() function!

template<typename VT , bool AF, bool TF>
size_t blaze::SparseSubvector< VT, AF, TF >::nonZeros ( ) const
inline

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

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

Note that the number of non-zero elements is always smaller than the size of the subvector.

template<typename , bool , bool >
template<typename VT2 >
SparseSubvector<VT,AF,TF>& blaze::SparseSubvector< typename, bool, bool >::operator*= ( const Vector< VT2, TF > &  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 subvector.
Returns
Reference to the assigned subvector.
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>, SparseSubvector<VT,AF,TF> >::Type& blaze::SparseSubvector< typename, bool, bool >::operator*= ( Other  rhs)
inline

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

Parameters
rhsThe right-hand side scalar value for the multiplication.
Returns
Reference to the assigned subvector.

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

template<typename , bool , bool >
template<typename VT2 >
SparseSubvector<VT,AF,TF>& blaze::SparseSubvector< typename, bool, bool >::operator+= ( const Vector< VT2, TF > &  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 subvector.
Returns
Reference to the assigned subvector.
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 VT2 >
SparseSubvector<VT,AF,TF>& blaze::SparseSubvector< typename, bool, bool >::operator-= ( const Vector< VT2, TF > &  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 subvector.
Returns
Reference to the assigned subvector.
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>, SparseSubvector<VT,AF,TF> >::Type& blaze::SparseSubvector< typename, bool, bool >::operator/= ( Other  rhs)
inline

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

Parameters
rhsThe right-hand side scalar value for the division.
Returns
Reference to the assigned subvector.

This operator can only be used for built-in data types. Additionally, the elements of the sparse subvector 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 VT , bool AF, bool TF>
SparseSubvector< VT, AF, TF > & blaze::SparseSubvector< VT, AF, TF >::operator= ( const SparseSubvector< typename, bool, bool > &  rhs)
inline

Copy assignment operator for SparseSubvector.

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

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

template<typename , bool , bool >
template<typename VT2 >
SparseSubvector<VT,AF,TF>& blaze::SparseSubvector< typename, bool, bool >::operator= ( const DenseVector< VT2, TF > &  rhs)
inline

Assignment operator for dense vectors.

Parameters
rhsDense vector to be assigned.
Returns
Reference to the assigned subvector.
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 VT2 >
SparseSubvector<VT,AF,TF>& blaze::SparseSubvector< typename, bool, bool >::operator= ( const SparseVector< VT2, TF > &  rhs)
inline

Assignment operator for different sparse vectors.

Parameters
rhsSparse vector to be assigned.
Returns
Reference to the assigned subvector.
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 VT , bool AF, bool TF>
SparseSubvector< VT, AF, TF >::Reference blaze::SparseSubvector< VT, AF, TF >::operator[] ( size_t  index)
inline

Subscript operator for the direct access to the subvector elements.

Parameters
indexAccess index. The index must be smaller than the number of subvector elements.
Returns
Reference to the accessed value.
template<typename VT , bool AF, bool TF>
SparseSubvector< VT, AF, TF >::ConstReference blaze::SparseSubvector< VT, AF, TF >::operator[] ( size_t  index) const
inline

Subscript operator for the direct access to the subvector 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 VT , bool AF, bool TF>
void blaze::SparseSubvector< VT, AF, TF >::reserve ( size_t  n)
inline

Setting the minimum capacity of the sparse subvector.

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

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

template<typename VT , bool AF, bool TF>
void blaze::SparseSubvector< VT, AF, TF >::reset ( )
inline

Reset to the default initial values.

Returns
void
template<typename , bool , bool >
template<typename Other >
SparseSubvector<VT,AF,TF>& blaze::SparseSubvector< typename, bool, bool >::scale ( Other  scalar)
inline

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

Parameters
scalarThe scalar value for the subvector scaling.
Returns
Reference to the sparse subvector.
template<typename VT , bool AF, bool TF>
size_t blaze::SparseSubvector< VT, AF, TF >::size ( ) const
inline

Returns the size/dimension of the sparse subvector.

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

template<typename VT , bool AF, bool TF>
SparseSubvector< VT, AF, TF >::ConstIterator blaze::SparseSubvector< VT, AF, TF >::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 subvector 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: