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  : bool { smpAssignable = VT::smpAssignable }
 Compilation flag for SMP assignments. More...
 
using This = SVecTransposer< VT, TF >
 Type of this SVecTransposer instance.
 
using ResultType = TransposeType_< VT >
 Result type for expression template evaluations.
 
using TransposeType = ResultType_< VT >
 Transpose type for expression template evaluations.
 
using ElementType = ElementType_< VT >
 Resulting element type.
 
using ReturnType = ReturnType_< VT >
 Return type for expression template evaluations.
 
using CompositeType = const This &
 Data type for composite expression templates.
 
using Reference = Reference_< VT >
 Reference to a non-constant matrix value.
 
using ConstReference = ConstReference_< VT >
 Reference to a constant matrix value.
 
using Iterator = Iterator_< VT >
 Iterator over non-constant elements.
 
using ConstIterator = ConstIterator_< VT >
 Iterator over constant elements.
 
using VectorType = SVecTransposer< VT, TF >
 Type of the vector.
 

Public Member Functions

 SVecTransposer (VT &sv) noexcept
 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...
 
size_t size () const noexcept
 Returns the current size/dimension of the vector. More...
 
size_t capacity () const noexcept
 Returns the maximum capacity of the vector. More...
 
size_t nonZeros () const
 Returns the number of non-zero elements in 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...
 
bool isIntact () const noexcept
 Returns whether the invariants of the vector are intact. More...
 
template<typename Other >
bool canAlias (const Other *alias) const noexcept
 Returns whether the vector can alias with the given address alias. More...
 
template<typename Other >
bool isAliased (const Other *alias) const noexcept
 Returns whether the vector is aliased with the given address alias. More...
 
bool canSMPAssign () const noexcept
 Returns whether the vector can be used in SMP assignments. More...
 
template<typename VT2 >
void assign (const Vector< VT2, TF > &rhs)
 Implementation of the transpose assignment of a vector. More...
 
BLAZE_ALWAYS_INLINE VectorTypeoperator~ () noexcept
 Conversion operator for non-constant vectors. More...
 
BLAZE_ALWAYS_INLINE const VectorTypeoperator~ () const noexcept
 Conversion operator for constant vectors. More...
 

Private Member Functions

size_t extendCapacity () const noexcept
 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

◆ anonymous enum

template<typename VT , bool TF>
anonymous enum : bool

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

◆ SVecTransposer()

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

Constructor for the SVecTransposer class.

Parameters
svThe sparse vector operand.

Member Function Documentation

◆ append()

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!

◆ assign()

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

Implementation of the transpose assignment of a vector.

Parameters
rhsThe right-hand side 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.

◆ at()

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.

◆ begin() [1/2]

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.

◆ begin() [2/2]

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.

◆ canAlias()

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

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.

◆ canSMPAssign()

template<typename VT , bool TF>
bool blaze::SVecTransposer< VT, TF >::canSMPAssign ( ) const
inlinenoexcept

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.

◆ capacity()

template<typename VT , bool TF>
size_t blaze::SVecTransposer< VT, TF >::capacity ( ) const
inlinenoexcept

Returns the maximum capacity of the vector.

Returns
The capacity of the vector.

◆ cbegin()

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.

◆ cend()

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.

◆ end() [1/2]

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.

◆ end() [2/2]

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.

◆ extendCapacity()

template<typename VT , bool TF>
size_t blaze::SVecTransposer< VT, TF >::extendCapacity ( ) const
inlineprivatenoexcept

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]$.

◆ find()

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!

◆ insert()

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.

◆ isAliased()

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

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.

◆ isIntact()

template<typename VT , bool TF>
bool blaze::SVecTransposer< VT, TF >::isIntact ( ) const
inlinenoexcept

Returns whether the invariants of the vector are intact.

Returns
true in case the vector's invariants are intact, false otherwise.

◆ nonZeros()

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

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

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

◆ operator[]()

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.

◆ operator~() [1/2]

BLAZE_ALWAYS_INLINE VectorType& blaze::Vector< SVecTransposer< VT, TF > , TF >::operator~ ( )
inlinenoexceptinherited

Conversion operator for non-constant vectors.

Returns
Reference of the actual type of the vector.

◆ operator~() [2/2]

BLAZE_ALWAYS_INLINE const VectorType& blaze::Vector< SVecTransposer< VT, TF > , TF >::operator~ ( ) const
inlinenoexceptinherited

Conversion operator for constant vectors.

Returns
Const reference of the actual type of the vector.

◆ reserve()

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.

◆ reset()

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

Resets the vector elements.

Returns
void

◆ size()

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

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: