Blaze 3.9
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>
57#include <blaze/system/Inline.h>
59#include <blaze/util/Assert.h>
60#include <blaze/util/Types.h>
61
62
63namespace blaze {
64
65//=================================================================================================
66//
67// CLASS DVECTRANSPOSER
68//
69//=================================================================================================
70
71//*************************************************************************************************
77template< typename VT // Type of the dense vector
78 , bool TF > // Transpose flag
80 : public DenseVector< DVecTransposer<VT,TF>, TF >
81{
82 public:
83 //**Type definitions****************************************************************************
91 using CompositeType = const This&;
98 //**********************************************************************************************
99
100 //**Compilation flags***************************************************************************
102
105 static constexpr bool simdEnabled = VT::simdEnabled;
106
108
111 static constexpr bool smpAssignable = VT::smpAssignable;
112 //**********************************************************************************************
113
114 //**Constructor*********************************************************************************
119 explicit inline DVecTransposer( VT& dv ) noexcept
120 : dv_( dv ) // The dense vector operand
121 {}
122 //**********************************************************************************************
123
124 //**Subscript operator**************************************************************************
130 inline Reference operator[]( size_t index ) {
131 BLAZE_USER_ASSERT( index < dv_.size(), "Invalid vector access index" );
132 return dv_[index];
133 }
134 //**********************************************************************************************
135
136 //**Subscript operator**************************************************************************
142 inline ConstReference operator[]( size_t index ) const {
143 BLAZE_USER_ASSERT( index < dv_.size(), "Invalid vector access index" );
144 return const_cast<const VT&>( dv_ )[index];
145 }
146 //**********************************************************************************************
147
148 //**At function*********************************************************************************
155 inline Reference at( size_t index ) {
156 if( index >= dv_.size() ) {
157 BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
158 }
159 return (*this)[index];
160 }
161 //**********************************************************************************************
162
163 //**At function*********************************************************************************
170 inline ConstReference at( size_t index ) const {
171 if( index >= dv_.size() ) {
172 BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
173 }
174 return (*this)[index];
175 }
176 //**********************************************************************************************
177
178 //**Low-level data access***********************************************************************
183 inline Pointer data() noexcept {
184 return dv_.data();
185 }
186 //**********************************************************************************************
187
188 //**Low-level data access***********************************************************************
193 inline ConstPointer data() const noexcept {
194 return dv_.data();
195 }
196 //**********************************************************************************************
197
198 //**Begin function******************************************************************************
203 inline Iterator begin() {
204 return dv_.begin();
205 }
206 //**********************************************************************************************
207
208 //**Begin function******************************************************************************
213 inline ConstIterator begin() const {
214 return dv_.cbegin();
215 }
216 //**********************************************************************************************
217
218 //**Cbegin function*****************************************************************************
223 inline ConstIterator cbegin() const {
224 return dv_.cbegin();
225 }
226 //**********************************************************************************************
227
228 //**End function********************************************************************************
233 inline Iterator end() {
234 return dv_.end();
235 }
236 //**********************************************************************************************
237
238 //**End function********************************************************************************
243 inline ConstIterator end() const {
244 return dv_.cend();
245 }
246 //**********************************************************************************************
247
248 //**Cend function*******************************************************************************
253 inline ConstIterator cend() const {
254 return dv_.cend();
255 }
256 //**********************************************************************************************
257
258 //**Size function*******************************************************************************
263 inline size_t size() const noexcept {
264 return dv_.size();
265 }
266 //**********************************************************************************************
267
268 //**Reset function******************************************************************************
273 inline void reset() {
274 return dv_.reset();
275 }
276 //**********************************************************************************************
277
278 //**IsIntact function***************************************************************************
283 inline bool isIntact() const noexcept
284 {
285 using blaze::isIntact;
286 return isIntact( dv_ );
287 }
288 //**********************************************************************************************
289
290 //**CanAliased function*************************************************************************
296 template< typename Other > // Data type of the foreign expression
297 inline bool canAlias( const Other* alias ) const noexcept
298 {
299 return dv_.canAlias( alias );
300 }
301 //**********************************************************************************************
302
303 //**IsAliased function**************************************************************************
309 template< typename Other > // Data type of the foreign expression
310 inline bool isAliased( const Other* alias ) const noexcept
311 {
312 return dv_.isAliased( alias );
313 }
314 //**********************************************************************************************
315
316 //**IsAligned function**************************************************************************
321 inline bool isAligned() const noexcept
322 {
323 return dv_.isAligned();
324 }
325 //**********************************************************************************************
326
327 //**CanSMPAssign function***********************************************************************
332 inline bool canSMPAssign() const noexcept
333 {
334 return dv_.canSMPAssign();
335 }
336 //**********************************************************************************************
337
338 //**Load function*******************************************************************************
348 BLAZE_ALWAYS_INLINE SIMDType load( size_t index ) const noexcept
349 {
350 return dv_.load( index );
351 }
352 //**********************************************************************************************
353
354 //**Loada function******************************************************************************
364 BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept
365 {
366 return dv_.loada( index );
367 }
368 //**********************************************************************************************
369
370 //**Loadu function******************************************************************************
380 BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept
381 {
382 return dv_.loadu( index );
383 }
384 //**********************************************************************************************
385
386 //**Store function******************************************************************************
397 BLAZE_ALWAYS_INLINE void store( size_t index, const SIMDType& value ) noexcept
398 {
399 dv_.store( index, value );
400 }
401 //**********************************************************************************************
402
403 //**Storea function******************************************************************************
414 BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept
415 {
416 dv_.storea( index, value );
417 }
418 //**********************************************************************************************
419
420 //**Storeu function*****************************************************************************
431 BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept
432 {
433 dv_.storeu( index, value );
434 }
435 //**********************************************************************************************
436
437 //**Stream function*****************************************************************************
448 BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept
449 {
450 dv_.stream( index, value );
451 }
452 //**********************************************************************************************
453
454 //**Transpose assignment of vectors*************************************************************
465 template< typename VT2 > // Type of the right-hand side vector
466 inline void assign( const Vector<VT2,TF>& rhs )
467 {
469
470 dv_.assign( trans( *rhs ) );
471 }
472 //**********************************************************************************************
473
474 //**Transpose addition assignment of vectors****************************************************
485 template< typename VT2 > // Type of the right-hand side vector
486 inline void addAssign( const Vector<VT2,TF>& rhs )
487 {
489
490 dv_.addAssign( trans( *rhs ) );
491 }
492 //**********************************************************************************************
493
494 //**Transpose subtraction assignment of vectors*************************************************
505 template< typename VT2 > // Type of the right-hand side vector
506 inline void subAssign( const Vector<VT2,TF>& rhs )
507 {
509
510 dv_.subAssign( trans( *rhs ) );
511 }
512 //**********************************************************************************************
513
514 //**Transpose multiplication assignment of vectors**********************************************
525 template< typename VT2 > // Type of the right-hand side vector
526 inline void multAssign( const Vector<VT2,TF>& rhs )
527 {
529
530 dv_.multAssign( trans( *rhs ) );
531 }
532 //**********************************************************************************************
533
534 //**Transpose division assignment of dense vectors**********************************************
545 template< typename VT2 > // Type of the right-hand side dense vector
546 inline void divAssign( const DenseVector<VT2,TF>& rhs )
547 {
549
550 dv_.divAssign( trans( *rhs ) );
551 }
552 //**********************************************************************************************
553
554 private:
555 //**Member variables****************************************************************************
556 VT& dv_;
557 //**********************************************************************************************
558
559 //**Compile time checks*************************************************************************
565 //**********************************************************************************************
566};
567//*************************************************************************************************
568
569
570
571
572//=================================================================================================
573//
574// GLOBAL OPERATORS
575//
576//=================================================================================================
577
578//*************************************************************************************************
586template< typename VT // Type of the dense vector
587 , bool TF > // Transpose flag
588inline bool isIntact( const DVecTransposer<VT,TF>& v ) noexcept
589{
590 return v.isIntact();
591}
593//*************************************************************************************************
594
595
596
597
598//=================================================================================================
599//
600// SIZE SPECIALIZATIONS
601//
602//=================================================================================================
603
604//*************************************************************************************************
606template< typename VT, bool TF >
607struct Size< DVecTransposer<VT,TF>, 0UL >
608 : public Size<VT,0UL>
609{};
611//*************************************************************************************************
612
613
614
615
616//=================================================================================================
617//
618// MAXSIZE SPECIALIZATIONS
619//
620//=================================================================================================
621
622//*************************************************************************************************
624template< typename VT, bool TF >
625struct MaxSize< DVecTransposer<VT,TF>, 0UL >
626 : public MaxSize<VT,0UL>
627{};
629//*************************************************************************************************
630
631
632
633
634//=================================================================================================
635//
636// HASCONSTDATAACCESS SPECIALIZATIONS
637//
638//=================================================================================================
639
640//*************************************************************************************************
642template< typename VT, bool TF >
643struct HasConstDataAccess< DVecTransposer<VT,TF> >
644 : public HasConstDataAccess<VT>
645{};
647//*************************************************************************************************
648
649
650
651
652//=================================================================================================
653//
654// HASMUTABLEDATAACCESS SPECIALIZATIONS
655//
656//=================================================================================================
657
658//*************************************************************************************************
660template< typename VT, bool TF >
661struct HasMutableDataAccess< DVecTransposer<VT,TF> >
662 : public HasMutableDataAccess<VT>
663{};
665//*************************************************************************************************
666
667
668
669
670//=================================================================================================
671//
672// ISALIGNED SPECIALIZATIONS
673//
674//=================================================================================================
675
676//*************************************************************************************************
678template< typename VT, bool TF >
679struct IsAligned< DVecTransposer<VT,TF> >
680 : public IsAligned<VT>
681{};
683//*************************************************************************************************
684
685
686
687
688//=================================================================================================
689//
690// ISCONTIGUOUS SPECIALIZATIONS
691//
692//=================================================================================================
693
694//*************************************************************************************************
696template< typename VT, bool TF >
697struct IsContiguous< DVecTransposer<VT,TF> >
698 : public IsContiguous<VT>
699{};
701//*************************************************************************************************
702
703
704
705
706//=================================================================================================
707//
708// ISPADDED SPECIALIZATIONS
709//
710//=================================================================================================
711
712//*************************************************************************************************
714template< typename VT, bool TF >
715struct IsPadded< DVecTransposer<VT,TF> >
716 : public IsPadded<VT>
717{};
719//*************************************************************************************************
720
721} // namespace blaze
722
723#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::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.
Deactivation of problematic macros.
Header file for the MaxSize type trait.
Header file for the SIMD trait.
Expression object for the transposition of a dense vector.
Definition: DVecTransposer.h:81
ConstReference_t< VT > ConstReference
Reference to a constant vector value.
Definition: DVecTransposer.h:93
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: DVecTransposer.h:364
Iterator begin()
Returns an iterator to the first element of the dense vector.
Definition: DVecTransposer.h:203
ElementType_t< VT > ElementType
Type of the vector elements.
Definition: DVecTransposer.h:88
Iterator end()
Returns an iterator just past the last element of the dense vector.
Definition: DVecTransposer.h:233
void multAssign(const Vector< VT2, TF > &rhs)
Implementation of the transpose multiplication assignment of a vector.
Definition: DVecTransposer.h:526
Reference operator[](size_t index)
Subscript operator for the direct access to the vector elements.
Definition: DVecTransposer.h:130
ConstIterator cend() const
Returns an iterator just past the last element of the dense vector.
Definition: DVecTransposer.h:253
ReturnType_t< VT > ReturnType
Return type for expression template evaluations.
Definition: DVecTransposer.h:90
ConstIterator begin() const
Returns an iterator to the first element of the dense vector.
Definition: DVecTransposer.h:213
ConstReference at(size_t index) const
Checked access to the vector elements.
Definition: DVecTransposer.h:170
void subAssign(const Vector< VT2, TF > &rhs)
Implementation of the transpose subtraction assignment of a vector.
Definition: DVecTransposer.h:506
BLAZE_ALWAYS_INLINE void storeu(size_t index, const SIMDType &value) noexcept
Unaligned store of a SIMD element of the vector.
Definition: DVecTransposer.h:431
ResultType_t< VT > TransposeType
Transpose type for expression template evaluations.
Definition: DVecTransposer.h:87
void assign(const Vector< VT2, TF > &rhs)
Implementation of the transpose assignment of a vector.
Definition: DVecTransposer.h:466
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: DVecTransposer.h:297
ConstIterator end() const
Returns an iterator just past the last element of the dense vector.
Definition: DVecTransposer.h:243
BLAZE_ALWAYS_INLINE SIMDType load(size_t index) const noexcept
Load of a SIMD element of the vector.
Definition: DVecTransposer.h:348
void divAssign(const DenseVector< VT2, TF > &rhs)
Implementation of the transpose division assignment of a dense vector.
Definition: DVecTransposer.h:546
BLAZE_ALWAYS_INLINE void store(size_t index, const SIMDType &value) noexcept
Store of a SIMD element of the vector.
Definition: DVecTransposer.h:397
BLAZE_ALWAYS_INLINE void storea(size_t index, const SIMDType &value) noexcept
Aligned store of a SIMD element of the vector.
Definition: DVecTransposer.h:414
bool isAligned() const noexcept
Returns whether the vector is properly aligned in memory.
Definition: DVecTransposer.h:321
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: DVecTransposer.h:111
Reference at(size_t index)
Checked access to the vector elements.
Definition: DVecTransposer.h:155
bool canSMPAssign() const noexcept
Returns whether the vector can be used in SMP assignments.
Definition: DVecTransposer.h:332
void reset()
Resets the vector elements.
Definition: DVecTransposer.h:273
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t index) const noexcept
Unaligned load of a SIMD element of the vector.
Definition: DVecTransposer.h:380
void addAssign(const Vector< VT2, TF > &rhs)
Implementation of the transpose addition assignment of a vector.
Definition: DVecTransposer.h:486
SIMDTrait_t< ElementType > SIMDType
SIMD type of the vector elements.
Definition: DVecTransposer.h:89
ConstPointer data() const noexcept
Low-level data access to the vector elements.
Definition: DVecTransposer.h:193
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:448
TransposeType_t< VT > ResultType
Result type for expression template evaluations.
Definition: DVecTransposer.h:86
ConstIterator cbegin() const
Returns an iterator to the first element of the dense vector.
Definition: DVecTransposer.h:223
DVecTransposer(VT &dv) noexcept
Constructor for the DVecTransposer class.
Definition: DVecTransposer.h:119
Pointer_t< VT > Pointer
Pointer to a non-constant vector value.
Definition: DVecTransposer.h:94
Pointer data() noexcept
Low-level data access to the vector elements.
Definition: DVecTransposer.h:183
Reference_t< VT > Reference
Reference to a non-constant vector value.
Definition: DVecTransposer.h:92
static constexpr bool simdEnabled
Compilation flag for SIMD optimization.
Definition: DVecTransposer.h:105
bool isIntact() const noexcept
Returns whether the invariants of the vector are intact.
Definition: DVecTransposer.h:283
VT & dv_
The dense vector operand.
Definition: DVecTransposer.h:556
Iterator_t< VT > Iterator
Iterator over non-constant elements.
Definition: DVecTransposer.h:96
ConstIterator_t< VT > ConstIterator
Iterator over constant elements.
Definition: DVecTransposer.h:97
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: DVecTransposer.h:310
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DVecTransposer.h:263
ConstPointer_t< VT > ConstPointer
Pointer to a constant vector value.
Definition: DVecTransposer.h:95
ConstReference operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DVecTransposer.h:142
Base class for N-dimensional dense vectors.
Definition: DenseVector.h:77
Base class for N-dimensional vectors.
Definition: Vector.h:82
Constraint on the data type.
Constraint on the data type.
Header file for the DenseVector 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_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.
Definition: TransposeFlag.h:63
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.
Definition: Computation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition: DenseVector.h:61
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.
Definition: Assert.h:117
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.
Constraint on the data type.
Header file for the Size type trait.
System settings for the inline keywords.
Header file for basic type definitions.