35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATTRANSPOSER_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATTRANSPOSER_H_
71 class SMatTransposer :
public SparseMatrix< SMatTransposer<MT,SO>, SO >
93 enum { smpAssignable = MT::smpAssignable };
132 return sm_.cbegin(i);
148 return sm_.cbegin(i);
191 template<
typename Other >
208 template<
typename Other >
224 return sm_.columns();
262 return sm_.insert( j, i, value );
277 sm_.reserve( nonzeros );
295 inline void reserve(
size_t i,
size_t nonzeros ) {
296 sm_.reserve( i, nonzeros );
328 sm_.append( j, i, value, check );
356 template<
typename Other >
359 return sm_.canAlias( alias );
369 template<
typename Other >
372 return sm_.isAliased( alias );
387 template<
typename MT2 >
398 const size_t m(
rows() );
400 for(
size_t i=0UL; i<m; ++i ) {
401 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
402 sm_.append( element->index(), i, element->value() );
419 template<
typename MT2 >
430 const size_t m(
rows() );
434 std::vector<size_t> rowLengths( m, 0UL );
435 for(
size_t j=0UL; j<n; ++j ) {
436 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
437 ++rowLengths[element->index()];
441 for(
size_t i=0UL; i<m; ++i ) {
442 sm_.reserve( i, rowLengths[i] );
446 for(
size_t j=0UL; j<n; ++j ) {
447 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
448 sm_.append( j, element->index(), element->value() );
486 template<
typename MT >
509 enum { smpAssignable = MT::smpAssignable };
543 return sm_.cbegin(j);
587 template<
typename Other >
604 template<
typename Other >
619 inline size_t rows()
const {
620 return sm_.columns();
629 inline size_t columns()
const {
639 inline void reset() {
658 return sm_.insert( j, i, value );
672 inline void reserve(
size_t nonzeros ) {
673 sm_.reserve( nonzeros );
688 inline void reserve(
size_t i,
size_t nonzeros ) {
689 sm_.reserve( i, nonzeros );
721 sm_.append( j, i, value, check );
749 template<
typename Other >
750 inline bool isAliased(
const Other* alias )
const
752 return sm_.isAliased( alias );
767 template<
typename MT2 >
768 inline void assign(
const SparseMatrix<MT2,false>& rhs )
778 const size_t m(
rows() );
782 std::vector<size_t> columnLengths( n, 0UL );
783 for(
size_t i=0UL; i<m; ++i ) {
784 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
785 ++columnLengths[element->index()];
789 for(
size_t j=0UL; j<n; ++j ) {
790 sm_.reserve( j, columnLengths[j] );
794 for(
size_t i=0UL; i<m; ++i ) {
795 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
796 sm_.append( element->index(), i, element->value() );
813 template<
typename MT2 >
814 inline void assign(
const SparseMatrix<MT2,true>& rhs )
826 for(
size_t j=0UL; j<n; ++j ) {
827 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
828 sm_.append( j, element->index(), element->value() );
867 template<
typename MT
869 inline void reset( SMatTransposer<MT,SO>& m )
887 template<
typename MT,
bool SO >
888 struct SubmatrixTrait< SMatTransposer<MT,SO> >
MT OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatTransposer.h:77
MT::ConstReference ConstReference
Reference to a constant matrix value.
Definition: SMatTransposer.h:83
MT::ElementType ElementType
Resulting element type.
Definition: SMatTransposer.h:79
Constraint on the data type.
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: SMatTransposer.h:131
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4599
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:199
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:118
MT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: SMatTransposer.h:80
void reset()
Resets the matrix elements.
Definition: SMatTransposer.h:243
SMatTransposer< MT, SO > This
Type of this SMatTransposer instance.
Definition: SMatTransposer.h:75
bool canAlias(const Other *alias) const
Returns whether the matrix can alias with the given address alias.
Definition: SMatTransposer.h:357
MT::ResultType TransposeType
Transpose type for expression template evaluations.
Definition: SMatTransposer.h:78
EnableIf< IsNumeric< Other >, SMatTransposer >::Type & operator*=(Other rhs)
Multiplication assignment operator for the multiplication between a matrix and a scalar value ( )...
Definition: SMatTransposer.h:192
Iterator insert(size_t i, size_t j, const ElementType &value)
Inserting an element into the sparse matrix.
Definition: SMatTransposer.h:261
ConstIterator cend(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: SMatTransposer.h:179
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:107
Header file for the SparseMatrix base class.
Constraint on the data type.
MT::Iterator Iterator
Iterator over non-constant elements.
Definition: SMatTransposer.h:84
bool isAliased(const Other *alias) const
Returns whether the matrix is aliased with the given address alias.
Definition: SMatTransposer.h:370
void reserve(size_t i, size_t nonzeros)
Setting the minimum capacity of a specific row/column of the sparse matrix.
Definition: SMatTransposer.h:295
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: StorageOrder.h:161
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2412
size_t nonZeros(const Matrix< MT, SO > &m)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:224
void assign(const SparseMatrix< MT2, false > &rhs)
Implementation of the transpose assignment of a row-major sparse matrix.
Definition: SMatTransposer.h:388
MT::TransposeType ResultType
Result type for expression template evaluations.
Definition: SMatTransposer.h:76
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: SMatTransposer.h:163
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2405
Constraints on the storage order of matrix types.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2406
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.
Definition: SMatTransposer.h:327
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2410
size_t rows() const
Returns the current number of rows of the matrix.
Definition: SMatTransposer.h:223
Header file for the EnableIf class template.
Header file for the IsNumeric type trait.
MT::ConstIterator ConstIterator
Iterator over constant elements.
Definition: SMatTransposer.h:85
void reserve(size_t nonzeros)
Setting the minimum capacity of the sparse matrix.
Definition: SMatTransposer.h:276
Expression object for the transposition of a sparse matrix.The SMatTransposer class is a wrapper obje...
Definition: Forward.h:103
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: StorageOrder.h:81
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2407
Header file for run time assertion macros.
Header file for the submatrix trait.
SMatTransposer(MT &sm)
Constructor for the SMatTransposer class.
Definition: SMatTransposer.h:101
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
MT & sm_
The sparse matrix operand.
Definition: SMatTransposer.h:456
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2411
ConstReference operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatTransposer.h:113
ConstIterator cbegin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: SMatTransposer.h:147
const This & CompositeType
Data type for composite expression templates.
Definition: SMatTransposer.h:81
void assign(const SparseMatrix< MT2, true > &rhs)
Implementation of the transpose assignment of a column-major sparse matrix.
Definition: SMatTransposer.h:420
void finalize(size_t i)
Finalizing the element insertion of a row/column.
Definition: SMatTransposer.h:345
EnableIf< IsNumeric< Other >, SMatTransposer >::Type & operator/=(Other rhs)
Division assignment operator for the division of a matrix by a scalar value ( ).
Definition: SMatTransposer.h:209
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2403
Header file for basic type definitions.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2409
MT::Reference Reference
Reference to a non-constant matrix value.
Definition: SMatTransposer.h:82
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:79
size_t columns() const
Returns the current number of columns of the matrix.
Definition: SMatTransposer.h:233