Blaze 3.9
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>
56#include <blaze/system/Inline.h>
57#include <blaze/util/Assert.h>
58#include <blaze/util/Types.h>
59
60
61namespace blaze {
62
63//=================================================================================================
64//
65// CLASS DMATTRANSPOSER
66//
67//=================================================================================================
68
69//*************************************************************************************************
75template< 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 //**Resize function*****************************************************************************
353 inline void resize( size_t m, size_t n, bool preserve=true ) {
354 dm_.resize( m, n, preserve );
355 }
356 //**********************************************************************************************
357
358 //**IsIntact function***************************************************************************
363 inline bool isIntact() const noexcept {
364 using blaze::isIntact;
365 return isIntact( dm_ );
366 }
367 //**********************************************************************************************
368
369 //**CanAliased function*************************************************************************
375 template< typename Other > // Data type of the foreign expression
376 inline bool canAlias( const Other* alias ) const noexcept
377 {
378 return dm_.canAlias( alias );
379 }
380 //**********************************************************************************************
381
382 //**IsAliased function**************************************************************************
388 template< typename Other > // Data type of the foreign expression
389 inline bool isAliased( const Other* alias ) const noexcept
390 {
391 return dm_.isAliased( alias );
392 }
393 //**********************************************************************************************
394
395 //**IsAligned function**************************************************************************
400 inline bool isAligned() const noexcept
401 {
402 return dm_.isAligned();
403 }
404 //**********************************************************************************************
405
406 //**CanSMPAssign function***********************************************************************
411 inline bool canSMPAssign() const noexcept
412 {
413 return dm_.canSMPAssign();
414 }
415 //**********************************************************************************************
416
417 //**Load function*******************************************************************************
428 BLAZE_ALWAYS_INLINE SIMDType load( size_t i, size_t j ) const noexcept
429 {
430 return dm_.load( j, i );
431 }
432 //**********************************************************************************************
433
434 //**Loada function******************************************************************************
445 BLAZE_ALWAYS_INLINE SIMDType loada( size_t i, size_t j ) const noexcept
446 {
447 return dm_.loada( j, i );
448 }
449 //**********************************************************************************************
450
451 //**Loadu function******************************************************************************
462 BLAZE_ALWAYS_INLINE SIMDType loadu( size_t i, size_t j ) const noexcept
463 {
464 return dm_.loadu( j, i );
465 }
466 //**********************************************************************************************
467
468 //**Store function******************************************************************************
480 BLAZE_ALWAYS_INLINE void store( size_t i, size_t j, const SIMDType& value ) noexcept
481 {
482 dm_.store( j, i, value );
483 }
484 //**********************************************************************************************
485
486 //**Storea function******************************************************************************
498 BLAZE_ALWAYS_INLINE void storea( size_t i, size_t j, const SIMDType& value ) noexcept
499 {
500 dm_.storea( j, i, value );
501 }
502 //**********************************************************************************************
503
504 //**Storeu function*****************************************************************************
516 BLAZE_ALWAYS_INLINE void storeu( size_t i, size_t j, const SIMDType& value ) noexcept
517 {
518 dm_.storeu( j, i, value );
519 }
520 //**********************************************************************************************
521
522 //**Stream function*****************************************************************************
534 BLAZE_ALWAYS_INLINE void stream( size_t i, size_t j, const SIMDType& value ) noexcept
535 {
536 dm_.stream( j, i, value );
537 }
538 //**********************************************************************************************
539
540 //**Transpose assignment of matrices************************************************************
551 template< typename MT2 // Type of the right-hand side matrix
552 , bool SO2 > // Storage order of the right-hand side matrix
553 inline void assign( const Matrix<MT2,SO2>& rhs )
554 {
555 dm_.assign( trans( *rhs ) );
556 }
557 //**********************************************************************************************
558
559 //**Transpose addition assignment of matrices***************************************************
570 template< typename MT2 // Type of the right-hand side matrix
571 , bool SO2 > // Storage order of the right-hand side matrix
572 inline void addAssign( const Matrix<MT2,SO2>& rhs )
573 {
574 dm_.addAssign( trans( *rhs ) );
575 }
576 //**********************************************************************************************
577
578 //**Transpose subtraction assignment of matrices************************************************
589 template< typename MT2 // Type of the right-hand side matrix
590 , bool SO2 > // Storage order of the right-hand side matrix
591 inline void subAssign( const Matrix<MT2,SO2>& rhs )
592 {
593 dm_.subAssign( trans( *rhs ) );
594 }
595 //**********************************************************************************************
596
597 //**Transpose Schur product assignment of matrices**********************************************
608 template< typename MT2 // Type of the right-hand side matrix
609 , bool SO2 > // Storage order of the right-hand side matrix
610 inline void schurAssign( const Matrix<MT2,SO2>& rhs )
611 {
612 dm_.schurAssign( trans( *rhs ) );
613 }
614 //**********************************************************************************************
615
616 //**Transpose multiplication assignment of matrices*********************************************
617 // No special implementation for the transpose multiplication assignment of matrices.
618 //**********************************************************************************************
619
620 private:
621 //**Member variables****************************************************************************
622 MT& dm_;
623 //**********************************************************************************************
624
625 //**Compile time checks*************************************************************************
630 //**********************************************************************************************
631};
632//*************************************************************************************************
633
634
635
636
637//=================================================================================================
638//
639// GLOBAL OPERATORS
640//
641//=================================================================================================
642
643//*************************************************************************************************
651template< typename MT // Type of the dense matrix
652 , bool SO > // Storage order
653inline bool isIntact( const DMatTransposer<MT,SO>& m ) noexcept
654{
655 return m.isIntact();
656}
658//*************************************************************************************************
659
660
661
662
663//=================================================================================================
664//
665// SIZE SPECIALIZATIONS
666//
667//=================================================================================================
668
669//*************************************************************************************************
671template< typename MT, bool SO >
672struct Size< DMatTransposer<MT,SO>, 0UL >
673 : public Size<MT,0UL>
674{};
675
676template< typename MT, bool SO >
677struct Size< DMatTransposer<MT,SO>, 1UL >
678 : public Size<MT,1UL>
679{};
681//*************************************************************************************************
682
683
684
685
686//=================================================================================================
687//
688// MAXSIZE SPECIALIZATIONS
689//
690//=================================================================================================
691
692//*************************************************************************************************
694template< typename MT, bool SO >
695struct MaxSize< DMatTransposer<MT,SO>, 0UL >
696 : public MaxSize<MT,0UL>
697{};
698
699template< typename MT, bool SO >
700struct MaxSize< DMatTransposer<MT,SO>, 1UL >
701 : public MaxSize<MT,1UL>
702{};
704//*************************************************************************************************
705
706
707
708
709//=================================================================================================
710//
711// HASCONSTDATAACCESS SPECIALIZATIONS
712//
713//=================================================================================================
714
715//*************************************************************************************************
717template< typename MT, bool SO >
718struct HasConstDataAccess< DMatTransposer<MT,SO> >
719 : public HasConstDataAccess<MT>
720{};
722//*************************************************************************************************
723
724
725
726
727//=================================================================================================
728//
729// HASMUTABLEDATAACCESS SPECIALIZATIONS
730//
731//=================================================================================================
732
733//*************************************************************************************************
735template< typename MT, bool SO >
736struct HasMutableDataAccess< DMatTransposer<MT,SO> >
737 : public HasMutableDataAccess<MT>
738{};
740//*************************************************************************************************
741
742
743
744
745//=================================================================================================
746//
747// ISALIGNED SPECIALIZATIONS
748//
749//=================================================================================================
750
751//*************************************************************************************************
753template< typename MT, bool SO >
754struct IsAligned< DMatTransposer<MT,SO> >
755 : public IsAligned<MT>
756{};
758//*************************************************************************************************
759
760
761
762
763//=================================================================================================
764//
765// ISCONTIGUOUS SPECIALIZATIONS
766//
767//=================================================================================================
768
769//*************************************************************************************************
771template< typename MT, bool SO >
772struct IsContiguous< DMatTransposer<MT,SO> >
773 : public IsContiguous<MT>
774{};
776//*************************************************************************************************
777
778
779
780
781//=================================================================================================
782//
783// ISPADDED SPECIALIZATIONS
784//
785//=================================================================================================
786
787//*************************************************************************************************
789template< typename MT, bool SO >
790struct IsPadded< DMatTransposer<MT,SO> >
791 : public IsPadded<MT>
792{};
794//*************************************************************************************************
795
796} // namespace blaze
797
798#endif
Header file for auxiliary alias declarations.
typename T::ConstReference ConstReference_t
Alias declaration for nested ConstReference type definitions.
Definition: Aliases.h:170
typename T::Pointer Pointer_t
Alias declaration for nested Pointer type definitions.
Definition: Aliases.h:330
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.
Definition: Aliases.h:470
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition: Aliases.h:450
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
typename T::Iterator Iterator_t
Alias declaration for nested Iterator type definitions.
Definition: Aliases.h:210
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.
Definition: Aliases.h:310
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.
Definition: Aliases.h:130
typename T::Reference Reference_t
Alias declaration for nested Reference type definitions.
Definition: Aliases.h:390
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition: Aliases.h:550
typename T::ConstPointer ConstPointer_t
Alias declaration for nested ConstPointer type definitions.
Definition: Aliases.h:150
Header file for run time assertion macros.
Header file for the HasConstDataAccess type trait.
Header file for the HasMutableDataAccess type trait.
Header file for the IsAligned type trait.
Header file for the IsContiguous type trait.
Header file for the IsPadded type trait.
Header file for the MaxSize type trait.
Header file for the SIMD trait.
Expression object for the transposition of a dense matrix.
Definition: DMatTransposer.h:79
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatTransposer.h:320
MT & dm_
The dense matrix operand.
Definition: DMatTransposer.h:622
void addAssign(const Matrix< MT2, SO2 > &rhs)
Implementation of the transpose addition assignment of a matrix.
Definition: DMatTransposer.h:572
void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the matrix.
Definition: DMatTransposer.h:353
bool isIntact() const noexcept
Returns whether the invariants of the matrix are intact.
Definition: DMatTransposer.h:363
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: DMatTransposer.h:284
ReturnType_t< MT > ReturnType
Return type for expression template evaluations.
Definition: DMatTransposer.h:89
Pointer data() noexcept
Low-level data access to the matrix elements.
Definition: DMatTransposer.h:194
ConstIterator cbegin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: DMatTransposer.h:252
TransposeType_t< MT > ResultType
Result type for expression template evaluations.
Definition: DMatTransposer.h:84
void assign(const Matrix< MT2, SO2 > &rhs)
Implementation of the transpose assignment of a matrix.
Definition: DMatTransposer.h:553
ConstPointer data() const noexcept
Low-level data access to the matrix elements.
Definition: DMatTransposer.h:204
DMatTransposer(MT &dm) noexcept
Constructor for the DMatTransposer class.
Definition: DMatTransposer.h:118
Pointer_t< MT > Pointer
Pointer to a non-constant matrix value.
Definition: DMatTransposer.h:93
Reference operator()(size_t i, size_t j)
2D-access to the matrix elements.
Definition: DMatTransposer.h:130
Iterator_t< MT > Iterator
Iterator over non-constant elements.
Definition: DMatTransposer.h:95
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: DMatTransposer.h:110
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:462
bool isAliased(const Other *alias) const noexcept
Returns whether the matrix is aliased with the given address alias.
Definition: DMatTransposer.h:389
void subAssign(const Matrix< MT2, SO2 > &rhs)
Implementation of the transpose subtraction assignment of a matrix.
Definition: DMatTransposer.h:591
Reference_t< MT > Reference
Reference to a non-constant matrix value.
Definition: DMatTransposer.h:91
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:498
size_t spacing() const noexcept
Returns the spacing between the beginning of two rows.
Definition: DMatTransposer.h:330
void schurAssign(const Matrix< MT2, SO2 > &rhs)
Implementation of the transpose Schur product assignment of a matrix.
Definition: DMatTransposer.h:610
OppositeType_t< MT > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatTransposer.h:85
SIMDTrait_t< ElementType > SIMDType
SIMD type of the matrix elements.
Definition: DMatTransposer.h:88
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatTransposer.h:310
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:516
ConstReference_t< MT > ConstReference
Reference to a constant matrix value.
Definition: DMatTransposer.h:92
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:480
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:534
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: DMatTransposer.h:236
ConstPointer_t< MT > ConstPointer
Pointer to a constant matrix value.
Definition: DMatTransposer.h:94
static constexpr bool simdEnabled
Compilation flag for SIMD optimization.
Definition: DMatTransposer.h:104
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:445
Iterator end(size_t i)
Returns an iterator just past the last non-zero element of row/column i.
Definition: DMatTransposer.h:268
bool isAligned() const noexcept
Returns whether the matrix is properly aligned in memory.
Definition: DMatTransposer.h:400
bool canAlias(const Other *alias) const noexcept
Returns whether the matrix can alias with the given address alias.
Definition: DMatTransposer.h:376
bool canSMPAssign() const noexcept
Returns whether the matrix can be used in SMP assignments.
Definition: DMatTransposer.h:411
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
ConstReference at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatTransposer.h:178
ResultType_t< MT > TransposeType
Transpose type for expression template evaluations.
Definition: DMatTransposer.h:86
ConstReference operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatTransposer.h:144
void reset()
Resets the matrix elements.
Definition: DMatTransposer.h:340
ElementType_t< MT > ElementType
Type of the matrix elements.
Definition: DMatTransposer.h:87
BLAZE_ALWAYS_INLINE SIMDType load(size_t i, size_t j) const noexcept
Load of a SIMD element of the matrix.
Definition: DMatTransposer.h:428
ConstIterator cend(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: DMatTransposer.h:300
ConstIterator_t< MT > ConstIterator
Iterator over constant elements.
Definition: DMatTransposer.h:96
Base class for dense matrices.
Definition: DenseMatrix.h:82
Base class for matrices.
Definition: Matrix.h:85
Constraint on the data type.
Constraint on the data type.
Header file for the DenseMatrix base class.
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:766
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:207
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: DenseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.
Definition: Computation.h:81
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
typename SIMDTrait< T >::Type SIMDTrait_t
Auxiliary alias declaration for the SIMDTrait class template.
Definition: SIMDTrait.h:315
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition: Exception.h:331
Header file for the exception macros of the math module.
Header file for the Size type trait.
System settings for the inline keywords.
Header file for basic type definitions.