Blaze 3.9
DenseVector.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_DENSE_DENSEVECTOR_H_
36#define _BLAZE_MATH_DENSE_DENSEVECTOR_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <blaze/math/Aliases.h>
61#include <blaze/util/Assert.h>
63#include <blaze/util/EnableIf.h>
64#include <blaze/util/Types.h>
67
68
69namespace blaze {
70
71//=================================================================================================
72//
73// GLOBAL OPERATORS
74//
75//=================================================================================================
76
77//*************************************************************************************************
80template< typename T1, typename T2, bool TF >
81auto operator==( const DenseVector<T1,TF>& vec, T2 scalar )
82 -> EnableIf_t< IsScalar_v<T2>, bool >;
83
84template< typename T1, typename T2, bool TF >
85auto operator==( T1 scalar, const DenseVector<T2,TF>& vec )
86 -> EnableIf_t< IsScalar_v<T1>, bool >;
87
88template< typename T1, typename T2, bool TF >
89auto operator!=( const DenseVector<T1,TF>& vec, T2 scalar )
90 -> EnableIf_t< IsScalar_v<T2>, bool >;
91
92template< typename T1, typename T2, bool TF >
93auto operator!=( T1 scalar, const DenseVector<T2,TF>& vec )
94 -> EnableIf_t< IsScalar_v<T1>, bool >;
95
96template< typename VT, bool TF, typename ST >
97auto operator+=( DenseVector<VT,TF>& vec, ST scalar )
98 -> EnableIf_t< IsScalar_v<ST>, VT& >;
99
100template< typename VT, bool TF, typename ST >
101auto operator+=( DenseVector<VT,TF>&& vec, ST scalar )
102 -> EnableIf_t< IsScalar_v<ST>, VT& >;
103
104template< typename VT, bool TF, typename ST >
105auto operator-=( DenseVector<VT,TF>& vec, ST scalar )
106 -> EnableIf_t< IsScalar_v<ST>, VT& >;
107
108template< typename VT, bool TF, typename ST >
109auto operator-=( DenseVector<VT,TF>&& vec, ST scalar )
110 -> EnableIf_t< IsScalar_v<ST>, VT& >;
111
112template< typename VT, bool TF, typename ST >
113auto operator*=( DenseVector<VT,TF>& vec, ST scalar )
114 -> EnableIf_t< IsScalar_v<ST>, VT& >;
115
116template< typename VT, bool TF, typename ST >
117auto operator*=( DenseVector<VT,TF>&& vec, ST scalar )
118 -> EnableIf_t< IsScalar_v<ST>, VT& >;
119
120template< typename VT, bool TF, typename ST >
121auto operator/=( DenseVector<VT,TF>& vec, ST scalar )
122 -> EnableIf_t< IsScalar_v<ST>, VT& >;
123
124template< typename VT, bool TF, typename ST >
125auto operator/=( DenseVector<VT,TF>&& vec, ST scalar )
126 -> EnableIf_t< IsScalar_v<ST>, VT& >;
127
128template< typename VT, bool TF >
129VT& operator<<=( DenseVector<VT,TF>& vec, int count );
130
131template< typename VT, bool TF >
132VT& operator<<=( DenseVector<VT,TF>&& vec, int count );
133
134template< typename VT1, typename VT2, bool TF >
135VT1& operator<<=( DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs );
136
137template< typename VT1, typename VT2, bool TF >
138VT1& operator<<=( DenseVector<VT1,TF>&& lhs, const DenseVector<VT2,TF>& rhs );
139
140template< typename VT, bool TF >
141VT& operator>>=( DenseVector<VT,TF>& vec, int count );
142
143template< typename VT, bool TF >
144VT& operator>>=( DenseVector<VT,TF>&& vec, int count );
145
146template< typename VT1, typename VT2, bool TF >
147VT1& operator>>=( DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs );
148
149template< typename VT1, typename VT2, bool TF >
150VT1& operator>>=( DenseVector<VT1,TF>&& lhs, const DenseVector<VT2,TF>& rhs );
151
152template< typename VT, bool TF, typename ST >
153auto operator&=( DenseVector<VT,TF>& vec, ST scalar )
154 -> EnableIf_t< IsScalar_v<ST>, VT& >;
155
156template< typename VT, bool TF, typename ST >
157auto operator&=( DenseVector<VT,TF>&& vec, ST scalar )
158 -> EnableIf_t< IsScalar_v<ST>, VT& >;
159
160template< typename VT1, typename VT2, bool TF >
161VT1& operator&=( DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs );
162
163template< typename VT1, typename VT2, bool TF >
164VT1& operator&=( DenseVector<VT1,TF>&& lhs, const DenseVector<VT2,TF>& rhs );
165
166template< typename VT, bool TF, typename ST >
167auto operator|=( DenseVector<VT,TF>& vec, ST scalar )
168 -> EnableIf_t< IsScalar_v<ST>, VT& >;
169
170template< typename VT, bool TF, typename ST >
171auto operator|=( DenseVector<VT,TF>&& vec, ST scalar )
172 -> EnableIf_t< IsScalar_v<ST>, VT& >;
173
174template< typename VT1, typename VT2, bool TF >
175VT1& operator|=( DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs );
176
177template< typename VT1, typename VT2, bool TF >
178VT1& operator|=( DenseVector<VT1,TF>&& lhs, const DenseVector<VT2,TF>& rhs );
179
180template< typename VT, bool TF, typename ST >
181auto operator^=( DenseVector<VT,TF>& vec, ST scalar )
182 -> EnableIf_t< IsScalar_v<ST>, VT& >;
183
184template< typename VT, bool TF, typename ST >
185auto operator^=( DenseVector<VT,TF>&& vec, ST scalar )
186 -> EnableIf_t< IsScalar_v<ST>, VT& >;
187
188template< typename VT1, typename VT2, bool TF >
189VT1& operator^=( DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs );
190
191template< typename VT1, typename VT2, bool TF >
192VT1& operator^=( DenseVector<VT1,TF>&& lhs, const DenseVector<VT2,TF>& rhs );
194//*************************************************************************************************
195
196
197//*************************************************************************************************
209template< typename T1 // Type of the left-hand side dense vector
210 , typename T2 // Type of the right-hand side scalar
211 , bool TF > // Transpose flag
212inline auto operator==( const DenseVector<T1,TF>& vec, T2 scalar )
214{
215 using CT1 = CompositeType_t<T1>;
216
217 // Evaluation of the dense vector operand
218 CT1 a( *vec );
219
220 // In order to compare the vector and the scalar value, the data values of the lower-order
221 // data type are converted to the higher-order data type within the equal function.
222 for( size_t i=0; i<a.size(); ++i )
223 if( !equal( a[i], scalar ) ) return false;
224 return true;
225}
226//*************************************************************************************************
227
228
229//*************************************************************************************************
241template< typename T1 // Type of the left-hand side scalar
242 , typename T2 // Type of the right-hand side dense vector
243 , bool TF > // Transpose flag
244inline auto operator==( T1 scalar, const DenseVector<T2,TF>& vec )
246{
247 return ( vec == scalar );
248}
249//*************************************************************************************************
250
251
252//*************************************************************************************************
264template< typename T1 // Type of the left-hand side dense vector
265 , typename T2 // Type of the right-hand side scalar
266 , bool TF > // Transpose flag
267inline auto operator!=( const DenseVector<T1,TF>& vec, T2 scalar )
269{
270 return !( vec == scalar );
271}
272//*************************************************************************************************
273
274
275//*************************************************************************************************
287template< typename T1 // Type of the left-hand side scalar
288 , typename T2 // Type of the right-hand side vector
289 , bool TF > // Transpose flag
290inline auto operator!=( T1 scalar, const DenseVector<T2,TF>& vec )
292{
293 return !( vec == scalar );
294}
295//*************************************************************************************************
296
297
298//*************************************************************************************************
311template< typename VT // Type of the left-hand side dense vector
312 , bool TF // Transpose flag
313 , typename ST > // Data type of the right-hand side scalar
314inline auto operator+=( DenseVector<VT,TF>& vec, ST scalar )
316{
317 if( IsRestricted_v<VT> ) {
318 if( !tryAdd( *vec, 0UL, (*vec).size(), scalar ) ) {
319 BLAZE_THROW_INVALID_ARGUMENT( "Invalid addition to restricted vector" );
320 }
321 }
322
323 decltype(auto) left( derestrict( *vec ) );
324
325 smpAssign( left, left + scalar );
326
327 BLAZE_INTERNAL_ASSERT( isIntact( *vec ), "Invariant violation detected" );
328
329 return *vec;
330}
331//*************************************************************************************************
332
333
334//*************************************************************************************************
347template< typename VT // Type of the left-hand side dense vector
348 , bool TF // Transpose flag
349 , typename ST > // Data type of the right-hand side scalar
350inline auto operator+=( DenseVector<VT,TF>&& vec, ST scalar )
352{
353 return operator+=( *vec, scalar );
354}
355//*************************************************************************************************
356
357
358//*************************************************************************************************
371template< typename VT // Type of the left-hand side dense vector
372 , bool TF // Transpose flag
373 , typename ST > // Data type of the right-hand side scalar
374inline auto operator-=( DenseVector<VT,TF>& vec, ST scalar )
376{
377 if( IsRestricted_v<VT> ) {
378 if( !trySub( *vec, 0UL, (*vec).size(), scalar ) ) {
379 BLAZE_THROW_INVALID_ARGUMENT( "Invalid subtraction from restricted vector" );
380 }
381 }
382
383 decltype(auto) left( derestrict( *vec ) );
384
385 smpAssign( left, left - scalar );
386
387 BLAZE_INTERNAL_ASSERT( isIntact( *vec ), "Invariant violation detected" );
388
389 return *vec;
390}
391//*************************************************************************************************
392
393
394//*************************************************************************************************
407template< typename VT // Type of the left-hand side dense vector
408 , bool TF // Transpose flag
409 , typename ST > // Data type of the right-hand side scalar
410inline auto operator-=( DenseVector<VT,TF>&& vec, ST scalar )
412{
413 return operator-=( *vec, scalar );
414}
415//*************************************************************************************************
416
417
418//*************************************************************************************************
431template< typename VT // Type of the left-hand side dense vector
432 , bool TF // Transpose flag
433 , typename ST > // Data type of the right-hand side scalar
434inline auto operator*=( DenseVector<VT,TF>& vec, ST scalar )
436{
437 if( IsRestricted_v<VT> ) {
438 if( !tryMult( *vec, 0UL, (*vec).size(), scalar ) ) {
439 BLAZE_THROW_INVALID_ARGUMENT( "Invalid scaling of restricted vector" );
440 }
441 }
442
443 decltype(auto) left( derestrict( *vec ) );
444
445 smpAssign( left, left * scalar );
446
447 BLAZE_INTERNAL_ASSERT( isIntact( *vec ), "Invariant violation detected" );
448
449 return *vec;
450}
451//*************************************************************************************************
452
453
454//*************************************************************************************************
467template< typename VT // Type of the left-hand side dense vector
468 , bool TF // Transpose flag
469 , typename ST > // Data type of the right-hand side scalar
470inline auto operator*=( DenseVector<VT,TF>&& vec, ST scalar )
472{
473 return operator*=( *vec, scalar );
474}
475//*************************************************************************************************
476
477
478//*************************************************************************************************
493template< typename VT // Type of the left-hand side dense vector
494 , bool TF // Transpose flag
495 , typename ST > // Data type of the right-hand side scalar
496inline auto operator/=( DenseVector<VT,TF>& vec, ST scalar )
498{
499 BLAZE_USER_ASSERT( isDivisor( scalar ), "Division by zero detected" );
500
501 if( IsRestricted_v<VT> ) {
502 if( !tryDiv( *vec, 0UL, (*vec).size(), scalar ) ) {
503 BLAZE_THROW_INVALID_ARGUMENT( "Invalid scaling of restricted vector" );
504 }
505 }
506
507 decltype(auto) left( derestrict( *vec ) );
508
509 smpAssign( left, left / scalar );
510
511 BLAZE_INTERNAL_ASSERT( isIntact( *vec ), "Invariant violation detected" );
512
513 return *vec;
514}
515//*************************************************************************************************
516
517
518//*************************************************************************************************
533template< typename VT // Type of the left-hand side dense vector
534 , bool TF // Transpose flag
535 , typename ST > // Data type of the right-hand side scalar
536inline auto operator/=( DenseVector<VT,TF>&& vec, ST scalar )
538{
539 return operator/=( *vec, scalar );
540}
541//*************************************************************************************************
542
543
544//*************************************************************************************************
556template< typename VT // Type of the dense vector
557 , bool TF > // Transpose flag
558inline VT& operator<<=( DenseVector<VT,TF>& vec, int count )
559{
560 if( IsRestricted_v<VT> ) {
561 if( !tryShift( *vec, 0UL, (*vec).size(), count ) ) {
562 BLAZE_THROW_INVALID_ARGUMENT( "Invalid left-shift of restricted vector" );
563 }
564 }
565
566 decltype(auto) left( derestrict( *vec ) );
567
568 smpAssign( left, left << count );
569
570 BLAZE_INTERNAL_ASSERT( isIntact( *vec ), "Invariant violation detected" );
571
572 return *vec;
573}
574//*************************************************************************************************
575
576
577//*************************************************************************************************
589template< typename VT // Type of the dense vector
590 , bool TF > // Transpose flag
591inline VT& operator<<=( DenseVector<VT,TF>&& vec, int count )
592{
593 return operator<<=( *vec, count );
594}
595//*************************************************************************************************
596
597
598//*************************************************************************************************
610template< typename VT1 // Type of the left-hand side dense vector
611 , typename VT2 // Type of the right-hand side dense vector
612 , bool TF > // Transpose flag
614{
615 if( IsRestricted_v<VT1> ) {
616 if( !tryShiftAssign( *lhs, *rhs, 0UL ) ) {
617 BLAZE_THROW_INVALID_ARGUMENT( "Invalid left-shift of restricted vector" );
618 }
619 }
620
621 decltype(auto) left( derestrict( *lhs ) );
622
623 smpAssign( left, left << (*rhs) );
624
625 BLAZE_INTERNAL_ASSERT( isIntact( *lhs ), "Invariant violation detected" );
626
627 return *lhs;
628}
629//*************************************************************************************************
630
631
632//*************************************************************************************************
645template< typename VT1 // Type of the left-hand side dense vector
646 , typename VT2 // Type of the right-hand side dense vector
647 , bool TF > // Transpose flag
649{
650 return operator<<=( *lhs, *rhs );
651}
652//*************************************************************************************************
653
654
655//*************************************************************************************************
667template< typename VT // Type of the dense vector
668 , bool TF > // Transpose flag
669inline VT& operator>>=( DenseVector<VT,TF>& vec, int count )
670{
671 if( IsRestricted_v<VT> ) {
672 if( !tryShift( *vec, 0UL, (*vec).size(), count ) ) {
673 BLAZE_THROW_INVALID_ARGUMENT( "Invalid right-shift of restricted vector" );
674 }
675 }
676
677 decltype(auto) left( derestrict( *vec ) );
678
679 smpAssign( left, left >> count );
680
681 BLAZE_INTERNAL_ASSERT( isIntact( *vec ), "Invariant violation detected" );
682
683 return *vec;
684}
685//*************************************************************************************************
686
687
688//*************************************************************************************************
700template< typename VT // Type of the dense vector
701 , bool TF > // Transpose flag
702inline VT& operator>>=( DenseVector<VT,TF>&& vec, int count )
703{
704 return operator>>=( *vec, count );
705}
706//*************************************************************************************************
707
708
709//*************************************************************************************************
721template< typename VT1 // Type of the left-hand side dense vector
722 , typename VT2 // Type of the right-hand side dense vector
723 , bool TF > // Transpose flag
725{
726 if( IsRestricted_v<VT1> ) {
727 if( !tryShiftAssign( *lhs, *rhs, 0UL ) ) {
728 BLAZE_THROW_INVALID_ARGUMENT( "Invalid right-shift of restricted vector" );
729 }
730 }
731
732 decltype(auto) left( derestrict( *lhs ) );
733
734 smpAssign( left, left >> (*rhs) );
735
736 BLAZE_INTERNAL_ASSERT( isIntact( *lhs ), "Invariant violation detected" );
737
738 return *lhs;
739}
740//*************************************************************************************************
741
742
743//*************************************************************************************************
755template< typename VT1 // Type of the left-hand side dense vector
756 , typename VT2 // Type of the right-hand side dense vector
757 , bool TF > // Transpose flag
759{
760 return operator>>=( *lhs, *rhs );
761}
762//*************************************************************************************************
763
764
765//*************************************************************************************************
777template< typename VT // Type of the left-hand side dense vector
778 , bool TF // Transpose flag
779 , typename ST > // Data type of the right-hand side scalar
780inline auto operator&=( DenseVector<VT,TF>& vec, ST scalar )
782{
783 if( IsRestricted_v<VT> ) {
784 if( !tryBitand( *vec, 0UL, (*vec).size(), scalar ) ) {
785 BLAZE_THROW_INVALID_ARGUMENT( "Invalid bitwise AND of restricted vector" );
786 }
787 }
788
789 decltype(auto) left( derestrict( *vec ) );
790
791 smpAssign( left, left & scalar );
792
793 BLAZE_INTERNAL_ASSERT( isIntact( *vec ), "Invariant violation detected" );
794
795 return *vec;
796}
797//*************************************************************************************************
798
799
800//*************************************************************************************************
813template< typename VT // Type of the left-hand side dense vector
814 , bool TF // Transpose flag
815 , typename ST > // Data type of the right-hand side scalar
816inline auto operator&=( DenseVector<VT,TF>&& vec, ST scalar )
818{
819 return operator&=( *vec, scalar );
820}
821//*************************************************************************************************
822
823
824//*************************************************************************************************
836template< typename VT1 // Type of the left-hand side dense vector
837 , typename VT2 // Type of the right-hand side dense vector
838 , bool TF > // Transpose flag
840{
841 if( IsRestricted_v<VT1> ) {
842 if( !tryBitandAssign( *lhs, *rhs, 0UL ) ) {
843 BLAZE_THROW_INVALID_ARGUMENT( "Invalid bitwise AND of restricted vector" );
844 }
845 }
846
847 decltype(auto) left( derestrict( *lhs ) );
848
849 smpAssign( left, left & (*rhs) );
850
851 BLAZE_INTERNAL_ASSERT( isIntact( *lhs ), "Invariant violation detected" );
852
853 return *lhs;
854}
855//*************************************************************************************************
856
857
858//*************************************************************************************************
870template< typename VT1 // Type of the left-hand side dense vector
871 , typename VT2 // Type of the right-hand side dense vector
872 , bool TF > // Transpose flag
873inline VT1& operator&=( DenseVector<VT1,TF>&& lhs, const DenseVector<VT2,TF>& rhs )
874{
875 return operator&=( *lhs, *rhs );
876}
877//*************************************************************************************************
878
879
880//*************************************************************************************************
892template< typename VT // Type of the left-hand side dense vector
893 , bool TF // Transpose flag
894 , typename ST > // Data type of the right-hand side scalar
895inline auto operator|=( DenseVector<VT,TF>& vec, ST scalar )
897{
898 if( IsRestricted_v<VT> ) {
899 if( !tryBitor( *vec, 0UL, (*vec).size(), scalar ) ) {
900 BLAZE_THROW_INVALID_ARGUMENT( "Invalid bitwise OR of restricted vector" );
901 }
902 }
903
904 decltype(auto) left( derestrict( *vec ) );
905
906 smpAssign( left, left | scalar );
907
908 BLAZE_INTERNAL_ASSERT( isIntact( *vec ), "Invariant violation detected" );
909
910 return *vec;
911}
912//*************************************************************************************************
913
914
915//*************************************************************************************************
928template< typename VT // Type of the left-hand side dense vector
929 , bool TF // Transpose flag
930 , typename ST > // Data type of the right-hand side scalar
931inline auto operator|=( DenseVector<VT,TF>&& vec, ST scalar )
933{
934 return operator|=( *vec, scalar );
935}
936//*************************************************************************************************
937
938
939//*************************************************************************************************
951template< typename VT1 // Type of the left-hand side dense vector
952 , typename VT2 // Type of the right-hand side dense vector
953 , bool TF > // Transpose flag
955{
956 if( IsRestricted_v<VT1> ) {
957 if( !tryBitorAssign( *lhs, *rhs, 0UL ) ) {
958 BLAZE_THROW_INVALID_ARGUMENT( "Invalid bitwise OR of restricted vector" );
959 }
960 }
961
962 decltype(auto) left( derestrict( *lhs ) );
963
964 smpAssign( left, left | (*rhs) );
965
966 BLAZE_INTERNAL_ASSERT( isIntact( *lhs ), "Invariant violation detected" );
967
968 return *lhs;
969}
970//*************************************************************************************************
971
972
973//*************************************************************************************************
985template< typename VT1 // Type of the left-hand side dense vector
986 , typename VT2 // Type of the right-hand side dense vector
987 , bool TF > // Transpose flag
988inline VT1& operator|=( DenseVector<VT1,TF>&& lhs, const DenseVector<VT2,TF>& rhs )
989{
990 return operator|=( *lhs, *rhs );
991}
992//*************************************************************************************************
993
994
995//*************************************************************************************************
1007template< typename VT // Type of the left-hand side dense vector
1008 , bool TF // Transpose flag
1009 , typename ST > // Data type of the right-hand side scalar
1010inline auto operator^=( DenseVector<VT,TF>& vec, ST scalar )
1012{
1013 if( IsRestricted_v<VT> ) {
1014 if( !tryBitxor( *vec, 0UL, (*vec).size(), scalar ) ) {
1015 BLAZE_THROW_INVALID_ARGUMENT( "Invalid bitwise XOR of restricted vector" );
1016 }
1017 }
1018
1019 decltype(auto) left( derestrict( *vec ) );
1020
1021 smpAssign( left, left ^ scalar );
1022
1023 BLAZE_INTERNAL_ASSERT( isIntact( *vec ), "Invariant violation detected" );
1024
1025 return *vec;
1026}
1027//*************************************************************************************************
1028
1029
1030//*************************************************************************************************
1043template< typename VT // Type of the left-hand side dense vector
1044 , bool TF // Transpose flag
1045 , typename ST > // Data type of the right-hand side scalar
1046inline auto operator^=( DenseVector<VT,TF>&& vec, ST scalar )
1048{
1049 return operator^=( *vec, scalar );
1050}
1051//*************************************************************************************************
1052
1053
1054//*************************************************************************************************
1066template< typename VT1 // Type of the left-hand side dense vector
1067 , typename VT2 // Type of the right-hand side dense vector
1068 , bool TF > // Transpose flag
1070{
1071 if( IsRestricted_v<VT1> ) {
1072 if( !tryBitxorAssign( *lhs, *rhs, 0UL ) ) {
1073 BLAZE_THROW_INVALID_ARGUMENT( "Invalid bitwise XOR of restricted vector" );
1074 }
1075 }
1076
1077 decltype(auto) left( derestrict( *lhs ) );
1078
1079 smpAssign( left, left ^ (*rhs) );
1080
1081 BLAZE_INTERNAL_ASSERT( isIntact( *lhs ), "Invariant violation detected" );
1082
1083 return *lhs;
1084}
1085//*************************************************************************************************
1086
1087
1088//*************************************************************************************************
1100template< typename VT1 // Type of the left-hand side dense vector
1101 , typename VT2 // Type of the right-hand side dense vector
1102 , bool TF > // Transpose flag
1104{
1105 return operator^=( *lhs, *rhs );
1106}
1107//*************************************************************************************************
1108
1109
1110
1111
1112//=================================================================================================
1113//
1114// GLOBAL FUNCTIONS
1115//
1116//=================================================================================================
1117
1118//*************************************************************************************************
1121template< typename VT, bool TF >
1122bool isnan( const DenseVector<VT,TF>& dv );
1123
1124template< typename VT, bool TF >
1125bool isinf( const DenseVector<VT,TF>& dv );
1126
1127template< typename VT, bool TF >
1128bool isfinite( const DenseVector<VT,TF>& dv );
1129
1130template< typename VT, bool TF >
1131bool isDivisor( const DenseVector<VT,TF>& dv );
1132
1133template< RelaxationFlag RF, typename VT, bool TF >
1134bool isUniform( const DenseVector<VT,TF>& dv );
1135
1136template< RelaxationFlag RF, typename VT, bool TF >
1137bool isZero( const DenseVector<VT,TF>& dv );
1139//*************************************************************************************************
1140
1141
1142//*************************************************************************************************
1159template< typename VT // Type of the dense vector
1160 , bool TF > // Transpose flag
1161bool isnan( const DenseVector<VT,TF>& dv )
1162{
1164 return false;
1165
1166 CompositeType_t<VT> a( *dv ); // Evaluation of the dense vector operand
1167
1168 for( size_t i=0UL; i<a.size(); ++i ) {
1169 if( isnan( a[i] ) ) return true;
1170 }
1171 return false;
1172}
1173//*************************************************************************************************
1174
1175
1176//*************************************************************************************************
1192template< typename VT // Type of the dense vector
1193 , bool TF > // Transpose flag
1194bool isinf( const DenseVector<VT,TF>& dv )
1195{
1197 return false;
1198
1199 CompositeType_t<VT> a( *dv ); // Evaluation of the dense vector operand
1200
1201 for( size_t i=0UL; i<a.size(); ++i ) {
1202 if( isinf( a[i] ) ) return true;
1203 }
1204 return false;
1205}
1206//*************************************************************************************************
1207
1208
1209//*************************************************************************************************
1226template< typename VT // Type of the dense vector
1227 , bool TF > // Transpose flag
1229{
1231 return true;
1232
1233 CompositeType_t<VT> a( *dv ); // Evaluation of the dense vector operand
1234
1235 for( size_t i=0UL; i<a.size(); ++i ) {
1236 if( !isfinite( a[i] ) ) return false;
1237 }
1238 return true;
1239}
1240//*************************************************************************************************
1241
1242
1243//*************************************************************************************************
1259template< typename VT // Type of the dense vector
1260 , bool TF > // Transpose flag
1262{
1263 CompositeType_t<VT> a( *dv ); // Evaluation of the dense vector operand
1264
1265 for( size_t i=0UL; i<a.size(); ++i ) {
1266 if( !isDivisor( a[i] ) ) return false;
1267 }
1268 return true;
1269}
1270//*************************************************************************************************
1271
1272
1273//*************************************************************************************************
1306template< RelaxationFlag RF // Relaxation flag
1307 , typename VT // Type of the dense vector
1308 , bool TF > // Transpose flag
1310{
1311 if( IsUniform_v<VT> || (*dv).size() < 2UL )
1312 return true;
1313
1314 CompositeType_t<VT> a( *dv ); // Evaluation of the dense vector operand
1315
1316 const auto& cmp( a[0UL] );
1317
1318 for( size_t i=1UL; i<a.size(); ++i ) {
1319 if( !equal<RF>( a[i], cmp ) )
1320 return false;
1321 }
1322
1323 return true;
1324}
1325//*************************************************************************************************
1326
1327
1328//*************************************************************************************************
1361template< RelaxationFlag RF // Relaxation flag
1362 , typename VT // Type of the dense vector
1363 , bool TF > // Transpose flag
1365{
1366 if( IsZero_v<VT> || (*dv).size() == 0UL )
1367 return true;
1368
1369 CompositeType_t<VT> a( *dv ); // Evaluation of the dense vector operand
1370
1371 for( size_t i=0UL; i<a.size(); ++i ) {
1372 if( !isZero<RF>( a[i] ) )
1373 return false;
1374 }
1375
1376 return true;
1377}
1378//*************************************************************************************************
1379
1380} // namespace blaze
1381
1382#endif
Header file for auxiliary alias declarations.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition: Aliases.h:110
Header file for run time assertion macros.
Header file for the EnableIf class template.
Header file for the isDivisor shim.
Header file for the isfinite shim.
Header file for the IsFloatingPoint type trait.
Header file for the isinf shim.
Header file for the isnan shim.
Header file for the IsRestricted type trait.
Header file for the IsScalar type trait.
Header file for the IsUniform type trait.
Deactivation of problematic macros.
Constraint on the data type.
Header file for the relaxation flag enumeration.
Header file for the RemoveReference type trait.
Header file for the UnderlyingBuiltin type trait.
Base class for N-dimensional dense vectors.
Definition: DenseVector.h:77
Header file for the DenseVector base class.
auto operator/=(DenseVector< VT, TF > &&vec, ST scalar) -> EnableIf_t< IsScalar_v< ST >, VT & >
Division assignment operator for the division of a temporary dense vector by a scalar value ( ).
Definition: DenseVector.h:536
bool isUniform(const DenseVector< VT, TF > &dv)
Checks if the given dense vector is a uniform vector.
Definition: DenseVector.h:1309
auto operator-=(DenseVector< VT, TF > &&vec, ST scalar) -> EnableIf_t< IsScalar_v< ST >, VT & >
Subtraction assignment operator for the subtraction of a temporary dense vector and a scalar value ( ...
Definition: DenseVector.h:410
auto operator!=(T1 scalar, const DenseVector< T2, TF > &vec) -> EnableIf_t< IsScalar_v< T1 >, bool >
Inequality operator for the comparison of a scalar value and a dense vector.
Definition: DenseVector.h:290
bool isDivisor(const DenseVector< VT, TF > &dv)
Returns whether the given dense vector is a valid divisor.
Definition: DenseVector.h:1261
VT1 & operator^=(DenseVector< VT1, TF > &&lhs, const DenseVector< VT2, TF > &rhs)
Bitwise XOR assignment operator for the bitwise XOR of a temporary dense vector.
Definition: DenseVector.h:1103
VT1 & operator&=(DenseVector< VT1, TF > &&lhs, const DenseVector< VT2, TF > &rhs)
Bitwise AND assignment operator for the bitwise AND of a temporary dense vector.
Definition: DenseVector.h:873
VT1 & operator>>=(DenseVector< VT1, TF > &&lhs, const DenseVector< VT2, TF > &rhs)
Right-shift assignment operator for the elementwise right-shift of a temporary dense.
Definition: DenseVector.h:758
VT1 & operator|=(DenseVector< VT1, TF > &&lhs, const DenseVector< VT2, TF > &rhs)
Bitwise OR assignment operator for the bitwise OR of a temporary dense vector.
Definition: DenseVector.h:988
bool isZero(const DenseVector< VT, TF > &dv)
Checks if the given dense vector is a zero vector.
Definition: DenseVector.h:1364
auto operator+=(DenseVector< VT, TF > &&vec, ST scalar) -> EnableIf_t< IsScalar_v< ST >, VT & >
Addition assignment operator for the addition of a temporary dense vector and a scalar value ( ).
Definition: DenseVector.h:350
auto operator*=(DenseVector< VT, TF > &&vec, ST scalar) -> EnableIf_t< IsScalar_v< ST >, VT & >
Multiplication assignment operator for the multiplication of a temporary dense vector and a scalar va...
Definition: DenseVector.h:470
VT1 & operator<<=(DenseVector< VT1, TF > &&lhs, const DenseVector< VT2, TF > &rhs)
Left-shift assignment operator for the elementwise left-shift of a temporary dense vector.
Definition: DenseVector.h:648
bool isnan(const DenseVector< VT, TF > &dv)
Checks the given dense vector for not-a-number elements.
Definition: DenseVector.h:1161
bool isinf(const DenseVector< VT, TF > &dv)
Checks the given dense vector for infinite elements.
Definition: DenseVector.h:1194
bool isfinite(const DenseVector< VT, TF > &dv)
Checks the given dense vector for finite elements.
Definition: DenseVector.h:1228
auto operator==(T1 scalar, const DenseVector< T2, TF > &vec) -> EnableIf_t< IsScalar_v< T1 >, bool >
Equality operator for the comparison of a scalar value and a dense vector.
Definition: DenseVector.h:244
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:207
typename UnderlyingBuiltin< T >::Type UnderlyingBuiltin_t
Auxiliary alias declaration for the UnderlyingBuiltin type trait.
Definition: UnderlyingBuiltin.h:117
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition: RelaxationFlag.h:66
#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
auto smpAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP assignment of a vector to a dense vector.
Definition: DenseVector.h:105
bool equal(const SharedValue< T1 > &lhs, const SharedValue< T2 > &rhs)
Equality check for a two shared values.
Definition: SharedValue.h:343
constexpr bool IsFloatingPoint_v
Auxiliary variable template for the IsFloatingPoint type trait.
Definition: IsFloatingPoint.h:95
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
#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 the equal shim.
Header file for the isZero shim.
Header file for the pow2 shim.
Header file for the sqrt shim.
Header file for the IsZero type trait.
Header file for basic type definitions.