Blaze 3.9
Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
blaze::SMatTransposer< MT, SO > Class Template Reference

Expression object for the transposition of a sparse matrix. More...

#include <SMatTransposer.h>

Inherits blaze::SparseMatrix< SMatTransposer< MT, SO >, SO >.

Public Types

using This = SMatTransposer< MT, SO >
 Type of this SMatTransposer instance.
 
using BaseType = SparseMatrix< This, SO >
 Base type of this SMatTransposer instance.
 
using ResultType = TransposeType_t< MT >
 Result type for expression template evaluations.
 
using OppositeType = MT
 Result type with opposite storage order for expression template evaluations.
 
using TransposeType = ResultType_t< MT >
 Transpose type for expression template evaluations.
 
using ElementType = ElementType_t< MT >
 Resulting element type.
 
using ReturnType = ReturnType_t< MT >
 Return type for expression template evaluations.
 
using CompositeType = const This &
 Data type for composite expression templates.
 
using Reference = Reference_t< MT >
 Reference to a non-constant matrix value.
 
using ConstReference = ConstReference_t< MT >
 Reference to a constant matrix value.
 
using Iterator = Iterator_t< MT >
 Iterator over non-constant elements.
 
using ConstIterator = ConstIterator_t< MT >
 Iterator over constant elements.
 
using MatrixType = SMatTransposer< MT, SO >
 Type of the matrix.
 

Public Member Functions

 SMatTransposer (MT &sm) noexcept
 Constructor for the SMatTransposer class. More...
 
ConstReference operator() (size_t i, size_t j) const
 2D-access to the matrix elements. More...
 
ConstReference at (size_t i, size_t j) const
 Checked access to the matrix elements. More...
 
Iterator begin (size_t i)
 Returns an iterator to the first non-zero element of row/column i. More...
 
ConstIterator begin (size_t i) const
 Returns an iterator to the first non-zero element of row/column i. More...
 
ConstIterator cbegin (size_t i) const
 Returns an iterator to the first non-zero element of row/column i. More...
 
Iterator end (size_t i)
 Returns an iterator just past the last non-zero element of row/column i. More...
 
ConstIterator end (size_t i) const
 Returns an iterator just past the last non-zero element of row/column i. More...
 
ConstIterator cend (size_t i) const
 Returns an iterator just past the last non-zero element of row/column i. More...
 
size_t rows () const noexcept
 Returns the current number of rows of the matrix. More...
 
size_t columns () const noexcept
 Returns the current number of columns of the matrix. More...
 
size_t capacity () const noexcept
 Returns the maximum capacity of the matrix. More...
 
size_t capacity (size_t i) const noexcept
 Returns the current capacity of the specified row/column. More...
 
size_t nonZeros () const
 Returns the number of non-zero elements in the matrix. More...
 
size_t nonZeros (size_t i) const
 Returns the number of non-zero elements in the specified row/column. More...
 
void reset ()
 Resets the matrix elements. More...
 
Iterator insert (size_t i, size_t j, const ElementType &value)
 Inserting an element into the sparse matrix. More...
 
void reserve (size_t nonzeros)
 Setting the minimum capacity of the sparse matrix. More...
 
void reserve (size_t i, size_t nonzeros)
 Setting the minimum capacity of a specific row/column of the sparse matrix. More...
 
void append (size_t i, size_t j, const ElementType &value, bool check=false)
 Appending an element to the specified row/column of the sparse matrix. More...
 
void finalize (size_t i)
 Finalizing the element insertion of a row/column. More...
 
bool isIntact () const noexcept
 Returns whether the invariants of the matrix are intact. More...
 
template<typename Other >
bool canAlias (const Other *alias) const noexcept
 Returns whether the matrix can alias with the given address alias. More...
 
template<typename Other >
bool isAliased (const Other *alias) const noexcept
 Returns whether the matrix is aliased with the given address alias. More...
 
bool canSMPAssign () const noexcept
 Returns whether the matrix can be used in SMP assignments. More...
 
template<typename MT2 , bool SO2>
void assign (const Matrix< MT2, SO2 > &rhs)
 Implementation of the transpose assignment of a matrix. More...
 
Conversion operators
BLAZE_ALWAYS_INLINE constexpr SMatTransposer< MT, SO > & operator~ () noexcept
 CRTP-based conversion operation for non-constant matrices. More...
 
BLAZE_ALWAYS_INLINE constexpr const SMatTransposer< MT, SO > & operator~ () const noexcept
 CRTP-based conversion operation for constant matrices. More...
 
constexpr SMatTransposer< MT, SO > & operator* () noexcept
 CRTP-based conversion operation for non-constant matrices. More...
 
constexpr const SMatTransposer< MT, SO > & operator* () const noexcept
 CRTP-based conversion operation for constant matrices. More...
 

Static Public Attributes

static constexpr bool smpAssignable = MT::smpAssignable
 Compilation flag for SMP assignments. More...
 
static constexpr bool storageOrder
 Storage order of the matrix.
 

Private Attributes

MT & sm_
 The sparse matrix operand.
 

Detailed Description

template<typename MT, bool SO>
class blaze::SMatTransposer< MT, SO >

Expression object for the transposition of a sparse matrix.

The SMatTransposer class is a wrapper object for the temporary transposition of a sparse matrix.

Constructor & Destructor Documentation

◆ SMatTransposer()

template<typename MT , bool SO>
blaze::SMatTransposer< MT, SO >::SMatTransposer ( MT &  sm)
inlineexplicitnoexcept

Constructor for the SMatTransposer class.

Parameters
smThe sparse matrix operand.

Member Function Documentation

◆ append()

template<typename MT , bool SO>
void blaze::SMatTransposer< MT, SO >::append ( size_t  i,
size_t  j,
const ElementType value,
bool  check = false 
)
inline

Appending an element to the specified row/column of the sparse matrix.

Parameters
iThe row index of the new element. The index has to be in the range $[0..M-1]$.
jThe column 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 matrix with elements. It appends a new element to the end of the specified row/column 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 specified row/column of the sparse matrix
  • the current number of non-zero elements in row/column i must be smaller than the capacity of row/column i.

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 MT , bool SO>
template<typename MT2 , bool SO2>
void blaze::SMatTransposer< MT, SO >::assign ( const Matrix< MT2, SO2 > &  rhs)
inline

Implementation of the transpose assignment of a matrix.

Parameters
rhsThe right-hand side matrix 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 MT , bool SO>
ConstReference blaze::SMatTransposer< MT, SO >::at ( size_t  i,
size_t  j 
) const
inline

Checked access to the matrix elements.

Parameters
iAccess index for the row. The index has to be in the range $[0..M-1]$.
jAccess index for the column. The index has to be in the range $[0..N-1]$.
Returns
The resulting value.
Exceptions
std::out_of_rangeInvalid matrix access index.

◆ begin() [1/2]

template<typename MT , bool SO>
Iterator blaze::SMatTransposer< MT, SO >::begin ( size_t  i)
inline

Returns an iterator to the first non-zero element of row/column i.

Parameters
iThe row/column index.
Returns
Iterator to the first non-zero element of row/column i.

This function returns a row/column iterator to the first non-zero element of row/column i. In case the storage order is set to rowMajor the function returns an iterator to the first non-zero element of row i, in case the storage flag is set to columnMajor the function returns an iterator to the first non-zero element of column i.

◆ begin() [2/2]

template<typename MT , bool SO>
ConstIterator blaze::SMatTransposer< MT, SO >::begin ( size_t  i) const
inline

Returns an iterator to the first non-zero element of row/column i.

Parameters
iThe row/column index.
Returns
Iterator to the first non-zero element of row/column i.

This function returns a row/column iterator to the first non-zero element of row/column i. In case the storage order is set to rowMajor the function returns an iterator to the first non-zero element of row i, in case the storage flag is set to columnMajor the function returns an iterator to the first non-zero element of column i.

◆ canAlias()

template<typename MT , bool SO>
template<typename Other >
bool blaze::SMatTransposer< MT, SO >::canAlias ( const Other *  alias) const
inlinenoexcept

Returns whether the matrix can alias with the given address alias.

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

◆ canSMPAssign()

template<typename MT , bool SO>
bool blaze::SMatTransposer< MT, SO >::canSMPAssign ( ) const
inlinenoexcept

Returns whether the matrix can be used in SMP assignments.

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

◆ capacity() [1/2]

template<typename MT , bool SO>
size_t blaze::SMatTransposer< MT, SO >::capacity ( ) const
inlinenoexcept

Returns the maximum capacity of the matrix.

Returns
The capacity of the matrix.

◆ capacity() [2/2]

template<typename MT , bool SO>
size_t blaze::SMatTransposer< MT, SO >::capacity ( size_t  i) const
inlinenoexcept

Returns the current capacity of the specified row/column.

Parameters
iThe index of the row/column.
Returns
The current capacity of row/column i.

◆ cbegin()

template<typename MT , bool SO>
ConstIterator blaze::SMatTransposer< MT, SO >::cbegin ( size_t  i) const
inline

Returns an iterator to the first non-zero element of row/column i.

Parameters
iThe row/column index.
Returns
Iterator to the first non-zero element of row/column i.

This function returns a row/column iterator to the first non-zero element of row/column i. In case the storage order is set to rowMajor the function returns an iterator to the first non-zero element of row i, in case the storage flag is set to columnMajor the function returns an iterator to the first non-zero element of column i.

◆ cend()

template<typename MT , bool SO>
ConstIterator blaze::SMatTransposer< MT, SO >::cend ( size_t  i) const
inline

Returns an iterator just past the last non-zero element of row/column i.

Parameters
iThe row/column index.
Returns
Iterator just past the last non-zero element of row/column i.

This function returns an row/column iterator just past the last non-zero element of row/column i. In case the storage order is set to rowMajor the function returns an iterator just past the last non-zero element of row i, in case the storage flag is set to columnMajor the function returns an iterator just past the last non-zero element of column i.

◆ columns()

template<typename MT , bool SO>
size_t blaze::SMatTransposer< MT, SO >::columns ( ) const
inlinenoexcept

Returns the current number of columns of the matrix.

Returns
The number of columns of the matrix.

◆ end() [1/2]

template<typename MT , bool SO>
Iterator blaze::SMatTransposer< MT, SO >::end ( size_t  i)
inline

Returns an iterator just past the last non-zero element of row/column i.

Parameters
iThe row/column index.
Returns
Iterator just past the last non-zero element of row/column i.

This function returns an row/column iterator just past the last non-zero element of row/column i. In case the storage order is set to rowMajor the function returns an iterator just past the last non-zero element of row i, in case the storage flag is set to columnMajor the function returns an iterator just past the last non-zero element of column i.

◆ end() [2/2]

template<typename MT , bool SO>
ConstIterator blaze::SMatTransposer< MT, SO >::end ( size_t  i) const
inline

Returns an iterator just past the last non-zero element of row/column i.

Parameters
iThe row/column index.
Returns
Iterator just past the last non-zero element of row/column i.

This function returns an row/column iterator just past the last non-zero element of row/column i. In case the storage order is set to rowMajor the function returns an iterator just past the last non-zero element of row i, in case the storage flag is set to columnMajor the function returns an iterator just past the last non-zero element of column i.

◆ finalize()

template<typename MT , bool SO>
void blaze::SMatTransposer< MT, SO >::finalize ( size_t  i)
inline

Finalizing the element insertion of a row/column.

Parameters
iThe index of the row/column to be finalized $[0..M-1]$.
Returns
void

This function is part of the low-level interface to efficiently fill the matrix with elements. After completion of row/column i via the append() function, this function can be called to finalize row/column i and prepare the next row/column for insertion process via append().

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

◆ insert()

template<typename MT , bool SO>
Iterator blaze::SMatTransposer< MT, SO >::insert ( size_t  i,
size_t  j,
const ElementType value 
)
inline

Inserting an element into the sparse matrix.

Parameters
iThe row index of the new element. The index has to be in the range $[0..M-1]$.
jThe column 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 newly inserted element.
Exceptions
std::invalid_argumentInvalid sparse matrix access index.

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

◆ isAliased()

template<typename MT , bool SO>
template<typename Other >
bool blaze::SMatTransposer< MT, SO >::isAliased ( const Other *  alias) const
inlinenoexcept

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

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

◆ isIntact()

template<typename MT , bool SO>
bool blaze::SMatTransposer< MT, SO >::isIntact ( ) const
inlinenoexcept

Returns whether the invariants of the matrix are intact.

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

◆ nonZeros() [1/2]

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

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

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

◆ nonZeros() [2/2]

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

Returns the number of non-zero elements in the specified row/column.

Parameters
iThe index of the row/column.
Returns
The number of non-zero elements of row/column i.

◆ operator()()

template<typename MT , bool SO>
ConstReference blaze::SMatTransposer< MT, SO >::operator() ( size_t  i,
size_t  j 
) const
inline

2D-access to the matrix elements.

Parameters
iAccess index for the row. The index has to be in the range $[0..M-1]$.
jAccess index for the column. The index has to be in the range $[0..N-1]$.
Returns
Reference to the accessed value.

◆ operator*() [1/2]

BLAZE_ALWAYS_INLINE constexpr const SMatTransposer< MT, SO > & blaze::Matrix< SMatTransposer< MT, SO > , SO >::operator*
constexprnoexceptinherited

CRTP-based conversion operation for constant matrices.

Returns
Constant reference of the actual type of the matrix.

This operator performs the CRTP-based type-safe downcast to the actual type MT of the matrix. It will return a constant reference to the actual type MT.

◆ operator*() [2/2]

BLAZE_ALWAYS_INLINE constexpr SMatTransposer< MT, SO > & blaze::Matrix< SMatTransposer< MT, SO > , SO >::operator*
constexprnoexceptinherited

CRTP-based conversion operation for non-constant matrices.

Returns
Mutable reference of the actual type of the matrix.

This operator performs the CRTP-based type-safe downcast to the actual type MT of the matrix. It will return a mutable reference to the actual type MT.

◆ operator~() [1/2]

BLAZE_ALWAYS_INLINE constexpr const SMatTransposer< MT, SO > & blaze::Matrix< SMatTransposer< MT, SO > , SO >::operator~
constexprnoexceptinherited

CRTP-based conversion operation for constant matrices.

Parameters
matrixThe matrix to be downcast.
Returns
Constant reference of the actual type of the matrix.

This operator performs the CRTP-based type-safe downcast to the actual type MT of the matrix. It will return a constant reference to the actual type MT.

◆ operator~() [2/2]

BLAZE_ALWAYS_INLINE constexpr SMatTransposer< MT, SO > & blaze::Matrix< SMatTransposer< MT, SO > , SO >::operator~
constexprnoexceptinherited

CRTP-based conversion operation for non-constant matrices.

Parameters
matrixThe matrix to be downcast.
Returns
Mutable reference of the actual type of the matrix.

This operator performs the CRTP-based type-safe downcast to the actual type MT of the matrix. It will return a mutable reference to the actual type MT.

◆ reserve() [1/2]

template<typename MT , bool SO>
void blaze::SMatTransposer< MT, SO >::reserve ( size_t  i,
size_t  nonzeros 
)
inline

Setting the minimum capacity of a specific row/column of the sparse matrix.

Parameters
iThe row/column index of the new element $[0..M-1]$ or $[0..N-1]$.
nonzerosThe new minimum capacity of the specified row.
Returns
void

This function increases the capacity of row/column i of the sparse matrix to at least nonzeros elements. The current values of the sparse matrix and all other individual row/column capacities are preserved. In case the storage order is set to rowMajor, the function reserves capacity for row i and the index has to be in the range $[0..M-1]$. In case the storage order is set to columnMajor, the function reserves capacity for column i and the index has to be in the range $[0..N-1]$.

◆ reserve() [2/2]

template<typename MT , bool SO>
void blaze::SMatTransposer< MT, SO >::reserve ( size_t  nonzeros)
inline

Setting the minimum capacity of the sparse matrix.

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

This function increases the capacity of the sparse matrix to at least nonzeros elements. The current values of the matrix elements and the individual capacities of the matrix rows are preserved.

◆ reset()

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

Resets the matrix elements.

Returns
void

◆ rows()

template<typename MT , bool SO>
size_t blaze::SMatTransposer< MT, SO >::rows ( ) const
inlinenoexcept

Returns the current number of rows of the matrix.

Returns
The number of rows of the matrix.

Member Data Documentation

◆ smpAssignable

template<typename MT , bool SO>
constexpr bool blaze::SMatTransposer< MT, SO >::smpAssignable = MT::smpAssignable
staticconstexpr

Compilation flag for SMP assignments.

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


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