DVecTransposer.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_DVECTRANSPOSER_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DVECTRANSPOSER_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
47 #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 DVECTRANSPOSER
66 //
67 //=================================================================================================
68 
69 //*************************************************************************************************
75 template< typename VT // Type of the dense vector
76  , bool TF > // Transpose flag
78  : public DenseVector< DVecTransposer<VT,TF>, TF >
79 {
80  public:
81  //**Type definitions****************************************************************************
88  using CompositeType = const This&;
95  //**********************************************************************************************
96 
97  //**Compilation flags***************************************************************************
99 
102  enum : bool { simdEnabled = VT::simdEnabled };
103 
105 
108  enum : bool { smpAssignable = VT::smpAssignable };
109  //**********************************************************************************************
110 
111  //**Constructor*********************************************************************************
116  explicit inline DVecTransposer( VT& dv ) noexcept
117  : dv_( dv ) // The dense vector operand
118  {}
119  //**********************************************************************************************
120 
121  //**Subscript operator**************************************************************************
127  inline Reference operator[]( size_t index ) {
128  BLAZE_USER_ASSERT( index < dv_.size(), "Invalid vector access index" );
129  return dv_[index];
130  }
131  //**********************************************************************************************
132 
133  //**Subscript operator**************************************************************************
139  inline ConstReference operator[]( size_t index ) const {
140  BLAZE_USER_ASSERT( index < dv_.size(), "Invalid vector access index" );
141  return const_cast<const VT&>( dv_ )[index];
142  }
143  //**********************************************************************************************
144 
145  //**At function*********************************************************************************
152  inline Reference at( size_t index ) {
153  if( index >= dv_.size() ) {
154  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
155  }
156  return (*this)[index];
157  }
158  //**********************************************************************************************
159 
160  //**At function*********************************************************************************
167  inline ConstReference at( size_t index ) const {
168  if( index >= dv_.size() ) {
169  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
170  }
171  return (*this)[index];
172  }
173  //**********************************************************************************************
174 
175  //**Low-level data access***********************************************************************
180  inline Pointer data() noexcept {
181  return dv_.data();
182  }
183  //**********************************************************************************************
184 
185  //**Low-level data access***********************************************************************
190  inline ConstPointer data() const noexcept {
191  return dv_.data();
192  }
193  //**********************************************************************************************
194 
195  //**Begin function******************************************************************************
200  inline Iterator begin() {
201  return dv_.begin();
202  }
203  //**********************************************************************************************
204 
205  //**Begin function******************************************************************************
210  inline ConstIterator begin() const {
211  return dv_.cbegin();
212  }
213  //**********************************************************************************************
214 
215  //**Cbegin function*****************************************************************************
220  inline ConstIterator cbegin() const {
221  return dv_.cbegin();
222  }
223  //**********************************************************************************************
224 
225  //**End function********************************************************************************
230  inline Iterator end() {
231  return dv_.end();
232  }
233  //**********************************************************************************************
234 
235  //**End function********************************************************************************
240  inline ConstIterator end() const {
241  return dv_.cend();
242  }
243  //**********************************************************************************************
244 
245  //**Cend function*******************************************************************************
250  inline ConstIterator cend() const {
251  return dv_.cend();
252  }
253  //**********************************************************************************************
254 
255  //**Size function*******************************************************************************
260  inline size_t size() const noexcept {
261  return dv_.size();
262  }
263  //**********************************************************************************************
264 
265  //**Reset function******************************************************************************
270  inline void reset() {
271  return dv_.reset();
272  }
273  //**********************************************************************************************
274 
275  //**IsIntact function***************************************************************************
280  inline bool isIntact() const noexcept
281  {
282  using blaze::isIntact;
283  return isIntact( dv_ );
284  }
285  //**********************************************************************************************
286 
287  //**CanAliased function*************************************************************************
293  template< typename Other > // Data type of the foreign expression
294  inline bool canAlias( const Other* alias ) const noexcept
295  {
296  return dv_.canAlias( alias );
297  }
298  //**********************************************************************************************
299 
300  //**IsAliased function**************************************************************************
306  template< typename Other > // Data type of the foreign expression
307  inline bool isAliased( const Other* alias ) const noexcept
308  {
309  return dv_.isAliased( alias );
310  }
311  //**********************************************************************************************
312 
313  //**IsAligned function**************************************************************************
318  inline bool isAligned() const noexcept
319  {
320  return dv_.isAligned();
321  }
322  //**********************************************************************************************
323 
324  //**CanSMPAssign function***********************************************************************
329  inline bool canSMPAssign() const noexcept
330  {
331  return dv_.canSMPAssign();
332  }
333  //**********************************************************************************************
334 
335  //**Load function*******************************************************************************
345  BLAZE_ALWAYS_INLINE SIMDType load( size_t index ) const noexcept
346  {
347  return dv_.load( index );
348  }
349  //**********************************************************************************************
350 
351  //**Loada function******************************************************************************
361  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept
362  {
363  return dv_.loada( index );
364  }
365  //**********************************************************************************************
366 
367  //**Loadu function******************************************************************************
377  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept
378  {
379  return dv_.loadu( index );
380  }
381  //**********************************************************************************************
382 
383  //**Store function******************************************************************************
394  BLAZE_ALWAYS_INLINE void store( size_t index, const SIMDType& value ) noexcept
395  {
396  dv_.store( index, value );
397  }
398  //**********************************************************************************************
399 
400  //**Storea function******************************************************************************
411  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept
412  {
413  dv_.storea( index, value );
414  }
415  //**********************************************************************************************
416 
417  //**Storeu function*****************************************************************************
428  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept
429  {
430  dv_.storeu( index, value );
431  }
432  //**********************************************************************************************
433 
434  //**Stream function*****************************************************************************
445  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept
446  {
447  dv_.stream( index, value );
448  }
449  //**********************************************************************************************
450 
451  //**Transpose assignment of vectors*************************************************************
462  template< typename VT2 > // Type of the right-hand side vector
463  inline void assign( const Vector<VT2,TF>& rhs )
464  {
466 
467  dv_.assign( trans( ~rhs ) );
468  }
469  //**********************************************************************************************
470 
471  //**Transpose addition assignment of vectors****************************************************
482  template< typename VT2 > // Type of the right-hand side vector
483  inline void addAssign( const Vector<VT2,TF>& rhs )
484  {
486 
487  dv_.addAssign( trans( ~rhs ) );
488  }
489  //**********************************************************************************************
490 
491  //**Transpose subtraction assignment of vectors*************************************************
502  template< typename VT2 > // Type of the right-hand side vector
503  inline void subAssign( const Vector<VT2,TF>& rhs )
504  {
506 
507  dv_.subAssign( trans( ~rhs ) );
508  }
509  //**********************************************************************************************
510 
511  //**Transpose multiplication assignment of vectors**********************************************
522  template< typename VT2 > // Type of the right-hand side vector
523  inline void multAssign( const Vector<VT2,TF>& rhs )
524  {
526 
527  dv_.multAssign( trans( ~rhs ) );
528  }
529  //**********************************************************************************************
530 
531  //**Transpose division assignment of dense vectors**********************************************
542  template< typename VT2 > // Type of the right-hand side dense vector
543  inline void divAssign( const DenseVector<VT2,TF>& rhs )
544  {
546 
547  dv_.divAssign( trans( ~rhs ) );
548  }
549  //**********************************************************************************************
550 
551  private:
552  //**Member variables****************************************************************************
553  VT& dv_;
554  //**********************************************************************************************
555 
556  //**Compile time checks*************************************************************************
562  //**********************************************************************************************
563 };
564 //*************************************************************************************************
565 
566 
567 
568 
569 //=================================================================================================
570 //
571 // GLOBAL OPERATORS
572 //
573 //=================================================================================================
574 
575 //*************************************************************************************************
583 template< typename VT // Type of the dense vector
584  , bool TF > // Transpose flag
585 inline void reset( DVecTransposer<VT,TF>& v )
586 {
587  v.reset();
588 }
590 //*************************************************************************************************
591 
592 
593 //*************************************************************************************************
601 template< typename VT // Type of the dense vector
602  , bool TF > // Transpose flag
603 inline bool isIntact( const DVecTransposer<VT,TF>& v ) noexcept
604 {
605  return v.isIntact();
606 }
608 //*************************************************************************************************
609 
610 
611 
612 
613 //=================================================================================================
614 //
615 // HASCONSTDATAACCESS SPECIALIZATIONS
616 //
617 //=================================================================================================
618 
619 //*************************************************************************************************
621 template< typename VT, bool TF >
622 struct HasConstDataAccess< DVecTransposer<VT,TF> >
623  : public HasConstDataAccess<VT>
624 {};
626 //*************************************************************************************************
627 
628 
629 
630 
631 //=================================================================================================
632 //
633 // HASMUTABLEDATAACCESS SPECIALIZATIONS
634 //
635 //=================================================================================================
636 
637 //*************************************************************************************************
639 template< typename VT, bool TF >
640 struct HasMutableDataAccess< DVecTransposer<VT,TF> >
641  : public HasMutableDataAccess<VT>
642 {};
644 //*************************************************************************************************
645 
646 
647 
648 
649 //=================================================================================================
650 //
651 // ISALIGNED SPECIALIZATIONS
652 //
653 //=================================================================================================
654 
655 //*************************************************************************************************
657 template< typename VT, bool TF >
658 struct IsAligned< DVecTransposer<VT,TF> >
659  : public IsAligned<VT>
660 {};
662 //*************************************************************************************************
663 
664 
665 
666 
667 //=================================================================================================
668 //
669 // ISPADDED SPECIALIZATIONS
670 //
671 //=================================================================================================
672 
673 //*************************************************************************************************
675 template< typename VT, bool TF >
676 struct IsPadded< DVecTransposer<VT,TF> >
677  : public IsPadded<VT>
678 {};
680 //*************************************************************************************************
681 
682 
683 
684 
685 //=================================================================================================
686 //
687 // SUBVECTORTRAIT SPECIALIZATIONS
688 //
689 //=================================================================================================
690 
691 //*************************************************************************************************
693 template< typename VT, bool TF, size_t... CSAs >
694 struct SubvectorTrait< DVecTransposer<VT,TF>, CSAs... >
695 {
696  using Type = SubvectorTrait_< ResultType_< DVecTransposer<VT,TF> >, CSAs... >;
697 };
699 //*************************************************************************************************
700 
701 
702 
703 
704 //=================================================================================================
705 //
706 // ELEMENTSTRAIT SPECIALIZATIONS
707 //
708 //=================================================================================================
709 
710 //*************************************************************************************************
712 template< typename VT, bool TF, size_t... CEAs >
713 struct ElementsTrait< DVecTransposer<VT,TF>, CEAs... >
714 {
715  using Type = ElementsTrait_< ResultType_< DVecTransposer<VT,TF> >, CEAs... >;
716 };
718 //*************************************************************************************************
719 
720 } // namespace blaze
721 
722 #endif
Reference operator[](size_t index)
Subscript operator for the direct access to the vector elements.
Definition: DVecTransposer.h:127
Constraint on the data type.
Iterator begin()
Returns an iterator to the first element of the dense vector.
Definition: DVecTransposer.h:200
Header file for auxiliary alias declarations.
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: DVecTransposer.h:307
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t index) const noexcept
Unaligned load of a SIMD element of the vector.
Definition: DVecTransposer.h:377
Compile time check for low-level access to constant data.This type trait tests whether the given data...
Definition: HasConstDataAccess.h:75
#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
void subAssign(const Vector< VT2, TF > &rhs)
Implementation of the transpose subtraction assignment of a vector.
Definition: DVecTransposer.h:503
void addAssign(const Vector< VT2, TF > &rhs)
Implementation of the transpose addition assignment of a vector.
Definition: DVecTransposer.h:483
Header file for basic type definitions.
bool isAligned() const noexcept
Returns whether the vector is properly aligned in memory.
Definition: DVecTransposer.h:318
#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
ConstPointer data() const noexcept
Low-level data access to the vector elements.
Definition: DVecTransposer.h:190
ConstReference_< VT > ConstReference
Reference to a constant vector value.
Definition: DVecTransposer.h:90
typename SIMDTrait< T >::Type SIMDTrait_
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_ alias declaration provide...
Definition: SIMDTrait.h:316
void multAssign(const Vector< VT2, TF > &rhs)
Implementation of the transpose multiplication assignment of a vector.
Definition: DVecTransposer.h:523
Header file for the DenseVector base class.
BLAZE_ALWAYS_INLINE SIMDType load(size_t index) const noexcept
Load of a SIMD element of the vector.
Definition: DVecTransposer.h:345
typename ElementsTrait< VT, CEAs... >::Type ElementsTrait_
Auxiliary alias declaration for the ElementsTrait type trait.The ElementsTrait_ alias declaration pro...
Definition: ElementsTrait.h:144
SIMDTrait_< ElementType > SIMDType
SIMD type of the vector elements.
Definition: DVecTransposer.h:86
Header file for the SIMD trait.
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:343
Header file for the elements trait.
ConstPointer_< VT > ConstPointer
Pointer to a constant vector value.
Definition: DVecTransposer.h:92
Expression object for the transposition of a dense vector.The DVecTransposer class is a wrapper objec...
Definition: DVecTransposer.h:77
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:363
Base template for the SubvectorTrait class.
Definition: SubvectorTrait.h:109
Compile time check for low-level access to mutable data.This type trait tests whether the given data ...
Definition: HasMutableDataAccess.h:75
Compile time check for the alignment of data types.This type trait tests whether the given data type ...
Definition: IsAligned.h:87
bool canSMPAssign() const noexcept
Returns whether the vector can be used in SMP assignments.
Definition: DVecTransposer.h:329
BLAZE_ALWAYS_INLINE void store(size_t index, const SIMDType &value) noexcept
Store of a SIMD element of the vector.
Definition: DVecTransposer.h:394
typename T::Pointer Pointer_
Alias declaration for nested Pointer type definitions.The Pointer_ alias declaration provides a conve...
Definition: Aliases.h:283
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
DVecTransposer(VT &dv) noexcept
Constructor for the DVecTransposer class.
Definition: DVecTransposer.h:116
Compile time check for data types with padding.This type trait tests whether the given data type empl...
Definition: IsPadded.h:76
#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 subvector trait.
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Reference at(size_t index)
Checked access to the vector elements.
Definition: DVecTransposer.h:152
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
Header file for the IsAligned type trait.
BLAZE_ALWAYS_INLINE void storeu(size_t index, const SIMDType &value) noexcept
Unaligned store of a SIMD element of the vector.
Definition: DVecTransposer.h:428
Constraint on the data type.
ConstIterator cend() const
Returns an iterator just past the last element of the dense vector.
Definition: DVecTransposer.h:250
Constraint on the data type.
Header file for the exception macros of the math module.
Base template for the ElementsTrait class.
Definition: ElementsTrait.h:108
BLAZE_ALWAYS_INLINE void storea(size_t index, const SIMDType &value) noexcept
Aligned store of a SIMD element of the vector.
Definition: DVecTransposer.h:411
typename T::Reference Reference_
Alias declaration for nested Reference type definitions.The Reference_ alias declaration provides a c...
Definition: Aliases.h:303
TransposeType_< VT > ResultType
Result type for expression template evaluations.
Definition: DVecTransposer.h:83
Header file for the IsPadded type trait.
typename SubvectorTrait< VT, CSAs... >::Type SubvectorTrait_
Auxiliary alias declaration for the SubvectorTrait type trait.The SubvectorTrait_ alias declaration p...
Definition: SubvectorTrait.h:145
void reset()
Resets the vector elements.
Definition: DVecTransposer.h:270
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: DVecTransposer.h:361
ConstIterator begin() const
Returns an iterator to the first element of the dense vector.
Definition: DVecTransposer.h:210
Header file for the HasConstDataAccess type trait.
ConstIterator_< VT > ConstIterator
Iterator over constant elements.
Definition: DVecTransposer.h:94
Header file for run time assertion macros.
Iterator end()
Returns an iterator just past the last element of the dense vector.
Definition: DVecTransposer.h:230
BLAZE_ALWAYS_INLINE void stream(size_t index, const SIMDType &value) noexcept
Aligned, non-temporal store of a SIMD element of the vector.
Definition: DVecTransposer.h:445
Pointer data() noexcept
Low-level data access to the vector elements.
Definition: DVecTransposer.h:180
void divAssign(const DenseVector< VT2, TF > &rhs)
Implementation of the transpose division assignment of a dense vector.
Definition: DVecTransposer.h:543
Header file for the HasMutableDataAccess type trait.
typename T::Iterator Iterator_
Alias declaration for nested Iterator type definitions.The Iterator_ alias declaration provides a con...
Definition: Aliases.h:183
typename T::ConstPointer ConstPointer_
Alias declaration for nested ConstPointer type definitions.The ConstPointer_ alias declaration provid...
Definition: Aliases.h:123
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
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:61
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:789
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:177
ConstIterator end() const
Returns an iterator just past the last element of the dense vector.
Definition: DVecTransposer.h:240
ConstReference operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DVecTransposer.h:139
ElementType_< VT > ElementType
Type of the vector elements.
Definition: DVecTransposer.h:85
Reference_< VT > Reference
Reference to a non-constant vector value.
Definition: DVecTransposer.h:89
void assign(const Vector< VT2, TF > &rhs)
Implementation of the transpose assignment of a vector.
Definition: DVecTransposer.h:463
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:254
bool isIntact() const noexcept
Returns whether the invariants of the vector are intact.
Definition: DVecTransposer.h:280
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:423
ResultType_< VT > TransposeType
Transpose type for expression template evaluations.
Definition: DVecTransposer.h:84
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: DVecTransposer.h:294
Pointer_< VT > Pointer
Pointer to a non-constant vector value.
Definition: DVecTransposer.h:91
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DVecTransposer.h:260
System settings for the inline keywords.
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.In case the given data type T is not a dense or sparse vector type and in...
Definition: TransposeFlag.h:63
Iterator_< VT > Iterator
Iterator over non-constant elements.
Definition: DVecTransposer.h:93
ConstReference at(size_t index) const
Checked access to the vector elements.
Definition: DVecTransposer.h:167
ReturnType_< VT > ReturnType
Return type for expression template evaluations.
Definition: DVecTransposer.h:87
VT & dv_
The dense vector operand.
Definition: DVecTransposer.h:553
ConstIterator cbegin() const
Returns an iterator to the first element of the dense vector.
Definition: DVecTransposer.h:220