35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATTRANSPOSER_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_SMATTRANSPOSER_H_ 75 :
public SparseMatrix< SMatTransposer<MT,SO>, SO >
97 enum :
bool { smpAssignable = MT::smpAssignable };
133 if( i >=
sm_.columns() ) {
136 if( j >=
sm_.rows() ) {
171 return sm_.cbegin(i);
187 return sm_.cbegin(i);
246 template<
typename Other >
263 template<
typename Other >
278 inline size_t rows() const noexcept {
279 return sm_.columns();
299 return sm_.capacity();
309 inline size_t capacity(
size_t i )
const noexcept {
310 return sm_.capacity( i );
320 return sm_.nonZeros();
331 return sm_.nonZeros( i );
359 return sm_.insert( j, i, value );
374 sm_.reserve( nonzeros );
392 inline void reserve(
size_t i,
size_t nonzeros ) {
393 sm_.reserve( i, nonzeros );
425 sm_.append( j, i, value, check );
463 template<
typename Other >
464 inline bool canAlias(
const Other* alias )
const noexcept
466 return sm_.canAlias( alias );
476 template<
typename Other >
477 inline bool isAliased(
const Other* alias )
const noexcept
479 return sm_.isAliased( alias );
490 return sm_.canSMPAssign();
505 template<
typename MT2 >
516 const size_t m(
rows() );
518 for(
size_t i=0UL; i<m; ++i ) {
519 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
520 sm_.append( element->index(), i, element->value() );
537 template<
typename MT2 >
548 const size_t m(
rows() );
552 std::vector<size_t> rowLengths( m, 0UL );
553 for(
size_t j=0UL; j<n; ++j ) {
554 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
555 ++rowLengths[element->index()];
559 for(
size_t i=0UL; i<m; ++i ) {
560 sm_.reserve( i, rowLengths[i] );
564 for(
size_t j=0UL; j<n; ++j ) {
565 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
566 sm_.append( j, element->index(), element->value() );
604 template<
typename MT >
628 enum :
bool { smpAssignable = MT::smpAssignable };
664 if( i >=
sm_.columns() ) {
667 if( j >=
sm_.rows() ) {
692 return sm_.cbegin(j);
703 return sm_.cbegin(j);
747 template<
typename Other >
764 template<
typename Other >
779 inline size_t rows() const noexcept {
780 return sm_.columns();
789 inline size_t columns() const noexcept {
799 inline size_t capacity() const noexcept {
800 return sm_.capacity();
810 inline size_t capacity(
size_t j )
const noexcept {
811 return sm_.capacity( j );
821 return sm_.nonZeros();
831 inline size_t nonZeros(
size_t j )
const {
832 return sm_.nonZeros( j );
841 inline void reset() {
860 return sm_.insert( j, i, value );
874 inline void reserve(
size_t nonzeros ) {
875 sm_.reserve( nonzeros );
890 inline void reserve(
size_t i,
size_t nonzeros ) {
891 sm_.reserve( i, nonzeros );
923 sm_.append( j, i, value, check );
950 inline bool isIntact() const noexcept {
961 template<
typename Other >
962 inline bool canAlias(
const Other* alias )
const noexcept
964 return sm_.canAlias( alias );
974 template<
typename Other >
975 inline bool isAliased(
const Other* alias )
const noexcept
977 return sm_.isAliased( alias );
988 return sm_.canSMPAssign();
1003 template<
typename MT2 >
1014 const size_t m(
rows() );
1018 std::vector<size_t> columnLengths( n, 0UL );
1019 for(
size_t i=0UL; i<m; ++i ) {
1020 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
1021 ++columnLengths[element->index()];
1025 for(
size_t j=0UL; j<n; ++j ) {
1026 sm_.reserve( j, columnLengths[j] );
1030 for(
size_t i=0UL; i<m; ++i ) {
1031 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
1032 sm_.append( element->index(), i, element->value() );
1049 template<
typename MT2 >
1062 for(
size_t j=0UL; j<n; ++j ) {
1063 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
1064 sm_.append( j, element->index(), element->value() );
1103 template<
typename MT
1121 template<
typename MT
1125 return m.isIntact();
1141 template<
typename MT,
bool SO >
size_t capacity(size_t i) const noexcept
Returns the current capacity of the specified row/column.
Definition: SMatTransposer.h:309
Constraint on the data type.
Header file for auxiliary alias declarations.
#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
Header file for basic type definitions.
ReturnType_< MT > ReturnType
Return type for expression template evaluations.
Definition: SMatTransposer.h:84
ConstReference at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatTransposer.h:132
Base template for the SubmatrixTrait class.
Definition: SubmatrixTrait.h:128
ConstIterator cend(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: SMatTransposer.h:234
#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:81
SMatTransposer(MT &sm) noexcept
Constructor for the SMatTransposer class.
Definition: SMatTransposer.h:105
bool isAliased(const Other *alias) const noexcept
Returns whether the matrix is aliased with the given address alias.
Definition: SMatTransposer.h:477
MT OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatTransposer.h:81
EnableIf_< IsNumeric< Other >, SMatTransposer > & operator*=(Other rhs)
Multiplication assignment operator for the multiplication between a matrix and a scalar value ( )...
Definition: SMatTransposer.h:247
Iterator_< MT > Iterator
Iterator over non-constant elements.
Definition: SMatTransposer.h:88
Constraints on the storage order of matrix types.
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: SMatTransposer.h:288
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:343
bool isIntact() const noexcept
Returns whether the invariants of the matrix are intact.
Definition: SMatTransposer.h:452
MT & sm_
The sparse matrix operand.
Definition: SMatTransposer.h:574
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:129
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:363
Header file for the SparseMatrix base class.
void reserve(size_t i, size_t nonzeros)
Setting the minimum capacity of a specific row/column of the sparse matrix.
Definition: SMatTransposer.h:392
Constraint on the data type.
size_t nonZeros() const
Returns the number of non-zero elements in the matrix.
Definition: SMatTransposer.h:319
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#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: ColumnMajorMatrix.h:61
Iterator begin(size_t i)
Returns an iterator to the first non-zero element of row/column i.
Definition: SMatTransposer.h:154
ConstReference operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatTransposer.h:117
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Reference_< MT > Reference
Reference to a non-constant matrix value.
Definition: SMatTransposer.h:86
void reset()
Resets the matrix elements.
Definition: SMatTransposer.h:340
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: SMatTransposer.h:170
Header file for the exception macros of the math module.
EnableIf_< IsNumeric< Other >, SMatTransposer > & operator/=(Other rhs)
Division assignment operator for the division of a matrix by a scalar value ( ).
Definition: SMatTransposer.h:264
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: SMatTransposer.h:218
ConstIterator cbegin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: SMatTransposer.h:186
typename T::Reference Reference_
Alias declaration for nested Reference type definitions.The Reference_ alias declaration provides a c...
Definition: Aliases.h:303
Header file for the EnableIf class template.
void reserve(size_t nonzeros)
Setting the minimum capacity of the sparse matrix.
Definition: SMatTransposer.h:373
ConstIterator_< MT > ConstIterator
Iterator over constant elements.
Definition: SMatTransposer.h:89
void assign(const SparseMatrix< MT2, true > &rhs)
Implementation of the transpose assignment of a column-major sparse matrix.
Definition: SMatTransposer.h:538
Header file for the IsNumeric type trait.
TransposeType_< MT > ResultType
Result type for expression template evaluations.
Definition: SMatTransposer.h:80
ElementType_< MT > ElementType
Resulting element type.
Definition: SMatTransposer.h:83
void assign(const SparseMatrix< MT2, false > &rhs)
Implementation of the transpose assignment of a row-major sparse matrix.
Definition: SMatTransposer.h:506
Expression object for the transposition of a sparse matrix.The SMatTransposer class is a wrapper obje...
Definition: Forward.h:124
#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: RowMajorMatrix.h:61
Header file for run time assertion macros.
bool canAlias(const Other *alias) const noexcept
Returns whether the matrix can alias with the given address alias.
Definition: SMatTransposer.h:464
ResultType_< MT > TransposeType
Transpose type for expression template evaluations.
Definition: SMatTransposer.h:82
Header file for the submatrix trait.
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:424
Iterator end(size_t i)
Returns an iterator just past the last non-zero element of row/column i.
Definition: SMatTransposer.h:202
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SMatTransposer.h:278
Constraints on the storage order of matrix types.
Iterator insert(size_t i, size_t j, const ElementType &value)
Inserting an element into the sparse matrix.
Definition: SMatTransposer.h:358
typename SubmatrixTrait< MT >::Type SubmatrixTrait_
Auxiliary alias declaration for the SubmatrixTrait type trait.The SubmatrixTrait_ alias declaration p...
Definition: SubmatrixTrait.h:163
ConstReference_< MT > ConstReference
Reference to a constant matrix value.
Definition: SMatTransposer.h:87
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
typename T::Iterator Iterator_
Alias declaration for nested Iterator type definitions.The Iterator_ alias declaration provides a con...
Definition: Aliases.h:183
void finalize(size_t i)
Finalizing the element insertion of a row/column.
Definition: SMatTransposer.h:442
typename T::ConstReference ConstReference_
Alias declaration for nested ConstReference type definitions.The ConstReference_ alias declaration pr...
Definition: Aliases.h:143
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
size_t capacity() const noexcept
Returns the maximum capacity of the matrix.
Definition: SMatTransposer.h:298
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row/column.
Definition: SMatTransposer.h:330
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:423
bool canSMPAssign() const noexcept
Returns whether the matrix can be used in SMP assignments.
Definition: SMatTransposer.h:488
#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:61