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

Expression object for the transposition of a sparse vector.The SVecTransposer class is a wrapper object for the temporary transposition of a sparse vector. More...

#include <SVecTransposer.h>

Inherits blaze::SparseVector< SVecTransposer< VT, TF >, TF >.

Public Types

typedef SVecTransposer< VT, TF > This
 Type of this SVecTransposer instance.
 
typedef VT::TransposeType ResultType
 Result type for expression template evaluations.
 
typedef VT::ResultType TransposeType
 Transpose type for expression template evaluations.
 
typedef VT::ElementType ElementType
 Resulting element type.
 
typedef VT::ReturnType ReturnType
 Return type for expression template evaluations.
 
typedef const ThisCompositeType
 Data type for composite expression templates.
 
typedef VT::Reference Reference
 Reference to a non-constant matrix value.
 
typedef VT::ConstReference ConstReference
 Reference to a constant matrix value.
 
typedef VT::Iterator Iterator
 Iterator over non-constant elements.
 
typedef VT::ConstIterator ConstIterator
 Iterator over constant elements.
 
typedef VT VectorType
 Type of the vector.
 

Public Member Functions

 SVecTransposer (VT &sv)
 Constructor for the SVecTransposer class.
 
Reference operator[] (size_t index)
 Subscript operator for the direct access to the vector elements.
 
ConstIterator begin () const
 Returns an iterator to the first non-zero element of the sparse vector.
 
ConstIterator end () const
 Returns an iterator just past the last non-zero element of the sparse vector.
 
size_t size () const
 Returns the current size/dimension of the vector.
 
void reset ()
 Resets the vector elements.
 
ElementTypeinsert (size_t index, const ElementType &value)
 Inserting an element into the sparse vector.
 
Iterator find (size_t index)
 Inserting an element into the sparse vector.
 
void reserve (size_t nonzeros)
 Setting the minimum capacity of the sparse vector.
 
void append (size_t index, const ElementType &value)
 Appending an element to the sparse vector.
 
template<typename Other >
bool isAliased (const Other *alias) const
 Returns whether the vector is aliased with the given address alias.
 
template<typename VT2 >
void assign (const DenseVector< VT2, TF > &rhs)
 Implementation of the transpose assignment of a dense vector.
 
template<typename VT2 >
void assign (const SparseVector< VT2, TF > &rhs)
 Implementation of the transpose assignment of a sparse vector.
 
VectorTypeoperator~ ()
 Conversion operator for non-constant vectors.
 
const VectorTypeoperator~ () const
 Conversion operator for constant vectors.
 

Private Member Functions

size_t extendCapacity () const
 Calculating a new vector capacity.
 

Private Attributes

VT & sv_
 The sparse vector operand.
 

Detailed Description

template<typename VT, bool TF>
class blaze::SVecTransposer< VT, TF >

Expression object for the transposition of a sparse vector.

The SVecTransposer class is a wrapper object for the temporary transposition of a sparse vector.

Constructor & Destructor Documentation

template<typename VT, bool TF>
blaze::SVecTransposer< VT, TF >::SVecTransposer ( VT &  sv)
inlineexplicit

Constructor for the SVecTransposer class.

Parameters
svThe sparse vector operand.

Member Function Documentation

template<typename VT, bool TF>
void blaze::SVecTransposer< VT, TF >::append ( size_t  index,
const ElementType value 
)
inline

Appending an element to the sparse vector.

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.
Returns
void

This function provides a very efficient way to fill a sparse vector with elements. It appends a new element to the end of the sparse vector without any additional check or 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 vector
  • the current number of non-zero elements must be smaller than the capacity of the vector

Ignoring these preconditions might result in undefined behavior!

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

template<typename VT, bool TF>
template<typename VT2 >
void blaze::SVecTransposer< VT, TF >::assign ( const DenseVector< VT2, TF > &  rhs)
inline

Implementation of the transpose 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 TF>
template<typename VT2 >
void blaze::SVecTransposer< VT, TF >::assign ( const SparseVector< VT2, TF > &  rhs)
inline

Implementation of the transpose 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 TF>
ConstIterator blaze::SVecTransposer< VT, TF >::begin ( ) const
inline

Returns an iterator to the first non-zero element of the sparse vector.

Returns
Iterator to the first non-zero element of the sparse vector.
template<typename VT, bool TF>
ConstIterator blaze::SVecTransposer< VT, TF >::end ( ) const
inline

Returns an iterator just past the last non-zero element of the sparse vector.

Returns
Iterator just past the last non-zero element of the sparse vector.
template<typename VT, bool TF>
size_t blaze::SVecTransposer< VT, TF >::extendCapacity ( ) const
inlineprivate

Calculating a new vector capacity.

Returns
The new compressed vector capacity.

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

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

Inserting an element into the sparse vector.

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

template<typename VT, bool TF>
ElementType& blaze::SVecTransposer< VT, TF >::insert ( size_t  index,
const ElementType value 
)
inline

Inserting an element into the sparse vector.

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
Iterator to the inserted element.
Exceptions
std::invalid_argumentInvalid sparse vector access index.

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

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

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

Parameters
aliasThe alias to be checked.
Returns
true in case the alias corresponds to this vector, false if not.
template<typename VT, bool TF>
Reference blaze::SVecTransposer< VT, TF >::operator[] ( size_t  index)
inline

Subscript operator for the direct access to the vector elements.

Parameters
indexAccess index. The index has to be in the range $[0..N-1]$.
Returns
Reference to the accessed value.
template<typename VT, bool TF>
VectorType& blaze::Vector< VT, TF >::operator~ ( )
inlineinherited

Conversion operator for non-constant vectors.

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

Conversion operator for constant vectors.

Returns
Const reference of the actual type of the vector.
template<typename VT, bool TF>
void blaze::SVecTransposer< VT, TF >::reserve ( size_t  nonzeros)
inline

Setting the minimum capacity of the sparse vector.

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

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

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

Resets the vector elements.

Returns
void
template<typename VT, bool TF>
size_t blaze::SVecTransposer< VT, TF >::size ( ) const
inline

Returns the current size/dimension of the vector.

Returns
The size of the vector.

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