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

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

#include <SMatTransposer.h>

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

Public Types

enum  { smpAssignable = MT::smpAssignable }
 Compilation flag for SMP assignments. More...
 
typedef SMatTransposer< MT, SO > This
 Type of this SMatTransposer instance.
 
typedef MT::TransposeType ResultType
 Result type for expression template evaluations.
 
typedef MT OppositeType
 Result type with opposite storage order for expression template evaluations.
 
typedef MT::ResultType TransposeType
 Transpose type for expression template evaluations.
 
typedef MT::ElementType ElementType
 Resulting element type.
 
typedef MT::ReturnType ReturnType
 Return type for expression template evaluations.
 
typedef const ThisCompositeType
 Data type for composite expression templates.
 
typedef MT::Reference Reference
 Reference to a non-constant matrix value.
 
typedef MT::ConstReference ConstReference
 Reference to a constant matrix value.
 
typedef MT::Iterator Iterator
 Iterator over non-constant elements.
 
typedef MT::ConstIterator ConstIterator
 Iterator over constant elements.
 
typedef MT MatrixType
 Type of the matrix.
 

Public Member Functions

 SMatTransposer (MT &sm)
 Constructor for the SMatTransposer class. More...
 
ConstReference operator() (size_t i, size_t j) const
 2D-access to the matrix elements. 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...
 
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...
 
template<typename Other >
EnableIf< IsNumeric< Other >
, SMatTransposer >::Type & 
operator*= (Other rhs)
 Multiplication assignment operator for the multiplication between a matrix and a scalar value ( $ A*=s $). More...
 
template<typename Other >
EnableIf< IsNumeric< Other >
, SMatTransposer >::Type & 
operator/= (Other rhs)
 Division assignment operator for the division of a matrix by a scalar value ( $ A/=s $). More...
 
size_t rows () const
 Returns the current number of rows of the matrix. More...
 
size_t columns () const
 Returns the current number of columns of the matrix. 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...
 
template<typename Other >
bool canAlias (const Other *alias) const
 Returns whether the matrix can alias with the given address alias. More...
 
template<typename Other >
bool isAliased (const Other *alias) const
 Returns whether the matrix is aliased with the given address alias. More...
 
template<typename MT2 >
void assign (const SparseMatrix< MT2, false > &rhs)
 Implementation of the transpose assignment of a row-major sparse matrix. More...
 
template<typename MT2 >
void assign (const SparseMatrix< MT2, true > &rhs)
 Implementation of the transpose assignment of a column-major sparse matrix. More...
 
MatrixTypeoperator~ ()
 Conversion operator for non-constant matrices. More...
 
const MatrixTypeoperator~ () const
 Conversion operator for constant matrices. More...
 

Private Attributes

MT & sm_
 The sparse matrix operand.
 

Detailed Description

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

Expression object for the transposition of a sparse matrix.

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

Member Enumeration Documentation

template<typename , bool >
anonymous enum

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

Constructor & Destructor Documentation

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

Constructor for the SMatTransposer class.

Parameters
smThe sparse matrix operand.

Member Function Documentation

template<typename , bool >
void blaze::SMatTransposer< typename, bool >::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!

template<typename , bool >
template<typename MT2 >
void blaze::SMatTransposer< typename, bool >::assign ( const SparseMatrix< MT2, false > &  rhs)
inline

Implementation of the transpose assignment of a row-major sparse matrix.

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

template<typename , bool >
template<typename MT2 >
void blaze::SMatTransposer< typename, bool >::assign ( const SparseMatrix< MT2, true > &  rhs)
inline

Implementation of the transpose assignment of a column-major sparse matrix.

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

template<typename , bool >
ConstIterator blaze::SMatTransposer< typename, bool >::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.

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

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.
template<typename , bool >
ConstIterator blaze::SMatTransposer< typename, bool >::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.

template<typename , bool >
ConstIterator blaze::SMatTransposer< typename, bool >::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.

template<typename , bool >
size_t blaze::SMatTransposer< typename, bool >::columns ( ) const
inline

Returns the current number of columns of the matrix.

Returns
The number of columns of the matrix.
template<typename , bool >
ConstIterator blaze::SMatTransposer< typename, bool >::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.

template<typename , bool >
void blaze::SMatTransposer< typename, bool >::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!

template<typename , bool >
Iterator blaze::SMatTransposer< typename, bool >::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.

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

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.
template<typename , bool >
ConstReference blaze::SMatTransposer< typename, bool >::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.
template<typename , bool >
template<typename Other >
EnableIf< IsNumeric<Other>, SMatTransposer >::Type& blaze::SMatTransposer< typename, bool >::operator*= ( Other  rhs)
inline

Multiplication assignment operator for the multiplication between a matrix and a scalar value ( $ A*=s $).

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

Division assignment operator for the division of a matrix by a scalar value ( $ A/=s $).

Parameters
rhsThe right-hand side scalar value for the division.
Returns
Reference to this SMatTransposer.

Note: A division by zero is only checked by an user assert.

MatrixType& blaze::Matrix< typename, bool >::operator~ ( )
inlineinherited

Conversion operator for non-constant matrices.

Returns
Reference of the actual type of the matrix.
const MatrixType& blaze::Matrix< typename, bool >::operator~ ( ) const
inlineinherited

Conversion operator for constant matrices.

Returns
Constant reference of the actual type of the matrix.
template<typename , bool >
void blaze::SMatTransposer< typename, bool >::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.

template<typename , bool >
void blaze::SMatTransposer< typename, bool >::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]$.

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

Resets the matrix elements.

Returns
void
template<typename , bool >
size_t blaze::SMatTransposer< typename, bool >::rows ( ) const
inline

Returns the current number of rows of the matrix.

Returns
The number of rows of the matrix.

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