35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATTRANSPOSER_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATTRANSPOSER_H_
73 class SMatTransposer :
public SparseMatrix< SMatTransposer<MT,SO>, SO >
95 enum { smpAssignable = MT::smpAssignable };
115 inline ConstReference
operator()(
size_t i,
size_t j )
const {
130 inline ConstReference
at(
size_t i,
size_t j )
const {
131 if( i >=
sm_.columns() ) {
134 if( j >=
sm_.rows() ) {
168 inline ConstIterator
begin(
size_t i )
const {
169 return sm_.cbegin(i);
184 inline ConstIterator
cbegin(
size_t i )
const {
185 return sm_.cbegin(i);
200 inline Iterator
end(
size_t i ) {
216 inline ConstIterator
end(
size_t i )
const {
232 inline ConstIterator
cend(
size_t i )
const {
244 template<
typename Other >
261 template<
typename Other >
277 return sm_.columns();
297 return sm_.capacity();
308 return sm_.capacity( i );
318 return sm_.nonZeros();
329 return sm_.nonZeros( i );
356 inline Iterator
insert(
size_t i,
size_t j,
const ElementType& value ) {
357 return sm_.insert( j, i, value );
372 sm_.reserve( nonzeros );
390 inline void reserve(
size_t i,
size_t nonzeros ) {
391 sm_.reserve( i, nonzeros );
422 inline void append(
size_t i,
size_t j,
const ElementType& value,
bool check=
false ) {
423 sm_.append( j, i, value, check );
461 template<
typename Other >
464 return sm_.canAlias( alias );
474 template<
typename Other >
477 return sm_.isAliased( alias );
488 return sm_.canSMPAssign();
503 template<
typename MT2 >
514 const size_t m(
rows() );
516 for(
size_t i=0UL; i<m; ++i ) {
517 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
518 sm_.append( element->index(), i, element->value() );
535 template<
typename MT2 >
546 const size_t m(
rows() );
550 std::vector<size_t> rowLengths( m, 0UL );
551 for(
size_t j=0UL; j<n; ++j ) {
552 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
553 ++rowLengths[element->index()];
557 for(
size_t i=0UL; i<m; ++i ) {
558 sm_.reserve( i, rowLengths[i] );
562 for(
size_t j=0UL; j<n; ++j ) {
563 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
564 sm_.append( j, element->index(), element->value() );
602 template<
typename MT >
625 enum { smpAssignable = MT::smpAssignable };
645 inline ConstReference
operator()(
size_t i,
size_t j )
const {
660 inline ConstReference
at(
size_t i,
size_t j )
const {
661 if( i >=
sm_.columns() ) {
664 if( j >=
sm_.rows() ) {
677 inline Iterator
begin(
size_t j ) {
688 inline ConstIterator
begin(
size_t j )
const {
689 return sm_.cbegin(j);
699 inline ConstIterator
cbegin(
size_t j )
const {
700 return sm_.cbegin(j);
710 inline Iterator
end(
size_t j ) {
721 inline ConstIterator
end(
size_t j )
const {
732 inline ConstIterator
cend(
size_t j )
const {
744 template<
typename Other >
761 template<
typename Other >
776 inline size_t rows()
const {
777 return sm_.columns();
786 inline size_t columns()
const {
797 return sm_.capacity();
807 inline size_t capacity(
size_t j )
const {
808 return sm_.capacity( j );
818 return sm_.nonZeros();
828 inline size_t nonZeros(
size_t j )
const {
829 return sm_.nonZeros( j );
838 inline void reset() {
856 inline Iterator
insert(
size_t i,
size_t j,
const ElementType& value ) {
857 return sm_.insert( j, i, value );
871 inline void reserve(
size_t nonzeros ) {
872 sm_.reserve( nonzeros );
887 inline void reserve(
size_t i,
size_t nonzeros ) {
888 sm_.reserve( i, nonzeros );
919 void append(
size_t i,
size_t j,
const ElementType& value,
bool check=
false ) {
920 sm_.append( j, i, value, check );
958 template<
typename Other >
959 inline bool canAlias(
const Other* alias )
const
961 return sm_.canAlias( alias );
971 template<
typename Other >
972 inline bool isAliased(
const Other* alias )
const
974 return sm_.isAliased( alias );
985 return sm_.canSMPAssign();
1000 template<
typename MT2 >
1001 inline void assign(
const SparseMatrix<MT2,false>& rhs )
1011 const size_t m(
rows() );
1015 std::vector<size_t> columnLengths( n, 0UL );
1016 for(
size_t i=0UL; i<m; ++i ) {
1017 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
1018 ++columnLengths[element->index()];
1022 for(
size_t j=0UL; j<n; ++j ) {
1023 sm_.reserve( j, columnLengths[j] );
1027 for(
size_t i=0UL; i<m; ++i ) {
1028 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
1029 sm_.append( element->index(), i, element->value() );
1046 template<
typename MT2 >
1047 inline void assign(
const SparseMatrix<MT2,true>& rhs )
1059 for(
size_t j=0UL; j<n; ++j ) {
1060 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
1061 sm_.append( j, element->index(), element->value() );
1100 template<
typename MT
1102 inline void reset( SMatTransposer<MT,SO>& m )
1118 template<
typename MT
1120 inline bool isIntact(
const SMatTransposer<MT,SO>& m )
1122 return m.isIntact();
1138 template<
typename MT,
bool SO >
1139 struct SubmatrixTrait< SMatTransposer<MT,SO> >
Constraint on the data type.
#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
ConstReference operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatTransposer.h:115
Header file for basic type definitions.
EnableIf< IsNumeric< Other >, SMatTransposer >::Type & operator/=(Other rhs)
Division assignment operator for the division of a matrix by a scalar value ( ).
Definition: SMatTransposer.h:262
size_t rows() const
Returns the current number of rows of the matrix.
Definition: SMatTransposer.h:276
#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::Reference Reference
Reference to a non-constant matrix value.
Definition: SMatTransposer.h:84
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:507
EnableIf< IsNumeric< Other >, SMatTransposer >::Type & operator*=(Other rhs)
Multiplication assignment operator for the multiplication between a matrix and a scalar value ( )...
Definition: SMatTransposer.h:245
MT::ElementType ElementType
Resulting element type.
Definition: SMatTransposer.h:81
Constraints on the storage order of matrix types.
ConstReference at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatTransposer.h:130
MT & sm_
The sparse matrix operand.
Definition: SMatTransposer.h:572
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:117
Header file for the SparseMatrix base class.
bool canSMPAssign() const
Returns whether the matrix can be used in SMP assignments.
Definition: SMatTransposer.h:486
void reserve(size_t i, size_t nonzeros)
Setting the minimum capacity of a specific row/column of the sparse matrix.
Definition: SMatTransposer.h:390
MT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: SMatTransposer.h:82
size_t capacity(size_t i) const
Returns the current capacity of the specified row/column.
Definition: SMatTransposer.h:307
Constraint on the data type.
bool isAliased(const Other *alias) const
Returns whether the matrix is aliased with the given address alias.
Definition: SMatTransposer.h:475
MT OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatTransposer.h:79
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:79
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
Iterator begin(size_t i)
Returns an iterator to the first non-zero element of row/column i.
Definition: SMatTransposer.h:152
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
void reset()
Resets the matrix elements.
Definition: SMatTransposer.h:338
MT::ConstReference ConstReference
Reference to a constant matrix value.
Definition: SMatTransposer.h:85
MT::TransposeType ResultType
Result type for expression template evaluations.
Definition: SMatTransposer.h:78
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2585
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: SMatTransposer.h:168
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: SMatTransposer.h:216
MT::ConstIterator ConstIterator
Iterator over constant elements.
Definition: SMatTransposer.h:87
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2590
Header file for the EnableIf class template.
void reserve(size_t nonzeros)
Setting the minimum capacity of the sparse matrix.
Definition: SMatTransposer.h:371
bool canAlias(const Other *alias) const
Returns whether the matrix can alias with the given address alias.
Definition: SMatTransposer.h:462
size_t nonZeros() const
Returns the number of non-zero elements in the matrix.
Definition: SMatTransposer.h:317
void assign(const SparseMatrix< MT2, true > &rhs)
Implementation of the transpose assignment of a column-major sparse matrix.
Definition: SMatTransposer.h:536
Header file for the IsNumeric type trait.
MT::Iterator Iterator
Iterator over non-constant elements.
Definition: SMatTransposer.h:86
void assign(const SparseMatrix< MT2, false > &rhs)
Implementation of the transpose assignment of a row-major sparse matrix.
Definition: SMatTransposer.h:504
Expression object for the transposition of a sparse matrix.The SMatTransposer class is a wrapper obje...
Definition: Forward.h:113
ConstIterator cend(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: SMatTransposer.h:232
#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:79
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2587
ConstIterator cbegin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: SMatTransposer.h:184
size_t columns() const
Returns the current number of columns of the matrix.
Definition: SMatTransposer.h:286
Header file for run time assertion macros.
Header file for the submatrix trait.
SMatTransposer(MT &sm)
Constructor for the SMatTransposer class.
Definition: SMatTransposer.h:103
SMatTransposer< MT, SO > This
Type of this SMatTransposer instance.
Definition: SMatTransposer.h:77
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
bool isIntact() const
Returns whether the invariants of the matrix are intact.
Definition: SMatTransposer.h:450
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row/column.
Definition: SMatTransposer.h:328
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:422
Iterator end(size_t i)
Returns an iterator just past the last non-zero element of row/column i.
Definition: SMatTransposer.h:200
size_t capacity() const
Returns the maximum capacity of the matrix.
Definition: SMatTransposer.h:296
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2591
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:356
void finalize(size_t i)
Finalizing the element insertion of a row/column.
Definition: SMatTransposer.h:440
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2583
MT::ResultType TransposeType
Transpose type for expression template evaluations.
Definition: SMatTransposer.h:80
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:237
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2589
Header file for exception macros.
const This & CompositeType
Data type for composite expression templates.
Definition: SMatTransposer.h:83
#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