Blaze 3.9
Loading...
Searching...
No Matches
UniformVector.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_DENSE_UNIFORMVECTOR_H_
36#define _BLAZE_MATH_DENSE_UNIFORMVECTOR_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <algorithm>
44#include <utility>
45#include <blaze/math/Aliases.h>
57#include <blaze/math/SIMD.h>
89#include <blaze/util/Assert.h>
95#include <blaze/util/EnableIf.h>
98#include <blaze/util/Types.h>
102
103
104namespace blaze {
105
106//=================================================================================================
107//
108// CLASS DEFINITION
109//
110//=================================================================================================
111
112//*************************************************************************************************
181template< typename Type // Data type of the vector
182 , bool TF // Transpose flag
183 , typename Tag > // Type tag
185 : public Expression< DenseVector< UniformVector<Type,TF,Tag>, TF > >
186{
187 public:
188 //**Type definitions****************************************************************************
191
194
197
200 using TagType = Tag;
201 using ReturnType = const Type&;
203
204 using Reference = const Type&;
205 using ConstReference = const Type&;
206 using Pointer = const Type*;
207 using ConstPointer = const Type*;
208
211 //**********************************************************************************************
212
213 //**Rebind struct definition********************************************************************
216 template< typename NewType > // Data type of the other vector
220 //**********************************************************************************************
221
222 //**Resize struct definition********************************************************************
225 template< size_t NewN > // Number of elements of the other vector
229 //**********************************************************************************************
230
231 //**Compilation flags***************************************************************************
233
237 static constexpr bool simdEnabled = IsVectorizable_v<Type>;
238
240
243 static constexpr bool smpAssignable = !IsSMPAssignable_v<Type>;
244 //**********************************************************************************************
245
246 //**Constructors********************************************************************************
249 constexpr UniformVector() noexcept;
250 explicit constexpr UniformVector( size_t n );
251 constexpr UniformVector( size_t n, const Type& init );
252
253 template< typename VT >
254 inline UniformVector( const Vector<VT,TF>& v );
255
256 UniformVector( const UniformVector& ) = default;
257 UniformVector( UniformVector&& ) = default;
259 //**********************************************************************************************
260
261 //**Destructor**********************************************************************************
264 ~UniformVector() = default;
266 //**********************************************************************************************
267
268 //**Data access functions***********************************************************************
271 constexpr ConstReference operator[]( size_t index ) const noexcept;
272 inline ConstReference at( size_t index ) const;
273 constexpr ConstPointer data () const noexcept;
274 constexpr ConstIterator begin () const noexcept;
275 constexpr ConstIterator cbegin() const noexcept;
276 constexpr ConstIterator end () const noexcept;
277 constexpr ConstIterator cend () const noexcept;
279 //**********************************************************************************************
280
281 //**Assignment operators************************************************************************
284 constexpr UniformVector& operator=( const Type& rhs ) &;
285
286 UniformVector& operator=( const UniformVector& ) & = default;
287 UniformVector& operator=( UniformVector&& ) & = default;
288
289 template< typename VT > inline UniformVector& operator= ( const Vector<VT,TF>& rhs ) &;
290 template< typename VT > inline UniformVector& operator+=( const Vector<VT,TF>& rhs ) &;
291 template< typename VT > inline UniformVector& operator-=( const Vector<VT,TF>& rhs ) &;
292 template< typename VT > inline UniformVector& operator*=( const Vector<VT,TF>& rhs ) &;
293 template< typename VT > inline UniformVector& operator/=( const DenseVector<VT,TF>& rhs ) &;
294
295 template< typename ST >
296 inline auto operator*=( ST rhs ) & -> EnableIf_t< IsScalar_v<ST>, UniformVector& >;
297
298 template< typename ST >
299 inline auto operator/=( ST rhs ) & -> EnableIf_t< IsScalar_v<ST>, UniformVector& >;
301 //**********************************************************************************************
302
303 //**Utility functions***************************************************************************
306 constexpr size_t size() const noexcept;
307 constexpr size_t spacing() const noexcept;
308 constexpr size_t capacity() const noexcept;
309 inline size_t nonZeros() const;
310 constexpr void reset();
311 constexpr void clear();
312 constexpr void resize( size_t n, bool preserve=true );
313 constexpr void extend( size_t n, bool preserve=true );
314 constexpr void swap( UniformVector& v ) noexcept;
316 //**********************************************************************************************
317
318 //**Numeric functions***************************************************************************
321 template< typename Other > inline UniformVector& scale( const Other& scalar );
323 //**********************************************************************************************
324
325 private:
326 //**********************************************************************************************
328 static constexpr size_t SIMDSIZE = SIMDTrait<ElementType>::size;
329 //**********************************************************************************************
330
331 public:
332 //**Expression template evaluation functions****************************************************
335 template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
336 template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
337
338 inline bool isAligned () const noexcept;
339 inline bool canSMPAssign() const noexcept;
340
341 BLAZE_ALWAYS_INLINE SIMDType load ( size_t index ) const noexcept;
342 BLAZE_ALWAYS_INLINE SIMDType loada( size_t index ) const noexcept;
343 BLAZE_ALWAYS_INLINE SIMDType loadu( size_t index ) const noexcept;
345 //**********************************************************************************************
346
347 private:
348 //**Member variables****************************************************************************
351 size_t size_;
354 //**********************************************************************************************
355
356 //**Compile time checks*************************************************************************
363 //**********************************************************************************************
364};
365//*************************************************************************************************
366
367
368
369
370//=================================================================================================
371//
372// CONSTRUCTORS
373//
374//=================================================================================================
375
376//*************************************************************************************************
379template< typename Type // Data type of the vector
380 , bool TF // Transpose flag
381 , typename Tag > // Type tag
382constexpr UniformVector<Type,TF,Tag>::UniformVector() noexcept
383 : size_ ( 0UL ) // The current size/dimension of the uniform vector
384 , value_() // The value of all elements of the uniform vector
385{}
386//*************************************************************************************************
387
388
389//*************************************************************************************************
394template< typename Type // Data type of the vector
395 , bool TF // Transpose flag
396 , typename Tag > // Type tag
398 : size_ ( n ) // The current size/dimension of the uniform vector
399 , value_() // The value of all elements of the uniform vector
400{}
401//*************************************************************************************************
402
403
404//*************************************************************************************************
412template< typename Type // Data type of the vector
413 , bool TF // Transpose flag
414 , typename Tag > // Type tag
415constexpr UniformVector<Type,TF,Tag>::UniformVector( size_t n, const Type& init )
416 : size_ ( n ) // The current size/dimension of the uniform vector
417 , value_( init ) // The value of all elements of the uniform vector
418{}
419//*************************************************************************************************
420
421
422//*************************************************************************************************
431template< typename Type // Data type of the vector
432 , bool TF // Transpose flag
433 , typename Tag > // Type tag
434template< typename VT > // Type of the foreign vector
436 : size_ ( (*v).size() ) // The current size/dimension of the uniform vector
437 , value_() // The value of all elements of the uniform vector
438{
440
441 if( !IsUniform_v<VT> && !isUniform( *v ) ) {
442 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of uniform vector" );
443 }
444
445 if( size_ > 0UL ) {
446 value_ = (*v)[0UL];
447 }
448}
449//*************************************************************************************************
450
451
452
453
454//=================================================================================================
455//
456// DATA ACCESS FUNCTIONS
457//
458//=================================================================================================
459
460//*************************************************************************************************
469template< typename Type // Data type of the vector
470 , bool TF // Transpose flag
471 , typename Tag > // Type tag
473 UniformVector<Type,TF,Tag>::operator[]( size_t index ) const noexcept
474{
475 MAYBE_UNUSED( index );
476
477 BLAZE_USER_ASSERT( index < size_, "Invalid vector access index" );
478
479 return value_;
480}
481//*************************************************************************************************
482
483
484//*************************************************************************************************
494template< typename Type // Data type of the vector
495 , bool TF // Transpose flag
496 , typename Tag > // Type tag
498 UniformVector<Type,TF,Tag>::at( size_t index ) const
499{
500 if( index >= size_ ) {
501 BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
502 }
503
504 return (*this)[index];
505}
506//*************************************************************************************************
507
508
509//*************************************************************************************************
517template< typename Type // Data type of the vector
518 , bool TF // Transpose flag
519 , typename Tag > // Type tag
522{
523 return &value_;
524}
525//*************************************************************************************************
526
527
528//*************************************************************************************************
533template< typename Type // Data type of the vector
534 , bool TF // Transpose flag
535 , typename Tag > // Type tag
538{
539 return ConstIterator( &value_, 0UL );
540}
541//*************************************************************************************************
542
543
544//*************************************************************************************************
549template< typename Type // Data type of the vector
550 , bool TF // Transpose flag
551 , typename Tag > // Type tag
554{
555 return ConstIterator( &value_, 0UL );
556}
557//*************************************************************************************************
558
559
560//*************************************************************************************************
565template< typename Type // Data type of the vector
566 , bool TF // Transpose flag
567 , typename Tag > // Type tag
570{
571 return ConstIterator( &value_, size_ );
572}
573//*************************************************************************************************
574
575
576//*************************************************************************************************
581template< typename Type // Data type of the vector
582 , bool TF // Transpose flag
583 , typename Tag > // Type tag
586{
587 return ConstIterator( &value_, size_ );
588}
589//*************************************************************************************************
590
591
592
593
594//=================================================================================================
595//
596// ASSIGNMENT OPERATORS
597//
598//=================================================================================================
599
600//*************************************************************************************************
606template< typename Type // Data type of the vector
607 , bool TF // Transpose flag
608 , typename Tag > // Type tag
611{
612 value_ = rhs;
613
614 return *this;
615}
616//*************************************************************************************************
617
618
619//*************************************************************************************************
628template< typename Type // Data type of the vector
629 , bool TF // Transpose flag
630 , typename Tag > // Type tag
631template< typename VT > // Type of the right-hand side vector
634{
636
637 if( !IsUniform_v<VT> && !isUniform( *rhs ) ) {
638 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment of uniform vector" );
639 }
640
641 size_ = (*rhs).size();
642
643 if( (*rhs).size() > 0UL ) {
644 value_ = (*rhs)[0UL];
645 }
646
647 return *this;
648}
649//*************************************************************************************************
650
651
652//*************************************************************************************************
663template< typename Type // Data type of the vector
664 , bool TF // Transpose flag
665 , typename Tag > // Type tag
666template< typename VT > // Type of the right-hand side vector
668 UniformVector<Type,TF,Tag>::operator+=( const Vector<VT,TF>& rhs ) &
669{
671
672 if( (*rhs).size() != size_ ) {
673 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
674 }
675
676 if( !IsUniform_v<VT> && !isUniform( *rhs ) ) {
677 BLAZE_THROW_INVALID_ARGUMENT( "Invalid addition assignment to uniform vector" );
678 }
679
680 if( (*rhs).size() > 0UL ) {
681 value_ += (*rhs)[0UL];
682 }
683
684 return *this;
685}
686//*************************************************************************************************
687
688
689//*************************************************************************************************
700template< typename Type // Data type of the vector
701 , bool TF // Transpose flag
702 , typename Tag > // Type tag
703template< typename VT > // Type of the right-hand side vector
705 UniformVector<Type,TF,Tag>::operator-=( const Vector<VT,TF>& rhs ) &
706{
708
709 if( (*rhs).size() != size_ ) {
710 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
711 }
712
713 if( !IsUniform_v<VT> && !isUniform( *rhs ) ) {
714 BLAZE_THROW_INVALID_ARGUMENT( "Invalid subtraction assignment to uniform vector" );
715 }
716
717 if( (*rhs).size() > 0UL ) {
718 value_ -= (*rhs)[0UL];
719 }
720
721 return *this;
722}
723//*************************************************************************************************
724
725
726//*************************************************************************************************
738template< typename Type // Data type of the vector
739 , bool TF // Transpose flag
740 , typename Tag > // Type tag
741template< typename VT > // Type of the right-hand side vector
743 UniformVector<Type,TF,Tag>::operator*=( const Vector<VT,TF>& rhs ) &
744{
746
747 if( (*rhs).size() != size_ ) {
748 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
749 }
750
751 if( !IsUniform_v<VT> && !isUniform( *rhs ) ) {
752 BLAZE_THROW_INVALID_ARGUMENT( "Invalid multiplication assignment to uniform vector" );
753 }
754
755 if( (*rhs).size() > 0UL ) {
756 value_ *= (*rhs)[0UL];
757 }
758
759 return *this;
760}
761//*************************************************************************************************
762
763
764//*************************************************************************************************
775template< typename Type // Data type of the vector
776 , bool TF // Transpose flag
777 , typename Tag > // Type tag
778template< typename VT > // Type of the right-hand side vector
780 UniformVector<Type,TF,Tag>::operator/=( const DenseVector<VT,TF>& rhs ) &
781{
783
784 if( (*rhs).size() != size_ ) {
785 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
786 }
787
788 if( !IsUniform_v<VT> && !isUniform( *rhs ) ) {
789 BLAZE_THROW_INVALID_ARGUMENT( "Invalid division assignment to uniform vector" );
790 }
791
792 if( (*rhs).size() > 0UL ) {
793 value_ /= (*rhs)[0UL];
794 }
795
796 return *this;
797}
798//*************************************************************************************************
799
800
801//*************************************************************************************************
808template< typename Type // Data type of the vector
809 , bool TF // Transpose flag
810 , typename Tag > // Type tag
811template< typename ST > // Data type of the right-hand side scalar
812inline auto UniformVector<Type,TF,Tag>::operator*=( ST scalar ) &
814{
815 if( size() > 0UL ) {
816 value_ *= scalar;
817 }
818
819 return *this;
820}
821//*************************************************************************************************
822
823
824//*************************************************************************************************
831template< typename Type // Data type of the vector
832 , bool TF // Transpose flag
833 , typename Tag > // Type tag
834template< typename ST > // Data type of the right-hand side scalar
835inline auto UniformVector<Type,TF,Tag>::operator/=( ST scalar ) &
837{
838 if( size() > 0UL ) {
839 value_ /= scalar;
840 }
841
842 return *this;
843}
844//*************************************************************************************************
845
846
847
848
849//=================================================================================================
850//
851// UTILITY FUNCTIONS
852//
853//=================================================================================================
854
855//*************************************************************************************************
860template< typename Type // Data type of the vector
861 , bool TF // Transpose flag
862 , typename Tag > // Type tag
863constexpr size_t UniformVector<Type,TF,Tag>::size() const noexcept
864{
865 return size_;
866}
867//*************************************************************************************************
868
869
870//*************************************************************************************************
878template< typename Type // Data type of the vector
879 , bool TF // Transpose flag
880 , typename Tag > // Type tag
881constexpr size_t UniformVector<Type,TF,Tag>::spacing() const noexcept
882{
883 return size_;
884}
885//*************************************************************************************************
886
887
888//*************************************************************************************************
893template< typename Type // Data type of the vector
894 , bool TF // Transpose flag
895 , typename Tag > // Type tag
896constexpr size_t UniformVector<Type,TF,Tag>::capacity() const noexcept
897{
898 return size_;
899}
900//*************************************************************************************************
901
902
903//*************************************************************************************************
912template< typename Type // Data type of the vector
913 , bool TF // Transpose flag
914 , typename Tag > // Type tag
916{
917 if( size_ == 0UL || isDefault<strict>( value_ ) )
918 return 0UL;
919 else
920 return size_;
921}
922//*************************************************************************************************
923
924
925//*************************************************************************************************
930template< typename Type // Data type of the vector
931 , bool TF // Transpose flag
932 , typename Tag > // Type tag
934{
935 using blaze::clear;
936
937 clear( value_ );
938}
939//*************************************************************************************************
940
941
942//*************************************************************************************************
949template< typename Type // Data type of the vector
950 , bool TF // Transpose flag
951 , typename Tag > // Type tag
953{
954 size_ = 0UL;
955}
956//*************************************************************************************************
957
958
959//*************************************************************************************************
971template< typename Type // Data type of the vector
972 , bool TF // Transpose flag
973 , typename Tag > // Type tag
974constexpr void UniformVector<Type,TF,Tag>::resize( size_t n, bool preserve )
975{
976 MAYBE_UNUSED( preserve );
977
978 size_ = n;
979}
980//*************************************************************************************************
981
982
983//*************************************************************************************************
994template< typename Type // Data type of the vector
995 , bool TF // Transpose flag
996 , typename Tag > // Type tag
997constexpr void UniformVector<Type,TF,Tag>::extend( size_t n, bool preserve )
998{
999 resize( size_+n, preserve );
1000}
1001//*************************************************************************************************
1002
1003
1004//*************************************************************************************************
1010template< typename Type // Data type of the vector
1011 , bool TF // Transpose flag
1012 , typename Tag > // Type tag
1014{
1015 using std::swap;
1016
1017 swap( size_, v.size_ );
1018 swap( value_, v.value_ );
1019}
1020//*************************************************************************************************
1021
1022
1023
1024
1025//=================================================================================================
1026//
1027// NUMERIC FUNCTIONS
1028//
1029//=================================================================================================
1030
1031//*************************************************************************************************
1048template< typename Type // Data type of the vector
1049 , bool TF // Transpose flag
1050 , typename Tag > // Type tag
1051template< typename Other > // Data type of the scalar value
1052inline UniformVector<Type,TF,Tag>& UniformVector<Type,TF,Tag>::scale( const Other& scalar )
1053{
1054 if( size_ > 0UL ) {
1055 value_ *= scalar;
1056 }
1057
1058 return *this;
1059}
1060//*************************************************************************************************
1061
1062
1063
1064
1065//=================================================================================================
1066//
1067// EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1068//
1069//=================================================================================================
1070
1071//*************************************************************************************************
1081template< typename Type // Data type of the vector
1082 , bool TF // Transpose flag
1083 , typename Tag > // Type tag
1084template< typename Other > // Data type of the foreign expression
1085inline bool UniformVector<Type,TF,Tag>::canAlias( const Other* alias ) const noexcept
1086{
1087 return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1088}
1089//*************************************************************************************************
1090
1091
1092//*************************************************************************************************
1102template< typename Type // Data type of the vector
1103 , bool TF // Transpose flag
1104 , typename Tag > // Type tag
1105template< typename Other > // Data type of the foreign expression
1106inline bool UniformVector<Type,TF,Tag>::isAliased( const Other* alias ) const noexcept
1107{
1108 return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1109}
1110//*************************************************************************************************
1111
1112
1113//*************************************************************************************************
1122template< typename Type // Data type of the vector
1123 , bool TF // Transpose flag
1124 , typename Tag > // Type tag
1125inline bool UniformVector<Type,TF,Tag>::isAligned() const noexcept
1126{
1127 return true;
1128}
1129//*************************************************************************************************
1130
1131
1132//*************************************************************************************************
1142template< typename Type // Data type of the vector
1143 , bool TF // Transpose flag
1144 , typename Tag > // Type tag
1146{
1147 return ( size() > SMP_DVECASSIGN_THRESHOLD );
1148}
1149//*************************************************************************************************
1150
1151
1152//*************************************************************************************************
1164template< typename Type // Data type of the vector
1165 , bool TF // Transpose flag
1166 , typename Tag > // Type tag
1168 UniformVector<Type,TF,Tag>::load( size_t index ) const noexcept
1169{
1170 return loada( index );
1171}
1172//*************************************************************************************************
1173
1174
1175//*************************************************************************************************
1188template< typename Type // Data type of the vector
1189 , bool TF // Transpose flag
1190 , typename Tag > // Type tag
1192 UniformVector<Type,TF,Tag>::loada( size_t index ) const noexcept
1193{
1194 MAYBE_UNUSED( index );
1195
1197
1198 BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1199 BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= size_, "Invalid vector access index" );
1200 BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
1201
1202 return set( value_ );
1203}
1204//*************************************************************************************************
1205
1206
1207//*************************************************************************************************
1220template< typename Type // Data type of the vector
1221 , bool TF // Transpose flag
1222 , typename Tag > // Type tag
1224 UniformVector<Type,TF,Tag>::loadu( size_t index ) const noexcept
1225{
1226 MAYBE_UNUSED( index );
1227
1229
1230 BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
1231 BLAZE_INTERNAL_ASSERT( index + SIMDSIZE <= size_, "Invalid vector access index" );
1232
1233 return set( value_ );
1234}
1235//*************************************************************************************************
1236
1237
1238
1239
1240//=================================================================================================
1241//
1242// UNIFORMVECTOR OPERATORS
1243//
1244//=================================================================================================
1245
1246//*************************************************************************************************
1249template< RelaxationFlag RF, typename Type, bool TF, typename Tag >
1250constexpr bool isDefault( const UniformVector<Type,TF,Tag>& v );
1251
1252template< typename Type, bool TF, typename Tag >
1253constexpr bool isIntact( const UniformVector<Type,TF,Tag>& v ) noexcept;
1254
1255template< typename Type, bool TF, typename Tag >
1256constexpr void swap( UniformVector<Type,TF,Tag>& a, UniformVector<Type,TF,Tag>& b ) noexcept;
1258//*************************************************************************************************
1259
1260
1261//*************************************************************************************************
1285template< RelaxationFlag RF // Relaxation flag
1286 , typename Type // Data type of the vector
1287 , bool TF // Transpose flag
1288 , typename Tag > // Type tag
1289constexpr bool isDefault( const UniformVector<Type,TF,Tag>& v )
1290{
1291 return ( v.size() == 0UL );
1292}
1293//*************************************************************************************************
1294
1295
1296//*************************************************************************************************
1314template< typename Type // Data type of the vector
1315 , bool TF // Transpose flag
1316 , typename Tag > // Type tag
1317constexpr bool isIntact( const UniformVector<Type,TF,Tag>& v ) noexcept
1318{
1319 MAYBE_UNUSED( v );
1320
1321 return true;
1322}
1323//*************************************************************************************************
1324
1325
1326//*************************************************************************************************
1334template< typename Type // Data type of the vector
1335 , bool TF // Transpose flag
1336 , typename Tag > // Type tag
1338{
1339 a.swap( b );
1340}
1341//*************************************************************************************************
1342
1343
1344
1345
1346//=================================================================================================
1347//
1348// GLOBAL FUNCTIONS
1349//
1350//=================================================================================================
1351
1352//*************************************************************************************************
1378template< bool TF = defaultTransposeFlag, typename T >
1379constexpr decltype(auto) uniform( size_t n, T&& init )
1380{
1381 return UniformVector< RemoveCVRef_t<T>, TF >( n, std::forward<T>( init ) );
1382}
1383//*************************************************************************************************
1384
1385
1386
1387
1388//=================================================================================================
1389//
1390// ISUNIFORM SPECIALIZATIONS
1391//
1392//=================================================================================================
1393
1394//*************************************************************************************************
1396template< typename Type, bool TF, typename Tag >
1397struct IsUniform< UniformVector<Type,TF,Tag> >
1398 : public TrueType
1399{};
1401//*************************************************************************************************
1402
1403
1404
1405
1406//=================================================================================================
1407//
1408// ISALIGNED SPECIALIZATIONS
1409//
1410//=================================================================================================
1411
1412//*************************************************************************************************
1414template< typename Type, bool TF, typename Tag >
1415struct IsAligned< UniformVector<Type,TF,Tag> >
1416 : public TrueType
1417{};
1419//*************************************************************************************************
1420
1421
1422
1423
1424//=================================================================================================
1425//
1426// ADDTRAIT SPECIALIZATIONS
1427//
1428//=================================================================================================
1429
1430//*************************************************************************************************
1432template< typename T1, typename T2 >
1433struct AddTraitEval1< T1, T2
1434 , EnableIf_t< IsVector_v<T1> &&
1437 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1438{
1442};
1444//*************************************************************************************************
1445
1446
1447
1448
1449//=================================================================================================
1450//
1451// SUBTRAIT SPECIALIZATIONS
1452//
1453//=================================================================================================
1454
1455//*************************************************************************************************
1457template< typename T1, typename T2 >
1458struct SubTraitEval1< T1, T2
1459 , EnableIf_t< IsVector_v<T1> &&
1462 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1463{
1467};
1469//*************************************************************************************************
1470
1471
1472
1473
1474//=================================================================================================
1475//
1476// MULTTRAIT SPECIALIZATIONS
1477//
1478//=================================================================================================
1479
1480//*************************************************************************************************
1482template< typename T1, typename T2 >
1483struct MultTraitEval1< T1, T2
1484 , EnableIf_t< IsVector_v<T1> &&
1487{
1491};
1492
1493template< typename T1, typename T2 >
1494struct MultTraitEval1< T1, T2
1495 , EnableIf_t< IsScalar_v<T1> &&
1498{
1502};
1503
1504template< typename T1, typename T2 >
1505struct MultTraitEval1< T1, T2
1506 , EnableIf_t< ( ( IsRowVector_v<T1> && IsRowVector_v<T2> ) ||
1509 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1510{
1514};
1515
1516template< typename T1, typename T2 >
1517struct MultTraitEval1< T1, T2
1518 , EnableIf_t< IsMatrix_v<T1> &&
1521 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1522{
1524 using MultTag = MultTrait_t< TagType_t<T1>, TagType_t<T2> >;
1525
1527 , false
1529};
1530
1531template< typename T1, typename T2 >
1532struct MultTraitEval1< T1, T2
1533 , EnableIf_t< IsRowVector_v<T1> &&
1536 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1537{
1539 using MultTag = MultTrait_t< TagType_t<T1>, TagType_t<T2> >;
1540
1542 , true
1544};
1546//*************************************************************************************************
1547
1548
1549
1550
1551//=================================================================================================
1552//
1553// KRONTRAIT SPECIALIZATIONS
1554//
1555//=================================================================================================
1556
1557//*************************************************************************************************
1559template< typename T1, typename T2 >
1560struct KronTraitEval1< T1, T2
1561 , EnableIf_t< IsVector_v<T1> &&
1564 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1565{
1569};
1571//*************************************************************************************************
1572
1573
1574
1575
1576//=================================================================================================
1577//
1578// DIVTRAIT SPECIALIZATIONS
1579//
1580//=================================================================================================
1581
1582//*************************************************************************************************
1584template< typename T1, typename T2 >
1585struct DivTraitEval1< T1, T2
1586 , EnableIf_t< IsVector_v<T1> &&
1589{
1592 , DivTrait_t< TagType_t<T1>, T2 > >;
1593};
1594
1595template< typename T1, typename T2 >
1596struct DivTraitEval1< T1, T2
1597 , EnableIf_t< ( ( IsRowVector_v<T1> && IsRowVector_v<T2> ) ||
1600 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1601{
1605};
1607//*************************************************************************************************
1608
1609
1610
1611
1612//=================================================================================================
1613//
1614// MAPTRAIT SPECIALIZATIONS
1615//
1616//=================================================================================================
1617
1618//*************************************************************************************************
1620template< typename T, typename OP >
1621struct UnaryMapTraitEval1< T, OP
1622 , EnableIf_t< IsVector_v<T> &&
1625{
1626 using ElementType = decltype( std::declval<OP>()( std::declval< ElementType_t<T> >() ) );
1627
1630 , MapTrait_t< TagType_t<T>, OP > >;
1631};
1633//*************************************************************************************************
1634
1635
1636//*************************************************************************************************
1638template< typename T1, typename T2, typename OP >
1639struct BinaryMapTraitEval1< T1, T2, OP
1640 , EnableIf_t< ( ( IsRowVector_v<T1> && IsRowVector_v<T2> ) ||
1644{
1645 using ElementType = decltype( std::declval<OP>()( std::declval< ElementType_t<T1> >()
1646 , std::declval< ElementType_t<T2> >() ) );
1647
1651};
1653//*************************************************************************************************
1654
1655
1656
1657
1658//=================================================================================================
1659//
1660// REDUCETRAIT SPECIALIZATIONS
1661//
1662//=================================================================================================
1663
1664//*************************************************************************************************
1666template< typename T, typename OP, ReductionFlag RF >
1667struct PartialReduceTraitEval1< T, OP, RF
1668 , EnableIf_t< IsMatrix_v<T> &&
1670{
1671 using ET = ElementType_t<T>;
1672
1673 using Type = UniformVector< decltype( std::declval<OP>()( std::declval<ET>(), std::declval<ET>() ) )
1674 , ( RF == columnwise )
1675 , MapTrait_t< TagType_t<T>, OP > >;
1676};
1678//*************************************************************************************************
1679
1680
1681
1682
1683//=================================================================================================
1684//
1685// REPEATTRAIT SPECIALIZATIONS
1686//
1687//=================================================================================================
1688
1689//*************************************************************************************************
1691template< typename T, size_t R0 >
1692struct RepeatTraitEval1< T, R0, inf, inf
1693 , EnableIf_t< IsVector_v<T> &&
1695{
1698 , TagType_t<T> >;
1699};
1701//*************************************************************************************************
1702
1703
1704
1705
1706//=================================================================================================
1707//
1708// HIGHTYPE SPECIALIZATIONS
1709//
1710//=================================================================================================
1711
1712//*************************************************************************************************
1714template< typename T1, bool TF, typename Tag, typename T2 >
1715struct HighType< UniformVector<T1,TF,Tag>, UniformVector<T2,TF,Tag> >
1716{
1717 using Type = UniformVector< typename HighType<T1,T2>::Type, TF, Tag >;
1718};
1720//*************************************************************************************************
1721
1722
1723
1724
1725//=================================================================================================
1726//
1727// LOWTYPE SPECIALIZATIONS
1728//
1729//=================================================================================================
1730
1731//*************************************************************************************************
1733template< typename T1, bool TF, typename Tag, typename T2 >
1734struct LowType< UniformVector<T1,TF,Tag>, UniformVector<T2,TF,Tag> >
1735{
1736 using Type = UniformVector< typename LowType<T1,T2>::Type, TF, Tag >;
1737};
1739//*************************************************************************************************
1740
1741
1742
1743
1744//=================================================================================================
1745//
1746// SUBVECTORTRAIT SPECIALIZATIONS
1747//
1748//=================================================================================================
1749
1750//*************************************************************************************************
1752template< typename VT, size_t I, size_t N >
1753struct SubvectorTraitEval1< VT, I, N
1754 , EnableIf_t< IsUniform_v<VT> && !IsZero_v<VT> > >
1755{
1758 , TagType_t<VT> >;
1759};
1761//*************************************************************************************************
1762
1763
1764
1765
1766//=================================================================================================
1767//
1768// ELEMENTSTRAIT SPECIALIZATIONS
1769//
1770//=================================================================================================
1771
1772//*************************************************************************************************
1774template< typename VT, size_t N >
1775struct ElementsTraitEval1< VT, N
1776 , EnableIf_t< IsUniform_v<VT> && !IsZero_v<VT> > >
1777{
1780 , TagType_t<VT> >;
1781};
1783//*************************************************************************************************
1784
1785
1786
1787
1788//=================================================================================================
1789//
1790// ROWTRAIT SPECIALIZATIONS
1791//
1792//=================================================================================================
1793
1794//*************************************************************************************************
1796template< typename MT, size_t I >
1797struct RowTraitEval1< MT, I
1798 , EnableIf_t< IsUniform_v<MT> && !IsZero_v<MT> > >
1799{
1801 , true
1802 , TagType_t<MT> >;
1803};
1805//*************************************************************************************************
1806
1807
1808
1809
1810//=================================================================================================
1811//
1812// COLUMNTRAIT SPECIALIZATIONS
1813//
1814//=================================================================================================
1815
1816//*************************************************************************************************
1818template< typename MT, size_t I >
1819struct ColumnTraitEval1< MT, I
1820 , EnableIf_t< IsUniform_v<MT> && !IsZero_v<MT> > >
1821{
1823 , false
1824 , TagType_t<MT> >;
1825};
1827//*************************************************************************************************
1828
1829
1830
1831
1832//=================================================================================================
1833//
1834// BANDTRAIT SPECIALIZATIONS
1835//
1836//=================================================================================================
1837
1838//*************************************************************************************************
1840template< typename MT, ptrdiff_t I >
1841struct BandTraitEval1< MT, I
1842 , EnableIf_t< IsUniform_v<MT> && !IsZero_v<MT> > >
1843{
1846 , TagType_t<MT> >;
1847};
1849//*************************************************************************************************
1850
1851} // namespace blaze
1852
1853#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::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition Aliases.h:190
Header file for the alignment flag enumeration.
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 division trait.
Header file for the elements trait.
Header file for the EnableIf class template.
Header file for the EvaluateTrait class template.
Header file for the HighType type trait.
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 isDefault shim.
Header file for the IsIdentity type trait.
Header file for the IsMatrix type trait.
Header file for the IsRowVector type trait.
Header file for the IsSMPAssignable type trait.
Header file for the IsScalar type trait.
Header file for the IsUniform 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 MAYBE_UNUSED function template.
Header file for the multiplication trait.
Constraint on the data type.
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 RemoveCVRef 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 subtraction trait.
Header file for the subvector trait.
Header file for the UniformIterator class template.
Constraint on the data type.
Constraint on the data type.
Header file for the YieldsUniform type trait.
Header file for the YieldsZero type trait.
Base class for N-dimensional dense vectors.
Definition DenseVector.h:77
Implementation of a generic iterator for uniform vectors and matrices.
Definition UniformIterator.h:60
Efficient implementation of a uniform vector.
Definition UniformVector.h:186
constexpr UniformVector & operator=(const Type &rhs) &
Homogenous assignment to all vector elements.
Definition UniformVector.h:610
constexpr void resize(size_t n, bool preserve=true)
This ResultType
Result type for expression template evaluations.
Definition UniformVector.h:193
Type ElementType
Definition UniformVector.h:198
const UniformVector & CompositeType
Definition UniformVector.h:202
static constexpr bool smpAssignable
Definition UniformVector.h:243
static constexpr bool simdEnabled
Definition UniformVector.h:237
bool canAlias(const Other *alias) const noexcept
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
constexpr UniformVector() noexcept
The default constructor for UniformVector.
Definition UniformVector.h:382
size_t size_
Definition UniformVector.h:351
constexpr ConstReference operator[](size_t index) const noexcept
Subscript operator for the direct access to the vector elements.
Definition UniformVector.h:473
UniformIterator< const Type, aligned > ConstIterator
Definition UniformVector.h:210
constexpr void swap(UniformVector &v) noexcept
constexpr ConstIterator cbegin() const noexcept
const Type & ReturnType
Definition UniformVector.h:201
constexpr size_t size() const noexcept
bool isAliased(const Other *alias) const noexcept
SIMDTrait_t< ElementType > SIMDType
Definition UniformVector.h:199
static constexpr size_t SIMDSIZE
Definition UniformVector.h:328
constexpr ConstIterator end() const noexcept
constexpr ConstPointer data() const noexcept
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t index) const noexcept
Type value_
Definition UniformVector.h:352
UniformVector< Type,!TF, Tag > TransposeType
Transpose type for expression template evaluations.
Definition UniformVector.h:196
const Type * Pointer
Definition UniformVector.h:206
const Type & Reference
Definition UniformVector.h:204
const Type & ConstReference
Definition UniformVector.h:205
BLAZE_ALWAYS_INLINE SIMDType load(size_t index) const noexcept
constexpr void extend(size_t n, bool preserve=true)
constexpr size_t capacity() const noexcept
const Type * ConstPointer
Definition UniformVector.h:207
Tag TagType
Definition UniformVector.h:200
UniformIterator< const Type, aligned > Iterator
Definition UniformVector.h:209
ConstReference at(size_t index) const
constexpr ConstIterator cend() const noexcept
constexpr ConstIterator begin() const noexcept
Expression< DenseVector< This, TF > > BaseType
Base type of this UniformVector instance.
Definition UniformVector.h:190
constexpr size_t spacing() const noexcept
bool canSMPAssign() const noexcept
UniformVector< Type, TF, Tag > This
Type of this UniformVector instance.
Definition UniformVector.h:189
Base class for N-dimensional vectors.
Definition Vector.h:82
Header file for the DenseVector base class.
Header file for the Expression 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
bool isUniform(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a uniform matrix.
Definition DenseMatrix.h:1766
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition DiagonalMatrix.h:207
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition DiagonalMatrix.h:225
bool isDefault(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the given diagonal matrix is in default state.
Definition DiagonalMatrix.h:169
typename SubTrait< T1, T2 >::Type SubTrait_t
Auxiliary alias declaration for the SubTrait class template.
Definition SubTrait.h:163
typename AddTrait< T1, T2 >::Type AddTrait_t
Auxiliary alias declaration for the AddTrait class template.
Definition AddTrait.h:163
typename MapTrait< Args... >::Type MapTrait_t
Auxiliary alias declaration for the MapTrait class template.
Definition MapTrait.h:131
typename DivTrait< T1, T2 >::Type DivTrait_t
Auxiliary alias declaration for the DivTrait class template.
Definition DivTrait.h:164
typename MultTrait< T1, T2 >::Type MultTrait_t
Auxiliary alias declaration for the MultTrait class template.
Definition MultTrait.h:165
constexpr bool IsScalar_v
Auxiliary variable template for the IsScalar type trait.
Definition IsScalar.h:104
constexpr bool IsUniform_v
Auxiliary variable template for the IsUniform type trait.
Definition IsUniform.h:164
constexpr bool IsVector_v
Auxiliary variable template for the IsVector type trait.
Definition IsVector.h:125
constexpr bool YieldsUniform_v
Auxiliary variable template for the YieldsUniform type trait.
Definition YieldsUniform.h:125
constexpr bool IsZero_v
Auxiliary variable template for the IsZero type trait.
Definition IsZero.h:166
constexpr bool YieldsZero_v
Auxiliary variable template for the YieldsZero type trait.
Definition YieldsZero.h:125
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.
Definition IsMatrix.h:124
constexpr bool IsColumnVector_v
Auxiliary variable template for the IsColumnVector type trait.
Definition IsColumnVector.h:126
constexpr bool IsIdentity_v
Auxiliary variable template for the IsIdentity type trait.
Definition IsIdentity.h:137
constexpr bool IsSMPAssignable_v
Auxiliary variable template for the IsSMPAssignable type trait.
Definition IsSMPAssignable.h:132
constexpr bool IsRowVector_v
Auxiliary variable template for the IsRowVector type trait.
Definition IsRowVector.h:126
constexpr bool TransposeFlag_v
Auxiliary variable template for the TransposeFlag type trait.
Definition TransposeFlag.h:93
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition RelaxationFlag.h:66
constexpr Infinity inf
Global Infinity instance.
Definition Infinity.h:1080
constexpr void clear(Matrix< MT, SO > &matrix)
Clearing the given matrix.
Definition Matrix.h:960
#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
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition Set.h:75
typename SIMDTrait< T >::Type SIMDTrait_t
Auxiliary alias declaration for the SIMDTrait class template.
Definition SIMDTrait.h:315
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition Inline.h:85
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 decltype(auto) uniform(size_t m, size_t n, T &&init)
Creating a uniform matrix.
Definition UniformMatrix.h:1640
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition MaybeUnused.h:81
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:138
BoolConstant< true > TrueType
Type traits base class.
Definition IntegralConstant.h:132
#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
Header file for the exception macros of the math module.
Header file for all forward declarations for dense vectors and matrices.
Header file for the TransposeFlag type trait.
Header file for the clear shim.
Base class for all expression templates.
Definition Expression.h:60
Base template for the HighType type trait.
Definition HighType.h:322
Compile time check for the alignment of data types.
Definition IsAligned.h:88
Base template for the LowType type trait.
Definition LowType.h:322
Rebind mechanism to obtain a UniformVector with different data/element type.
Definition UniformVector.h:217
UniformVector< NewType, TF, Tag > Other
The type of the other UniformVector.
Definition UniformVector.h:218
Resize mechanism to obtain a UniformVector with a different fixed number of elements.
Definition UniformVector.h:226
UniformVector< Type, TF, Tag > Other
The type of the other UniformVector.
Definition UniformVector.h:227
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
Header file for the default transpose flag for all vectors of the Blaze library.
Header file for the IsZero type trait.
Header file for basic type definitions.