Blaze  3.6
DMatTransposer.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATTRANSPOSER_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DMATTRANSPOSER_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
46 #include <blaze/math/Exception.h>
56 #include <blaze/system/Inline.h>
57 #include <blaze/util/Assert.h>
58 #include <blaze/util/Types.h>
59 
60 
61 namespace blaze {
62 
63 //=================================================================================================
64 //
65 // CLASS DMATTRANSPOSER
66 //
67 //=================================================================================================
68 
69 //*************************************************************************************************
75 template< typename MT // Type of the dense matrix
76  , bool SO > // Storage order
78  : public DenseMatrix< DMatTransposer<MT,SO>, SO >
79 {
80  public:
81  //**Type definitions****************************************************************************
90  using CompositeType = const This&;
97  //**********************************************************************************************
98 
99  //**Compilation flags***************************************************************************
101 
104  static constexpr bool simdEnabled = MT::simdEnabled;
105 
107 
110  static constexpr bool smpAssignable = MT::smpAssignable;
111  //**********************************************************************************************
112 
113  //**Constructor*********************************************************************************
118  explicit inline DMatTransposer( MT& dm ) noexcept
119  : dm_( dm ) // The dense matrix operand
120  {}
121  //**********************************************************************************************
122 
123  //**Access operator*****************************************************************************
130  inline Reference operator()( size_t i, size_t j ) {
131  BLAZE_INTERNAL_ASSERT( i < dm_.columns(), "Invalid row access index" );
132  BLAZE_INTERNAL_ASSERT( j < dm_.rows() , "Invalid column access index" );
133  return dm_(j,i);
134  }
135  //**********************************************************************************************
136 
137  //**Access operator*****************************************************************************
144  inline ConstReference operator()( size_t i, size_t j ) const {
145  BLAZE_INTERNAL_ASSERT( i < dm_.columns(), "Invalid row access index" );
146  BLAZE_INTERNAL_ASSERT( j < dm_.rows() , "Invalid column access index" );
147  return const_cast<const MT&>( dm_ )(j,i);
148  }
149  //**********************************************************************************************
150 
151  //**At function*********************************************************************************
159  inline Reference at( size_t i, size_t j ) {
160  if( i >= dm_.columns() ) {
161  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
162  }
163  if( j >= dm_.rows() ) {
164  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
165  }
166  return (*this)(i,j);
167  }
168  //**********************************************************************************************
169 
170  //**At function*********************************************************************************
178  inline ConstReference at( size_t i, size_t j ) const {
179  if( i >= dm_.columns() ) {
180  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
181  }
182  if( j >= dm_.rows() ) {
183  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
184  }
185  return (*this)(i,j);
186  }
187  //**********************************************************************************************
188 
189  //**Low-level data access***********************************************************************
194  inline Pointer data() noexcept {
195  return dm_.data();
196  }
197  //**********************************************************************************************
198 
199  //**Low-level data access***********************************************************************
204  inline ConstPointer data() const noexcept {
205  return dm_.data();
206  }
207  //**********************************************************************************************
208 
209  //**Begin function******************************************************************************
220  inline Iterator begin( size_t i ) {
221  return dm_.begin( i );
222  }
223  //**********************************************************************************************
224 
225  //**Begin function******************************************************************************
236  inline ConstIterator begin( size_t i ) const {
237  return dm_.cbegin( i );
238  }
239  //**********************************************************************************************
240 
241  //**Cbegin function*****************************************************************************
252  inline ConstIterator cbegin( size_t i ) const {
253  return dm_.cbegin( i );
254  }
255  //**********************************************************************************************
256 
257  //**End function********************************************************************************
268  inline Iterator end( size_t i ) {
269  return dm_.end( i );
270  }
271  //**********************************************************************************************
272 
273  //**End function********************************************************************************
284  inline ConstIterator end( size_t i ) const {
285  return dm_.cend( i );
286  }
287  //**********************************************************************************************
288 
289  //**Cend function*******************************************************************************
300  inline ConstIterator cend( size_t i ) const {
301  return dm_.cend( i );
302  }
303  //**********************************************************************************************
304 
305  //**Rows function*******************************************************************************
310  inline size_t rows() const noexcept {
311  return dm_.columns();
312  }
313  //**********************************************************************************************
314 
315  //**Columns function****************************************************************************
320  inline size_t columns() const noexcept {
321  return dm_.rows();
322  }
323  //**********************************************************************************************
324 
325  //**Spacing function****************************************************************************
330  inline size_t spacing() const noexcept {
331  return dm_.spacing();
332  }
333  //**********************************************************************************************
334 
335  //**Reset function******************************************************************************
340  inline void reset() {
341  return dm_.reset();
342  }
343  //**********************************************************************************************
344 
345  //**IsIntact function***************************************************************************
350  inline bool isIntact() const noexcept {
351  using blaze::isIntact;
352  return isIntact( dm_ );
353  }
354  //**********************************************************************************************
355 
356  //**CanAliased function*************************************************************************
362  template< typename Other > // Data type of the foreign expression
363  inline bool canAlias( const Other* alias ) const noexcept
364  {
365  return dm_.canAlias( alias );
366  }
367  //**********************************************************************************************
368 
369  //**IsAliased function**************************************************************************
375  template< typename Other > // Data type of the foreign expression
376  inline bool isAliased( const Other* alias ) const noexcept
377  {
378  return dm_.isAliased( alias );
379  }
380  //**********************************************************************************************
381 
382  //**IsAligned function**************************************************************************
387  inline bool isAligned() const noexcept
388  {
389  return dm_.isAligned();
390  }
391  //**********************************************************************************************
392 
393  //**CanSMPAssign function***********************************************************************
398  inline bool canSMPAssign() const noexcept
399  {
400  return dm_.canSMPAssign();
401  }
402  //**********************************************************************************************
403 
404  //**Load function*******************************************************************************
415  BLAZE_ALWAYS_INLINE SIMDType load( size_t i, size_t j ) const noexcept
416  {
417  return dm_.load( j, i );
418  }
419  //**********************************************************************************************
420 
421  //**Loada function******************************************************************************
432  BLAZE_ALWAYS_INLINE SIMDType loada( size_t i, size_t j ) const noexcept
433  {
434  return dm_.loada( j, i );
435  }
436  //**********************************************************************************************
437 
438  //**Loadu function******************************************************************************
449  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t i, size_t j ) const noexcept
450  {
451  return dm_.loadu( j, i );
452  }
453  //**********************************************************************************************
454 
455  //**Store function******************************************************************************
467  BLAZE_ALWAYS_INLINE void store( size_t i, size_t j, const SIMDType& value ) noexcept
468  {
469  dm_.store( j, i, value );
470  }
471  //**********************************************************************************************
472 
473  //**Storea function******************************************************************************
485  BLAZE_ALWAYS_INLINE void storea( size_t i, size_t j, const SIMDType& value ) noexcept
486  {
487  dm_.storea( j, i, value );
488  }
489  //**********************************************************************************************
490 
491  //**Storeu function*****************************************************************************
503  BLAZE_ALWAYS_INLINE void storeu( size_t i, size_t j, const SIMDType& value ) noexcept
504  {
505  dm_.storeu( j, i, value );
506  }
507  //**********************************************************************************************
508 
509  //**Stream function*****************************************************************************
521  BLAZE_ALWAYS_INLINE void stream( size_t i, size_t j, const SIMDType& value ) noexcept
522  {
523  dm_.stream( j, i, value );
524  }
525  //**********************************************************************************************
526 
527  //**Transpose assignment of matrices************************************************************
538  template< typename MT2 // Type of the right-hand side matrix
539  , bool SO2 > // Storage order of the right-hand side matrix
540  inline void assign( const Matrix<MT2,SO2>& rhs )
541  {
542  dm_.assign( trans( ~rhs ) );
543  }
544  //**********************************************************************************************
545 
546  //**Transpose addition assignment of matrices***************************************************
557  template< typename MT2 // Type of the right-hand side matrix
558  , bool SO2 > // Storage order of the right-hand side matrix
559  inline void addAssign( const Matrix<MT2,SO2>& rhs )
560  {
561  dm_.addAssign( trans( ~rhs ) );
562  }
563  //**********************************************************************************************
564 
565  //**Transpose subtraction assignment of matrices************************************************
576  template< typename MT2 // Type of the right-hand side matrix
577  , bool SO2 > // Storage order of the right-hand side matrix
578  inline void subAssign( const Matrix<MT2,SO2>& rhs )
579  {
580  dm_.subAssign( trans( ~rhs ) );
581  }
582  //**********************************************************************************************
583 
584  //**Transpose Schur product assignment of matrices**********************************************
595  template< typename MT2 // Type of the right-hand side matrix
596  , bool SO2 > // Storage order of the right-hand side matrix
597  inline void schurAssign( const Matrix<MT2,SO2>& rhs )
598  {
599  dm_.schurAssign( trans( ~rhs ) );
600  }
601  //**********************************************************************************************
602 
603  //**Transpose multiplication assignment of matrices*********************************************
604  // No special implementation for the transpose multiplication assignment of matrices.
605  //**********************************************************************************************
606 
607  private:
608  //**Member variables****************************************************************************
609  MT& dm_;
610  //**********************************************************************************************
611 
612  //**Compile time checks*************************************************************************
617  //**********************************************************************************************
618 };
619 //*************************************************************************************************
620 
621 
622 
623 
624 //=================================================================================================
625 //
626 // GLOBAL OPERATORS
627 //
628 //=================================================================================================
629 
630 //*************************************************************************************************
638 template< typename MT // Type of the dense matrix
639  , bool SO > // Storage order
640 inline void reset( DMatTransposer<MT,SO>& m )
641 {
642  m.reset();
643 }
645 //*************************************************************************************************
646 
647 
648 //*************************************************************************************************
656 template< typename MT // Type of the dense matrix
657  , bool SO > // Storage order
658 inline bool isIntact( const DMatTransposer<MT,SO>& m ) noexcept
659 {
660  return m.isIntact();
661 }
663 //*************************************************************************************************
664 
665 
666 
667 
668 //=================================================================================================
669 //
670 // SIZE SPECIALIZATIONS
671 //
672 //=================================================================================================
673 
674 //*************************************************************************************************
676 template< typename MT, bool SO >
677 struct Size< DMatTransposer<MT,SO>, 0UL >
678  : public Size<MT,0UL>
679 {};
680 
681 template< typename MT, bool SO >
682 struct Size< DMatTransposer<MT,SO>, 1UL >
683  : public Size<MT,1UL>
684 {};
686 //*************************************************************************************************
687 
688 
689 
690 
691 //=================================================================================================
692 //
693 // MAXSIZE SPECIALIZATIONS
694 //
695 //=================================================================================================
696 
697 //*************************************************************************************************
699 template< typename MT, bool SO >
700 struct MaxSize< DMatTransposer<MT,SO>, 0UL >
701  : public MaxSize<MT,0UL>
702 {};
703 
704 template< typename MT, bool SO >
705 struct MaxSize< DMatTransposer<MT,SO>, 1UL >
706  : public MaxSize<MT,1UL>
707 {};
709 //*************************************************************************************************
710 
711 
712 
713 
714 //=================================================================================================
715 //
716 // HASCONSTDATAACCESS SPECIALIZATIONS
717 //
718 //=================================================================================================
719 
720 //*************************************************************************************************
722 template< typename MT, bool SO >
723 struct HasConstDataAccess< DMatTransposer<MT,SO> >
724  : public HasConstDataAccess<MT>
725 {};
727 //*************************************************************************************************
728 
729 
730 
731 
732 //=================================================================================================
733 //
734 // HASMUTABLEDATAACCESS SPECIALIZATIONS
735 //
736 //=================================================================================================
737 
738 //*************************************************************************************************
740 template< typename MT, bool SO >
741 struct HasMutableDataAccess< DMatTransposer<MT,SO> >
742  : public HasMutableDataAccess<MT>
743 {};
745 //*************************************************************************************************
746 
747 
748 
749 
750 //=================================================================================================
751 //
752 // ISALIGNED SPECIALIZATIONS
753 //
754 //=================================================================================================
755 
756 //*************************************************************************************************
758 template< typename MT, bool SO >
759 struct IsAligned< DMatTransposer<MT,SO> >
760  : public IsAligned<MT>
761 {};
763 //*************************************************************************************************
764 
765 
766 
767 
768 //=================================================================================================
769 //
770 // ISCONTIGUOUS SPECIALIZATIONS
771 //
772 //=================================================================================================
773 
774 //*************************************************************************************************
776 template< typename MT, bool SO >
777 struct IsContiguous< DMatTransposer<MT,SO> >
778  : public IsContiguous<MT>
779 {};
781 //*************************************************************************************************
782 
783 
784 
785 
786 //=================================================================================================
787 //
788 // ISPADDED SPECIALIZATIONS
789 //
790 //=================================================================================================
791 
792 //*************************************************************************************************
794 template< typename MT, bool SO >
795 struct IsPadded< DMatTransposer<MT,SO> >
796  : public IsPadded<MT>
797 {};
799 //*************************************************************************************************
800 
801 } // namespace blaze
802 
803 #endif
Constraint on the data type.
TransposeType_t< MT > ResultType
Result type for expression template evaluations.
Definition: DMatTransposer.h:84
BLAZE_ALWAYS_INLINE void storea(size_t i, size_t j, const SIMDType &value) noexcept
Aligned store of a SIMD element of the matrix.
Definition: DMatTransposer.h:485
Header file for auxiliary alias declarations.
void assign(const Matrix< MT2, SO2 > &rhs)
Implementation of the transpose assignment of a matrix.
Definition: DMatTransposer.h:540
ReturnType_t< MT > ReturnType
Return type for expression template evaluations.
Definition: DMatTransposer.h:89
BLAZE_ALWAYS_INLINE void storeu(size_t i, size_t j, const SIMDType &value) noexcept
Unaligned store of a SIMD element of the matrix.
Definition: DMatTransposer.h:503
ConstIterator cend(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: DMatTransposer.h:300
Header file for basic type definitions.
DMatTransposer(MT &dm) noexcept
Constructor for the DMatTransposer class.
Definition: DMatTransposer.h:118
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
typename T::Reference Reference_t
Alias declaration for nested Reference type definitions.The Reference_t alias declaration provides a ...
Definition: Aliases.h:330
#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
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type,...
Definition: DenseMatrix.h:61
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: DMatTransposer.h:236
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
typename SIMDTrait< T >::Type SIMDTrait_t
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_t alias declaration provid...
Definition: SIMDTrait.h:315
bool canAlias(const Other *alias) const noexcept
Returns whether the matrix can alias with the given address alias.
Definition: DMatTransposer.h:363
SIMDTrait_t< ElementType > SIMDType
SIMD type of the matrix elements.
Definition: DMatTransposer.h:88
void schurAssign(const Matrix< MT2, SO2 > &rhs)
Implementation of the transpose Schur product assignment of a matrix.
Definition: DMatTransposer.h:597
Iterator_t< MT > Iterator
Iterator over non-constant elements.
Definition: DMatTransposer.h:95
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.The ReturnType_t alias declaration provides ...
Definition: Aliases.h:410
Header file for the SIMD trait.
Header file for the MaxSize type trait.
Pointer data() noexcept
Low-level data access to the matrix elements.
Definition: DMatTransposer.h:194
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes....
Definition: DenseMatrix.h:81
typename T::Pointer Pointer_t
Alias declaration for nested Pointer type definitions.The Pointer_t alias declaration provides a conv...
Definition: Aliases.h:290
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
ConstReference operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatTransposer.h:144
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: DMatTransposer.h:284
BLAZE_ALWAYS_INLINE SIMDType load(size_t i, size_t j) const noexcept
Load of a SIMD element of the matrix.
Definition: DMatTransposer.h:415
Constraint on the data type.
BLAZE_ALWAYS_INLINE SIMDType loada(size_t i, size_t j) const noexcept
Aligned load of a SIMD element of the matrix.
Definition: DMatTransposer.h:432
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
ElementType_t< MT > ElementType
Type of the matrix elements.
Definition: DMatTransposer.h:87
ConstPointer data() const noexcept
Low-level data access to the matrix elements.
Definition: DMatTransposer.h:204
Reference operator()(size_t i, size_t j)
2D-access to the matrix elements.
Definition: DMatTransposer.h:130
#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
Header file for the DenseMatrix base class.
void subAssign(const Matrix< MT2, SO2 > &rhs)
Implementation of the transpose subtraction assignment of a matrix.
Definition: DMatTransposer.h:578
size_t spacing() const noexcept
Returns the spacing between the beginning of two rows.
Definition: DMatTransposer.h:330
Expression object for the transposition of a dense matrix.The DMatTransposer class is a wrapper objec...
Definition: DMatTransposer.h:77
bool canSMPAssign() const noexcept
Returns whether the matrix can be used in SMP assignments.
Definition: DMatTransposer.h:398
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatTransposer.h:310
MT & dm_
The dense matrix operand.
Definition: DMatTransposer.h:609
Header file for the IsAligned type trait.
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatTransposer.h:320
Header file for the exception macros of the math module.
static constexpr bool simdEnabled
Compilation flag for SIMD optimization.
Definition: DMatTransposer.h:104
void reset()
Resets the matrix elements.
Definition: DMatTransposer.h:340
BLAZE_ALWAYS_INLINE void store(size_t i, size_t j, const SIMDType &value) noexcept
Store of a SIMD element of the matrix.
Definition: DMatTransposer.h:467
BLAZE_ALWAYS_INLINE void stream(size_t i, size_t j, const SIMDType &value) noexcept
Aligned, non-temporal store of a SIMD element of the matrix.
Definition: DMatTransposer.h:521
Header file for the IsPadded type trait.
Reference_t< MT > Reference
Reference to a non-constant matrix value.
Definition: DMatTransposer.h:91
ConstPointer_t< MT > ConstPointer
Pointer to a constant matrix value.
Definition: DMatTransposer.h:94
ResultType_t< MT > TransposeType
Transpose type for expression template evaluations.
Definition: DMatTransposer.h:86
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.The OppositeType_t alias declaration provi...
Definition: Aliases.h:270
Header file for the HasConstDataAccess type trait.
typename T::Iterator Iterator_t
Alias declaration for nested Iterator type definitions.The Iterator_t alias declaration provides a co...
Definition: Aliases.h:190
ConstIterator cbegin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: DMatTransposer.h:252
void addAssign(const Matrix< MT2, SO2 > &rhs)
Implementation of the transpose addition assignment of a matrix.
Definition: DMatTransposer.h:559
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.The TransposeType_t alias declaration pro...
Definition: Aliases.h:470
Header file for run time assertion macros.
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: DMatTransposer.h:110
Header file for the IsContiguous type trait.
typename T::ConstPointer ConstPointer_t
Alias declaration for nested ConstPointer type definitions.The ConstPointer_t alias declaration provi...
Definition: Aliases.h:130
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:114
typename T::ConstReference ConstReference_t
Alias declaration for nested ConstReference type definitions.The ConstReference_t alias declaration p...
Definition: Aliases.h:150
Header file for the HasMutableDataAccess type trait.
bool isAliased(const Other *alias) const noexcept
Returns whether the matrix is aliased with the given address alias.
Definition: DMatTransposer.h:376
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.The ConstIterator_t alias declaration pro...
Definition: Aliases.h:110
ConstIterator_t< MT > ConstIterator
Iterator over constant elements.
Definition: DMatTransposer.h:96
OppositeType_t< MT > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatTransposer.h:85
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
ConstReference_t< MT > ConstReference
Reference to a constant matrix value.
Definition: DMatTransposer.h:92
Reference at(size_t i, size_t j)
Checked access to the matrix elements.
Definition: DMatTransposer.h:159
Iterator begin(size_t i)
Returns an iterator to the first non-zero element of row/column i.
Definition: DMatTransposer.h:220
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
Pointer_t< MT > Pointer
Pointer to a non-constant matrix value.
Definition: DMatTransposer.h:93
ConstReference at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatTransposer.h:178
System settings for the inline keywords.
Header file for the Size type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
Definition: Assert.h:101
bool isAligned() const noexcept
Returns whether the matrix is properly aligned in memory.
Definition: DMatTransposer.h:387
Iterator end(size_t i)
Returns an iterator just past the last non-zero element of row/column i.
Definition: DMatTransposer.h:268
bool isIntact() const noexcept
Returns whether the invariants of the matrix are intact.
Definition: DMatTransposer.h:350
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t i, size_t j) const noexcept
Unaligned load of a SIMD element of the matrix.
Definition: DMatTransposer.h:449