Blaze  3.6
Vector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_VECTOR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_VECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Exception.h>
46 #include <blaze/system/Inline.h>
47 #include <blaze/util/Assert.h>
48 #include <blaze/util/DisableIf.h>
49 #include <blaze/util/EnableIf.h>
51 #include <blaze/util/MaybeUnused.h>
52 #include <blaze/util/Types.h>
54 
55 
56 namespace blaze {
57 
58 //=================================================================================================
59 //
60 // CLASS DEFINITION
61 //
62 //=================================================================================================
63 
64 //*************************************************************************************************
76 template< typename VT // Type of the vector
77  , bool TF > // Transpose flag
78 struct Vector
79 {
80  //**Type definitions****************************************************************************
81  using VectorType = VT;
82  //**********************************************************************************************
83 
84  //**Compilation flags***************************************************************************
85  static constexpr bool transposeFlag = TF;
86  //**********************************************************************************************
87 
88  //**Non-const conversion operator***************************************************************
93  BLAZE_ALWAYS_INLINE constexpr VectorType& operator~() noexcept {
94  return *static_cast<VectorType*>( this );
95  }
96  //**********************************************************************************************
97 
98  //**Const conversion operators******************************************************************
103  BLAZE_ALWAYS_INLINE constexpr const VectorType& operator~() const noexcept {
104  return *static_cast<const VectorType*>( this );
105  }
106  //**********************************************************************************************
107 };
108 //*************************************************************************************************
109 
110 
111 
112 
113 //=================================================================================================
114 //
115 // GLOBAL FUNCTIONS
116 //
117 //=================================================================================================
118 
119 //*************************************************************************************************
122 template< typename VT, bool TF >
123 typename VT::Iterator begin( Vector<VT,TF>& vector );
124 
125 template< typename VT, bool TF >
126 typename VT::ConstIterator begin( const Vector<VT,TF>& vector );
127 
128 template< typename VT, bool TF >
129 typename VT::ConstIterator cbegin( const Vector<VT,TF>& vector );
130 
131 template< typename VT, bool TF >
132 typename VT::Iterator end( Vector<VT,TF>& vector );
133 
134 template< typename VT, bool TF >
135 typename VT::ConstIterator end( const Vector<VT,TF>& vector );
136 
137 template< typename VT, bool TF >
138 typename VT::ConstIterator cend( const Vector<VT,TF>& vector );
139 
140 template< typename VT, bool TF >
141 constexpr size_t size( const Vector<VT,TF>& vector ) noexcept;
142 
143 template< typename VT, bool TF >
144 size_t capacity( const Vector<VT,TF>& vector ) noexcept;
145 
146 template< typename VT, bool TF >
147 size_t nonZeros( const Vector<VT,TF>& vector );
148 
149 template< typename VT, bool TF >
150 void resize( Vector<VT,TF>& vector, size_t n, bool preserve=true );
151 
152 template< typename VT, bool TF >
153 void shrinkToFit( Vector<VT,TF>& vector );
154 
155 template< typename VT, bool TF >
156 const typename VT::ResultType evaluate( const Vector<VT,TF>& vector );
157 
158 template< typename VT, bool TF >
159 constexpr bool isEmpty( const Vector<VT,TF>& vector ) noexcept;
160 
161 template< typename VT1, bool TF1, typename VT2, bool TF2 >
162 bool isSame( const Vector<VT1,TF1>& a, const Vector<VT2,TF2>& b ) noexcept;
164 //*************************************************************************************************
165 
166 
167 //*************************************************************************************************
174 template< typename VT // Type of the vector
175  , bool TF > // Transpose flag of the vector
176 BLAZE_ALWAYS_INLINE typename VT::Iterator begin( Vector<VT,TF>& vector )
177 {
178  return (~vector).begin();
179 }
180 //*************************************************************************************************
181 
182 
183 //*************************************************************************************************
190 template< typename VT // Type of the vector
191  , bool TF > // Transpose flag of the vector
192 BLAZE_ALWAYS_INLINE typename VT::ConstIterator begin( const Vector<VT,TF>& vector )
193 {
194  return (~vector).begin();
195 }
196 //*************************************************************************************************
197 
198 
199 //*************************************************************************************************
206 template< typename VT // Type of the vector
207  , bool TF > // Transpose flag of the vector
208 BLAZE_ALWAYS_INLINE typename VT::ConstIterator cbegin( const Vector<VT,TF>& vector )
209 {
210  return (~vector).begin();
211 }
212 //*************************************************************************************************
213 
214 
215 //*************************************************************************************************
222 template< typename VT // Type of the vector
223  , bool TF > // Transpose flag of the vector
224 BLAZE_ALWAYS_INLINE typename VT::Iterator end( Vector<VT,TF>& vector )
225 {
226  return (~vector).end();
227 }
228 //*************************************************************************************************
229 
230 
231 //*************************************************************************************************
238 template< typename VT // Type of the vector
239  , bool TF > // Transpose flag of the vector
240 BLAZE_ALWAYS_INLINE typename VT::ConstIterator end( const Vector<VT,TF>& vector )
241 {
242  return (~vector).end();
243 }
244 //*************************************************************************************************
245 
246 
247 //*************************************************************************************************
254 template< typename VT // Type of the vector
255  , bool TF > // Transpose flag of the vector
256 BLAZE_ALWAYS_INLINE typename VT::ConstIterator cend( const Vector<VT,TF>& vector )
257 {
258  return (~vector).end();
259 }
260 //*************************************************************************************************
261 
262 
263 //*************************************************************************************************
270 template< typename VT // Type of the vector
271  , bool TF > // Transpose flag of the vector
272 BLAZE_ALWAYS_INLINE constexpr size_t size( const Vector<VT,TF>& vector ) noexcept
273 {
274  return (~vector).size();
275 }
276 //*************************************************************************************************
277 
278 
279 //*************************************************************************************************
286 template< typename VT // Type of the vector
287  , bool TF > // Transpose flag of the vector
288 BLAZE_ALWAYS_INLINE size_t capacity( const Vector<VT,TF>& vector ) noexcept
289 {
290  return (~vector).capacity();
291 }
292 //*************************************************************************************************
293 
294 
295 //*************************************************************************************************
305 template< typename VT // Type of the vector
306  , bool TF > // Transpose flag of the vector
308 {
309  return (~vector).nonZeros();
310 }
311 //*************************************************************************************************
312 
313 
314 //*************************************************************************************************
328 template< typename VT // Type of the vector
329  , bool TF > // Transpose flag of the vector
330 BLAZE_ALWAYS_INLINE auto resize_backend( Vector<VT,TF>& vector, size_t n, bool preserve )
331  -> DisableIf_t< IsResizable_v<VT> >
332 {
333  MAYBE_UNUSED( preserve );
334 
335  if( (~vector).size() != n ) {
336  BLAZE_THROW_INVALID_ARGUMENT( "Vector cannot be resized" );
337  }
338 }
340 //*************************************************************************************************
341 
342 
343 //*************************************************************************************************
355 template< typename VT // Type of the vector
356  , bool TF > // Transpose flag of the vector
357 BLAZE_ALWAYS_INLINE auto resize_backend( Vector<VT,TF>& vector, size_t n, bool preserve )
358  -> EnableIf_t< IsResizable_v<VT> >
359 {
360  (~vector).resize( n, preserve );
361 }
363 //*************************************************************************************************
364 
365 
366 //*************************************************************************************************
394 template< typename VT // Type of the vector
395  , bool TF > // Transpose flag of the vector
396 BLAZE_ALWAYS_INLINE void resize( Vector<VT,TF>& vector, size_t n, bool preserve )
397 {
398  resize_backend( vector, n, preserve );
399 }
400 //*************************************************************************************************
401 
402 
403 //*************************************************************************************************
411 template< typename VT // Type of the vector
412  , bool TF > // Transpose flag of the vector
413 BLAZE_ALWAYS_INLINE auto shrinkToFit_backend( Vector<VT,TF>& vector )
414  -> DisableIf_t< IsShrinkable_v<VT> >
415 {
416  MAYBE_UNUSED( vector );
417 }
419 //*************************************************************************************************
420 
421 
422 //*************************************************************************************************
430 template< typename VT // Type of the vector
431  , bool TF > // Transpose flag of the vector
432 BLAZE_ALWAYS_INLINE auto shrinkToFit_backend( Vector<VT,TF>& vector )
433  -> EnableIf_t< IsShrinkable_v<VT> >
434 {
435  (~vector).shrinkToFit();
436 }
438 //*************************************************************************************************
439 
440 
441 //*************************************************************************************************
454 template< typename VT // Type of the vector
455  , bool TF > // Transpose flag of the vector
457 {
458  shrinkToFit_backend( vector );
459 }
460 //*************************************************************************************************
461 
462 
463 //*************************************************************************************************
513 template< typename VT // Type of the vector
514  , bool TF > // Transpose flag of the vector
515 inline const typename VT::ResultType evaluate( const Vector<VT,TF>& vector )
516 {
517  const typename VT::ResultType tmp( ~vector );
518  return tmp;
519 }
520 //*************************************************************************************************
521 
522 
523 //*************************************************************************************************
533 template< typename VT // Type of the vector
534  , bool TF > // Transpose flag of the vector
535 BLAZE_ALWAYS_INLINE constexpr bool isEmpty( const Vector<VT,TF>& vector ) noexcept
536 {
537  return size( ~vector ) == 0UL;
538 }
539 //*************************************************************************************************
540 
541 
542 //*************************************************************************************************
572 template< typename VT1 // Type of the left-hand side vector
573  , bool TF1 // Transpose flag of the left-hand side vector
574  , typename VT2 // Type of the right-hand side vector
575  , bool TF2 > // Transpose flag of the right-hand side vector
576 BLAZE_ALWAYS_INLINE bool isSame( const Vector<VT1,TF1>& a, const Vector<VT2,TF2>& b ) noexcept
577 {
578  return ( IsSame_v<VT1,VT2> &&
579  reinterpret_cast<const void*>( &a ) == reinterpret_cast<const void*>( &b ) );
580 }
581 //*************************************************************************************************
582 
583 
584 //*************************************************************************************************
599 template< typename VT1 // Type of the left-hand side vector
600  , bool TF1 // Transpose flag of the left-hand side vector
601  , typename VT2 // Type of the right-hand side vector
602  , bool TF2 > // Transpose flag of the right-hand side vector
603 BLAZE_ALWAYS_INLINE void assign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
604 {
606 
607  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
608  (~lhs).assign( ~rhs );
609 }
611 //*************************************************************************************************
612 
613 
614 //*************************************************************************************************
629 template< typename VT1 // Type of the left-hand side vector
630  , bool TF1 // Transpose flag of the left-hand side vector
631  , typename VT2 // Type of the right-hand side vector
632  , bool TF2 > // Transpose flag of the right-hand side vector
633 BLAZE_ALWAYS_INLINE void addAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
634 {
636 
637  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
638  (~lhs).addAssign( ~rhs );
639 }
641 //*************************************************************************************************
642 
643 
644 //*************************************************************************************************
659 template< typename VT1 // Type of the left-hand side vector
660  , bool TF1 // Transpose flag of the left-hand side vector
661  , typename VT2 // Type of the right-hand side vector
662  , bool TF2 > // Transpose flag of the right-hand side vector
663 BLAZE_ALWAYS_INLINE void subAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
664 {
666 
667  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
668  (~lhs).subAssign( ~rhs );
669 }
671 //*************************************************************************************************
672 
673 
674 //*************************************************************************************************
689 template< typename VT1 // Type of the left-hand side vector
690  , bool TF1 // Transpose flag of the left-hand side vector
691  , typename VT2 // Type of the right-hand side vector
692  , bool TF2 > // Transpose flag of the right-hand side vector
693 BLAZE_ALWAYS_INLINE void multAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
694 {
696 
697  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
698  (~lhs).multAssign( ~rhs );
699 }
701 //*************************************************************************************************
702 
703 
704 //*************************************************************************************************
719 template< typename VT1 // Type of the left-hand side vector
720  , bool TF1 // Transpose flag of the left-hand side vector
721  , typename VT2 // Type of the right-hand side vector
722  , bool TF2 > // Transpose flag of the right-hand side vector
723 BLAZE_ALWAYS_INLINE void divAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
724 {
726 
727  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
728  (~lhs).divAssign( ~rhs );
729 }
731 //*************************************************************************************************
732 
733 
734 //*************************************************************************************************
749 template< typename VT // Type of the vector
750  , bool TF // Transpose flag
751  , typename ET > // Type of the element
752 BLAZE_ALWAYS_INLINE bool trySet( const Vector<VT,TF>& vec, size_t index, const ET& value )
753 {
754  BLAZE_INTERNAL_ASSERT( index < (~vec).size(), "Invalid vector access index" );
755 
756  MAYBE_UNUSED( vec, index, value );
757 
758  return true;
759 }
761 //*************************************************************************************************
762 
763 
764 //*************************************************************************************************
780 template< typename VT // Type of the vector
781  , bool TF // Transpose flag
782  , typename ET > // Type of the element
784  trySet( const Vector<VT,TF>& vec, size_t index, size_t size, const ET& value )
785 {
786  BLAZE_INTERNAL_ASSERT( index <= (~vec).size(), "Invalid vector access index" );
787  BLAZE_INTERNAL_ASSERT( index + size <= (~vec).size(), "Invalid range size" );
788 
789  MAYBE_UNUSED( vec, index, size, value );
790 
791  return true;
792 }
794 //*************************************************************************************************
795 
796 
797 //*************************************************************************************************
812 template< typename VT // Type of the vector
813  , bool TF // Transpose flag
814  , typename ET > // Type of the element
815 BLAZE_ALWAYS_INLINE bool tryAdd( const Vector<VT,TF>& vec, size_t index, const ET& value )
816 {
817  BLAZE_INTERNAL_ASSERT( index < (~vec).size(), "Invalid vector access index" );
818 
819  MAYBE_UNUSED( vec, index, value );
820 
821  return true;
822 }
824 //*************************************************************************************************
825 
826 
827 //*************************************************************************************************
843 template< typename VT // Type of the vector
844  , bool TF // Transpose flag
845  , typename ET > // Type of the element
847  tryAdd( const Vector<VT,TF>& vec, size_t index, size_t size, const ET& value )
848 {
849  BLAZE_INTERNAL_ASSERT( index <= (~vec).size(), "Invalid vector access index" );
850  BLAZE_INTERNAL_ASSERT( index + size <= (~vec).size(), "Invalid range size" );
851 
852  MAYBE_UNUSED( vec, index, size, value );
853 
854  return true;
855 }
857 //*************************************************************************************************
858 
859 
860 //*************************************************************************************************
875 template< typename VT // Type of the vector
876  , bool TF // Transpose flag
877  , typename ET > // Type of the element
878 BLAZE_ALWAYS_INLINE bool trySub( const Vector<VT,TF>& vec, size_t index, const ET& value )
879 {
880  BLAZE_INTERNAL_ASSERT( index < (~vec).size(), "Invalid vector access index" );
881 
882  MAYBE_UNUSED( vec, index, value );
883 
884  return true;
885 }
887 //*************************************************************************************************
888 
889 
890 //*************************************************************************************************
906 template< typename VT // Type of the vector
907  , bool TF // Transpose flag
908  , typename ET > // Type of the element
910  trySub( const Vector<VT,TF>& vec, size_t index, size_t size, const ET& value )
911 {
912  BLAZE_INTERNAL_ASSERT( index <= (~vec).size(), "Invalid vector access index" );
913  BLAZE_INTERNAL_ASSERT( index + size <= (~vec).size(), "Invalid range size" );
914 
915  MAYBE_UNUSED( vec, index, size, value );
916 
917  return true;
918 }
920 //*************************************************************************************************
921 
922 
923 //*************************************************************************************************
938 template< typename VT // Type of the vector
939  , bool TF // Transpose flag
940  , typename ET > // Type of the element
941 BLAZE_ALWAYS_INLINE bool tryMult( const Vector<VT,TF>& vec, size_t index, const ET& value )
942 {
943  BLAZE_INTERNAL_ASSERT( index < (~vec).size(), "Invalid vector access index" );
944 
945  MAYBE_UNUSED( vec, index, value );
946 
947  return true;
948 }
950 //*************************************************************************************************
951 
952 
953 //*************************************************************************************************
969 template< typename VT // Type of the vector
970  , bool TF // Transpose flag
971  , typename ET > // Type of the element
973  tryMult( const Vector<VT,TF>& vec, size_t index, size_t size, const ET& value )
974 {
975  BLAZE_INTERNAL_ASSERT( index <= (~vec).size(), "Invalid vector access index" );
976  BLAZE_INTERNAL_ASSERT( index + size <= (~vec).size(), "Invalid range size" );
977 
978  MAYBE_UNUSED( vec, index, size, value );
979 
980  return true;
981 }
983 //*************************************************************************************************
984 
985 
986 //*************************************************************************************************
1001 template< typename VT // Type of the vector
1002  , bool TF // Transpose flag
1003  , typename ET > // Type of the element
1004 BLAZE_ALWAYS_INLINE bool tryDiv( const Vector<VT,TF>& vec, size_t index, const ET& value )
1005 {
1006  BLAZE_INTERNAL_ASSERT( index < (~vec).size(), "Invalid vector access index" );
1007 
1008  MAYBE_UNUSED( vec, index, value );
1009 
1010  return true;
1011 }
1013 //*************************************************************************************************
1014 
1015 
1016 //*************************************************************************************************
1032 template< typename VT // Type of the vector
1033  , bool TF // Transpose flag
1034  , typename ET > // Type of the element
1036  tryDiv( const Vector<VT,TF>& vec, size_t index, size_t size, const ET& value )
1037 {
1038  BLAZE_INTERNAL_ASSERT( index <= (~vec).size(), "Invalid vector access index" );
1039  BLAZE_INTERNAL_ASSERT( index + size <= (~vec).size(), "Invalid range size" );
1040 
1041  MAYBE_UNUSED( vec, index, size, value );
1042 
1043  return true;
1044 }
1046 //*************************************************************************************************
1047 
1048 
1049 //*************************************************************************************************
1064 template< typename VT // Type of the vector
1065  , bool TF > // Transpose flag
1066 BLAZE_ALWAYS_INLINE bool tryShift( const Vector<VT,TF>& vec, size_t index, int count )
1067 {
1068  BLAZE_INTERNAL_ASSERT( index < (~vec).size(), "Invalid vector access index" );
1069 
1070  MAYBE_UNUSED( vec, index, count );
1071 
1072  return true;
1073 }
1075 //*************************************************************************************************
1076 
1077 
1078 //*************************************************************************************************
1094 template< typename VT // Type of the vector
1095  , bool TF > // Transpose flag
1097  tryShift( const Vector<VT,TF>& vec, size_t index, size_t size, int count )
1098 {
1099  BLAZE_INTERNAL_ASSERT( index <= (~vec).size(), "Invalid vector access index" );
1100  BLAZE_INTERNAL_ASSERT( index + size <= (~vec).size(), "Invalid range size" );
1101 
1102  MAYBE_UNUSED( vec, index, size, count );
1103 
1104  return true;
1105 }
1107 //*************************************************************************************************
1108 
1109 
1110 //*************************************************************************************************
1125 template< typename VT // Type of the vector
1126  , bool TF // Transpose flag
1127  , typename ET > // Type of the element
1128 BLAZE_ALWAYS_INLINE bool tryBitand( const Vector<VT,TF>& vec, size_t index, const ET& value )
1129 {
1130  BLAZE_INTERNAL_ASSERT( index < (~vec).size(), "Invalid vector access index" );
1131 
1132  MAYBE_UNUSED( vec, index, value );
1133 
1134  return true;
1135 }
1137 //*************************************************************************************************
1138 
1139 
1140 //*************************************************************************************************
1156 template< typename VT // Type of the vector
1157  , bool TF // Transpose flag
1158  , typename ET > // Type of the element
1160  tryBitand( const Vector<VT,TF>& vec, size_t index, size_t size, const ET& value )
1161 {
1162  BLAZE_INTERNAL_ASSERT( index <= (~vec).size(), "Invalid vector access index" );
1163  BLAZE_INTERNAL_ASSERT( index + size <= (~vec).size(), "Invalid range size" );
1164 
1165  MAYBE_UNUSED( vec, index, size, value );
1166 
1167  return true;
1168 }
1170 //*************************************************************************************************
1171 
1172 
1173 //*************************************************************************************************
1188 template< typename VT // Type of the vector
1189  , bool TF // Transpose flag
1190  , typename ET > // Type of the element
1191 BLAZE_ALWAYS_INLINE bool tryBitor( const Vector<VT,TF>& vec, size_t index, const ET& value )
1192 {
1193  BLAZE_INTERNAL_ASSERT( index < (~vec).size(), "Invalid vector access index" );
1194 
1195  MAYBE_UNUSED( vec, index, value );
1196 
1197  return true;
1198 }
1200 //*************************************************************************************************
1201 
1202 
1203 //*************************************************************************************************
1219 template< typename VT // Type of the vector
1220  , bool TF // Transpose flag
1221  , typename ET > // Type of the element
1223  tryBitor( const Vector<VT,TF>& vec, size_t index, size_t size, const ET& value )
1224 {
1225  BLAZE_INTERNAL_ASSERT( index <= (~vec).size(), "Invalid vector access index" );
1226  BLAZE_INTERNAL_ASSERT( index + size <= (~vec).size(), "Invalid range size" );
1227 
1228  MAYBE_UNUSED( vec, index, size, value );
1229 
1230  return true;
1231 }
1233 //*************************************************************************************************
1234 
1235 
1236 //*************************************************************************************************
1251 template< typename VT // Type of the vector
1252  , bool TF // Transpose flag
1253  , typename ET > // Type of the element
1254 BLAZE_ALWAYS_INLINE bool tryBitxor( const Vector<VT,TF>& vec, size_t index, const ET& value )
1255 {
1256  BLAZE_INTERNAL_ASSERT( index < (~vec).size(), "Invalid vector access index" );
1257 
1258  MAYBE_UNUSED( vec, index, value );
1259 
1260  return true;
1261 }
1263 //*************************************************************************************************
1264 
1265 
1266 //*************************************************************************************************
1282 template< typename VT // Type of the vector
1283  , bool TF // Transpose flag
1284  , typename ET > // Type of the element
1286  tryBitxor( const Vector<VT,TF>& vec, size_t index, size_t size, const ET& value )
1287 {
1288  BLAZE_INTERNAL_ASSERT( index <= (~vec).size(), "Invalid vector access index" );
1289  BLAZE_INTERNAL_ASSERT( index + size <= (~vec).size(), "Invalid range size" );
1290 
1291  MAYBE_UNUSED( vec, index, size, value );
1292 
1293  return true;
1294 }
1296 //*************************************************************************************************
1297 
1298 
1299 //*************************************************************************************************
1314 template< typename VT1 // Type of the left-hand side vector
1315  , bool TF1 // Transpose flag of the left-hand side vector
1316  , typename VT2 // Type of the right-hand side vector
1317  , bool TF2 > // Transpose flag of the right-hand side vector
1318 BLAZE_ALWAYS_INLINE bool tryAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1319 {
1320  BLAZE_INTERNAL_ASSERT( index <= (~lhs).size(), "Invalid vector access index" );
1321  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= (~lhs).size(), "Invalid vector size" );
1322 
1323  MAYBE_UNUSED( lhs, rhs, index );
1324 
1325  return true;
1326 }
1328 //*************************************************************************************************
1329 
1330 
1331 //*************************************************************************************************
1346 template< typename VT1 // Type of the left-hand side vector
1347  , bool TF1 // Transpose flag of the left-hand side vector
1348  , typename VT2 // Type of the right-hand side vector
1349  , bool TF2 > // Transpose flag of the right-hand side vector
1350 BLAZE_ALWAYS_INLINE bool tryAddAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1351 {
1352  BLAZE_INTERNAL_ASSERT( index <= (~lhs).size(), "Invalid vector access index" );
1353  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= (~lhs).size(), "Invalid vector size" );
1354 
1355  MAYBE_UNUSED( lhs, rhs, index );
1356 
1357  return true;
1358 }
1360 //*************************************************************************************************
1361 
1362 
1363 //*************************************************************************************************
1378 template< typename VT1 // Type of the left-hand side vector
1379  , bool TF1 // Transpose flag of the left-hand side vector
1380  , typename VT2 // Type of the right-hand side vector
1381  , bool TF2 > // Transpose flag of the right-hand side vector
1382 BLAZE_ALWAYS_INLINE bool trySubAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1383 {
1384  BLAZE_INTERNAL_ASSERT( index <= (~lhs).size(), "Invalid vector access index" );
1385  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= (~lhs).size(), "Invalid vector size" );
1386 
1387  MAYBE_UNUSED( lhs, rhs, index );
1388 
1389  return true;
1390 }
1392 //*************************************************************************************************
1393 
1394 
1395 //*************************************************************************************************
1410 template< typename VT1 // Type of the left-hand side vector
1411  , bool TF1 // Transpose flag of the left-hand side vector
1412  , typename VT2 // Type of the right-hand side vector
1413  , bool TF2 > // Transpose flag of the right-hand side vector
1414 BLAZE_ALWAYS_INLINE bool tryMultAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1415 {
1416  BLAZE_INTERNAL_ASSERT( index <= (~lhs).size(), "Invalid vector access index" );
1417  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= (~lhs).size(), "Invalid vector size" );
1418 
1419  MAYBE_UNUSED( lhs, rhs, index );
1420 
1421  return true;
1422 }
1424 //*************************************************************************************************
1425 
1426 
1427 //*************************************************************************************************
1442 template< typename VT1 // Type of the left-hand side vector
1443  , bool TF1 // Transpose flag of the left-hand side vector
1444  , typename VT2 // Type of the right-hand side vector
1445  , bool TF2 > // Transpose flag of the right-hand side vector
1446 BLAZE_ALWAYS_INLINE bool tryDivAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1447 {
1448  BLAZE_INTERNAL_ASSERT( index <= (~lhs).size(), "Invalid vector access index" );
1449  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= (~lhs).size(), "Invalid vector size" );
1450 
1451  MAYBE_UNUSED( lhs, rhs, index );
1452 
1453  return true;
1454 }
1456 //*************************************************************************************************
1457 
1458 
1459 //*************************************************************************************************
1474 template< typename VT1 // Type of the left-hand side vector
1475  , bool TF1 // Transpose flag of the left-hand side vector
1476  , typename VT2 // Type of the right-hand side vector
1477  , bool TF2 > // Transpose flag of the right-hand side vector
1478 BLAZE_ALWAYS_INLINE bool tryShiftAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1479 {
1480  BLAZE_INTERNAL_ASSERT( index <= (~lhs).size(), "Invalid vector access index" );
1481  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= (~lhs).size(), "Invalid vector size" );
1482 
1483  MAYBE_UNUSED( lhs, rhs, index );
1484 
1485  return true;
1486 }
1488 //*************************************************************************************************
1489 
1490 
1491 //*************************************************************************************************
1506 template< typename VT1 // Type of the left-hand side vector
1507  , bool TF1 // Transpose flag of the left-hand side vector
1508  , typename VT2 // Type of the right-hand side vector
1509  , bool TF2 > // Transpose flag of the right-hand side vector
1510 BLAZE_ALWAYS_INLINE bool tryBitandAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1511 {
1512  BLAZE_INTERNAL_ASSERT( index <= (~lhs).size(), "Invalid vector access index" );
1513  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= (~lhs).size(), "Invalid vector size" );
1514 
1515  MAYBE_UNUSED( lhs, rhs, index );
1516 
1517  return true;
1518 }
1520 //*************************************************************************************************
1521 
1522 
1523 //*************************************************************************************************
1538 template< typename VT1 // Type of the left-hand side vector
1539  , bool TF1 // Transpose flag of the left-hand side vector
1540  , typename VT2 // Type of the right-hand side vector
1541  , bool TF2 > // Transpose flag of the right-hand side vector
1542 BLAZE_ALWAYS_INLINE bool tryBitorAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1543 {
1544  BLAZE_INTERNAL_ASSERT( index <= (~lhs).size(), "Invalid vector access index" );
1545  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= (~lhs).size(), "Invalid vector size" );
1546 
1547  MAYBE_UNUSED( lhs, rhs, index );
1548 
1549  return true;
1550 }
1552 //*************************************************************************************************
1553 
1554 
1555 //*************************************************************************************************
1570 template< typename VT1 // Type of the left-hand side vector
1571  , bool TF1 // Transpose flag of the left-hand side vector
1572  , typename VT2 // Type of the right-hand side vector
1573  , bool TF2 > // Transpose flag of the right-hand side vector
1574 BLAZE_ALWAYS_INLINE bool tryBitxorAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1575 {
1576  BLAZE_INTERNAL_ASSERT( index <= (~lhs).size(), "Invalid vector access index" );
1577  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= (~lhs).size(), "Invalid vector size" );
1578 
1579  MAYBE_UNUSED( lhs, rhs, index );
1580 
1581  return true;
1582 }
1584 //*************************************************************************************************
1585 
1586 
1587 //*************************************************************************************************
1602 template< typename VT // Type of the vector
1603  , bool TF > // Transpose flag of the vector
1604 BLAZE_ALWAYS_INLINE VT& derestrict( Vector<VT,TF>& vector )
1605 {
1606  return ~vector;
1607 }
1609 //*************************************************************************************************
1610 
1611 } // namespace blaze
1612 
1613 #endif
#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
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:546
bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:992
Header file for basic type definitions.
static constexpr bool transposeFlag
Transpose flag of the vector.
Definition: Vector.h:85
Header file for the IsSame and IsStrictlySame type traits.
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:799
Header file for the MAYBE_UNUSED function template.
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
const MT::ResultType evaluate(const Matrix< MT, SO > &matrix)
Evaluates the given matrix expression.
Definition: Matrix.h:912
MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:482
MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:416
Header file for the DisableIf class template.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Expression object for sparse matrix-sparse vector multiplications.The TSMatSVecMultExpr class represe...
Definition: Forward.h:187
Header file for the IsShrinkable type trait.
BLAZE_ALWAYS_INLINE constexpr const VectorType & operator~() const noexcept
Conversion operator for constant vectors.
Definition: Vector.h:103
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
Header file for the exception macros of the math module.
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:738
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:438
Header file for the EnableIf class template.
BLAZE_ALWAYS_INLINE constexpr VectorType & operator~() noexcept
Conversion operator for non-constant vectors.
Definition: Vector.h:93
Header file for run time assertion macros.
constexpr bool isEmpty(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is empty.
Definition: Matrix.h:932
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:198
Header file for the IsResizable type trait.
System settings for the inline keywords.
#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
Header file for the function trace functionality.