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

enum  { smpAssignable = VT::smpAssignable }
 Compilation flag for SMP assignments. More...
 
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 SVecTransposer< VT, TF > VectorType
 Type of the vector.
 

Public Member Functions

 SVecTransposer (VT &sv)
 Constructor for the SVecTransposer class. More...
 
ConstReference operator[] (size_t index) const
 Subscript operator for the direct access to the vector elements. More...
 
ConstReference at (size_t index) const
 Checked access to the vector elements. More...
 
Iterator begin ()
 Returns an iterator to the first non-zero element of the sparse vector. More...
 
ConstIterator begin () const
 Returns an iterator to the first non-zero element of the sparse vector. More...
 
ConstIterator cbegin () const
 Returns an iterator to the first non-zero element of the sparse vector. More...
 
Iterator end ()
 Returns an iterator just past the last non-zero element of the sparse vector. More...
 
ConstIterator end () const
 Returns an iterator just past the last non-zero element of the sparse vector. More...
 
ConstIterator cend () const
 Returns an iterator just past the last non-zero element of the sparse vector. More...
 
template<typename Other >
EnableIf< IsNumeric< Other >, SVecTransposer >::Type & operator*= (Other rhs)
 Multiplication assignment operator for the multiplication between a vector and a scalar value ( $ \vec{a}*=s $). More...
 
template<typename Other >
EnableIf< IsNumeric< Other >, SVecTransposer >::Type & operator/= (Other rhs)
 Division assignment operator for the division of a vector by a scalar value ( $ \vec{a}/=s $). More...
 
size_t size () const
 Returns the current size/dimension of the vector. More...
 
void reset ()
 Resets the vector elements. More...
 
Iterator insert (size_t index, const ElementType &value)
 Inserting an element into the sparse vector. More...
 
Iterator find (size_t index)
 Inserting an element into the sparse vector. More...
 
void reserve (size_t nonzeros)
 Setting the minimum capacity of the sparse vector. More...
 
void append (size_t index, const ElementType &value, bool check=false)
 Appending an element to the sparse vector. More...
 
template<typename Other >
bool canAlias (const Other *alias) const
 Returns whether the vector can alias with the given address alias. More...
 
template<typename Other >
bool isAliased (const Other *alias) const
 Returns whether the vector is aliased with the given address alias. More...
 
bool canSMPAssign () const
 Returns whether the vector can be used in SMP assignments. More...
 
template<typename VT2 >
void assign (const DenseVector< VT2, TF > &rhs)
 Implementation of the transpose assignment of a dense vector. More...
 
template<typename VT2 >
void assign (const SparseVector< VT2, TF > &rhs)
 Implementation of the transpose assignment of a sparse vector. More...
 
BLAZE_ALWAYS_INLINE VectorTypeoperator~ ()
 Conversion operator for non-constant vectors. More...
 
BLAZE_ALWAYS_INLINE const VectorTypeoperator~ () const
 Conversion operator for constant vectors. More...
 

Private Member Functions

size_t extendCapacity () const
 Calculating a new vector capacity. More...
 

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.

Member Enumeration Documentation

template<typename VT , bool TF>
anonymous enum

Compilation flag for SMP assignments.

The smpAssignable compilation flag indicates whether the vector can be used in SMP (shared memory parallel) assignments (both on the left-hand and right-hand side of the assignment).

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,
bool  check = false 
)
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.
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 vector with elements. It appends a new element to the end of the sparse vector without any additional memory allocation. Therefore it is strictly necessary to keep the following preconditions in mind:

  • the index of the new element must be strictly larger than the largest index of non-zero elements in the 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! 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 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>
ConstReference blaze::SVecTransposer< VT, TF >::at ( size_t  index) const
inline

Checked access to the vector elements.

Parameters
indexAccess index. The index has to be in the range $[0..N-1]$.
Returns
The resulting value.
Exceptions
std::out_of_rangeInvalid vector access index.
template<typename VT , bool TF>
Iterator blaze::SVecTransposer< VT, TF >::begin ( )
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 >::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>
template<typename Other >
bool blaze::SVecTransposer< VT, TF >::canAlias ( const Other *  alias) const
inline

Returns whether the vector can alias 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>
bool blaze::SVecTransposer< VT, TF >::canSMPAssign ( ) const
inline

Returns whether the vector can be used in SMP assignments.

Returns
true in case the vector can be used in SMP assignments, false if not.
template<typename VT , bool TF>
ConstIterator blaze::SVecTransposer< VT, TF >::cbegin ( ) 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 >::cend ( ) 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>
Iterator blaze::SVecTransposer< VT, TF >::end ( )
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>
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>
Iterator 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>
template<typename Other >
EnableIf< IsNumeric<Other>, SVecTransposer >::Type& blaze::SVecTransposer< VT, TF >::operator*= ( Other  rhs)
inline

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

Parameters
rhsThe right-hand side scalar value for the multiplication.
Returns
Reference to this SVecTransposer.
template<typename VT , bool TF>
template<typename Other >
EnableIf< IsNumeric<Other>, SVecTransposer >::Type& blaze::SVecTransposer< VT, TF >::operator/= ( Other  rhs)
inline

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

Parameters
rhsThe right-hand side scalar value for the division.
Returns
Reference to this SVecTransposer.
Note
: A division by zero is only checked by an user assert.
template<typename VT , bool TF>
ConstReference blaze::SVecTransposer< VT, TF >::operator[] ( size_t  index) const
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.
BLAZE_ALWAYS_INLINE VectorType& blaze::Vector< SVecTransposer< VT, TF > , TF >::operator~ ( )
inlineinherited

Conversion operator for non-constant vectors.

Returns
Reference of the actual type of the vector.
BLAZE_ALWAYS_INLINE const VectorType& blaze::Vector< SVecTransposer< VT, TF > , 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 files: