Blaze  3.6
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>
57 #include <blaze/system/Inline.h>
58 #include <blaze/util/Assert.h>
59 #include <blaze/util/Types.h>
60 
61 
62 namespace blaze {
63 
64 //=================================================================================================
65 //
66 // CLASS DVECTRANSPOSER
67 //
68 //=================================================================================================
69 
70 //*************************************************************************************************
76 template< typename VT // Type of the dense vector
77  , bool TF > // Transpose flag
79  : public DenseVector< DVecTransposer<VT,TF>, TF >
80 {
81  public:
82  //**Type definitions****************************************************************************
90  using CompositeType = const This&;
97  //**********************************************************************************************
98 
99  //**Compilation flags***************************************************************************
101 
104  static constexpr bool simdEnabled = VT::simdEnabled;
105 
107 
110  static constexpr bool smpAssignable = VT::smpAssignable;
111  //**********************************************************************************************
112 
113  //**Constructor*********************************************************************************
118  explicit inline DVecTransposer( VT& dv ) noexcept
119  : dv_( dv ) // The dense vector operand
120  {}
121  //**********************************************************************************************
122 
123  //**Subscript operator**************************************************************************
129  inline Reference operator[]( size_t index ) {
130  BLAZE_USER_ASSERT( index < dv_.size(), "Invalid vector access index" );
131  return dv_[index];
132  }
133  //**********************************************************************************************
134 
135  //**Subscript operator**************************************************************************
141  inline ConstReference operator[]( size_t index ) const {
142  BLAZE_USER_ASSERT( index < dv_.size(), "Invalid vector access index" );
143  return const_cast<const VT&>( dv_ )[index];
144  }
145  //**********************************************************************************************
146 
147  //**At function*********************************************************************************
154  inline Reference at( size_t index ) {
155  if( index >= dv_.size() ) {
156  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
157  }
158  return (*this)[index];
159  }
160  //**********************************************************************************************
161 
162  //**At function*********************************************************************************
169  inline ConstReference at( size_t index ) const {
170  if( index >= dv_.size() ) {
171  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
172  }
173  return (*this)[index];
174  }
175  //**********************************************************************************************
176 
177  //**Low-level data access***********************************************************************
182  inline Pointer data() noexcept {
183  return dv_.data();
184  }
185  //**********************************************************************************************
186 
187  //**Low-level data access***********************************************************************
192  inline ConstPointer data() const noexcept {
193  return dv_.data();
194  }
195  //**********************************************************************************************
196 
197  //**Begin function******************************************************************************
202  inline Iterator begin() {
203  return dv_.begin();
204  }
205  //**********************************************************************************************
206 
207  //**Begin function******************************************************************************
212  inline ConstIterator begin() const {
213  return dv_.cbegin();
214  }
215  //**********************************************************************************************
216 
217  //**Cbegin function*****************************************************************************
222  inline ConstIterator cbegin() const {
223  return dv_.cbegin();
224  }
225  //**********************************************************************************************
226 
227  //**End function********************************************************************************
232  inline Iterator end() {
233  return dv_.end();
234  }
235  //**********************************************************************************************
236 
237  //**End function********************************************************************************
242  inline ConstIterator end() const {
243  return dv_.cend();
244  }
245  //**********************************************************************************************
246 
247  //**Cend function*******************************************************************************
252  inline ConstIterator cend() const {
253  return dv_.cend();
254  }
255  //**********************************************************************************************
256 
257  //**Size function*******************************************************************************
262  inline size_t size() const noexcept {
263  return dv_.size();
264  }
265  //**********************************************************************************************
266 
267  //**Reset function******************************************************************************
272  inline void reset() {
273  return dv_.reset();
274  }
275  //**********************************************************************************************
276 
277  //**IsIntact function***************************************************************************
282  inline bool isIntact() const noexcept
283  {
284  using blaze::isIntact;
285  return isIntact( dv_ );
286  }
287  //**********************************************************************************************
288 
289  //**CanAliased function*************************************************************************
295  template< typename Other > // Data type of the foreign expression
296  inline bool canAlias( const Other* alias ) const noexcept
297  {
298  return dv_.canAlias( alias );
299  }
300  //**********************************************************************************************
301 
302  //**IsAliased function**************************************************************************
308  template< typename Other > // Data type of the foreign expression
309  inline bool isAliased( const Other* alias ) const noexcept
310  {
311  return dv_.isAliased( alias );
312  }
313  //**********************************************************************************************
314 
315  //**IsAligned function**************************************************************************
320  inline bool isAligned() const noexcept
321  {
322  return dv_.isAligned();
323  }
324  //**********************************************************************************************
325 
326  //**CanSMPAssign function***********************************************************************
331  inline bool canSMPAssign() const noexcept
332  {
333  return dv_.canSMPAssign();
334  }
335  //**********************************************************************************************
336 
337  //**Load function*******************************************************************************
347  BLAZE_ALWAYS_INLINE SIMDType load( size_t index ) const noexcept
348  {
349  return dv_.load( index );
350  }
351  //**********************************************************************************************
352 
353  //**Loada function******************************************************************************
363  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept
364  {
365  return dv_.loada( index );
366  }
367  //**********************************************************************************************
368 
369  //**Loadu function******************************************************************************
379  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept
380  {
381  return dv_.loadu( index );
382  }
383  //**********************************************************************************************
384 
385  //**Store function******************************************************************************
396  BLAZE_ALWAYS_INLINE void store( size_t index, const SIMDType& value ) noexcept
397  {
398  dv_.store( index, value );
399  }
400  //**********************************************************************************************
401 
402  //**Storea function******************************************************************************
413  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept
414  {
415  dv_.storea( index, value );
416  }
417  //**********************************************************************************************
418 
419  //**Storeu function*****************************************************************************
430  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept
431  {
432  dv_.storeu( index, value );
433  }
434  //**********************************************************************************************
435 
436  //**Stream function*****************************************************************************
447  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept
448  {
449  dv_.stream( index, value );
450  }
451  //**********************************************************************************************
452 
453  //**Transpose assignment of vectors*************************************************************
464  template< typename VT2 > // Type of the right-hand side vector
465  inline void assign( const Vector<VT2,TF>& rhs )
466  {
468 
469  dv_.assign( trans( ~rhs ) );
470  }
471  //**********************************************************************************************
472 
473  //**Transpose addition assignment of vectors****************************************************
484  template< typename VT2 > // Type of the right-hand side vector
485  inline void addAssign( const Vector<VT2,TF>& rhs )
486  {
488 
489  dv_.addAssign( trans( ~rhs ) );
490  }
491  //**********************************************************************************************
492 
493  //**Transpose subtraction assignment of vectors*************************************************
504  template< typename VT2 > // Type of the right-hand side vector
505  inline void subAssign( const Vector<VT2,TF>& rhs )
506  {
508 
509  dv_.subAssign( trans( ~rhs ) );
510  }
511  //**********************************************************************************************
512 
513  //**Transpose multiplication assignment of vectors**********************************************
524  template< typename VT2 > // Type of the right-hand side vector
525  inline void multAssign( const Vector<VT2,TF>& rhs )
526  {
528 
529  dv_.multAssign( trans( ~rhs ) );
530  }
531  //**********************************************************************************************
532 
533  //**Transpose division assignment of dense vectors**********************************************
544  template< typename VT2 > // Type of the right-hand side dense vector
545  inline void divAssign( const DenseVector<VT2,TF>& rhs )
546  {
548 
549  dv_.divAssign( trans( ~rhs ) );
550  }
551  //**********************************************************************************************
552 
553  private:
554  //**Member variables****************************************************************************
555  VT& dv_;
556  //**********************************************************************************************
557 
558  //**Compile time checks*************************************************************************
564  //**********************************************************************************************
565 };
566 //*************************************************************************************************
567 
568 
569 
570 
571 //=================================================================================================
572 //
573 // GLOBAL OPERATORS
574 //
575 //=================================================================================================
576 
577 //*************************************************************************************************
585 template< typename VT // Type of the dense vector
586  , bool TF > // Transpose flag
587 inline void reset( DVecTransposer<VT,TF>& v )
588 {
589  v.reset();
590 }
592 //*************************************************************************************************
593 
594 
595 //*************************************************************************************************
603 template< typename VT // Type of the dense vector
604  , bool TF > // Transpose flag
605 inline bool isIntact( const DVecTransposer<VT,TF>& v ) noexcept
606 {
607  return v.isIntact();
608 }
610 //*************************************************************************************************
611 
612 
613 
614 
615 //=================================================================================================
616 //
617 // SIZE SPECIALIZATIONS
618 //
619 //=================================================================================================
620 
621 //*************************************************************************************************
623 template< typename VT, bool TF >
624 struct Size< DVecTransposer<VT,TF>, 0UL >
625  : public Size<VT,0UL>
626 {};
628 //*************************************************************************************************
629 
630 
631 
632 
633 //=================================================================================================
634 //
635 // MAXSIZE SPECIALIZATIONS
636 //
637 //=================================================================================================
638 
639 //*************************************************************************************************
641 template< typename VT, bool TF >
642 struct MaxSize< DVecTransposer<VT,TF>, 0UL >
643  : public MaxSize<VT,0UL>
644 {};
646 //*************************************************************************************************
647 
648 
649 
650 
651 //=================================================================================================
652 //
653 // HASCONSTDATAACCESS SPECIALIZATIONS
654 //
655 //=================================================================================================
656 
657 //*************************************************************************************************
659 template< typename VT, bool TF >
660 struct HasConstDataAccess< DVecTransposer<VT,TF> >
661  : public HasConstDataAccess<VT>
662 {};
664 //*************************************************************************************************
665 
666 
667 
668 
669 //=================================================================================================
670 //
671 // HASMUTABLEDATAACCESS SPECIALIZATIONS
672 //
673 //=================================================================================================
674 
675 //*************************************************************************************************
677 template< typename VT, bool TF >
678 struct HasMutableDataAccess< DVecTransposer<VT,TF> >
679  : public HasMutableDataAccess<VT>
680 {};
682 //*************************************************************************************************
683 
684 
685 
686 
687 //=================================================================================================
688 //
689 // ISALIGNED SPECIALIZATIONS
690 //
691 //=================================================================================================
692 
693 //*************************************************************************************************
695 template< typename VT, bool TF >
696 struct IsAligned< DVecTransposer<VT,TF> >
697  : public IsAligned<VT>
698 {};
700 //*************************************************************************************************
701 
702 
703 
704 
705 //=================================================================================================
706 //
707 // ISCONTIGUOUS SPECIALIZATIONS
708 //
709 //=================================================================================================
710 
711 //*************************************************************************************************
713 template< typename VT, bool TF >
714 struct IsContiguous< DVecTransposer<VT,TF> >
715  : public IsContiguous<VT>
716 {};
718 //*************************************************************************************************
719 
720 
721 
722 
723 //=================================================================================================
724 //
725 // ISPADDED SPECIALIZATIONS
726 //
727 //=================================================================================================
728 
729 //*************************************************************************************************
731 template< typename VT, bool TF >
732 struct IsPadded< DVecTransposer<VT,TF> >
733  : public IsPadded<VT>
734 {};
736 //*************************************************************************************************
737 
738 } // namespace blaze
739 
740 #endif
Reference operator[](size_t index)
Subscript operator for the direct access to the vector elements.
Definition: DVecTransposer.h:129
Constraint on the data type.
Iterator begin()
Returns an iterator to the first element of the dense vector.
Definition: DVecTransposer.h:202
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:309
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t index) const noexcept
Unaligned load of a SIMD element of the vector.
Definition: DVecTransposer.h:379
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression,...
Definition: Assert.h:117
void subAssign(const Vector< VT2, TF > &rhs)
Implementation of the transpose subtraction assignment of a vector.
Definition: DVecTransposer.h:505
void addAssign(const Vector< VT2, TF > &rhs)
Implementation of the transpose addition assignment of a vector.
Definition: DVecTransposer.h:485
Header file for basic type definitions.
bool isAligned() const noexcept
Returns whether the vector is properly aligned in memory.
Definition: DVecTransposer.h:320
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
ConstPointer data() const noexcept
Low-level data access to the vector elements.
Definition: DVecTransposer.h:192
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
void multAssign(const Vector< VT2, TF > &rhs)
Implementation of the transpose multiplication assignment of a vector.
Definition: DVecTransposer.h:525
typename SIMDTrait< T >::Type SIMDTrait_t
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_t alias declaration provid...
Definition: SIMDTrait.h:315
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:347
ResultType_t< VT > TransposeType
Transpose type for expression template evaluations.
Definition: DVecTransposer.h:86
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.
SIMDTrait_t< ElementType > SIMDType
SIMD type of the vector elements.
Definition: DVecTransposer.h:88
Header file for the MaxSize type trait.
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
Iterator_t< VT > Iterator
Iterator over non-constant elements.
Definition: DVecTransposer.h:95
Expression object for the transposition of a dense vector.The DVecTransposer class is a wrapper objec...
Definition: DVecTransposer.h:78
bool canSMPAssign() const noexcept
Returns whether the vector can be used in SMP assignments.
Definition: DVecTransposer.h:331
BLAZE_ALWAYS_INLINE void store(size_t index, const SIMDType &value) noexcept
Store of a SIMD element of the vector.
Definition: DVecTransposer.h:396
ConstReference_t< VT > ConstReference
Reference to a constant vector value.
Definition: DVecTransposer.h:92
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:118
ElementType_t< VT > ElementType
Type of the vector elements.
Definition: DVecTransposer.h:87
TransposeType_t< VT > ResultType
Result type for expression template evaluations.
Definition: DVecTransposer.h:85
Pointer_t< VT > Pointer
Pointer to a non-constant vector value.
Definition: DVecTransposer.h:93
#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
ReturnType_t< VT > ReturnType
Return type for expression template evaluations.
Definition: DVecTransposer.h:89
Reference at(size_t index)
Checked access to the vector elements.
Definition: DVecTransposer.h:154
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: DVecTransposer.h:110
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:430
Constraint on the data type.
ConstIterator cend() const
Returns an iterator just past the last element of the dense vector.
Definition: DVecTransposer.h:252
Constraint on the data type.
Header file for the exception macros of the math module.
BLAZE_ALWAYS_INLINE void storea(size_t index, const SIMDType &value) noexcept
Aligned store of a SIMD element of the vector.
Definition: DVecTransposer.h:413
Header file for the IsPadded type trait.
void reset()
Resets the vector elements.
Definition: DVecTransposer.h:272
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: DVecTransposer.h:363
ConstIterator begin() const
Returns an iterator to the first element of the dense vector.
Definition: DVecTransposer.h:212
Header file for the HasConstDataAccess type trait.
static constexpr bool simdEnabled
Compilation flag for SIMD optimization.
Definition: DVecTransposer.h:104
typename T::Iterator Iterator_t
Alias declaration for nested Iterator type definitions.The Iterator_t alias declaration provides a co...
Definition: Aliases.h:190
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.
Iterator end()
Returns an iterator just past the last element of the dense vector.
Definition: DVecTransposer.h:232
Header file for the IsContiguous type trait.
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:447
ConstPointer_t< VT > ConstPointer
Pointer to a constant vector value.
Definition: DVecTransposer.h:94
typename T::ConstPointer ConstPointer_t
Alias declaration for nested ConstPointer type definitions.The ConstPointer_t alias declaration provi...
Definition: Aliases.h:130
Pointer data() noexcept
Low-level data access to the vector elements.
Definition: DVecTransposer.h:182
typename T::ConstReference ConstReference_t
Alias declaration for nested ConstReference type definitions.The ConstReference_t alias declaration p...
Definition: Aliases.h:150
void divAssign(const DenseVector< VT2, TF > &rhs)
Implementation of the transpose division assignment of a dense vector.
Definition: DVecTransposer.h:545
Header file for the HasMutableDataAccess type trait.
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.The ConstIterator_t alias declaration pro...
Definition: Aliases.h:110
#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:765
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:198
Reference_t< VT > Reference
Reference to a non-constant vector value.
Definition: DVecTransposer.h:91
ConstIterator end() const
Returns an iterator just past the last element of the dense vector.
Definition: DVecTransposer.h:242
ConstReference operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DVecTransposer.h:141
void assign(const Vector< VT2, TF > &rhs)
Implementation of the transpose assignment of a vector.
Definition: DVecTransposer.h:465
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
bool isIntact() const noexcept
Returns whether the invariants of the vector are intact.
Definition: DVecTransposer.h:282
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: DVecTransposer.h:296
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DVecTransposer.h:262
System settings for the inline keywords.
Header file for the Size type trait.
#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
ConstReference at(size_t index) const
Checked access to the vector elements.
Definition: DVecTransposer.h:169
VT & dv_
The dense vector operand.
Definition: DVecTransposer.h:555
ConstIterator_t< VT > ConstIterator
Iterator over constant elements.
Definition: DVecTransposer.h:96
ConstIterator cbegin() const
Returns an iterator to the first element of the dense vector.
Definition: DVecTransposer.h:222