Blaze 3.9
HybridVector.h
Go to the documentation of this file.
1//=================================================================================================
24//=================================================================================================
25
26#ifndef _BLAZE_MATH_DENSE_HYBRIDVECTOR_H_
27#define _BLAZE_MATH_DENSE_HYBRIDVECTOR_H_
28
29
30//*************************************************************************************************
31// Includes
32//*************************************************************************************************
33
34#include <array>
35#include <utility>
36#include <blaze/math/Aliases.h>
47#include <blaze/math/Forward.h>
48#include <blaze/math/Infinity.h>
58#include <blaze/math/SIMD.h>
98#include <blaze/system/Inline.h>
105#include <blaze/util/Assert.h>
111#include <blaze/util/EnableIf.h>
114#include <blaze/util/Memory.h>
116#include <blaze/util/Types.h>
122
123
124namespace blaze {
125
126//=================================================================================================
127//
128// CLASS DEFINITION
129//
130//=================================================================================================
131
132//*************************************************************************************************
214template< typename Type // Data type of the vector
215 , size_t N // Number of elements
216 , bool TF // Transpose flag
217 , AlignmentFlag AF // Alignment flag
218 , PaddingFlag PF // Padding flag
219 , typename Tag > // Type tag
221 : public DenseVector< HybridVector<Type,N,TF,AF,PF,Tag>, TF >
222{
223 public:
224 //**Type definitions****************************************************************************
227 using ResultType = This;
228
231
232 using ElementType = Type;
234 using ReturnType = const Type&;
235 using TagType = Tag;
237
238 using Reference = Type&;
239 using ConstReference = const Type&;
240 using Pointer = Type*;
241 using ConstPointer = const Type*;
242
245 //**********************************************************************************************
246
247 //**Rebind struct definition********************************************************************
250 template< typename NewType > // Data type of the other vector
251 struct Rebind {
253 };
254 //**********************************************************************************************
255
256 //**Resize struct definition********************************************************************
259 template< size_t NewN > // Number of elements of the other vector
260 struct Resize {
262 };
263 //**********************************************************************************************
264
265 //**Compilation flags***************************************************************************
267
271 static constexpr bool simdEnabled = IsVectorizable_v<Type>;
272
274
277 static constexpr bool smpAssignable = false;
278 //**********************************************************************************************
279
280 //**Constructors********************************************************************************
283 constexpr HybridVector();
284 explicit constexpr HybridVector( size_t n );
285 inline HybridVector( size_t n, const Type& init );
286 constexpr HybridVector( initializer_list<Type> list );
287
288 template< typename Other >
289 inline HybridVector( size_t n, const Other* array );
290
291 template< typename Other, size_t Dim >
292 constexpr HybridVector( const Other (&array)[Dim] );
293
294 template< typename Other, size_t Dim >
295 constexpr HybridVector( const std::array<Other,Dim>& array );
296
297 constexpr HybridVector( const HybridVector& v );
298
299 template< typename VT >
300 inline HybridVector( const Vector<VT,TF>& v );
302 //**********************************************************************************************
303
304 //**Destructor**********************************************************************************
307 ~HybridVector() = default;
309 //**********************************************************************************************
310
311 //**Data access functions***********************************************************************
314 constexpr Reference operator[]( size_t index ) noexcept;
315 constexpr ConstReference operator[]( size_t index ) const noexcept;
316 inline Reference at( size_t index );
317 inline ConstReference at( size_t index ) const;
318 constexpr Pointer data () noexcept;
319 constexpr ConstPointer data () const noexcept;
320 constexpr Iterator begin () noexcept;
321 constexpr ConstIterator begin () const noexcept;
322 constexpr ConstIterator cbegin() const noexcept;
323 constexpr Iterator end () noexcept;
324 constexpr ConstIterator end () const noexcept;
325 constexpr ConstIterator cend () const noexcept;
327 //**********************************************************************************************
328
329 //**Assignment operators************************************************************************
332 constexpr HybridVector& operator=( const Type& rhs ) &;
333 constexpr HybridVector& operator=( initializer_list<Type> list ) &;
334
335 template< typename Other, size_t Dim >
336 constexpr HybridVector& operator=( const Other (&array)[Dim] ) &;
337
338 template< typename Other, size_t Dim >
339 constexpr HybridVector& operator=( const std::array<Other,Dim>& array ) &;
340
341 constexpr HybridVector& operator=( const HybridVector& rhs ) &;
342
343 template< typename VT > inline HybridVector& operator= ( const Vector<VT,TF>& rhs ) &;
344 template< typename VT > inline HybridVector& operator+=( const Vector<VT,TF>& rhs ) &;
345 template< typename VT > inline HybridVector& operator-=( const Vector<VT,TF>& rhs ) &;
346 template< typename VT > inline HybridVector& operator*=( const Vector<VT,TF>& rhs ) &;
347 template< typename VT > inline HybridVector& operator/=( const DenseVector<VT,TF>& rhs ) &;
348 template< typename VT > inline HybridVector& operator%=( const Vector<VT,TF>& rhs ) &;
350 //**********************************************************************************************
351
352 //**Utility functions***************************************************************************
355 constexpr size_t size() const noexcept;
356 static constexpr size_t spacing() noexcept;
357 static constexpr size_t capacity() noexcept;
358 inline size_t nonZeros() const;
359 constexpr void reset();
360 constexpr void clear();
361 constexpr void resize( size_t n, bool preserve=true );
362 constexpr void extend( size_t n, bool preserve=true );
363 inline void swap( HybridVector& v ) noexcept;
365 //**********************************************************************************************
366
367 //**Numeric functions***************************************************************************
370 template< typename Other > inline HybridVector& scale( const Other& scalar );
372 //**********************************************************************************************
373
374 //**Memory functions****************************************************************************
377 static inline void* operator new ( std::size_t size );
378 static inline void* operator new[]( std::size_t size );
379 static inline void* operator new ( std::size_t size, const std::nothrow_t& );
380 static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
381
382 static inline void operator delete ( void* ptr );
383 static inline void operator delete[]( void* ptr );
384 static inline void operator delete ( void* ptr, const std::nothrow_t& );
385 static inline void operator delete[]( void* ptr, const std::nothrow_t& );
387 //**********************************************************************************************
388
389 private:
390 //**********************************************************************************************
392 static constexpr size_t SIMDSIZE = SIMDTrait<Type>::size;
393
395 static constexpr size_t NN = ( PF == padded ? nextMultiple( N, SIMDSIZE ) : N );
396 //**********************************************************************************************
397
398 //**********************************************************************************************
400
401 template< typename VT >
402 static constexpr bool VectorizedAssign_v =
403 ( useOptimizedKernels &&
404 NN >= SIMDSIZE &&
405 simdEnabled && VT::simdEnabled &&
406 IsSIMDCombinable_v< Type, ElementType_t<VT> > );
408 //**********************************************************************************************
409
410 //**********************************************************************************************
412
413 template< typename VT >
414 static constexpr bool VectorizedAddAssign_v =
415 ( VectorizedAssign_v<VT> &&
416 HasSIMDAdd_v< Type, ElementType_t<VT> > );
418 //**********************************************************************************************
419
420 //**********************************************************************************************
422
423 template< typename VT >
424 static constexpr bool VectorizedSubAssign_v =
425 ( VectorizedAssign_v<VT> &&
426 HasSIMDSub_v< Type, ElementType_t<VT> > );
428 //**********************************************************************************************
429
430 //**********************************************************************************************
432
433 template< typename VT >
434 static constexpr bool VectorizedMultAssign_v =
435 ( VectorizedAssign_v<VT> &&
436 HasSIMDMult_v< Type, ElementType_t<VT> > );
438 //**********************************************************************************************
439
440 //**********************************************************************************************
442
443 template< typename VT >
444 static constexpr bool VectorizedDivAssign_v =
445 ( VectorizedAssign_v<VT> &&
446 HasSIMDDiv_v< Type, ElementType_t<VT> > );
448 //**********************************************************************************************
449
450 public:
451 //**Debugging functions*************************************************************************
454 constexpr bool isIntact() const noexcept;
456 //**********************************************************************************************
457
458 //**Expression template evaluation functions****************************************************
461 template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
462 template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
463
464 static constexpr bool isAligned() noexcept;
465
466 BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
467 BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
468 BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
469
470 BLAZE_ALWAYS_INLINE void store ( size_t index, const SIMDType& value ) noexcept;
471 BLAZE_ALWAYS_INLINE void storea( size_t index, const SIMDType& value ) noexcept;
472 BLAZE_ALWAYS_INLINE void storeu( size_t index, const SIMDType& value ) noexcept;
473 BLAZE_ALWAYS_INLINE void stream( size_t index, const SIMDType& value ) noexcept;
474
475 template< typename VT >
476 inline auto assign( const DenseVector<VT,TF>& rhs ) -> DisableIf_t< VectorizedAssign_v<VT> >;
477
478 template< typename VT >
479 inline auto assign( const DenseVector<VT,TF>& rhs ) -> EnableIf_t< VectorizedAssign_v<VT> >;
480
481 template< typename VT > inline void assign( const SparseVector<VT,TF>& rhs );
482
483 template< typename VT >
484 inline auto addAssign( const DenseVector<VT,TF>& rhs ) -> DisableIf_t< VectorizedAddAssign_v<VT> >;
485
486 template< typename VT >
487 inline auto addAssign( const DenseVector<VT,TF>& rhs ) -> EnableIf_t< VectorizedAddAssign_v<VT> >;
488
489 template< typename VT > inline void addAssign( const SparseVector<VT,TF>& rhs );
490
491 template< typename VT >
492 inline auto subAssign( const DenseVector<VT,TF>& rhs ) -> DisableIf_t< VectorizedSubAssign_v<VT> >;
493
494 template< typename VT >
495 inline auto subAssign( const DenseVector<VT,TF>& rhs ) -> EnableIf_t< VectorizedSubAssign_v<VT> >;
496
497 template< typename VT > inline void subAssign( const SparseVector<VT,TF>& rhs );
498
499 template< typename VT >
500 inline auto multAssign( const DenseVector<VT,TF>& rhs ) -> DisableIf_t< VectorizedMultAssign_v<VT> >;
501
502 template< typename VT >
503 inline auto multAssign( const DenseVector<VT,TF>& rhs ) -> EnableIf_t< VectorizedMultAssign_v<VT> >;
504
505 template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
506
507 template< typename VT >
508 inline auto divAssign( const DenseVector<VT,TF>& rhs ) -> DisableIf_t< VectorizedDivAssign_v<VT> >;
509
510 template< typename VT >
511 inline auto divAssign( const DenseVector<VT,TF>& rhs ) -> EnableIf_t< VectorizedDivAssign_v<VT> >;
513 //**********************************************************************************************
514
515 private:
516 //**********************************************************************************************
518 static constexpr size_t Alignment =
519 ( AF == aligned ? AlignmentOf_v<Type> : std::alignment_of<Type>::value );
520
523 //**********************************************************************************************
524
525 //**Member variables****************************************************************************
534 size_t size_;
536 //**********************************************************************************************
537
538 //**Compile time checks*************************************************************************
544 BLAZE_STATIC_ASSERT( PF == unpadded || NN % SIMDSIZE == 0UL );
545 BLAZE_STATIC_ASSERT( NN >= N );
546 BLAZE_STATIC_ASSERT( IsVectorizable_v<Type> || NN == N );
548 //**********************************************************************************************
549};
550//*************************************************************************************************
551
552
553
554
555//=================================================================================================
556//
557// DEDUCTION GUIDES
558//
559//=================================================================================================
560
561//*************************************************************************************************
562#if BLAZE_CPP17_MODE
563
564template< typename Type, typename... Ts >
565HybridVector( Type, Ts... ) -> HybridVector<Type,1+sizeof...(Ts)>;
566
567template< typename Type, size_t N >
568HybridVector( Type (&)[N] ) -> HybridVector< RemoveCV_t<Type>, N >;
569
570template< typename Type, size_t N >
571HybridVector( std::array<Type,N> ) -> HybridVector<Type,N>;
572
573#endif
574//*************************************************************************************************
575
576
577
578
579//=================================================================================================
580//
581// CONSTRUCTORS
582//
583//=================================================================================================
584
585//*************************************************************************************************
590template< typename Type // Data type of the vector
591 , size_t N // Number of elements
592 , bool TF // Transpose flag
593 , AlignmentFlag AF // Alignment flag
594 , PaddingFlag PF // Padding flag
595 , typename Tag > // Type tag
597 : v_ () // The statically allocated vector elements
598 , size_( 0UL ) // The current size/dimension of the vector
599{
600 BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
601}
602//*************************************************************************************************
603
604
605//*************************************************************************************************
615template< typename Type // Data type of the vector
616 , size_t N // Number of elements
617 , bool TF // Transpose flag
618 , AlignmentFlag AF // Alignment flag
619 , PaddingFlag PF // Padding flag
620 , typename Tag > // Type tag
622 : v_ () // The statically allocated vector elements
623 , size_( n ) // The current size/dimension of the vector
624{
625 if( n > N ) {
626 BLAZE_THROW_INVALID_ARGUMENT( "Invalid size for hybrid vector" );
627 }
628
629 BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
630}
631//*************************************************************************************************
632
633
634//*************************************************************************************************
645template< typename Type // Data type of the vector
646 , size_t N // Number of elements
647 , bool TF // Transpose flag
648 , AlignmentFlag AF // Alignment flag
649 , PaddingFlag PF // Padding flag
650 , typename Tag > // Type tag
651inline HybridVector<Type,N,TF,AF,PF,Tag>::HybridVector( size_t n, const Type& init )
652 : size_( n ) // The current size/dimension of the vector
653 // v_ is intentionally left uninitialized
654{
655 using blaze::clear;
656
657 if( n > N ) {
658 BLAZE_THROW_INVALID_ARGUMENT( "Invalid size for hybrid vector" );
659 }
660
661 for( size_t i=0UL; i<n; ++i )
662 v_[i] = init;
663
664 if( IsNumeric_v<Type> ) {
665 for( size_t i=n; i<NN; ++i )
666 clear( v_[i] );
667 }
668
669 BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
670}
671//*************************************************************************************************
672
673
674//*************************************************************************************************
692template< typename Type // Data type of the vector
693 , size_t N // Number of elements
694 , bool TF // Transpose flag
695 , AlignmentFlag AF // Alignment flag
696 , PaddingFlag PF // Padding flag
697 , typename Tag > // Type tag
698constexpr HybridVector<Type,N,TF,AF,PF,Tag>::HybridVector( initializer_list<Type> list )
699 : v_ () // The statically allocated vector elements
700 , size_( list.size() ) // The current size/dimension of the vector
701{
702 if( size_ > N ) {
703 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of hybrid vector" );
704 }
705
706 size_t i( 0UL );
707
708 for( const auto& element : list ) {
709 v_[i] = element;
710 ++i;
711 }
712
713 BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
714}
715//*************************************************************************************************
716
717
718//*************************************************************************************************
741template< typename Type // Data type of the vector
742 , size_t N // Number of elements
743 , bool TF // Transpose flag
744 , AlignmentFlag AF // Alignment flag
745 , PaddingFlag PF // Padding flag
746 , typename Tag > // Type tag
747template< typename Other > // Data type of the initialization array
748inline HybridVector<Type,N,TF,AF,PF,Tag>::HybridVector( size_t n, const Other* array )
749 : size_( n ) // The current size/dimension of the vector
750 // v_ is intentionally left uninitialized
751{
752 using blaze::clear;
753
754 if( n > N ) {
755 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of hybrid vector" );
756 }
757
758 for( size_t i=0UL; i<n; ++i )
759 v_[i] = array[i];
760
761 if( IsNumeric_v<Type> ) {
762 for( size_t i=n; i<NN; ++i )
763 clear( v_[i] );
764 }
765
766 BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
767}
768//*************************************************************************************************
769
770
771//*************************************************************************************************
789template< typename Type // Data type of the vector
790 , size_t N // Number of elements
791 , bool TF // Transpose flag
792 , AlignmentFlag AF // Alignment flag
793 , PaddingFlag PF // Padding flag
794 , typename Tag > // Type tag
795template< typename Other // Data type of the static array
796 , size_t Dim > // Number of elements of the static array
797constexpr HybridVector<Type,N,TF,AF,PF,Tag>::HybridVector( const Other (&array)[Dim] )
798 : v_ ( array ) // The statically allocated vector elements
799 , size_( Dim ) // The current size/dimension of the vector
800{
801 BLAZE_STATIC_ASSERT( Dim <= N );
802
803 BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
804}
805//*************************************************************************************************
806
807
808//*************************************************************************************************
826template< typename Type // Data type of the vector
827 , size_t N // Number of elements
828 , bool TF // Transpose flag
829 , AlignmentFlag AF // Alignment flag
830 , PaddingFlag PF // Padding flag
831 , typename Tag > // Type tag
832template< typename Other // Data type of the std::array
833 , size_t Dim > // Dimension of the std::array
834constexpr HybridVector<Type,N,TF,AF,PF,Tag>::HybridVector( const std::array<Other,Dim>& array )
835 : v_ ( array ) // The statically allocated vector elements
836 , size_( Dim ) // The current size/dimension of the vector
837{
838 BLAZE_STATIC_ASSERT( Dim <= N );
839
840 BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
841}
842//*************************************************************************************************
843
844
845//*************************************************************************************************
852template< typename Type // Data type of the vector
853 , size_t N // Number of elements
854 , bool TF // Transpose flag
855 , AlignmentFlag AF // Alignment flag
856 , PaddingFlag PF // Padding flag
857 , typename Tag > // Type tag
859 : BaseType() // Initialization of the base class
860 , v_ ( v.v_ ) // The statically allocated vector elements
861 , size_( v.size_ ) // The current size/dimension of the vector
862{
863 BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
864}
865//*************************************************************************************************
866
867
868//*************************************************************************************************
878template< typename Type // Data type of the vector
879 , size_t N // Number of elements
880 , bool TF // Transpose flag
881 , AlignmentFlag AF // Alignment flag
882 , PaddingFlag PF // Padding flag
883 , typename Tag > // Type tag
884template< typename VT > // Type of the foreign vector
886 : size_( (*v).size() ) // The current size/dimension of the vector
887 // v_ is intentionally left uninitialized
888{
889 using blaze::assign;
890 using blaze::clear;
891
893
894 if( (*v).size() > N ) {
895 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of hybrid vector" );
896 }
897
898 for( size_t i=( IsSparseVector_v<VT> ? 0UL : size_ );
899 i<( IsNumeric_v<Type> ? NN : size_ ); ++i ) {
900 clear( v_[i] );
901 }
902
903 assign( *this, *v );
904
905 BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
906}
907//*************************************************************************************************
908
909
910
911
912//=================================================================================================
913//
914// DATA ACCESS FUNCTIONS
915//
916//=================================================================================================
917
918//*************************************************************************************************
927template< typename Type // Data type of the vector
928 , size_t N // Number of elements
929 , bool TF // Transpose flag
930 , AlignmentFlag AF // Alignment flag
931 , PaddingFlag PF // Padding flag
932 , typename Tag > // Type tag
935{
936 BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
937 return v_[index];
938}
939//*************************************************************************************************
940
941
942//*************************************************************************************************
951template< typename Type // Data type of the vector
952 , size_t N // Number of elements
953 , bool TF // Transpose flag
954 , AlignmentFlag AF // Alignment flag
955 , PaddingFlag PF // Padding flag
956 , typename Tag > // Type tag
959{
960 BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
961 return v_[index];
962}
963//*************************************************************************************************
964
965
966//*************************************************************************************************
976template< typename Type // Data type of the vector
977 , size_t N // Number of elements
978 , bool TF // Transpose flag
979 , AlignmentFlag AF // Alignment flag
980 , PaddingFlag PF // Padding flag
981 , typename Tag > // Type tag
984{
985 if( index >= size_ ) {
986 BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
987 }
988 return (*this)[index];
989}
990//*************************************************************************************************
991
992
993//*************************************************************************************************
1003template< typename Type // Data type of the vector
1004 , size_t N // Number of elements
1005 , bool TF // Transpose flag
1006 , AlignmentFlag AF // Alignment flag
1007 , PaddingFlag PF // Padding flag
1008 , typename Tag > // Type tag
1011{
1012 if( index >= size_ ) {
1013 BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
1014 }
1015 return (*this)[index];
1016}
1017//*************************************************************************************************
1018
1019
1020//*************************************************************************************************
1027template< typename Type // Data type of the vector
1028 , size_t N // Number of elements
1029 , bool TF // Transpose flag
1030 , AlignmentFlag AF // Alignment flag
1031 , PaddingFlag PF // Padding flag
1032 , typename Tag > // Type tag
1035{
1036 return v_;
1037}
1038//*************************************************************************************************
1039
1040
1041//*************************************************************************************************
1048template< typename Type // Data type of the vector
1049 , size_t N // Number of elements
1050 , bool TF // Transpose flag
1051 , AlignmentFlag AF // Alignment flag
1052 , PaddingFlag PF // Padding flag
1053 , typename Tag > // Type tag
1056{
1057 return v_;
1058}
1059//*************************************************************************************************
1060
1061
1062//*************************************************************************************************
1067template< typename Type // Data type of the vector
1068 , size_t N // Number of elements
1069 , bool TF // Transpose flag
1070 , AlignmentFlag AF // Alignment flag
1071 , PaddingFlag PF // Padding flag
1072 , typename Tag > // Type tag
1075{
1076 return Iterator( v_ );
1077}
1078//*************************************************************************************************
1079
1080
1081//*************************************************************************************************
1086template< typename Type // Data type of the vector
1087 , size_t N // Number of elements
1088 , bool TF // Transpose flag
1089 , AlignmentFlag AF // Alignment flag
1090 , PaddingFlag PF // Padding flag
1091 , typename Tag > // Type tag
1094{
1095 return ConstIterator( v_ );
1096}
1097//*************************************************************************************************
1098
1099
1100//*************************************************************************************************
1105template< typename Type // Data type of the vector
1106 , size_t N // Number of elements
1107 , bool TF // Transpose flag
1108 , AlignmentFlag AF // Alignment flag
1109 , PaddingFlag PF // Padding flag
1110 , typename Tag > // Type tag
1113{
1114 return ConstIterator( v_ );
1115}
1116//*************************************************************************************************
1117
1118
1119//*************************************************************************************************
1124template< typename Type // Data type of the vector
1125 , size_t N // Number of elements
1126 , bool TF // Transpose flag
1127 , AlignmentFlag AF // Alignment flag
1128 , PaddingFlag PF // Padding flag
1129 , typename Tag > // Type tag
1132{
1133 BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1134 return Iterator( v_ + size_ );
1135}
1136//*************************************************************************************************
1137
1138
1139//*************************************************************************************************
1144template< typename Type // Data type of the vector
1145 , size_t N // Number of elements
1146 , bool TF // Transpose flag
1147 , AlignmentFlag AF // Alignment flag
1148 , PaddingFlag PF // Padding flag
1149 , typename Tag > // Type tag
1152{
1153 BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1154 return ConstIterator( v_ + size_ );
1155}
1156//*************************************************************************************************
1157
1158
1159//*************************************************************************************************
1164template< typename Type // Data type of the vector
1165 , size_t N // Number of elements
1166 , bool TF // Transpose flag
1167 , AlignmentFlag AF // Alignment flag
1168 , PaddingFlag PF // Padding flag
1169 , typename Tag > // Type tag
1172{
1173 BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1174 return ConstIterator( v_ + size_ );
1175}
1176//*************************************************************************************************
1177
1178
1179
1180
1181//=================================================================================================
1182//
1183// ASSIGNMENT OPERATORS
1184//
1185//=================================================================================================
1186
1187//*************************************************************************************************
1193template< typename Type // Data type of the vector
1194 , size_t N // Number of elements
1195 , bool TF // Transpose flag
1196 , AlignmentFlag AF // Alignment flag
1197 , PaddingFlag PF // Padding flag
1198 , typename Tag > // Type tag
1201{
1202 BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1203
1204 for( size_t i=0UL; i<size_; ++i )
1205 v_[i] = rhs;
1206 return *this;
1207}
1208//*************************************************************************************************
1209
1210
1211//*************************************************************************************************
1230template< typename Type // Data type of the vector
1231 , size_t N // Number of elements
1232 , bool TF // Transpose flag
1233 , AlignmentFlag AF // Alignment flag
1234 , PaddingFlag PF // Padding flag
1235 , typename Tag > // Type tag
1237 HybridVector<Type,N,TF,AF,PF,Tag>::operator=( initializer_list<Type> list ) &
1238{
1239 if( list.size() > N ) {
1240 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to hybrid vector" );
1241 }
1242
1243 resize( list.size(), false );
1244
1245 size_t i( 0UL );
1246
1247 for( const auto& element : list ) {
1248 v_[i] = element;
1249 ++i;
1250 }
1251
1252 return *this;
1253}
1254//*************************************************************************************************
1255
1256
1257//*************************************************************************************************
1276template< typename Type // Data type of the vector
1277 , size_t N // Number of elements
1278 , bool TF // Transpose flag
1279 , AlignmentFlag AF // Alignment flag
1280 , PaddingFlag PF // Padding flag
1281 , typename Tag > // Type tag
1282template< typename Other // Data type of the static array
1283 , size_t Dim > // Number of elements of the static array
1286{
1287 BLAZE_STATIC_ASSERT( Dim <= N );
1288
1289 resize( Dim, false );
1290
1291 for( size_t i=0UL; i<Dim; ++i )
1292 v_[i] = array[i];
1293
1294 return *this;
1295}
1296//*************************************************************************************************
1297
1298
1299//*************************************************************************************************
1318template< typename Type // Data type of the vector
1319 , size_t N // Number of elements
1320 , bool TF // Transpose flag
1321 , AlignmentFlag AF // Alignment flag
1322 , PaddingFlag PF // Padding flag
1323 , typename Tag > // Type tag
1324template< typename Other // Data type of the std::array
1325 , size_t Dim > // Dimension of the std::array
1327 HybridVector<Type,N,TF,AF,PF,Tag>::operator=( const std::array<Other,Dim>& array ) &
1328{
1329 BLAZE_STATIC_ASSERT( Dim <= N );
1330
1331 resize( Dim, false );
1332
1333 for( size_t i=0UL; i<Dim; ++i )
1334 v_[i] = array[i];
1335
1336 return *this;
1337}
1338//*************************************************************************************************
1339
1340
1341//*************************************************************************************************
1349template< typename Type // Data type of the vector
1350 , size_t N // Number of elements
1351 , bool TF // Transpose flag
1352 , AlignmentFlag AF // Alignment flag
1353 , PaddingFlag PF // Padding flag
1354 , typename Tag > // Type tag
1357{
1358 using blaze::assign;
1359
1360 BLAZE_INTERNAL_ASSERT( size_ <= N, "Invalid size detected" );
1361
1362 resize( rhs.size() );
1363 assign( *this, *rhs );
1364
1365 BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1366
1367 return *this;
1368}
1369//*************************************************************************************************
1370
1371
1372//*************************************************************************************************
1382template< typename Type // Data type of the vector
1383 , size_t N // Number of elements
1384 , bool TF // Transpose flag
1385 , AlignmentFlag AF // Alignment flag
1386 , PaddingFlag PF // Padding flag
1387 , typename Tag > // Type tag
1388template< typename VT > // Type of the right-hand side vector
1391{
1392 using blaze::assign;
1393
1395
1396 if( (*rhs).size() > N ) {
1397 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to hybrid vector" );
1398 }
1399
1400 if( (*rhs).canAlias( this ) ) {
1401 HybridVector tmp( *rhs );
1402 swap( tmp );
1403 }
1404 else {
1405 resize( (*rhs).size(), false );
1406 if( IsSparseVector_v<VT> )
1407 reset();
1408 assign( *this, *rhs );
1409 }
1410
1411 BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1412
1413 return *this;
1414}
1415//*************************************************************************************************
1416
1417
1418//*************************************************************************************************
1428template< typename Type // Data type of the vector
1429 , size_t N // Number of elements
1430 , bool TF // Transpose flag
1431 , AlignmentFlag AF // Alignment flag
1432 , PaddingFlag PF // Padding flag
1433 , typename Tag > // Type tag
1434template< typename VT > // Type of the right-hand side vector
1437{
1438 using blaze::addAssign;
1439
1441
1442 if( (*rhs).size() != size_ ) {
1443 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1444 }
1445
1446 if( (*rhs).canAlias( this ) ) {
1447 const ResultType_t<VT> tmp( *rhs );
1448 addAssign( *this, tmp );
1449 }
1450 else {
1451 addAssign( *this, *rhs );
1452 }
1453
1454 BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1455
1456 return *this;
1457}
1458//*************************************************************************************************
1459
1460
1461//*************************************************************************************************
1471template< typename Type // Data type of the vector
1472 , size_t N // Number of elements
1473 , bool TF // Transpose flag
1474 , AlignmentFlag AF // Alignment flag
1475 , PaddingFlag PF // Padding flag
1476 , typename Tag > // Type tag
1477template< typename VT > // Type of the right-hand side vector
1480{
1481 using blaze::subAssign;
1482
1484
1485 if( (*rhs).size() != size_ ) {
1486 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1487 }
1488
1489 if( (*rhs).canAlias( this ) ) {
1490 const ResultType_t<VT> tmp( *rhs );
1491 subAssign( *this, tmp );
1492 }
1493 else {
1494 subAssign( *this, *rhs );
1495 }
1496
1497 BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1498
1499 return *this;
1500}
1501//*************************************************************************************************
1502
1503
1504//*************************************************************************************************
1515template< typename Type // Data type of the vector
1516 , size_t N // Number of elements
1517 , bool TF // Transpose flag
1518 , AlignmentFlag AF // Alignment flag
1519 , PaddingFlag PF // Padding flag
1520 , typename Tag > // Type tag
1521template< typename VT > // Type of the right-hand side vector
1524{
1525 using blaze::assign;
1526 using blaze::multAssign;
1527
1529
1530 if( (*rhs).size() != size_ ) {
1531 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1532 }
1533
1534 if( IsSparseVector_v<VT> || (*rhs).canAlias( this ) ) {
1535 const HybridVector tmp( *this * (*rhs) );
1536 assign( *this, tmp );
1537 }
1538 else {
1539 multAssign( *this, *rhs );
1540 }
1541
1542 BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1543
1544 return *this;
1545}
1546//*************************************************************************************************
1547
1548
1549//*************************************************************************************************
1559template< typename Type // Data type of the vector
1560 , size_t N // Number of elements
1561 , bool TF // Transpose flag
1562 , AlignmentFlag AF // Alignment flag
1563 , PaddingFlag PF // Padding flag
1564 , typename Tag > // Type tag
1565template< typename VT > // Type of the right-hand side vector
1568{
1569 using blaze::assign;
1570 using blaze::divAssign;
1571
1573
1574 if( (*rhs).size() != size_ ) {
1575 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1576 }
1577
1578 if( (*rhs).canAlias( this ) ) {
1579 const HybridVector tmp( *this / (*rhs) );
1580 assign( *this, tmp );
1581 }
1582 else {
1583 divAssign( *this, *rhs );
1584 }
1585
1586 BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1587
1588 return *this;
1589}
1590//*************************************************************************************************
1591
1592
1593//*************************************************************************************************
1604template< typename Type // Data type of the vector
1605 , size_t N // Number of elements
1606 , bool TF // Transpose flag
1607 , AlignmentFlag AF // Alignment flag
1608 , PaddingFlag PF // Padding flag
1609 , typename Tag > // Type tag
1610template< typename VT > // Type of the right-hand side vector
1613{
1614 using blaze::assign;
1615
1617
1620
1621 using CrossType = CrossTrait_t< This, ResultType_t<VT> >;
1622
1626
1627 if( size_ != 3UL || (*rhs).size() != 3UL ) {
1628 BLAZE_THROW_INVALID_ARGUMENT( "Invalid vector size for cross product" );
1629 }
1630
1631 const CrossType tmp( *this % (*rhs) );
1632 assign( *this, tmp );
1633
1634 BLAZE_INTERNAL_ASSERT( isIntact(), "Invariant violation detected" );
1635
1636 return *this;
1637}
1638//*************************************************************************************************
1639
1640
1641
1642
1643//=================================================================================================
1644//
1645// UTILITY FUNCTIONS
1646//
1647//=================================================================================================
1648
1649//*************************************************************************************************
1654template< typename Type // Data type of the vector
1655 , size_t N // Number of elements
1656 , bool TF // Transpose flag
1657 , AlignmentFlag AF // Alignment flag
1658 , PaddingFlag PF // Padding flag
1659 , typename Tag > // Type tag
1660constexpr size_t HybridVector<Type,N,TF,AF,PF,Tag>::size() const noexcept
1661{
1662 return size_;
1663}
1664//*************************************************************************************************
1665
1666
1667//*************************************************************************************************
1675template< typename Type // Data type of the vector
1676 , size_t N // Number of elements
1677 , bool TF // Transpose flag
1678 , AlignmentFlag AF // Alignment flag
1679 , PaddingFlag PF // Padding flag
1680 , typename Tag > // Type tag
1682{
1683 return NN;
1684}
1685//*************************************************************************************************
1686
1687
1688//*************************************************************************************************
1693template< typename Type // Data type of the vector
1694 , size_t N // Number of elements
1695 , bool TF // Transpose flag
1696 , AlignmentFlag AF // Alignment flag
1697 , PaddingFlag PF // Padding flag
1698 , typename Tag > // Type tag
1700{
1701 return NN;
1702}
1703//*************************************************************************************************
1704
1705
1706//*************************************************************************************************
1715template< typename Type // Data type of the vector
1716 , size_t N // Number of elements
1717 , bool TF // Transpose flag
1718 , AlignmentFlag AF // Alignment flag
1719 , PaddingFlag PF // Padding flag
1720 , typename Tag > // Type tag
1722{
1723 size_t nonzeros( 0 );
1724
1725 for( size_t i=0UL; i<size_; ++i ) {
1726 if( !isDefault<strict>( v_[i] ) )
1727 ++nonzeros;
1728 }
1729
1730 return nonzeros;
1731}
1732//*************************************************************************************************
1733
1734
1735//*************************************************************************************************
1740template< typename Type // Data type of the vector
1741 , size_t N // Number of elements
1742 , bool TF // Transpose flag
1743 , AlignmentFlag AF // Alignment flag
1744 , PaddingFlag PF // Padding flag
1745 , typename Tag > // Type tag
1747{
1748 using blaze::clear;
1749 for( size_t i=0UL; i<size_; ++i )
1750 clear( v_[i] );
1751}
1752//*************************************************************************************************
1753
1754
1755//*************************************************************************************************
1762template< typename Type // Data type of the vector
1763 , size_t N // Number of elements
1764 , bool TF // Transpose flag
1765 , AlignmentFlag AF // Alignment flag
1766 , PaddingFlag PF // Padding flag
1767 , typename Tag > // Type tag
1769{
1770 resize( 0UL );
1771}
1772//*************************************************************************************************
1773
1774
1775//*************************************************************************************************
1806template< typename Type // Data type of the vector
1807 , size_t N // Number of elements
1808 , bool TF // Transpose flag
1809 , AlignmentFlag AF // Alignment flag
1810 , PaddingFlag PF // Padding flag
1811 , typename Tag > // Type tag
1812constexpr void HybridVector<Type,N,TF,AF,PF,Tag>::resize( size_t n, bool preserve )
1813{
1814 using blaze::clear;
1815
1816 MAYBE_UNUSED( preserve );
1817
1818 if( n > N ) {
1819 BLAZE_THROW_INVALID_ARGUMENT( "Invalid size for hybrid vector" );
1820 }
1821
1822 if( IsNumeric_v<Type> && n < size_ ) {
1823 for( size_t i=n; i<size_; ++i )
1824 clear( v_[i] );
1825 }
1826
1827 size_ = n;
1828}
1829//*************************************************************************************************
1830
1831
1832//*************************************************************************************************
1846template< typename Type // Data type of the vector
1847 , size_t N // Number of elements
1848 , bool TF // Transpose flag
1849 , AlignmentFlag AF // Alignment flag
1850 , PaddingFlag PF // Padding flag
1851 , typename Tag > // Type tag
1852constexpr void HybridVector<Type,N,TF,AF,PF,Tag>::extend( size_t n, bool preserve )
1853{
1854 MAYBE_UNUSED( preserve );
1855 resize( size_+n );
1856}
1857//*************************************************************************************************
1858
1859
1860//*************************************************************************************************
1866template< typename Type // Data type of the vector
1867 , size_t N // Number of elements
1868 , bool TF // Transpose flag
1869 , AlignmentFlag AF // Alignment flag
1870 , PaddingFlag PF // Padding flag
1871 , typename Tag > // Type tag
1873{
1874 using std::swap;
1875
1876 const size_t maxsize( max( size_, v.size_ ) );
1877 for( size_t i=0UL; i<maxsize; ++i )
1878 swap( v_[i], v.v_[i] );
1879 swap( size_, v.size_ );
1880}
1881//*************************************************************************************************
1882
1883
1884
1885
1886//=================================================================================================
1887//
1888// NUMERIC FUNCTIONS
1889//
1890//=================================================================================================
1891
1892//*************************************************************************************************
1909template< typename Type // Data type of the vector
1910 , size_t N // Number of elements
1911 , bool TF // Transpose flag
1912 , AlignmentFlag AF // Alignment flag
1913 , PaddingFlag PF // Padding flag
1914 , typename Tag > // Type tag
1915template< typename Other > // Data type of the scalar value
1918{
1919 for( size_t i=0; i<size_; ++i )
1920 v_[i] *= scalar;
1921 return *this;
1922}
1923//*************************************************************************************************
1924
1925
1926
1927
1928//=================================================================================================
1929//
1930// MEMORY FUNCTIONS
1931//
1932//=================================================================================================
1933
1934//*************************************************************************************************
1944template< typename Type // Data type of the vector
1945 , size_t N // Number of elements
1946 , bool TF // Transpose flag
1947 , AlignmentFlag AF // Alignment flag
1948 , PaddingFlag PF // Padding flag
1949 , typename Tag > // Type tag
1951{
1952 MAYBE_UNUSED( size );
1953
1954 BLAZE_INTERNAL_ASSERT( size == sizeof( HybridVector ), "Invalid number of bytes detected" );
1955
1956 return allocate<HybridVector>( 1UL );
1957}
1958//*************************************************************************************************
1959
1960
1961//*************************************************************************************************
1971template< typename Type // Data type of the vector
1972 , size_t N // Number of elements
1973 , bool TF // Transpose flag
1974 , AlignmentFlag AF // Alignment flag
1975 , PaddingFlag PF // Padding flag
1976 , typename Tag > // Type tag
1977inline void* HybridVector<Type,N,TF,AF,PF,Tag>::operator new[]( std::size_t size )
1978{
1979 BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridVector ) , "Invalid number of bytes detected" );
1980 BLAZE_INTERNAL_ASSERT( size % sizeof( HybridVector ) == 0UL, "Invalid number of bytes detected" );
1981
1982 return allocate<HybridVector>( size/sizeof(HybridVector) );
1983}
1984//*************************************************************************************************
1985
1986
1987//*************************************************************************************************
1997template< typename Type // Data type of the vector
1998 , size_t N // Number of elements
1999 , bool TF // Transpose flag
2000 , AlignmentFlag AF // Alignment flag
2001 , PaddingFlag PF // Padding flag
2002 , typename Tag > // Type tag
2003inline void* HybridVector<Type,N,TF,AF,PF,Tag>::operator new( std::size_t size, const std::nothrow_t& )
2004{
2005 MAYBE_UNUSED( size );
2006
2007 BLAZE_INTERNAL_ASSERT( size == sizeof( HybridVector ), "Invalid number of bytes detected" );
2008
2009 return allocate<HybridVector>( 1UL );
2010}
2011//*************************************************************************************************
2012
2013
2014//*************************************************************************************************
2024template< typename Type // Data type of the vector
2025 , size_t N // Number of elements
2026 , bool TF // Transpose flag
2027 , AlignmentFlag AF // Alignment flag
2028 , PaddingFlag PF // Padding flag
2029 , typename Tag > // Type tag
2030inline void* HybridVector<Type,N,TF,AF,PF,Tag>::operator new[]( std::size_t size, const std::nothrow_t& )
2031{
2032 BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridVector ) , "Invalid number of bytes detected" );
2033 BLAZE_INTERNAL_ASSERT( size % sizeof( HybridVector ) == 0UL, "Invalid number of bytes detected" );
2034
2035 return allocate<HybridVector>( size/sizeof(HybridVector) );
2036}
2037//*************************************************************************************************
2038
2039
2040//*************************************************************************************************
2046template< typename Type // Data type of the vector
2047 , size_t N // Number of elements
2048 , bool TF // Transpose flag
2049 , AlignmentFlag AF // Alignment flag
2050 , PaddingFlag PF // Padding flag
2051 , typename Tag > // Type tag
2052inline void HybridVector<Type,N,TF,AF,PF,Tag>::operator delete( void* ptr )
2053{
2054 deallocate( static_cast<HybridVector*>( ptr ) );
2055}
2056//*************************************************************************************************
2057
2058
2059//*************************************************************************************************
2065template< typename Type // Data type of the vector
2066 , size_t N // Number of elements
2067 , bool TF // Transpose flag
2068 , AlignmentFlag AF // Alignment flag
2069 , PaddingFlag PF // Padding flag
2070 , typename Tag > // Type tag
2071inline void HybridVector<Type,N,TF,AF,PF,Tag>::operator delete[]( void* ptr )
2072{
2073 deallocate( static_cast<HybridVector*>( ptr ) );
2074}
2075//*************************************************************************************************
2076
2077
2078//*************************************************************************************************
2084template< typename Type // Data type of the vector
2085 , size_t N // Number of elements
2086 , bool TF // Transpose flag
2087 , AlignmentFlag AF // Alignment flag
2088 , PaddingFlag PF // Padding flag
2089 , typename Tag > // Type tag
2090inline void HybridVector<Type,N,TF,AF,PF,Tag>::operator delete( void* ptr, const std::nothrow_t& )
2091{
2092 deallocate( static_cast<HybridVector*>( ptr ) );
2093}
2094//*************************************************************************************************
2095
2096
2097//*************************************************************************************************
2103template< typename Type // Data type of the vector
2104 , size_t N // Number of elements
2105 , bool TF // Transpose flag
2106 , AlignmentFlag AF // Alignment flag
2107 , PaddingFlag PF // Padding flag
2108 , typename Tag > // Type tag
2109inline void HybridVector<Type,N,TF,AF,PF,Tag>::operator delete[]( void* ptr, const std::nothrow_t& )
2110{
2111 deallocate( static_cast<HybridVector*>( ptr ) );
2112}
2113//*************************************************************************************************
2114
2115
2116
2117
2118//=================================================================================================
2119//
2120// DEBUGGING FUNCTIONS
2121//
2122//=================================================================================================
2123
2124//*************************************************************************************************
2133template< typename Type // Data type of the vector
2134 , size_t N // Number of elements
2135 , bool TF // Transpose flag
2136 , AlignmentFlag AF // Alignment flag
2137 , PaddingFlag PF // Padding flag
2138 , typename Tag > // Type tag
2139constexpr bool HybridVector<Type,N,TF,AF,PF,Tag>::isIntact() const noexcept
2140{
2141 if( size_ > N )
2142 return false;
2143
2144 if( IsVectorizable_v<Type> ) {
2145 for( size_t i=size_; i<NN; ++i ) {
2146 if( !isDefault<strict>( v_[i] ) )
2147 return false;
2148 }
2149 }
2150
2151 return true;
2152}
2153//*************************************************************************************************
2154
2155
2156
2157
2158//=================================================================================================
2159//
2160// EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2161//
2162//=================================================================================================
2163
2164//*************************************************************************************************
2174template< typename Type // Data type of the vector
2175 , size_t N // Number of elements
2176 , bool TF // Transpose flag
2177 , AlignmentFlag AF // Alignment flag
2178 , PaddingFlag PF // Padding flag
2179 , typename Tag > // Type tag
2180template< typename Other > // Data type of the foreign expression
2181inline bool HybridVector<Type,N,TF,AF,PF,Tag>::canAlias( const Other* alias ) const noexcept
2182{
2183 return static_cast<const void*>( this ) == static_cast<const void*>( alias );
2184}
2185//*************************************************************************************************
2186
2187
2188//*************************************************************************************************
2198template< typename Type // Data type of the vector
2199 , size_t N // Number of elements
2200 , bool TF // Transpose flag
2201 , AlignmentFlag AF // Alignment flag
2202 , PaddingFlag PF // Padding flag
2203 , typename Tag > // Type tag
2204template< typename Other > // Data type of the foreign expression
2205inline bool HybridVector<Type,N,TF,AF,PF,Tag>::isAliased( const Other* alias ) const noexcept
2206{
2207 return static_cast<const void*>( this ) == static_cast<const void*>( alias );
2208}
2209//*************************************************************************************************
2210
2211
2212//*************************************************************************************************
2221template< typename Type // Data type of the vector
2222 , size_t N // Number of elements
2223 , bool TF // Transpose flag
2224 , AlignmentFlag AF // Alignment flag
2225 , PaddingFlag PF // Padding flag
2226 , typename Tag > // Type tag
2228{
2229 return AF == aligned;
2230}
2231//*************************************************************************************************
2232
2233
2234//*************************************************************************************************
2246template< typename Type // Data type of the vector
2247 , size_t N // Number of elements
2248 , bool TF // Transpose flag
2249 , AlignmentFlag AF // Alignment flag
2250 , PaddingFlag PF // Padding flag
2251 , typename Tag > // Type tag
2253 HybridVector<Type,N,TF,AF,PF,Tag>::load( size_t index ) const noexcept
2254{
2255 if( AF == aligned )
2256 return loada( index );
2257 else
2258 return loadu( index );
2259}
2260//*************************************************************************************************
2261
2262
2263//*************************************************************************************************
2276template< typename Type // Data type of the vector
2277 , size_t N // Number of elements
2278 , bool TF // Transpose flag
2279 , AlignmentFlag AF // Alignment flag
2280 , PaddingFlag PF // Padding flag
2281 , typename Tag > // Type tag
2283 HybridVector<Type,N,TF,AF,PF,Tag>::loada( size_t index ) const noexcept
2284{
2285 using blaze::loada;
2286
2288
2289 BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2290 BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2291 BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
2292 BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
2293
2294 return loada( &v_[index] );
2295}
2296//*************************************************************************************************
2297
2298
2299//*************************************************************************************************
2312template< typename Type // Data type of the vector
2313 , size_t N // Number of elements
2314 , bool TF // Transpose flag
2315 , AlignmentFlag AF // Alignment flag
2316 , PaddingFlag PF // Padding flag
2317 , typename Tag > // Type tag
2319 HybridVector<Type,N,TF,AF,PF,Tag>::loadu( size_t index ) const noexcept
2320{
2321 using blaze::loadu;
2322
2324
2325 BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2326 BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2327
2328 return loadu( &v_[index] );
2329}
2330//*************************************************************************************************
2331
2332
2333//*************************************************************************************************
2346template< typename Type // Data type of the vector
2347 , size_t N // Number of elements
2348 , bool TF // Transpose flag
2349 , AlignmentFlag AF // Alignment flag
2350 , PaddingFlag PF // Padding flag
2351 , typename Tag > // Type tag
2353 HybridVector<Type,N,TF,AF,PF,Tag>::store( size_t index, const SIMDType& value ) noexcept
2354{
2355 if( AF == aligned )
2356 storea( index, value );
2357 else
2358 storeu( index, value );
2359}
2360//*************************************************************************************************
2361
2362
2363//*************************************************************************************************
2376template< typename Type // Data type of the vector
2377 , size_t N // Number of elements
2378 , bool TF // Transpose flag
2379 , AlignmentFlag AF // Alignment flag
2380 , PaddingFlag PF // Padding flag
2381 , typename Tag > // Type tag
2383 HybridVector<Type,N,TF,AF,PF,Tag>::storea( size_t index, const SIMDType& value ) noexcept
2384{
2385 using blaze::storea;
2386
2388
2389 BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2390 BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2391 BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
2392 BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
2393
2394 storea( &v_[index], value );
2395}
2396//*************************************************************************************************
2397
2398
2399//*************************************************************************************************
2412template< typename Type // Data type of the vector
2413 , size_t N // Number of elements
2414 , bool TF // Transpose flag
2415 , AlignmentFlag AF // Alignment flag
2416 , PaddingFlag PF // Padding flag
2417 , typename Tag > // Type tag
2419 HybridVector<Type,N,TF,AF,PF,Tag>::storeu( size_t index, const SIMDType& value ) noexcept
2420{
2421 using blaze::storeu;
2422
2424
2425 BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2426 BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2427
2428 storeu( &v_[index], value );
2429}
2430//*************************************************************************************************
2431
2432
2433//*************************************************************************************************
2447template< typename Type // Data type of the vector
2448 , size_t N // Number of elements
2449 , bool TF // Transpose flag
2450 , AlignmentFlag AF // Alignment flag
2451 , PaddingFlag PF // Padding flag
2452 , typename Tag > // Type tag
2454 HybridVector<Type,N,TF,AF,PF,Tag>::stream( size_t index, const SIMDType& value ) noexcept
2455{
2456 using blaze::stream;
2457
2459
2460 BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2461 BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= NN, "Invalid vector access index" );
2462 BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
2463 BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[index] ), "Invalid alignment detected" );
2464
2465 stream( &v_[index], value );
2466}
2467//*************************************************************************************************
2468
2469
2470//*************************************************************************************************
2481template< typename Type // Data type of the vector
2482 , size_t N // Number of elements
2483 , bool TF // Transpose flag
2484 , AlignmentFlag AF // Alignment flag
2485 , PaddingFlag PF // Padding flag
2486 , typename Tag > // Type tag
2487template< typename VT > // Type of the right-hand side dense vector
2490{
2491 BLAZE_INTERNAL_ASSERT( (*rhs).size() == size_, "Invalid vector sizes" );
2492
2493 for( size_t i=0UL; i<size_; ++i )
2494 v_[i] = (*rhs)[i];
2495}
2496//*************************************************************************************************
2497
2498
2499//*************************************************************************************************
2510template< typename Type // Data type of the vector
2511 , size_t N // Number of elements
2512 , bool TF // Transpose flag
2513 , AlignmentFlag AF // Alignment flag
2514 , PaddingFlag PF // Padding flag
2515 , typename Tag > // Type tag
2516template< typename VT > // Type of the right-hand side dense vector
2519{
2521
2522 BLAZE_INTERNAL_ASSERT( (*rhs).size() == size_, "Invalid vector sizes" );
2523
2524 constexpr bool remainder( PF == unpadded || !IsPadded_v<VT> );
2525
2526 const size_t ipos( remainder ? prevMultiple( size_, SIMDSIZE ) : size_ );
2527 BLAZE_INTERNAL_ASSERT( ipos <= size_, "Invalid end calculation" );
2528
2529 size_t i( 0UL );
2530
2531 for( ; i<ipos; i+=SIMDSIZE ) {
2532 store( i, (*rhs).load(i) );
2533 }
2534 for( ; remainder && i<size_; ++i ) {
2535 v_[i] = (*rhs)[i];
2536 }
2537}
2538//*************************************************************************************************
2539
2540
2541//*************************************************************************************************
2552template< typename Type // Data type of the vector
2553 , size_t N // Number of elements
2554 , bool TF // Transpose flag
2555 , AlignmentFlag AF // Alignment flag
2556 , PaddingFlag PF // Padding flag
2557 , typename Tag > // Type tag
2558template< typename VT > // Type of the right-hand side sparse vector
2560{
2561 BLAZE_INTERNAL_ASSERT( (*rhs).size() == size_, "Invalid vector sizes" );
2562
2563 for( auto element=(*rhs).begin(); element!=(*rhs).end(); ++element )
2564 v_[element->index()] = element->value();
2565}
2566//*************************************************************************************************
2567
2568
2569//*************************************************************************************************
2580template< typename Type // Data type of the vector
2581 , size_t N // Number of elements
2582 , bool TF // Transpose flag
2583 , AlignmentFlag AF // Alignment flag
2584 , PaddingFlag PF // Padding flag
2585 , typename Tag > // Type tag
2586template< typename VT > // Type of the right-hand side dense vector
2589{
2590 BLAZE_INTERNAL_ASSERT( (*rhs).size() == size_, "Invalid vector sizes" );
2591
2592 for( size_t i=0UL; i<size_; ++i )
2593 v_[i] += (*rhs)[i];
2594}
2595//*************************************************************************************************
2596
2597
2598//*************************************************************************************************
2609template< typename Type // Data type of the vector
2610 , size_t N // Number of elements
2611 , bool TF // Transpose flag
2612 , AlignmentFlag AF // Alignment flag
2613 , PaddingFlag PF // Padding flag
2614 , typename Tag > // Type tag
2615template< typename VT > // Type of the right-hand side dense vector
2618{
2620
2621 BLAZE_INTERNAL_ASSERT( (*rhs).size() == size_, "Invalid vector sizes" );
2622
2623 constexpr bool remainder( PF == unpadded || !IsPadded_v<VT> );
2624
2625 const size_t ipos( remainder ? prevMultiple( size_, SIMDSIZE ) : size_ );
2626 BLAZE_INTERNAL_ASSERT( ipos <= size_, "Invalid end calculation" );
2627
2628 size_t i( 0UL );
2629
2630 for( ; i<ipos; i+=SIMDSIZE ) {
2631 store( i, load(i) + (*rhs).load(i) );
2632 }
2633 for( ; remainder && i<size_; ++i ) {
2634 v_[i] += (*rhs)[i];
2635 }
2636}
2637//*************************************************************************************************
2638
2639
2640//*************************************************************************************************
2651template< typename Type // Data type of the vector
2652 , size_t N // Number of elements
2653 , bool TF // Transpose flag
2654 , AlignmentFlag AF // Alignment flag
2655 , PaddingFlag PF // Padding flag
2656 , typename Tag > // Type tag
2657template< typename VT > // Type of the right-hand side sparse vector
2659{
2660 BLAZE_INTERNAL_ASSERT( (*rhs).size() == size_, "Invalid vector sizes" );
2661
2662 for( auto element=(*rhs).begin(); element!=(*rhs).end(); ++element )
2663 v_[element->index()] += element->value();
2664}
2665//*************************************************************************************************
2666
2667
2668//*************************************************************************************************
2679template< typename Type // Data type of the vector
2680 , size_t N // Number of elements
2681 , bool TF // Transpose flag
2682 , AlignmentFlag AF // Alignment flag
2683 , PaddingFlag PF // Padding flag
2684 , typename Tag > // Type tag
2685template< typename VT > // Type of the right-hand side dense vector
2688{
2689 BLAZE_INTERNAL_ASSERT( (*rhs).size() == size_, "Invalid vector sizes" );
2690
2691 for( size_t i=0UL; i<size_; ++i )
2692 v_[i] -= (*rhs)[i];
2693}
2694//*************************************************************************************************
2695
2696
2697//*************************************************************************************************
2708template< typename Type // Data type of the vector
2709 , size_t N // Number of elements
2710 , bool TF // Transpose flag
2711 , AlignmentFlag AF // Alignment flag
2712 , PaddingFlag PF // Padding flag
2713 , typename Tag > // Type tag
2714template< typename VT > // Type of the right-hand side dense vector
2717{
2719
2720 BLAZE_INTERNAL_ASSERT( (*rhs).size() == size_, "Invalid vector sizes" );
2721
2722 constexpr bool remainder( PF == unpadded || !IsPadded_v<VT> );
2723
2724 const size_t ipos( remainder ? prevMultiple( size_, SIMDSIZE ) : size_ );
2725 BLAZE_INTERNAL_ASSERT( ipos <= size_, "Invalid end calculation" );
2726
2727 size_t i( 0UL );
2728
2729 for( ; i<ipos; i+=SIMDSIZE ) {
2730 store( i, load(i) - (*rhs).load(i) );
2731 }
2732 for( ; remainder && i<size_; ++i ) {
2733 v_[i] -= (*rhs)[i];
2734 }
2735}
2736//*************************************************************************************************
2737
2738
2739//*************************************************************************************************
2750template< typename Type // Data type of the vector
2751 , size_t N // Number of elements
2752 , bool TF // Transpose flag
2753 , AlignmentFlag AF // Alignment flag
2754 , PaddingFlag PF // Padding flag
2755 , typename Tag > // Type tag
2756template< typename VT > // Type of the right-hand side sparse vector
2758{
2759 BLAZE_INTERNAL_ASSERT( (*rhs).size() == size_, "Invalid vector sizes" );
2760
2761 for( auto element=(*rhs).begin(); element!=(*rhs).end(); ++element )
2762 v_[element->index()] -= element->value();
2763}
2764//*************************************************************************************************
2765
2766
2767//*************************************************************************************************
2778template< typename Type // Data type of the vector
2779 , size_t N // Number of elements
2780 , bool TF // Transpose flag
2781 , AlignmentFlag AF // Alignment flag
2782 , PaddingFlag PF // Padding flag
2783 , typename Tag > // Type tag
2784template< typename VT > // Type of the right-hand side dense vector
2787{
2788 BLAZE_INTERNAL_ASSERT( (*rhs).size() == size_, "Invalid vector sizes" );
2789
2790 for( size_t i=0UL; i<size_; ++i )
2791 v_[i] *= (*rhs)[i];
2792}
2793//*************************************************************************************************
2794
2795
2796//*************************************************************************************************
2807template< typename Type // Data type of the vector
2808 , size_t N // Number of elements
2809 , bool TF // Transpose flag
2810 , AlignmentFlag AF // Alignment flag
2811 , PaddingFlag PF // Padding flag
2812 , typename Tag > // Type tag
2813template< typename VT > // Type of the right-hand side dense vector
2816{
2818
2819 BLAZE_INTERNAL_ASSERT( (*rhs).size() == size_, "Invalid vector sizes" );
2820
2821 constexpr bool remainder( PF == unpadded || !IsPadded_v<VT> );
2822
2823 const size_t ipos( remainder ? prevMultiple( size_, SIMDSIZE ) : size_ );
2824 BLAZE_INTERNAL_ASSERT( ipos <= size_, "Invalid end calculation" );
2825
2826 size_t i( 0UL );
2827
2828 for( ; i<ipos; i+=SIMDSIZE ) {
2829 store( i, load(i) * (*rhs).load(i) );
2830 }
2831 for( ; remainder && i<size_; ++i ) {
2832 v_[i] *= (*rhs)[i];
2833 }
2834}
2835//*************************************************************************************************
2836
2837
2838//*************************************************************************************************
2849template< typename Type // Data type of the vector
2850 , size_t N // Number of elements
2851 , bool TF // Transpose flag
2852 , AlignmentFlag AF // Alignment flag
2853 , PaddingFlag PF // Padding flag
2854 , typename Tag > // Type tag
2855template< typename VT > // Type of the right-hand side sparse vector
2857{
2858 BLAZE_INTERNAL_ASSERT( (*rhs).size() == size_, "Invalid vector sizes" );
2859
2860 const HybridVector tmp( serial( *this ) );
2861
2862 reset();
2863
2864 for( auto element=(*rhs).begin(); element!=(*rhs).end(); ++element )
2865 v_[element->index()] = tmp[element->index()] * element->value();
2866}
2867//*************************************************************************************************
2868
2869
2870//*************************************************************************************************
2881template< typename Type // Data type of the vector
2882 , size_t N // Number of elements
2883 , bool TF // Transpose flag
2884 , AlignmentFlag AF // Alignment flag
2885 , PaddingFlag PF // Padding flag
2886 , typename Tag > // Type tag
2887template< typename VT > // Type of the right-hand side dense vector
2890{
2891 BLAZE_INTERNAL_ASSERT( (*rhs).size() == size_, "Invalid vector sizes" );
2892
2893 for( size_t i=0UL; i<size_; ++i )
2894 v_[i] /= (*rhs)[i];
2895}
2896//*************************************************************************************************
2897
2898
2899//*************************************************************************************************
2910template< typename Type // Data type of the vector
2911 , size_t N // Number of elements
2912 , bool TF // Transpose flag
2913 , AlignmentFlag AF // Alignment flag
2914 , PaddingFlag PF // Padding flag
2915 , typename Tag > // Type tag
2916template< typename VT > // Type of the right-hand side dense vector
2919{
2921
2922 BLAZE_INTERNAL_ASSERT( (*rhs).size() == size_, "Invalid vector sizes" );
2923
2924 const size_t ipos( prevMultiple( size_, SIMDSIZE ) );
2925 BLAZE_INTERNAL_ASSERT( ipos <= size_, "Invalid end calculation" );
2926
2927 size_t i( 0UL );
2928
2929 for( ; i<ipos; i+=SIMDSIZE ) {
2930 store( i, load(i) / (*rhs).load(i) );
2931 }
2932 for( ; i<size_; ++i ) {
2933 v_[i] /= (*rhs)[i];
2934 }
2935}
2936//*************************************************************************************************
2937
2938
2939
2940
2941
2942
2943
2944
2945//=================================================================================================
2946//
2947// HYBRIDVECTOR OPERATORS
2948//
2949//=================================================================================================
2950
2951//*************************************************************************************************
2954template< RelaxationFlag RF, typename Type, size_t N, bool TF, AlignmentFlag AF, PaddingFlag PF, typename Tag >
2955bool isDefault( const HybridVector<Type,N,TF,AF,PF,Tag>& v );
2956
2957template< typename Type, size_t N, bool TF, AlignmentFlag AF, PaddingFlag PF, typename Tag >
2958constexpr bool isIntact( const HybridVector<Type,N,TF,AF,PF,Tag>& v );
2959
2960template< typename Type, size_t N, bool TF, AlignmentFlag AF, PaddingFlag PF, typename Tag >
2961void swap( HybridVector<Type,N,TF,AF,PF,Tag>& a, HybridVector<Type,N,TF,AF,PF,Tag>& b ) noexcept;
2963//*************************************************************************************************
2964
2965
2966//*************************************************************************************************
2990template< RelaxationFlag RF // Relaxation flag
2991 , typename Type // Data type of the vector
2992 , size_t N // Number of elements
2993 , bool TF // Transpose flag
2994 , AlignmentFlag AF // Alignment flag
2995 , PaddingFlag PF // Padding flag
2996 , typename Tag > // Type tag
2998{
2999 return ( v.size() == 0UL );
3000}
3001//*************************************************************************************************
3002
3003
3004//*************************************************************************************************
3022template< typename Type // Data type of the vector
3023 , size_t N // Number of elements
3024 , bool TF // Transpose flag
3025 , AlignmentFlag AF // Alignment flag
3026 , PaddingFlag PF // Padding flag
3027 , typename Tag > // Type tag
3029{
3030 return v.isIntact();
3031}
3032//*************************************************************************************************
3033
3034
3035//*************************************************************************************************
3043template< typename Type // Data type of the vector
3044 , size_t N // Number of elements
3045 , bool TF // Transpose flag
3046 , AlignmentFlag AF // Alignment flag
3047 , PaddingFlag PF // Padding flag
3048 , typename Tag > // Type tag
3050{
3051 a.swap( b );
3052}
3053//*************************************************************************************************
3054
3055
3056
3057
3058//=================================================================================================
3059//
3060// MAXSIZE SPECIALIZATIONS
3061//
3062//=================================================================================================
3063
3064//*************************************************************************************************
3066template< typename T, size_t N, bool TF, AlignmentFlag AF, PaddingFlag PF, typename Tag >
3067struct MaxSize< HybridVector<T,N,TF,AF,PF,Tag>, 0UL >
3068 : public Ptrdiff_t< static_cast<ptrdiff_t>(N) >
3069{};
3071//*************************************************************************************************
3072
3073
3074
3075
3076//=================================================================================================
3077//
3078// HASCONSTDATAACCESS SPECIALIZATIONS
3079//
3080//=================================================================================================
3081
3082//*************************************************************************************************
3084template< typename T, size_t N, bool TF, AlignmentFlag AF, PaddingFlag PF, typename Tag >
3085struct HasConstDataAccess< HybridVector<T,N,TF,AF,PF,Tag> >
3086 : public TrueType
3087{};
3089//*************************************************************************************************
3090
3091
3092
3093
3094//=================================================================================================
3095//
3096// HASMUTABLEDATAACCESS SPECIALIZATIONS
3097//
3098//=================================================================================================
3099
3100//*************************************************************************************************
3102template< typename T, size_t N, bool TF, AlignmentFlag AF, PaddingFlag PF, typename Tag >
3103struct HasMutableDataAccess< HybridVector<T,N,TF,AF,PF,Tag> >
3104 : public TrueType
3105{};
3107//*************************************************************************************************
3108
3109
3110
3111
3112//=================================================================================================
3113//
3114// ISALIGNED SPECIALIZATIONS
3115//
3116//=================================================================================================
3117
3118//*************************************************************************************************
3120template< typename T, size_t N, bool TF, AlignmentFlag AF, PaddingFlag PF, typename Tag >
3121struct IsAligned< HybridVector<T,N,TF,AF,PF,Tag> >
3122 : public BoolConstant< AF == aligned >
3123{};
3125//*************************************************************************************************
3126
3127
3128
3129
3130//=================================================================================================
3131//
3132// ISCONTIGUOUS SPECIALIZATIONS
3133//
3134//=================================================================================================
3135
3136//*************************************************************************************************
3138template< typename T, size_t N, bool TF, AlignmentFlag AF, PaddingFlag PF, typename Tag >
3139struct IsContiguous< HybridVector<T,N,TF,AF,PF,Tag> >
3140 : public TrueType
3141{};
3143//*************************************************************************************************
3144
3145
3146
3147
3148//=================================================================================================
3149//
3150// ISPADDED SPECIALIZATIONS
3151//
3152//=================================================================================================
3153
3154//*************************************************************************************************
3156template< typename T, size_t N, bool TF, AlignmentFlag AF, PaddingFlag PF, typename Tag >
3157struct IsPadded< HybridVector<T,N,TF,AF,PF,Tag> >
3158 : public BoolConstant< PF == padded >
3159{};
3161//*************************************************************************************************
3162
3163
3164
3165
3166//=================================================================================================
3167//
3168// ADDTRAIT SPECIALIZATIONS
3169//
3170//=================================================================================================
3171
3172//*************************************************************************************************
3174template< typename T1, typename T2 >
3175struct AddTraitEval2< T1, T2
3176 , EnableIf_t< IsVector_v<T1> &&
3177 IsVector_v<T2> &&
3178 ( Size_v<T1,0UL> == DefaultSize_v ) &&
3179 ( Size_v<T2,0UL> == DefaultSize_v ) &&
3180 ( MaxSize_v<T1,0UL> != DefaultMaxSize_v ||
3181 MaxSize_v<T2,0UL> != DefaultMaxSize_v ) > >
3182{
3183 using Type = HybridVector< AddTrait_t< ElementType_t<T1>, ElementType_t<T2> >
3184 , min( size_t( MaxSize_v<T1,0UL> ), size_t( MaxSize_v<T2,0UL> ) )
3185 , TransposeFlag_v<T1>
3188 , AddTrait_t< TagType_t<T1>, TagType_t<T2> > >;
3189};
3191//*************************************************************************************************
3192
3193
3194
3195
3196//=================================================================================================
3197//
3198// SUBTRAIT SPECIALIZATIONS
3199//
3200//=================================================================================================
3201
3202//*************************************************************************************************
3204template< typename T1, typename T2 >
3205struct SubTraitEval2< T1, T2
3206 , EnableIf_t< IsVector_v<T1> &&
3207 IsVector_v<T2> &&
3208 ( Size_v<T1,0UL> == DefaultSize_v ) &&
3209 ( Size_v<T2,0UL> == DefaultSize_v ) &&
3210 ( MaxSize_v<T1,0UL> != DefaultMaxSize_v ||
3211 MaxSize_v<T2,0UL> != DefaultMaxSize_v ) > >
3212{
3213 using Type = HybridVector< SubTrait_t< ElementType_t<T1>, ElementType_t<T2> >
3214 , min( size_t( MaxSize_v<T1,0UL> ), size_t( MaxSize_v<T2,0UL> ) )
3215 , TransposeFlag_v<T1>
3218 , SubTrait_t< TagType_t<T1>, TagType_t<T2> > >;
3219};
3221//*************************************************************************************************
3222
3223
3224
3225
3226//=================================================================================================
3227//
3228// MULTTRAIT SPECIALIZATIONS
3229//
3230//=================================================================================================
3231
3232//*************************************************************************************************
3234template< typename T1, typename T2 >
3235struct MultTraitEval2< T1, T2
3236 , EnableIf_t< IsVector_v<T1> &&
3237 IsScalar_v<T2> &&
3238 ( Size_v<T1,0UL> == DefaultSize_v ) &&
3239 ( MaxSize_v<T1,0UL> != DefaultMaxSize_v ) > >
3240{
3241 using Type = HybridVector< MultTrait_t< ElementType_t<T1>, T2 >
3242 , MaxSize_v<T1,0UL>
3243 , TransposeFlag_v<T1>
3246 , MultTrait_t< TagType_t<T1>, T2 > >;
3247};
3248
3249template< typename T1, typename T2 >
3250struct MultTraitEval2< T1, T2
3251 , EnableIf_t< IsScalar_v<T1> &&
3252 IsVector_v<T2> &&
3253 ( Size_v<T2,0UL> == DefaultSize_v ) &&
3254 ( MaxSize_v<T2,0UL> != DefaultMaxSize_v ) > >
3255{
3256 using Type = HybridVector< MultTrait_t< T1, ElementType_t<T2> >
3257 , MaxSize_v<T2,0UL>
3258 , TransposeFlag_v<T2>
3261 , MultTrait_t< T1, TagType_t<T2> > >;
3262};
3263
3264template< typename T1, typename T2 >
3265struct MultTraitEval2< T1, T2
3266 , EnableIf_t< ( ( IsRowVector_v<T1> && IsRowVector_v<T2> ) ||
3267 ( IsColumnVector_v<T1> && IsColumnVector_v<T2> ) ) &&
3268 IsDenseVector_v<T1> &&
3269 IsDenseVector_v<T2> &&
3270 ( Size_v<T1,0UL> == DefaultSize_v ) &&
3271 ( Size_v<T2,0UL> == DefaultSize_v ) &&
3272 ( MaxSize_v<T1,0UL> != DefaultMaxSize_v ||
3273 MaxSize_v<T2,0UL> != DefaultMaxSize_v ) > >
3274{
3275 using Type = HybridVector< MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >
3276 , min( size_t( MaxSize_v<T1,0UL> ), size_t( MaxSize_v<T2,0UL> ) )
3277 , TransposeFlag_v<T1>
3280 , MultTrait_t< TagType_t<T1>, TagType_t<T2> > >;
3281};
3282
3283template< typename T1, typename T2 >
3284struct MultTraitEval2< T1, T2
3285 , EnableIf_t< IsMatrix_v<T1> &&
3286 IsColumnVector_v<T2> &&
3287 ( Size_v<T1,0UL> == DefaultSize_v &&
3288 ( !IsSquare_v<T1> || Size_v<T2,0UL> == DefaultSize_v ) ) &&
3289 ( MaxSize_v<T1,0UL> != DefaultMaxSize_v ||
3290 ( IsSquare_v<T1> && MaxSize_v<T2,0UL> != DefaultMaxSize_v ) ) > >
3291{
3292 using MultType = MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >;
3293 using MultTag = MultTrait_t< TagType_t<T1>, TagType_t<T2> >;
3294
3295 using Type = HybridVector< AddTrait_t<MultType,MultType>
3296 , ( MaxSize_v<T1,0UL> != DefaultMaxSize_v ? MaxSize_v<T1,0UL> : MaxSize_v<T2,0UL> )
3297 , false
3300 , AddTrait_t<MultTag,MultTag> >;
3301};
3302
3303template< typename T1, typename T2 >
3304struct MultTraitEval2< T1, T2
3305 , EnableIf_t< IsRowVector_v<T1> &&
3306 IsMatrix_v<T2> &&
3307 ( Size_v<T2,1UL> == DefaultSize_v &&
3308 ( !IsSquare_v<T2> || Size_v<T1,0UL> == DefaultSize_v ) ) &&
3309 ( MaxSize_v<T2,1UL> != DefaultMaxSize_v ||
3310 ( IsSquare_v<T2> && MaxSize_v<T1,0UL> != DefaultMaxSize_v ) ) > >
3311{
3312 using MultType = MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >;
3313 using MultTag = MultTrait_t< TagType_t<T1>, TagType_t<T2> >;
3314
3315 using Type = HybridVector< AddTrait_t<MultType,MultType>
3316 , ( MaxSize_v<T2,1UL> != DefaultMaxSize_v ? MaxSize_v<T2,1UL> : MaxSize_v<T1,0UL> )
3317 , true
3320 , AddTrait_t<MultTag,MultTag> >;
3321};
3323//*************************************************************************************************
3324
3325
3326
3327
3328//=================================================================================================
3329//
3330// KRONTRAIT SPECIALIZATIONS
3331//
3332//=================================================================================================
3333
3334//*************************************************************************************************
3336template< typename T1, typename T2 >
3337struct KronTraitEval2< T1, T2
3338 , EnableIf_t< IsDenseVector_v<T1> &&
3339 IsDenseVector_v<T2> &&
3340 ( ( Size_v<T1,0UL> == DefaultSize_v ) ||
3341 ( Size_v<T2,0UL> == DefaultSize_v ) ) &&
3342 ( MaxSize_v<T1,0UL> != DefaultMaxSize_v ) &&
3343 ( MaxSize_v<T2,0UL> != DefaultMaxSize_v ) > >
3344{
3345 using Type = HybridVector< MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >
3346 , MaxSize_v<T1,0UL> * MaxSize_v<T2,0UL>
3347 , TransposeFlag_v<T2>
3350 , MultTrait_t< TagType_t<T1>, TagType_t<T2> > >;
3351};
3353//*************************************************************************************************
3354
3355
3356
3357
3358//=================================================================================================
3359//
3360// DIVTRAIT SPECIALIZATIONS
3361//
3362//=================================================================================================
3363
3364//*************************************************************************************************
3366template< typename T1, typename T2 >
3367struct DivTraitEval2< T1, T2
3368 , EnableIf_t< IsVector_v<T1> &&
3369 IsScalar_v<T2> &&
3370 ( Size_v<T1,0UL> == DefaultSize_v ) &&
3371 ( MaxSize_v<T1,0UL> != DefaultMaxSize_v ) > >
3372{
3373 using Type = HybridVector< DivTrait_t< ElementType_t<T1>, T2 >
3374 , MaxSize_v<T1,0UL>
3375 , TransposeFlag_v<T1>
3378 , DivTrait_t< TagType_t<T1>, T2 > >;
3379};
3380
3381template< typename T1, typename T2 >
3382struct DivTraitEval2< T1, T2
3383 , EnableIf_t< IsDenseVector_v<T1> &&
3384 IsDenseVector_v<T2> &&
3385 ( Size_v<T1,0UL> == DefaultSize_v ) &&
3386 ( Size_v<T2,0UL> == DefaultSize_v ) &&
3387 ( MaxSize_v<T1,0UL> != DefaultMaxSize_v ||
3388 MaxSize_v<T2,0UL> != DefaultMaxSize_v ) > >
3389{
3390 using Type = HybridVector< DivTrait_t< ElementType_t<T1>, ElementType_t<T2> >
3391 , min( size_t( MaxSize_v<T1,0UL> ), size_t( MaxSize_v<T2,0UL> ) )
3392 , TransposeFlag_v<T1>
3395 , DivTrait_t< TagType_t<T1>, TagType_t<T2> > >;
3396};
3398//*************************************************************************************************
3399
3400
3401
3402
3403//=================================================================================================
3404//
3405// MAPTRAIT SPECIALIZATIONS
3406//
3407//=================================================================================================
3408
3409//*************************************************************************************************
3411template< typename T, typename OP >
3412struct UnaryMapTraitEval2< T, OP
3413 , EnableIf_t< IsVector_v<T> &&
3414 Size_v<T,0UL> == DefaultSize_v &&
3415 MaxSize_v<T,0UL> != DefaultMaxSize_v > >
3416{
3417 using ElementType = decltype( std::declval<OP>()( std::declval< ElementType_t<T> >() ) );
3418
3419 using Type = HybridVector< EvaluateTrait_t<ElementType>
3420 , MaxSize_v<T,0UL>
3421 , TransposeFlag_v<T>
3424 , MapTrait_t< TagType_t<T>, OP > >;
3425};
3427//*************************************************************************************************
3428
3429
3430//*************************************************************************************************
3432template< typename T1, typename T2, typename OP >
3433struct BinaryMapTraitEval2< T1, T2, OP
3434 , EnableIf_t< ( ( IsRowVector_v<T1> && IsRowVector_v<T2> ) ||
3435 ( IsColumnVector_v<T1> && IsColumnVector_v<T2> ) ) &&
3436 Size_v<T1,0UL> == DefaultSize_v &&
3437 Size_v<T2,0UL> == DefaultSize_v &&
3438 ( MaxSize_v<T1,0UL> != DefaultMaxSize_v ||
3439 MaxSize_v<T2,0UL> != DefaultMaxSize_v ) > >
3440{
3441 using ElementType = decltype( std::declval<OP>()( std::declval< ElementType_t<T1> >()
3442 , std::declval< ElementType_t<T2> >() ) );
3443
3444 using Type = HybridVector< EvaluateTrait_t<ElementType>
3445 , min( size_t( MaxSize_v<T1,0UL> ), size_t( MaxSize_v<T2,0UL> ) )
3446 , TransposeFlag_v<T1>
3449 , MapTrait_t< TagType_t<T1>, TagType_t<T2>, OP > >;
3450};
3452//*************************************************************************************************
3453
3454
3455
3456
3457//=================================================================================================
3458//
3459// REDUCETRAIT SPECIALIZATIONS
3460//
3461//=================================================================================================
3462
3463//*************************************************************************************************
3465template< typename T, typename OP, ReductionFlag RF >
3466struct PartialReduceTraitEval2< T, OP, RF
3467 , EnableIf_t< IsMatrix_v<T> &&
3468 ( Size_v<T,0UL> == DefaultSize_v ||
3469 Size_v<T,1UL> == DefaultSize_v ) &&
3470 MaxSize_v<T,0UL> != DefaultMaxSize_v &&
3471 MaxSize_v<T,1UL> != DefaultMaxSize_v > >
3472{
3473 using ET = ElementType_t<T>;
3474
3475 static constexpr bool TF = ( RF == columnwise );
3476
3477 using Type = HybridVector< decltype( std::declval<OP>()( std::declval<ET>(), std::declval<ET>() ) )
3478 , MaxSize_v< T, TF ? 1UL : 0UL >
3479 , TF
3482 , MapTrait_t< TagType_t<T>, OP > >;
3483};
3485//*************************************************************************************************
3486
3487
3488
3489
3490//=================================================================================================
3491//
3492// REPEATTRAIT SPECIALIZATIONS
3493//
3494//=================================================================================================
3495
3496//*************************************************************************************************
3498template< typename T, size_t R0 >
3499struct RepeatTraitEval2< T, R0, inf, inf
3501 ( R0 != inf ) &&
3502 ( Size_v<T,0UL> == DefaultSize_v ) &&
3503 ( MaxSize_v<T,0UL> != DefaultMaxSize_v ) > >
3504{
3505 using Type = HybridVector< ElementType_t<T>
3506 , R0*MaxSize_v<T,0UL>
3507 , TransposeFlag_v<T>
3510 , TagType_t<T> >;
3511};
3513//*************************************************************************************************
3514
3515
3516
3517
3518//=================================================================================================
3519//
3520// SOLVETRAIT SPECIALIZATIONS
3521//
3522//=================================================================================================
3523
3524//*************************************************************************************************
3526template< typename T1, typename T2 >
3527struct SolveTraitEval2< T1, T2
3528 , EnableIf_t< IsDenseMatrix_v<T1> &&
3529 IsDenseVector_v<T2> &&
3530 ( Size_v<T1,0UL> == DefaultSize_v ) &&
3531 ( Size_v<T1,1UL> == DefaultSize_v ) &&
3532 ( Size_v<T2,0UL> == DefaultSize_v ) &&
3533 ( ( MaxSize_v<T1,0UL> != DefaultMaxSize_v ) ||
3534 ( MaxSize_v<T1,1UL> != DefaultMaxSize_v ) ||
3535 ( MaxSize_v<T2,0UL> != DefaultMaxSize_v ) ) > >
3536{
3537 static constexpr size_t N = ( MaxSize_v<T1,0UL> != DefaultMaxSize_v
3538 ?( MaxSize_v<T1,1UL> != DefaultMaxSize_v
3539 ?( MaxSize_v<T2,0UL> != DefaultMaxSize_v
3540 ? min( MaxSize_v<T1,0UL>, MaxSize_v<T1,1UL>, MaxSize_v<T2,0UL> )
3541 : min( MaxSize_v<T1,0UL>, MaxSize_v<T1,1UL> ) )
3542 :( MaxSize_v<T2,0UL> != DefaultMaxSize_v
3543 ? min( MaxSize_v<T1,0UL>, MaxSize_v<T2,0UL> )
3544 : MaxSize_v<T1,0UL> ) )
3545 :( MaxSize_v<T1,1UL> != DefaultMaxSize_v
3546 ?( MaxSize_v<T2,0UL> != DefaultMaxSize_v
3547 ? min( MaxSize_v<T1,1UL>, MaxSize_v<T2,0UL> )
3548 : MaxSize_v<T1,1UL> )
3549 : MaxSize_v<T2,0UL> ) );
3550
3551 using Type = HybridVector< ElementType_t<T2>
3552 , N
3553 , TransposeFlag_v<T2>
3556 , TagType_t<T2> >;
3557};
3559//*************************************************************************************************
3560
3561
3562
3563
3564//=================================================================================================
3565//
3566// HIGHTYPE SPECIALIZATIONS
3567//
3568//=================================================================================================
3569
3570//*************************************************************************************************
3572template< typename T1, size_t N, bool TF, AlignmentFlag AF, PaddingFlag PF, typename Tag, typename T2 >
3573struct HighType< HybridVector<T1,N,TF,AF,PF,Tag>, HybridVector<T2,N,TF,AF,PF,Tag> >
3574{
3575 using Type = StaticVector< typename HighType<T1,T2>::Type, N, TF, AF, PF, Tag >;
3576};
3578//*************************************************************************************************
3579
3580
3581
3582
3583//=================================================================================================
3584//
3585// LOWTYPE SPECIALIZATIONS
3586//
3587//=================================================================================================
3588
3589//*************************************************************************************************
3591template< typename T1, size_t N, bool TF, AlignmentFlag AF, PaddingFlag PF, typename Tag, typename T2 >
3592struct LowType< HybridVector<T1,N,TF,AF,PF,Tag>, HybridVector<T2,N,TF,AF,PF,Tag> >
3593{
3594 using Type = StaticVector< typename LowType<T1,T2>::Type, N, TF, AF, PF, Tag >;
3595};
3597//*************************************************************************************************
3598
3599
3600
3601
3602//=================================================================================================
3603//
3604// SUBVECTORTRAIT SPECIALIZATIONS
3605//
3606//=================================================================================================
3607
3608//*************************************************************************************************
3610template< typename VT >
3611struct SubvectorTraitEval2< VT, inf, inf
3612 , EnableIf_t< IsDenseVector_v<VT> &&
3613 ( Size_v<VT,0UL> != DefaultSize_v ||
3614 MaxSize_v<VT,0UL> != DefaultMaxSize_v ) > >
3615{
3616 using Type = HybridVector< RemoveConst_t< ElementType_t<VT> >
3617 , max( Size_v<VT,0UL>, MaxSize_v<VT,0UL> )
3618 , TransposeFlag_v<VT>
3621 , TagType_t<VT> >;
3622};
3624//*************************************************************************************************
3625
3626
3627
3628
3629//=================================================================================================
3630//
3631// ROWTRAIT SPECIALIZATIONS
3632//
3633//=================================================================================================
3634
3635//*************************************************************************************************
3637template< typename MT, size_t I >
3638struct RowTraitEval2< MT, I
3639 , EnableIf_t< IsDenseMatrix_v<MT> &&
3640 Size_v<MT,1UL> == DefaultSize_v &&
3641 MaxSize_v<MT,1UL> != DefaultMaxSize_v > >
3642{
3643 using Type = HybridVector< RemoveConst_t< ElementType_t<MT> >
3644 , MaxSize_v<MT,1UL>
3645 , true
3648 , TagType_t<MT> >;
3649};
3651//*************************************************************************************************
3652
3653
3654
3655
3656//=================================================================================================
3657//
3658// COLUMNTRAIT SPECIALIZATIONS
3659//
3660//=================================================================================================
3661
3662//*************************************************************************************************
3664template< typename MT, size_t I >
3665struct ColumnTraitEval2< MT, I
3666 , EnableIf_t< IsDenseMatrix_v<MT> &&
3667 Size_v<MT,0UL> == DefaultSize_v &&
3668 MaxSize_v<MT,0UL> != DefaultMaxSize_v > >
3669{
3670 using Type = HybridVector< RemoveConst_t< ElementType_t<MT> >
3671 , MaxSize_v<MT,0UL>
3672 , false
3675 , TagType_t<MT> >;
3676};
3678//*************************************************************************************************
3679
3680
3681
3682
3683//=================================================================================================
3684//
3685// BANDTRAIT SPECIALIZATIONS
3686//
3687//=================================================================================================
3688
3689//*************************************************************************************************
3691template< typename MT, ptrdiff_t I >
3692struct BandTraitEval2< MT, I
3693 , EnableIf_t< IsDenseMatrix_v<MT> &&
3694 ( Size_v<MT,0UL> == DefaultSize_v ||
3695 Size_v<MT,1UL> == DefaultSize_v ) &&
3696 MaxSize_v<MT,0UL> != DefaultMaxSize_v &&
3697 MaxSize_v<MT,1UL> != DefaultMaxSize_v > >
3698{
3699 static constexpr size_t M = MaxSize_v<MT,0UL>;
3700 static constexpr size_t N = MaxSize_v<MT,1UL>;
3701 static constexpr size_t Min = min( M - ( I >= 0L ? 0UL : -I ), N - ( I >= 0L ? I : 0UL ) );
3702
3703 using Type = HybridVector< RemoveConst_t< ElementType_t<MT> >
3704 , Min
3708 , TagType_t<MT> >;
3709};
3710
3711template< typename MT >
3712struct BandTraitEval2< MT, inf
3713 , EnableIf_t< IsDenseMatrix_v<MT> &&
3714 Size_v<MT,0UL> != DefaultSize_v &&
3715 Size_v<MT,1UL> != DefaultSize_v > >
3716{
3717 using Type = HybridVector< RemoveConst_t< ElementType_t<MT> >
3718 , min( Size_v<MT,0UL>, Size_v<MT,1UL> )
3722 , TagType_t<MT> >;
3723};
3724
3725template< typename MT >
3726struct BandTraitEval2< MT, inf
3727 , EnableIf_t< IsDenseMatrix_v<MT> &&
3728 ( Size_v<MT,0UL> == DefaultSize_v ||
3729 Size_v<MT,1UL> == DefaultSize_v ) &&
3730 MaxSize_v<MT,0UL> != DefaultMaxSize_v &&
3731 MaxSize_v<MT,1UL> != DefaultMaxSize_v > >
3732{
3733 using Type = HybridVector< RemoveConst_t< ElementType_t<MT> >
3734 , min( MaxSize_v<MT,0UL>, MaxSize_v<MT,1UL> )
3738 , TagType_t<MT> >;
3739};
3741//*************************************************************************************************
3742
3743} // namespace blaze
3744
3745#endif
Header file for the addition trait.
Header file for auxiliary alias declarations.
typename ResultType_t< T >::TagType TagType_t
Alias declaration for nested TagType type definitions.
Definition: Aliases.h:530
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
Header file for the AlignedArray implementation.
Header file for the alignment check function.
Header file for the alignment flag enumeration.
Header file for the AlignmentOf type trait.
Header file for run time assertion macros.
Header file for the band trait.
Header file for the column trait.
Constraint on the data type.
Header file for the cross product trait.
Header file for the DenseIterator class template.
Header file for the division trait.
Header file for the EnableIf class template.
Header file for the EvaluateTrait class template.
Header file for the HasConstDataAccess type trait.
Header file for the HasMutableDataAccess type trait.
Header file for the HasSIMDAdd type trait.
Header file for the HasSIMDDiv type trait.
Header file for the HasSIMDMult type trait.
Header file for the HasSIMDSub type trait.
Header file for the HighType type trait.
Numerical infinity for built-in data types.
Header file for the IntegralConstant class template.
Header file for the IsAligned type trait.
Header file for the IsColumnVector type trait.
Header file for the IsContiguous type trait.
Header file for the isDefault shim.
Header file for the IsDenseMatrix type trait.
Header file for the IsDenseVector type trait.
Header file for the IsMatrix type trait.
Header file for the IsNumeric type trait.
Header file for the IsPadded type trait.
Header file for the IsRowVector type trait.
Header file for the IsSIMDCombinable type trait.
Header file for the IsScalar type trait.
Header file for the IsSparseVector type trait.
Header file for the IsSquare type trait.
Header file for the IsVector type trait.
Header file for the IsVectorizable type trait.
Header file for the Kron product trait.
Header file for the LowType type trait.
Header file for the map trait.
Header file for the MaxSize type trait.
Header file for the MAYBE_UNUSED function template.
Header file for memory allocation and deallocation functionality.
Header file for the multiplication trait.
Header file for the nextMultiple shim.
Header file for the padding flag enumeration.
Constraint on the data type.
Header file for the prevMultiple shim.
Header file for the reduce trait.
Header file for the reduction flags.
constexpr ReductionFlag columnwise
Reduction flag for column-wise reduction operations.
Definition: ReductionFlag.h:97
Constraint on the data type.
Header file for the relaxation flag enumeration.
Header file for the RemoveCV type trait.
Header file for the RemoveConst type trait.
Header file for the repeat trait.
Header file for the row trait.
Header file for all SIMD functionality.
Data type constraint.
Header file for the Solver trait.
Compile time assertion.
Header file for the subtraction trait.
Header file for the subvector trait.
Constraint on the data type.
Constraint on the data type.
Implementation of a generic iterator for dense vectors and matrices.
Definition: DenseIterator.h:60
Base class for N-dimensional dense vectors.
Definition: DenseVector.h:77
Efficient implementation of a dynamically sized vector with static memory.
Definition: HybridVector.h:222
static constexpr bool isAligned() noexcept
Returns whether the vector is properly aligned in memory.
Definition: HybridVector.h:2227
const Type & ReturnType
Return type for expression template evaluations.
Definition: HybridVector.h:234
BLAZE_ALWAYS_INLINE void store(size_t index, const SIMDType &value) noexcept
Store of a SIMD element of the vector.
Definition: HybridVector.h:2353
size_t nonZeros() const
Returns the number of non-zero elements in the vector.
Definition: HybridVector.h:1721
BLAZE_ALWAYS_INLINE void storeu(size_t index, const SIMDType &value) noexcept
Unaligned store of a SIMD element of the vector.
Definition: HybridVector.h:2419
constexpr void extend(size_t n, bool preserve=true)
Extending the size of the vector.
Definition: HybridVector.h:1852
size_t size_
The current size/dimension of the vector.
Definition: HybridVector.h:534
constexpr HybridVector()
The default constructor for HybridVector.
Definition: HybridVector.h:596
HybridVector< Type, N, TF, AF, PF, Tag > This
Type of this HybridVector instance.
Definition: HybridVector.h:225
Reference at(size_t index)
Checked access to the vector elements.
Definition: HybridVector.h:983
auto multAssign(const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedMultAssign_v< VT > >
Default implementation of the multiplication assignment of a dense vector.
Definition: HybridVector.h:2785
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: HybridVector.h:2181
BLAZE_ALWAYS_INLINE void storea(size_t index, const SIMDType &value) noexcept
Aligned store of a SIMD element of the vector.
Definition: HybridVector.h:2383
const Type * ConstPointer
Pointer to a constant vector value.
Definition: HybridVector.h:241
constexpr Iterator begin() noexcept
Returns an iterator to the first element of the hybrid vector.
Definition: HybridVector.h:1074
Type ElementType
Type of the vector elements.
Definition: HybridVector.h:232
static constexpr size_t Alignment
Alignment of the data elements.
Definition: HybridVector.h:518
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: HybridVector.h:2205
constexpr void resize(size_t n, bool preserve=true)
Changing the size of the vector.
Definition: HybridVector.h:1812
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
Aligned load of a SIMD element of the vector.
Definition: HybridVector.h:2283
constexpr size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: HybridVector.h:1660
constexpr void clear()
Clearing the vector.
Definition: HybridVector.h:1768
auto assign(const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedAssign_v< VT > >
Default implementation of the assignment of a dense vector.
Definition: HybridVector.h:2488
constexpr ConstIterator cbegin() const noexcept
Returns an iterator to the first element of the hybrid vector.
Definition: HybridVector.h:1112
SIMDTrait_t< ElementType > SIMDType
SIMD type of the vector elements.
Definition: HybridVector.h:233
auto divAssign(const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedDivAssign_v< VT > >
Default implementation of the division assignment of a dense vector.
Definition: HybridVector.h:2888
static constexpr size_t spacing() noexcept
Returns the minimum capacity of the vector.
Definition: HybridVector.h:1681
static constexpr size_t NN
Alignment adjustment.
Definition: HybridVector.h:395
const Type & ConstReference
Reference to a constant vector value.
Definition: HybridVector.h:239
constexpr Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the vector elements.
Definition: HybridVector.h:934
static constexpr bool simdEnabled
Compilation flag for SIMD optimization.
Definition: HybridVector.h:271
static constexpr size_t capacity() noexcept
Returns the maximum capacity of the vector.
Definition: HybridVector.h:1699
BLAZE_ALWAYS_INLINE SIMDType load(size_t index) const noexcept
Load of a SIMD element of the vector.
Definition: HybridVector.h:2253
constexpr HybridVector & operator=(const Type &rhs) &
Homogenous assignment to all vector elements.
Definition: HybridVector.h:1200
constexpr ConstIterator cend() const noexcept
Returns an iterator just past the last element of the hybrid vector.
Definition: HybridVector.h:1171
auto subAssign(const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedSubAssign_v< VT > >
Default implementation of the subtraction assignment of a dense vector.
Definition: HybridVector.h:2686
Type & Reference
Reference to a non-constant vector value.
Definition: HybridVector.h:238
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t index) const noexcept
Unaligned load of a SIMD element of the vector.
Definition: HybridVector.h:2319
void swap(HybridVector &v) noexcept
Swapping the contents of two hybrid vectors.
Definition: HybridVector.h:1872
BLAZE_ALWAYS_INLINE void stream(size_t index, const SIMDType &value) noexcept
Aligned, non-temporal store of a SIMD element of the vector.
Definition: HybridVector.h:2454
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD vector.
Definition: HybridVector.h:392
AlignedStorage v_
The statically allocated vector elements.
Definition: HybridVector.h:528
constexpr void reset()
Reset to the default initial values.
Definition: HybridVector.h:1746
Type * Pointer
Pointer to a non-constant vector value.
Definition: HybridVector.h:240
Tag TagType
Tag type of this HybridVector instance.
Definition: HybridVector.h:235
constexpr bool isIntact() const noexcept
Returns whether the invariants of the hybrid vector are intact.
Definition: HybridVector.h:2139
auto addAssign(const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedAddAssign_v< VT > >
Default implementation of the addition assignment of a dense vector.
Definition: HybridVector.h:2587
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: HybridVector.h:277
constexpr Pointer data() noexcept
Low-level data access to the vector elements.
Definition: HybridVector.h:1034
constexpr Iterator end() noexcept
Returns an iterator just past the last element of the hybrid vector.
Definition: HybridVector.h:1131
SIMD characteristics of data types.
Definition: SIMDTrait.h:297
Base class for sparse vectors.
Definition: SparseVector.h:72
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.
Header file for the SparseVector base class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.
Definition: Volatile.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.
Definition: Pointer.h:79
#define BLAZE_CONSTRAINT_MUST_BE_VECTORIZABLE_TYPE(T)
Constraint on the data type.
Definition: Vectorizable.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.
Definition: Const.h:79
#define BLAZE_CONSTRAINT_MUST_BE_SAME_TAG(A, B)
Data type constraint.
Definition: SameTag.h:68
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.
Definition: Reference.h:79
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1339
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1375
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
constexpr bool isIntact(const HybridVector< Type, N, TF, AF, PF, Tag > &v)
Returns whether the invariants of the given hybrid vector are intact.
Definition: HybridVector.h:3028
void swap(HybridVector< Type, N, TF, AF, PF, Tag > &a, HybridVector< Type, N, TF, AF, PF, Tag > &b) noexcept
Swapping the contents of two hybrid vectors.
Definition: HybridVector.h:3049
bool isDefault(const HybridVector< Type, N, TF, AF, PF, Tag > &v)
Returns whether the given hybrid vector is in default state.
Definition: HybridVector.h:2997
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition: RequiresEvaluation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.
Definition: TransposeFlag.h:63
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition: DenseVector.h:61
typename CrossTrait< T1, T2 >::Type CrossTrait_t
Auxiliary alias declaration for the CrossTrait class template.
Definition: CrossTrait.h:138
constexpr bool HasSIMDSub_v
Auxiliary variable template for the HasSIMDSub type trait.
Definition: HasSIMDSub.h:187
constexpr ptrdiff_t DefaultMaxSize_v
Default size of the MaxSize type trait.
Definition: MaxSize.h:72
constexpr ptrdiff_t MaxSize_v
Auxiliary variable template for the MaxSize type trait.
Definition: MaxSize.h:175
constexpr bool IsScalar_v
Auxiliary variable template for the IsScalar type trait.
Definition: IsScalar.h:104
constexpr bool IsSIMDCombinable_v
Auxiliary variable template for the IsSIMDCombinable type trait.
Definition: IsSIMDCombinable.h:137
constexpr ptrdiff_t DefaultSize_v
Default size of the Size type trait.
Definition: Size.h:72
constexpr bool IsVector_v
Auxiliary variable template for the IsVector type trait.
Definition: IsVector.h:125
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.
Definition: IsMatrix.h:124
constexpr bool HasSIMDAdd_v
Auxiliary variable template for the HasSIMDAdd type trait.
Definition: HasSIMDAdd.h:187
constexpr bool HasSIMDDiv_v
Auxiliary variable template for the HasSIMDDiv type trait.
Definition: HasSIMDDiv.h:173
constexpr bool HasSIMDMult_v
Auxiliary variable template for the HasSIMDMult type trait.
Definition: HasSIMDMult.h:188
constexpr bool IsRowVector_v
Auxiliary variable template for the IsRowVector type trait.
Definition: IsRowVector.h:126
constexpr bool IsDenseMatrix_v
Auxiliary variable template for the IsDenseMatrix type trait.
Definition: IsDenseMatrix.h:124
constexpr bool IsDenseVector_v
Auxiliary variable template for the IsDenseVector type trait.
Definition: IsDenseVector.h:124
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition: RelaxationFlag.h:66
BLAZE_ALWAYS_INLINE constexpr auto prevMultiple(T1 value, T2 factor) noexcept
Rounds down an integral value to the previous multiple of a given factor.
Definition: PrevMultiple.h:68
constexpr Infinity inf
Global Infinity instance.
Definition: Infinity.h:1080
BLAZE_ALWAYS_INLINE constexpr auto nextMultiple(T1 value, T2 factor) noexcept
Rounds up an integral value to the next multiple of a given factor.
Definition: NextMultiple.h:68
PaddingFlag
Padding flag for (un-)padded vectors and matrices.
Definition: PaddingFlag.h:77
AlignmentFlag
Alignment flag for (un-)aligned vectors and matrices.
Definition: AlignmentFlag.h:63
@ padded
Flag for padded vectors and matrices.
Definition: PaddingFlag.h:79
@ unpadded
Flag for unpadded vectors and matrices.
Definition: PaddingFlag.h:78
@ aligned
Flag for aligned vectors and matrices.
Definition: AlignmentFlag.h:65
constexpr void clear(Matrix< MT, SO > &matrix)
Clearing the given matrix.
Definition: Matrix.h:960
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition: Matrix.h:806
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:1108
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:676
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
#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
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< T1, 1UL > > storea(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned store of a vector of 1-byte integral values.
Definition: Storea.h:78
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< T1, 1UL > > storeu(T1 *address, const SIMDi8< T2 > &value) noexcept
Unaligned store of a vector of 1-byte integral values.
Definition: Storeu.h:75
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< T1, 1UL > > stream(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned, non-temporal store of a vector of 1-byte integral values.
Definition: Stream.h:74
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > loadu(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loadu.h:76
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > loada(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loada.h:79
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.
Definition: StaticAssert.h:112
constexpr PaddingFlag defaultPaddingFlag
The default padding flag for all vectors and matrices of the Blaze library.
Definition: Padding.h:74
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
constexpr AlignmentFlag defaultAlignmentFlag
The default alignment for all vectors and matrices of the Blaze library.
Definition: Alignment.h:75
constexpr bool defaultTransposeFlag
The default transpose flag for all vectors of the Blaze library.
Definition: TransposeFlag.h:75
constexpr bool IsVectorizable_v
Auxiliary variable template for the IsVectorizable type trait.
Definition: IsVectorizable.h:157
constexpr size_t AlignmentOf_v
Auxiliary variable template for the AlignmentOf type trait.
Definition: AlignmentOf.h:239
BoolConstant< true > TrueType
Type traits base class.
Definition: IntegralConstant.h:132
void deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition: Memory.h:230
IntegralConstant< ptrdiff_t, N > Ptrdiff_t
Compile time integral constant wrapper for ptrdiff_t.
Definition: IntegralConstant.h:237
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.
Definition: IntegralConstant.h:110
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition: Exception.h:331
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
BLAZE_ALWAYS_INLINE bool checkAlignment(const T *address)
Checks the alignment of the given address.
Definition: AlignmentCheck.h:68
typename EnableIf<!Condition, T >::Type DisableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:175
Header file for the exception macros of the math module.
Header file for all forward declarations of the math module.
Header file for the extended initializer_list functionality.
Constraint on the data type.
Header file for all forward declarations for dense vectors and matrices.
Header file for the Size type trait.
Header file for the TransposeFlag type trait.
Header file for the clear shim.
Header file for the serial shim.
Rebind mechanism to obtain a HybridVector with different data/element type.
Definition: HybridVector.h:251
Resize mechanism to obtain a HybridVector with a different fixed number of elements.
Definition: HybridVector.h:260
System settings for the inline keywords.
System settings for performance optimizations.
Header file for the default transpose flag for all vectors of the Blaze library.
Header file for basic type definitions.
Header file for the generic max algorithm.
Header file for the generic min algorithm.