Blaze  3.6
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>
45 #include <blaze/math/Exception.h>
46 #include <blaze/math/shims/Equal.h>
48 #include <blaze/math/shims/IsNaN.h>
50 #include <blaze/math/shims/Pow2.h>
51 #include <blaze/math/shims/Sqrt.h>
55 #include <blaze/util/Assert.h>
57 #include <blaze/util/EnableIf.h>
58 #include <blaze/util/Types.h>
61 
62 
63 namespace blaze {
64 
65 //=================================================================================================
66 //
67 // GLOBAL OPERATORS
68 //
69 //=================================================================================================
70 
71 //*************************************************************************************************
74 template< typename T1, typename T2, bool TF >
75 auto operator==( const DenseVector<T1,TF>& vec, T2 scalar )
76  -> EnableIf_t< IsNumeric_v<T2>, bool >;
77 
78 template< typename T1, typename T2, bool TF >
79 auto operator==( T1 scalar, const DenseVector<T2,TF>& vec )
80  -> EnableIf_t< IsNumeric_v<T1>, bool >;
81 
82 template< typename T1, typename T2, bool TF >
83 auto operator!=( const DenseVector<T1,TF>& vec, T2 scalar )
84  -> EnableIf_t< IsNumeric_v<T2>, bool >;
85 
86 template< typename T1, typename T2, bool TF >
87 auto operator!=( T1 scalar, const DenseVector<T2,TF>& vec )
88  -> EnableIf_t< IsNumeric_v<T1>, bool >;
89 
90 template< typename VT, bool TF, typename ST >
91 auto operator+=( DenseVector<VT,TF>& vec, ST scalar )
92  -> EnableIf_t< IsNumeric_v<ST>, VT& >;
93 
94 template< typename VT, bool TF, typename ST >
95 auto operator+=( DenseVector<VT,TF>&& vec, ST scalar )
96  -> EnableIf_t< IsNumeric_v<ST>, VT& >;
97 
98 template< typename VT, bool TF, typename ST >
99 auto operator-=( DenseVector<VT,TF>& vec, ST scalar )
100  -> EnableIf_t< IsNumeric_v<ST>, VT& >;
101 
102 template< typename VT, bool TF, typename ST >
103 auto operator-=( DenseVector<VT,TF>&& vec, ST scalar )
104  -> EnableIf_t< IsNumeric_v<ST>, VT& >;
105 
106 template< typename VT, bool TF, typename ST >
107 auto operator*=( DenseVector<VT,TF>& vec, ST scalar )
108  -> EnableIf_t< IsNumeric_v<ST>, VT& >;
109 
110 template< typename VT, bool TF, typename ST >
111 auto operator*=( DenseVector<VT,TF>&& vec, ST scalar )
112  -> EnableIf_t< IsNumeric_v<ST>, VT& >;
113 
114 template< typename VT, bool TF, typename ST >
115 auto operator/=( DenseVector<VT,TF>& vec, ST scalar )
116  -> EnableIf_t< IsNumeric_v<ST>, VT& >;
117 
118 template< typename VT, bool TF, typename ST >
119 auto operator/=( DenseVector<VT,TF>&& vec, ST scalar )
120  -> EnableIf_t< IsNumeric_v<ST>, VT& >;
121 
122 template< typename VT, bool TF >
123 VT& operator<<=( DenseVector<VT,TF>& vec, int count );
124 
125 template< typename VT, bool TF >
126 VT& operator<<=( DenseVector<VT,TF>&& vec, int count );
127 
128 template< typename VT1, typename VT2, bool TF >
129 VT1& operator<<=( DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs );
130 
131 template< typename VT1, typename VT2, bool TF >
132 VT1& operator<<=( DenseVector<VT1,TF>&& lhs, const DenseVector<VT2,TF>& rhs );
133 
134 template< typename VT, bool TF >
135 VT& operator>>=( DenseVector<VT,TF>& vec, int count );
136 
137 template< typename VT, bool TF >
138 VT& operator>>=( DenseVector<VT,TF>&& vec, int count );
139 
140 template< typename VT1, typename VT2, bool TF >
141 VT1& operator>>=( DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs );
142 
143 template< typename VT1, typename VT2, bool TF >
144 VT1& operator>>=( DenseVector<VT1,TF>&& lhs, const DenseVector<VT2,TF>& rhs );
145 
146 template< typename VT, bool TF, typename ST >
147 auto operator&=( DenseVector<VT,TF>& vec, ST scalar )
148  -> EnableIf_t< IsNumeric_v<ST>, VT& >;
149 
150 template< typename VT, bool TF, typename ST >
151 auto operator&=( DenseVector<VT,TF>&& vec, ST scalar )
152  -> EnableIf_t< IsNumeric_v<ST>, VT& >;
153 
154 template< typename VT1, typename VT2, bool TF >
155 VT1& operator&=( DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs );
156 
157 template< typename VT1, typename VT2, bool TF >
158 VT1& operator&=( DenseVector<VT1,TF>&& lhs, const DenseVector<VT2,TF>& rhs );
159 
160 template< typename VT, bool TF, typename ST >
161 auto operator|=( DenseVector<VT,TF>& vec, ST scalar )
162  -> EnableIf_t< IsNumeric_v<ST>, VT& >;
163 
164 template< typename VT, bool TF, typename ST >
165 auto operator|=( DenseVector<VT,TF>&& vec, ST scalar )
166  -> EnableIf_t< IsNumeric_v<ST>, VT& >;
167 
168 template< typename VT1, typename VT2, bool TF >
169 VT1& operator|=( DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs );
170 
171 template< typename VT1, typename VT2, bool TF >
172 VT1& operator|=( DenseVector<VT1,TF>&& lhs, const DenseVector<VT2,TF>& rhs );
173 
174 template< typename VT, bool TF, typename ST >
175 auto operator^=( DenseVector<VT,TF>& vec, ST scalar )
176  -> EnableIf_t< IsNumeric_v<ST>, VT& >;
177 
178 template< typename VT, bool TF, typename ST >
179 auto operator^=( DenseVector<VT,TF>&& vec, ST scalar )
180  -> EnableIf_t< IsNumeric_v<ST>, VT& >;
181 
182 template< typename VT1, typename VT2, bool TF >
183 VT1& operator^=( DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs );
184 
185 template< typename VT1, typename VT2, bool TF >
186 VT1& operator^=( DenseVector<VT1,TF>&& lhs, const DenseVector<VT2,TF>& rhs );
188 //*************************************************************************************************
189 
190 
191 //*************************************************************************************************
203 template< typename T1 // Type of the left-hand side dense vector
204  , typename T2 // Type of the right-hand side scalar
205  , bool TF > // Transpose flag
206 inline auto operator==( const DenseVector<T1,TF>& vec, T2 scalar )
207  -> EnableIf_t< IsNumeric_v<T2>, bool >
208 {
209  using CT1 = CompositeType_t<T1>;
210 
211  // Evaluation of the dense vector operand
212  CT1 a( ~vec );
213 
214  // In order to compare the vector and the scalar value, the data values of the lower-order
215  // data type are converted to the higher-order data type within the equal function.
216  for( size_t i=0; i<a.size(); ++i )
217  if( !equal( a[i], scalar ) ) return false;
218  return true;
219 }
220 //*************************************************************************************************
221 
222 
223 //*************************************************************************************************
235 template< typename T1 // Type of the left-hand side scalar
236  , typename T2 // Type of the right-hand side dense vector
237  , bool TF > // Transpose flag
238 inline auto operator==( T1 scalar, const DenseVector<T2,TF>& vec )
239  -> EnableIf_t< IsNumeric_v<T1>, bool >
240 {
241  return ( vec == scalar );
242 }
243 //*************************************************************************************************
244 
245 
246 //*************************************************************************************************
258 template< typename T1 // Type of the left-hand side dense vector
259  , typename T2 // Type of the right-hand side scalar
260  , bool TF > // Transpose flag
261 inline auto operator!=( const DenseVector<T1,TF>& vec, T2 scalar )
262  -> EnableIf_t< IsNumeric_v<T2>, bool >
263 {
264  return !( vec == scalar );
265 }
266 //*************************************************************************************************
267 
268 
269 //*************************************************************************************************
281 template< typename T1 // Type of the left-hand side scalar
282  , typename T2 // Type of the right-hand side vector
283  , bool TF > // Transpose flag
284 inline auto operator!=( T1 scalar, const DenseVector<T2,TF>& vec )
285  -> EnableIf_t< IsNumeric_v<T1>, bool >
286 {
287  return !( vec == scalar );
288 }
289 //*************************************************************************************************
290 
291 
292 //*************************************************************************************************
305 template< typename VT // Type of the left-hand side dense vector
306  , bool TF // Transpose flag
307  , typename ST > // Data type of the right-hand side scalar
308 inline auto operator+=( DenseVector<VT,TF>& vec, ST scalar )
310 {
311  if( IsRestricted_v<VT> ) {
312  if( !tryAdd( ~vec, 0UL, (~vec).size(), scalar ) ) {
313  BLAZE_THROW_INVALID_ARGUMENT( "Invalid addition to restricted vector" );
314  }
315  }
316 
317  decltype(auto) left( derestrict( ~vec ) );
318 
319  smpAssign( left, left + scalar );
320 
321  BLAZE_INTERNAL_ASSERT( isIntact( ~vec ), "Invariant violation detected" );
322 
323  return ~vec;
324 }
325 //*************************************************************************************************
326 
327 
328 //*************************************************************************************************
341 template< typename VT // Type of the left-hand side dense vector
342  , bool TF // Transpose flag
343  , typename ST > // Data type of the right-hand side scalar
344 inline auto operator+=( DenseVector<VT,TF>&& vec, ST scalar )
346 {
347  return operator+=( ~vec, scalar );
348 }
349 //*************************************************************************************************
350 
351 
352 //*************************************************************************************************
365 template< typename VT // Type of the left-hand side dense vector
366  , bool TF // Transpose flag
367  , typename ST > // Data type of the right-hand side scalar
368 inline auto operator-=( DenseVector<VT,TF>& vec, ST scalar )
370 {
371  if( IsRestricted_v<VT> ) {
372  if( !trySub( ~vec, 0UL, (~vec).size(), scalar ) ) {
373  BLAZE_THROW_INVALID_ARGUMENT( "Invalid subtraction from restricted vector" );
374  }
375  }
376 
377  decltype(auto) left( derestrict( ~vec ) );
378 
379  smpAssign( left, left - scalar );
380 
381  BLAZE_INTERNAL_ASSERT( isIntact( ~vec ), "Invariant violation detected" );
382 
383  return ~vec;
384 }
385 //*************************************************************************************************
386 
387 
388 //*************************************************************************************************
401 template< typename VT // Type of the left-hand side dense vector
402  , bool TF // Transpose flag
403  , typename ST > // Data type of the right-hand side scalar
404 inline auto operator-=( DenseVector<VT,TF>&& vec, ST scalar )
406 {
407  return operator-=( ~vec, scalar );
408 }
409 //*************************************************************************************************
410 
411 
412 //*************************************************************************************************
425 template< typename VT // Type of the left-hand side dense vector
426  , bool TF // Transpose flag
427  , typename ST > // Data type of the right-hand side scalar
428 inline auto operator*=( DenseVector<VT,TF>& vec, ST scalar )
430 {
431  if( IsRestricted_v<VT> ) {
432  if( !tryMult( ~vec, 0UL, (~vec).size(), scalar ) ) {
433  BLAZE_THROW_INVALID_ARGUMENT( "Invalid scaling of restricted vector" );
434  }
435  }
436 
437  decltype(auto) left( derestrict( ~vec ) );
438 
439  smpAssign( left, left * scalar );
440 
441  BLAZE_INTERNAL_ASSERT( isIntact( ~vec ), "Invariant violation detected" );
442 
443  return ~vec;
444 }
445 //*************************************************************************************************
446 
447 
448 //*************************************************************************************************
461 template< typename VT // Type of the left-hand side dense vector
462  , bool TF // Transpose flag
463  , typename ST > // Data type of the right-hand side scalar
464 inline auto operator*=( DenseVector<VT,TF>&& vec, ST scalar )
466 {
467  return operator*=( ~vec, scalar );
468 }
469 //*************************************************************************************************
470 
471 
472 //*************************************************************************************************
487 template< typename VT // Type of the left-hand side dense vector
488  , bool TF // Transpose flag
489  , typename ST > // Data type of the right-hand side scalar
490 inline auto operator/=( DenseVector<VT,TF>& vec, ST scalar )
492 {
493  BLAZE_USER_ASSERT( !isZero( scalar ), "Division by zero detected" );
494 
495  if( IsRestricted_v<VT> ) {
496  if( !tryDiv( ~vec, 0UL, (~vec).size(), scalar ) ) {
497  BLAZE_THROW_INVALID_ARGUMENT( "Invalid scaling of restricted vector" );
498  }
499  }
500 
501  decltype(auto) left( derestrict( ~vec ) );
502 
503  smpAssign( left, left / scalar );
504 
505  BLAZE_INTERNAL_ASSERT( isIntact( ~vec ), "Invariant violation detected" );
506 
507  return ~vec;
508 }
509 //*************************************************************************************************
510 
511 
512 //*************************************************************************************************
527 template< typename VT // Type of the left-hand side dense vector
528  , bool TF // Transpose flag
529  , typename ST > // Data type of the right-hand side scalar
530 inline auto operator/=( DenseVector<VT,TF>&& vec, ST scalar )
532 {
533  return operator/=( ~vec, scalar );
534 }
535 //*************************************************************************************************
536 
537 
538 //*************************************************************************************************
550 template< typename VT // Type of the dense vector
551  , bool TF > // Transpose flag
552 inline VT& operator<<=( DenseVector<VT,TF>& vec, int count )
553 {
554  if( IsRestricted_v<VT> ) {
555  if( !tryShift( ~vec, 0UL, (~vec).size(), count ) ) {
556  BLAZE_THROW_INVALID_ARGUMENT( "Invalid left-shift of restricted vector" );
557  }
558  }
559 
560  decltype(auto) left( derestrict( ~vec ) );
561 
562  smpAssign( left, left << count );
563 
564  BLAZE_INTERNAL_ASSERT( isIntact( ~vec ), "Invariant violation detected" );
565 
566  return ~vec;
567 }
568 //*************************************************************************************************
569 
570 
571 //*************************************************************************************************
583 template< typename VT // Type of the dense vector
584  , bool TF > // Transpose flag
585 inline VT& operator<<=( DenseVector<VT,TF>&& vec, int count )
586 {
587  return operator<<=( ~vec, count );
588 }
589 //*************************************************************************************************
590 
591 
592 //*************************************************************************************************
604 template< typename VT1 // Type of the left-hand side dense vector
605  , typename VT2 // Type of the right-hand side dense vector
606  , bool TF > // Transpose flag
607 inline VT1& operator<<=( DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
608 {
609  if( IsRestricted_v<VT1> ) {
610  if( !tryShiftAssign( ~lhs, ~rhs, 0UL ) ) {
611  BLAZE_THROW_INVALID_ARGUMENT( "Invalid left-shift of restricted vector" );
612  }
613  }
614 
615  decltype(auto) left( derestrict( ~lhs ) );
616 
617  smpAssign( left, left << (~rhs) );
618 
619  BLAZE_INTERNAL_ASSERT( isIntact( ~lhs ), "Invariant violation detected" );
620 
621  return ~lhs;
622 }
623 //*************************************************************************************************
624 
625 
626 //*************************************************************************************************
639 template< typename VT1 // Type of the left-hand side dense vector
640  , typename VT2 // Type of the right-hand side dense vector
641  , bool TF > // Transpose flag
642 inline VT1& operator<<=( DenseVector<VT1,TF>&& lhs, const DenseVector<VT2,TF>& rhs )
643 {
644  return operator<<=( ~lhs, ~rhs );
645 }
646 //*************************************************************************************************
647 
648 
649 //*************************************************************************************************
661 template< typename VT // Type of the dense vector
662  , bool TF > // Transpose flag
663 inline VT& operator>>=( DenseVector<VT,TF>& vec, int count )
664 {
665  if( IsRestricted_v<VT> ) {
666  if( !tryShift( ~vec, 0UL, (~vec).size(), count ) ) {
667  BLAZE_THROW_INVALID_ARGUMENT( "Invalid right-shift of restricted vector" );
668  }
669  }
670 
671  decltype(auto) left( derestrict( ~vec ) );
672 
673  smpAssign( left, left >> count );
674 
675  BLAZE_INTERNAL_ASSERT( isIntact( ~vec ), "Invariant violation detected" );
676 
677  return ~vec;
678 }
679 //*************************************************************************************************
680 
681 
682 //*************************************************************************************************
694 template< typename VT // Type of the dense vector
695  , bool TF > // Transpose flag
696 inline VT& operator>>=( DenseVector<VT,TF>&& vec, int count )
697 {
698  return operator>>=( ~vec, count );
699 }
700 //*************************************************************************************************
701 
702 
703 //*************************************************************************************************
715 template< typename VT1 // Type of the left-hand side dense vector
716  , typename VT2 // Type of the right-hand side dense vector
717  , bool TF > // Transpose flag
718 inline VT1& operator>>=( DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
719 {
720  if( IsRestricted_v<VT1> ) {
721  if( !tryShiftAssign( ~lhs, ~rhs, 0UL ) ) {
722  BLAZE_THROW_INVALID_ARGUMENT( "Invalid right-shift of restricted vector" );
723  }
724  }
725 
726  decltype(auto) left( derestrict( ~lhs ) );
727 
728  smpAssign( left, left >> (~rhs) );
729 
730  BLAZE_INTERNAL_ASSERT( isIntact( ~lhs ), "Invariant violation detected" );
731 
732  return ~lhs;
733 }
734 //*************************************************************************************************
735 
736 
737 //*************************************************************************************************
749 template< typename VT1 // Type of the left-hand side dense vector
750  , typename VT2 // Type of the right-hand side dense vector
751  , bool TF > // Transpose flag
752 inline VT1& operator>>=( DenseVector<VT1,TF>&& lhs, const DenseVector<VT2,TF>& rhs )
753 {
754  return operator>>=( ~lhs, ~rhs );
755 }
756 //*************************************************************************************************
757 
758 
759 //*************************************************************************************************
771 template< typename VT // Type of the left-hand side dense vector
772  , bool TF // Transpose flag
773  , typename ST > // Data type of the right-hand side scalar
774 inline auto operator&=( DenseVector<VT,TF>& vec, ST scalar )
776 {
777  if( IsRestricted_v<VT> ) {
778  if( !tryBitand( ~vec, 0UL, (~vec).size(), scalar ) ) {
779  BLAZE_THROW_INVALID_ARGUMENT( "Invalid bitwise AND of restricted vector" );
780  }
781  }
782 
783  decltype(auto) left( derestrict( ~vec ) );
784 
785  smpAssign( left, left & scalar );
786 
787  BLAZE_INTERNAL_ASSERT( isIntact( ~vec ), "Invariant violation detected" );
788 
789  return ~vec;
790 }
791 //*************************************************************************************************
792 
793 
794 //*************************************************************************************************
807 template< typename VT // Type of the left-hand side dense vector
808  , bool TF // Transpose flag
809  , typename ST > // Data type of the right-hand side scalar
810 inline auto operator&=( DenseVector<VT,TF>&& vec, ST scalar )
812 {
813  return operator&=( ~vec, scalar );
814 }
815 //*************************************************************************************************
816 
817 
818 //*************************************************************************************************
830 template< typename VT1 // Type of the left-hand side dense vector
831  , typename VT2 // Type of the right-hand side dense vector
832  , bool TF > // Transpose flag
833 inline VT1& operator&=( DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
834 {
835  if( IsRestricted_v<VT1> ) {
836  if( !tryBitandAssign( ~lhs, ~rhs, 0UL ) ) {
837  BLAZE_THROW_INVALID_ARGUMENT( "Invalid bitwise AND of restricted vector" );
838  }
839  }
840 
841  decltype(auto) left( derestrict( ~lhs ) );
842 
843  smpAssign( left, left & (~rhs) );
844 
845  BLAZE_INTERNAL_ASSERT( isIntact( ~lhs ), "Invariant violation detected" );
846 
847  return ~lhs;
848 }
849 //*************************************************************************************************
850 
851 
852 //*************************************************************************************************
864 template< typename VT1 // Type of the left-hand side dense vector
865  , typename VT2 // Type of the right-hand side dense vector
866  , bool TF > // Transpose flag
867 inline VT1& operator&=( DenseVector<VT1,TF>&& lhs, const DenseVector<VT2,TF>& rhs )
868 {
869  return operator&=( ~lhs, ~rhs );
870 }
871 //*************************************************************************************************
872 
873 
874 //*************************************************************************************************
886 template< typename VT // Type of the left-hand side dense vector
887  , bool TF // Transpose flag
888  , typename ST > // Data type of the right-hand side scalar
889 inline auto operator|=( DenseVector<VT,TF>& vec, ST scalar )
891 {
892  if( IsRestricted_v<VT> ) {
893  if( !tryBitor( ~vec, 0UL, (~vec).size(), scalar ) ) {
894  BLAZE_THROW_INVALID_ARGUMENT( "Invalid bitwise OR of restricted vector" );
895  }
896  }
897 
898  decltype(auto) left( derestrict( ~vec ) );
899 
900  smpAssign( left, left | scalar );
901 
902  BLAZE_INTERNAL_ASSERT( isIntact( ~vec ), "Invariant violation detected" );
903 
904  return ~vec;
905 }
906 //*************************************************************************************************
907 
908 
909 //*************************************************************************************************
922 template< typename VT // Type of the left-hand side dense vector
923  , bool TF // Transpose flag
924  , typename ST > // Data type of the right-hand side scalar
925 inline auto operator|=( DenseVector<VT,TF>&& vec, ST scalar )
927 {
928  return operator|=( ~vec, scalar );
929 }
930 //*************************************************************************************************
931 
932 
933 //*************************************************************************************************
945 template< typename VT1 // Type of the left-hand side dense vector
946  , typename VT2 // Type of the right-hand side dense vector
947  , bool TF > // Transpose flag
948 inline VT1& operator|=( DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
949 {
950  if( IsRestricted_v<VT1> ) {
951  if( !tryBitorAssign( ~lhs, ~rhs, 0UL ) ) {
952  BLAZE_THROW_INVALID_ARGUMENT( "Invalid bitwise OR of restricted vector" );
953  }
954  }
955 
956  decltype(auto) left( derestrict( ~lhs ) );
957 
958  smpAssign( left, left | (~rhs) );
959 
960  BLAZE_INTERNAL_ASSERT( isIntact( ~lhs ), "Invariant violation detected" );
961 
962  return ~lhs;
963 }
964 //*************************************************************************************************
965 
966 
967 //*************************************************************************************************
979 template< typename VT1 // Type of the left-hand side dense vector
980  , typename VT2 // Type of the right-hand side dense vector
981  , bool TF > // Transpose flag
982 inline VT1& operator|=( DenseVector<VT1,TF>&& lhs, const DenseVector<VT2,TF>& rhs )
983 {
984  return operator|=( ~lhs, ~rhs );
985 }
986 //*************************************************************************************************
987 
988 
989 //*************************************************************************************************
1001 template< typename VT // Type of the left-hand side dense vector
1002  , bool TF // Transpose flag
1003  , typename ST > // Data type of the right-hand side scalar
1004 inline auto operator^=( DenseVector<VT,TF>& vec, ST scalar )
1005  -> EnableIf_t< IsNumeric_v<ST>, VT& >
1006 {
1007  if( IsRestricted_v<VT> ) {
1008  if( !tryBitxor( ~vec, 0UL, (~vec).size(), scalar ) ) {
1009  BLAZE_THROW_INVALID_ARGUMENT( "Invalid bitwise XOR of restricted vector" );
1010  }
1011  }
1012 
1013  decltype(auto) left( derestrict( ~vec ) );
1014 
1015  smpAssign( left, left ^ scalar );
1016 
1017  BLAZE_INTERNAL_ASSERT( isIntact( ~vec ), "Invariant violation detected" );
1018 
1019  return ~vec;
1020 }
1021 //*************************************************************************************************
1022 
1023 
1024 //*************************************************************************************************
1037 template< typename VT // Type of the left-hand side dense vector
1038  , bool TF // Transpose flag
1039  , typename ST > // Data type of the right-hand side scalar
1040 inline auto operator^=( DenseVector<VT,TF>&& vec, ST scalar )
1041  -> EnableIf_t< IsNumeric_v<ST>, VT& >
1042 {
1043  return operator^=( ~vec, scalar );
1044 }
1045 //*************************************************************************************************
1046 
1047 
1048 //*************************************************************************************************
1060 template< typename VT1 // Type of the left-hand side dense vector
1061  , typename VT2 // Type of the right-hand side dense vector
1062  , bool TF > // Transpose flag
1063 inline VT1& operator^=( DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1064 {
1065  if( IsRestricted_v<VT1> ) {
1066  if( !tryBitxorAssign( ~lhs, ~rhs, 0UL ) ) {
1067  BLAZE_THROW_INVALID_ARGUMENT( "Invalid bitwise XOR of restricted vector" );
1068  }
1069  }
1070 
1071  decltype(auto) left( derestrict( ~lhs ) );
1072 
1073  smpAssign( left, left ^ (~rhs) );
1074 
1075  BLAZE_INTERNAL_ASSERT( isIntact( ~lhs ), "Invariant violation detected" );
1076 
1077  return ~lhs;
1078 }
1079 //*************************************************************************************************
1080 
1081 
1082 //*************************************************************************************************
1094 template< typename VT1 // Type of the left-hand side dense vector
1095  , typename VT2 // Type of the right-hand side dense vector
1096  , bool TF > // Transpose flag
1097 inline VT1& operator^=( DenseVector<VT1,TF>&& lhs, const DenseVector<VT2,TF>& rhs )
1098 {
1099  return operator^=( ~lhs, ~rhs );
1100 }
1101 //*************************************************************************************************
1102 
1103 
1104 
1105 
1106 //=================================================================================================
1107 //
1108 // GLOBAL FUNCTIONS
1109 //
1110 //=================================================================================================
1111 
1112 //*************************************************************************************************
1115 template< typename VT, bool TF >
1116 bool isnan( const DenseVector<VT,TF>& dv );
1117 
1118 template< typename VT, bool TF >
1119 bool isDivisor( const DenseVector<VT,TF>& dv );
1120 
1121 template< bool RF, typename VT, bool TF >
1122 bool isUniform( const DenseVector<VT,TF>& dv );
1124 //*************************************************************************************************
1125 
1126 
1127 //*************************************************************************************************
1147 template< typename VT // Type of the dense vector
1148  , bool TF > // Transpose flag
1149 bool isnan( const DenseVector<VT,TF>& dv )
1150 {
1151  CompositeType_t<VT> a( ~dv ); // Evaluation of the dense vector operand
1152 
1153  for( size_t i=0UL; i<a.size(); ++i ) {
1154  if( isnan( a[i] ) ) return true;
1155  }
1156  return false;
1157 }
1158 //*************************************************************************************************
1159 
1160 
1161 //*************************************************************************************************
1177 template< typename VT // Type of the dense vector
1178  , bool TF > // Transpose flag
1180 {
1181  CompositeType_t<VT> a( ~dv ); // Evaluation of the dense vector operand
1182 
1183  for( size_t i=0UL; i<a.size(); ++i ) {
1184  if( !isDivisor( a[i] ) ) return false;
1185  }
1186  return true;
1187 }
1188 //*************************************************************************************************
1189 
1190 
1191 //*************************************************************************************************
1224 template< bool RF // Relaxation flag
1225  , typename VT // Type of the dense vector
1226  , bool TF > // Transpose flag
1228 {
1229  if( IsUniform_v<VT> || (~dv).size() < 2UL )
1230  return true;
1231 
1232  CompositeType_t<VT> a( ~dv ); // Evaluation of the dense vector operand
1233 
1234  const auto& cmp( a[0UL] );
1235 
1236  for( size_t i=1UL; i<a.size(); ++i ) {
1237  if( !equal<RF>( a[i], cmp ) )
1238  return false;
1239  }
1240 
1241  return true;
1242 }
1243 //*************************************************************************************************
1244 
1245 
1246 //*************************************************************************************************
1279 template< bool RF // Relaxation flag
1280  , typename VT // Type of the dense vector
1281  , bool TF > // Transpose flag
1282 bool isZero( const DenseVector<VT,TF>& dv )
1283 {
1284  if( IsZero_v<VT> || (~dv).size() == 0UL )
1285  return true;
1286 
1287  CompositeType_t<VT> a( ~dv ); // Evaluation of the dense vector operand
1288 
1289  for( size_t i=0UL; i<a.size(); ++i ) {
1290  if( !isZero<RF>( a[i] ) )
1291  return false;
1292  }
1293 
1294  return true;
1295 }
1296 //*************************************************************************************************
1297 
1298 } // namespace blaze
1299 
1300 #endif
Header file for the isnan shim.
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
auto operator-=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Subtraction assignment operator for the subtraction of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:432
Constraint on the data type.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression,...
Definition: Assert.h:117
Header file for basic type definitions.
Header file for the isZero shim.
auto operator^=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Bitwise XOR assignment operator for the bitwise XOR of a dense matrix and a scalar value.
Definition: DenseMatrix.h:1089
Header file for the DenseVector base class.
auto operator&=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Bitwise AND assignment operator for the bitwise AND of a dense matrix and a scalar value.
Definition: DenseMatrix.h:851
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:677
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
Header file for the sqrt shim.
MT & operator<<=(DenseMatrix< MT, SO > &mat, int count)
Left-shift assignment operator for the uniform left-shift of a dense matrix.
Definition: DenseMatrix.h:622
Header file for the IsUniform type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
auto operator+=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Addition assignment operator for the addition of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:370
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:253
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
Header file for the pow2 shim.
Header file for the equal shim.
bool isnan(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is not a number.
Definition: DiagonalProxy.h:717
Header file for the exception macros of the math module.
bool isUniform(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a uniform matrix.
Definition: DenseMatrix.h:1638
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
Header file for the EnableIf class template.
Header file for the IsNumeric type trait.
bool isDivisor(const DenseVector< VT, TF > &dv)
Returns whether the given dense vector is a valid divisor.
Definition: DenseVector.h:1179
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( ).
Definition: DenseMatrix.h:558
Header file for run time assertion macros.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.The CompositeType_t alias declaration pro...
Definition: Aliases.h:90
Header file for the IsZero type trait.
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
Header file for the RemoveReference type trait.
auto operator|=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Bitwise OR assignment operator for the bitwise OR of a dense matrix and a scalar value.
Definition: DenseMatrix.h:970
Header file for the isDivisor shim.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
auto operator *=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:494
MT & operator>>=(DenseMatrix< MT, SO > &mat, int count)
Right-shift assignment operator for the uniform right-shift of a dense matrix.
Definition: DenseMatrix.h:736
Header file for the IsRestricted type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
Definition: Assert.h:101
bool equal(const SharedValue< T1 > &lhs, const SharedValue< T2 > &rhs)
Equality check for a two shared values.
Definition: SharedValue.h:342