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****************************************************************************
89  using CompositeType = const This&;
96  //**********************************************************************************************
97 
98  //**Compilation flags***************************************************************************
100 
103  static constexpr bool simdEnabled = VT::simdEnabled;
104 
106 
109  static constexpr bool smpAssignable = VT::smpAssignable;
110  //**********************************************************************************************
111 
112  //**Constructor*********************************************************************************
117  explicit inline DVecTransposer( VT& dv ) noexcept
118  : dv_( dv ) // The dense vector operand
119  {}
120  //**********************************************************************************************
121 
122  //**Subscript operator**************************************************************************
128  inline Reference operator[]( size_t index ) {
129  BLAZE_USER_ASSERT( index < dv_.size(), "Invalid vector access index" );
130  return dv_[index];
131  }
132  //**********************************************************************************************
133 
134  //**Subscript operator**************************************************************************
140  inline ConstReference operator[]( size_t index ) const {
141  BLAZE_USER_ASSERT( index < dv_.size(), "Invalid vector access index" );
142  return const_cast<const VT&>( dv_ )[index];
143  }
144  //**********************************************************************************************
145 
146  //**At function*********************************************************************************
153  inline Reference at( size_t index ) {
154  if( index >= dv_.size() ) {
155  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
156  }
157  return (*this)[index];
158  }
159  //**********************************************************************************************
160 
161  //**At function*********************************************************************************
168  inline ConstReference at( size_t index ) const {
169  if( index >= dv_.size() ) {
170  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
171  }
172  return (*this)[index];
173  }
174  //**********************************************************************************************
175 
176  //**Low-level data access***********************************************************************
181  inline Pointer data() noexcept {
182  return dv_.data();
183  }
184  //**********************************************************************************************
185 
186  //**Low-level data access***********************************************************************
191  inline ConstPointer data() const noexcept {
192  return dv_.data();
193  }
194  //**********************************************************************************************
195 
196  //**Begin function******************************************************************************
201  inline Iterator begin() {
202  return dv_.begin();
203  }
204  //**********************************************************************************************
205 
206  //**Begin function******************************************************************************
211  inline ConstIterator begin() const {
212  return dv_.cbegin();
213  }
214  //**********************************************************************************************
215 
216  //**Cbegin function*****************************************************************************
221  inline ConstIterator cbegin() const {
222  return dv_.cbegin();
223  }
224  //**********************************************************************************************
225 
226  //**End function********************************************************************************
231  inline Iterator end() {
232  return dv_.end();
233  }
234  //**********************************************************************************************
235 
236  //**End function********************************************************************************
241  inline ConstIterator end() const {
242  return dv_.cend();
243  }
244  //**********************************************************************************************
245 
246  //**Cend function*******************************************************************************
251  inline ConstIterator cend() const {
252  return dv_.cend();
253  }
254  //**********************************************************************************************
255 
256  //**Size function*******************************************************************************
261  inline size_t size() const noexcept {
262  return dv_.size();
263  }
264  //**********************************************************************************************
265 
266  //**Reset function******************************************************************************
271  inline void reset() {
272  return dv_.reset();
273  }
274  //**********************************************************************************************
275 
276  //**IsIntact function***************************************************************************
281  inline bool isIntact() const noexcept
282  {
283  using blaze::isIntact;
284  return isIntact( dv_ );
285  }
286  //**********************************************************************************************
287 
288  //**CanAliased function*************************************************************************
294  template< typename Other > // Data type of the foreign expression
295  inline bool canAlias( const Other* alias ) const noexcept
296  {
297  return dv_.canAlias( alias );
298  }
299  //**********************************************************************************************
300 
301  //**IsAliased function**************************************************************************
307  template< typename Other > // Data type of the foreign expression
308  inline bool isAliased( const Other* alias ) const noexcept
309  {
310  return dv_.isAliased( alias );
311  }
312  //**********************************************************************************************
313 
314  //**IsAligned function**************************************************************************
319  inline bool isAligned() const noexcept
320  {
321  return dv_.isAligned();
322  }
323  //**********************************************************************************************
324 
325  //**CanSMPAssign function***********************************************************************
330  inline bool canSMPAssign() const noexcept
331  {
332  return dv_.canSMPAssign();
333  }
334  //**********************************************************************************************
335 
336  //**Load function*******************************************************************************
346  BLAZE_ALWAYS_INLINE SIMDType load( size_t index ) const noexcept
347  {
348  return dv_.load( index );
349  }
350  //**********************************************************************************************
351 
352  //**Loada function******************************************************************************
362  BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept
363  {
364  return dv_.loada( index );
365  }
366  //**********************************************************************************************
367 
368  //**Loadu function******************************************************************************
378  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept
379  {
380  return dv_.loadu( index );
381  }
382  //**********************************************************************************************
383 
384  //**Store function******************************************************************************
395  BLAZE_ALWAYS_INLINE void store( size_t index, const SIMDType& value ) noexcept
396  {
397  dv_.store( index, value );
398  }
399  //**********************************************************************************************
400 
401  //**Storea function******************************************************************************
412  BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept
413  {
414  dv_.storea( index, value );
415  }
416  //**********************************************************************************************
417 
418  //**Storeu function*****************************************************************************
429  BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept
430  {
431  dv_.storeu( index, value );
432  }
433  //**********************************************************************************************
434 
435  //**Stream function*****************************************************************************
446  BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept
447  {
448  dv_.stream( index, value );
449  }
450  //**********************************************************************************************
451 
452  //**Transpose assignment of vectors*************************************************************
463  template< typename VT2 > // Type of the right-hand side vector
464  inline void assign( const Vector<VT2,TF>& rhs )
465  {
467 
468  dv_.assign( trans( ~rhs ) );
469  }
470  //**********************************************************************************************
471 
472  //**Transpose addition assignment of vectors****************************************************
483  template< typename VT2 > // Type of the right-hand side vector
484  inline void addAssign( const Vector<VT2,TF>& rhs )
485  {
487 
488  dv_.addAssign( trans( ~rhs ) );
489  }
490  //**********************************************************************************************
491 
492  //**Transpose subtraction assignment of vectors*************************************************
503  template< typename VT2 > // Type of the right-hand side vector
504  inline void subAssign( const Vector<VT2,TF>& rhs )
505  {
507 
508  dv_.subAssign( trans( ~rhs ) );
509  }
510  //**********************************************************************************************
511 
512  //**Transpose multiplication assignment of vectors**********************************************
523  template< typename VT2 > // Type of the right-hand side vector
524  inline void multAssign( const Vector<VT2,TF>& rhs )
525  {
527 
528  dv_.multAssign( trans( ~rhs ) );
529  }
530  //**********************************************************************************************
531 
532  //**Transpose division assignment of dense vectors**********************************************
543  template< typename VT2 > // Type of the right-hand side dense vector
544  inline void divAssign( const DenseVector<VT2,TF>& rhs )
545  {
547 
548  dv_.divAssign( trans( ~rhs ) );
549  }
550  //**********************************************************************************************
551 
552  private:
553  //**Member variables****************************************************************************
554  VT& dv_;
555  //**********************************************************************************************
556 
557  //**Compile time checks*************************************************************************
563  //**********************************************************************************************
564 };
565 //*************************************************************************************************
566 
567 
568 
569 
570 //=================================================================================================
571 //
572 // GLOBAL OPERATORS
573 //
574 //=================================================================================================
575 
576 //*************************************************************************************************
584 template< typename VT // Type of the dense vector
585  , bool TF > // Transpose flag
586 inline void reset( DVecTransposer<VT,TF>& v )
587 {
588  v.reset();
589 }
591 //*************************************************************************************************
592 
593 
594 //*************************************************************************************************
602 template< typename VT // Type of the dense vector
603  , bool TF > // Transpose flag
604 inline bool isIntact( const DVecTransposer<VT,TF>& v ) noexcept
605 {
606  return v.isIntact();
607 }
609 //*************************************************************************************************
610 
611 
612 
613 
614 //=================================================================================================
615 //
616 // SIZE SPECIALIZATIONS
617 //
618 //=================================================================================================
619 
620 //*************************************************************************************************
622 template< typename VT, bool TF >
623 struct Size< DVecTransposer<VT,TF>, 0UL >
624  : public Size<VT,0UL>
625 {};
627 //*************************************************************************************************
628 
629 
630 
631 
632 //=================================================================================================
633 //
634 // MAXSIZE SPECIALIZATIONS
635 //
636 //=================================================================================================
637 
638 //*************************************************************************************************
640 template< typename VT, bool TF >
641 struct MaxSize< DVecTransposer<VT,TF>, 0UL >
642  : public MaxSize<VT,0UL>
643 {};
645 //*************************************************************************************************
646 
647 
648 
649 
650 //=================================================================================================
651 //
652 // HASCONSTDATAACCESS SPECIALIZATIONS
653 //
654 //=================================================================================================
655 
656 //*************************************************************************************************
658 template< typename VT, bool TF >
659 struct HasConstDataAccess< DVecTransposer<VT,TF> >
660  : public HasConstDataAccess<VT>
661 {};
663 //*************************************************************************************************
664 
665 
666 
667 
668 //=================================================================================================
669 //
670 // HASMUTABLEDATAACCESS SPECIALIZATIONS
671 //
672 //=================================================================================================
673 
674 //*************************************************************************************************
676 template< typename VT, bool TF >
677 struct HasMutableDataAccess< DVecTransposer<VT,TF> >
678  : public HasMutableDataAccess<VT>
679 {};
681 //*************************************************************************************************
682 
683 
684 
685 
686 //=================================================================================================
687 //
688 // ISALIGNED SPECIALIZATIONS
689 //
690 //=================================================================================================
691 
692 //*************************************************************************************************
694 template< typename VT, bool TF >
695 struct IsAligned< DVecTransposer<VT,TF> >
696  : public IsAligned<VT>
697 {};
699 //*************************************************************************************************
700 
701 
702 
703 
704 //=================================================================================================
705 //
706 // ISPADDED SPECIALIZATIONS
707 //
708 //=================================================================================================
709 
710 //*************************************************************************************************
712 template< typename VT, bool TF >
713 struct IsPadded< DVecTransposer<VT,TF> >
714  : public IsPadded<VT>
715 {};
717 //*************************************************************************************************
718 
719 } // namespace blaze
720 
721 #endif
Reference operator[](size_t index)
Subscript operator for the direct access to the vector elements.
Definition: DVecTransposer.h:128
Constraint on the data type.
Iterator begin()
Returns an iterator to the first element of the dense vector.
Definition: DVecTransposer.h:201
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:308
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t index) const noexcept
Unaligned load of a SIMD element of the vector.
Definition: DVecTransposer.h:378
#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:504
void addAssign(const Vector< VT2, TF > &rhs)
Implementation of the transpose addition assignment of a vector.
Definition: DVecTransposer.h:484
Header file for basic type definitions.
bool isAligned() const noexcept
Returns whether the vector is properly aligned in memory.
Definition: DVecTransposer.h:319
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:191
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
void multAssign(const Vector< VT2, TF > &rhs)
Implementation of the transpose multiplication assignment of a vector.
Definition: DVecTransposer.h:524
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:346
ResultType_t< VT > TransposeType
Transpose type for expression template evaluations.
Definition: DVecTransposer.h:85
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:87
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:94
Expression object for the transposition of a dense vector.The DVecTransposer class is a wrapper objec...
Definition: DVecTransposer.h:77
bool canSMPAssign() const noexcept
Returns whether the vector can be used in SMP assignments.
Definition: DVecTransposer.h:330
BLAZE_ALWAYS_INLINE void store(size_t index, const SIMDType &value) noexcept
Store of a SIMD element of the vector.
Definition: DVecTransposer.h:395
ConstReference_t< VT > ConstReference
Reference to a constant vector value.
Definition: DVecTransposer.h:91
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:117
ElementType_t< VT > ElementType
Type of the vector elements.
Definition: DVecTransposer.h:86
TransposeType_t< VT > ResultType
Result type for expression template evaluations.
Definition: DVecTransposer.h:84
Pointer_t< VT > Pointer
Pointer to a non-constant vector value.
Definition: DVecTransposer.h:92
#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:88
Reference at(size_t index)
Checked access to the vector elements.
Definition: DVecTransposer.h:153
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:109
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:429
Constraint on the data type.
ConstIterator cend() const
Returns an iterator just past the last element of the dense vector.
Definition: DVecTransposer.h:251
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:412
Header file for the IsPadded type trait.
void reset()
Resets the vector elements.
Definition: DVecTransposer.h:271
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: DVecTransposer.h:362
ConstIterator begin() const
Returns an iterator to the first element of the dense vector.
Definition: DVecTransposer.h:211
Header file for the HasConstDataAccess type trait.
static constexpr bool simdEnabled
Compilation flag for SIMD optimization.
Definition: DVecTransposer.h:103
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:231
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:446
ConstPointer_t< VT > ConstPointer
Pointer to a constant vector value.
Definition: DVecTransposer.h:93
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:181
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:544
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:186
Reference_t< VT > Reference
Reference to a non-constant vector value.
Definition: DVecTransposer.h:90
ConstIterator end() const
Returns an iterator just past the last element of the dense vector.
Definition: DVecTransposer.h:241
ConstReference operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DVecTransposer.h:140
void assign(const Vector< VT2, TF > &rhs)
Implementation of the transpose assignment of a vector.
Definition: DVecTransposer.h:464
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
bool isIntact() const noexcept
Returns whether the invariants of the vector are intact.
Definition: DVecTransposer.h:281
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: DVecTransposer.h:295
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DVecTransposer.h:261
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:168
VT & dv_
The dense vector operand.
Definition: DVecTransposer.h:554
ConstIterator_t< VT > ConstIterator
Iterator over constant elements.
Definition: DVecTransposer.h:95
ConstIterator cbegin() const
Returns an iterator to the first element of the dense vector.
Definition: DVecTransposer.h:221