Blaze 3.9
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
48#include <blaze/system/Inline.h>
50#include <blaze/util/Assert.h>
51#include <blaze/util/EnableIf.h>
55#include <blaze/util/Types.h>
57
58
59namespace blaze {
60
61//=================================================================================================
62//
63// CLASS DEFINITION
64//
65//=================================================================================================
66
67//*************************************************************************************************
79template< typename VT // Type of the vector
80 , bool TF > // Transpose flag
81class Vector
82{
83 public:
84 //**Type definitions****************************************************************************
85 using VectorType = VT;
86 //**********************************************************************************************
87
88 //**Compilation flags***************************************************************************
89 static constexpr bool transposeFlag = TF;
90 //**********************************************************************************************
91
92 //**Conversion operators************************************************************************
95 [[deprecated]] BLAZE_ALWAYS_INLINE constexpr VT& operator~() noexcept;
96 [[deprecated]] BLAZE_ALWAYS_INLINE constexpr const VT& operator~() const noexcept;
97
98 constexpr VT& operator*() noexcept;
99 constexpr const VT& operator*() const noexcept;
101 //**********************************************************************************************
102
103 protected:
104 //**Special member functions********************************************************************
107 Vector() = default;
108 Vector( const Vector& ) = default;
109 Vector( Vector&& ) = default;
110 ~Vector() = default;
111 Vector& operator=( const Vector& ) = default;
112 Vector& operator=( Vector&& ) = default;
114 //**********************************************************************************************
115};
116//*************************************************************************************************
117
118
119
120
121//=================================================================================================
122//
123// CONVERSION OPERATIONS
124//
125//=================================================================================================
126
127//*************************************************************************************************
135template< typename VT // Type of the vector
136 , bool TF > // Transpose flag
137[[deprecated]] BLAZE_ALWAYS_INLINE constexpr VT& Vector<VT,TF>::operator~() noexcept
138{
139 return static_cast<VT&>( *this );
140}
141//*************************************************************************************************
142
143
144//*************************************************************************************************
152template< typename VT // Type of the vector
153 , bool TF > // Transpose flag
154[[deprecated]] BLAZE_ALWAYS_INLINE constexpr const VT& Vector<VT,TF>::operator~() const noexcept
155{
156 return static_cast<const VT&>( *this );
157}
158//*************************************************************************************************
159
160
161//*************************************************************************************************
169template< typename VT // Type of the vector
170 , bool TF > // Transpose flag
172{
173 return static_cast<VT&>( *this );
174}
175//*************************************************************************************************
176
177
178//*************************************************************************************************
186template< typename VT // Type of the vector
187 , bool TF > // Transpose flag
188BLAZE_ALWAYS_INLINE constexpr const VT& Vector<VT,TF>::operator*() const noexcept
189{
190 return static_cast<const VT&>( *this );
191}
192//*************************************************************************************************
193
194
195
196
197//=================================================================================================
198//
199// GLOBAL FUNCTIONS
200//
201//=================================================================================================
202
203//*************************************************************************************************
206template< typename VT, bool TF >
207VT& crtp_cast( Vector<VT,TF>& vector );
208
209template< typename VT, bool TF >
210const VT& crtp_cast( const Vector<VT,TF>& vector );
211
212template< typename VT, bool TF >
213typename VT::Iterator begin( Vector<VT,TF>& vector );
214
215template< typename VT, bool TF >
216typename VT::ConstIterator begin( const Vector<VT,TF>& vector );
217
218template< typename VT, bool TF >
219typename VT::ConstIterator cbegin( const Vector<VT,TF>& vector );
220
221template< typename VT, bool TF >
222typename VT::Iterator end( Vector<VT,TF>& vector );
223
224template< typename VT, bool TF >
225typename VT::ConstIterator end( const Vector<VT,TF>& vector );
226
227template< typename VT, bool TF >
228typename VT::ConstIterator cend( const Vector<VT,TF>& vector );
229
230template< typename VT, bool TF >
231constexpr size_t size( const Vector<VT,TF>& vector ) noexcept;
232
233template< typename VT, bool TF >
234size_t capacity( const Vector<VT,TF>& vector ) noexcept;
235
236template< typename VT, bool TF >
237size_t nonZeros( const Vector<VT,TF>& vector );
238
239template< typename VT, bool TF >
240constexpr void reset( Vector<VT,TF>& vector );
241
242template< typename VT, bool TF >
243constexpr void reset( Vector<VT,TF>&& vector );
244
245template< typename VT, bool TF >
246constexpr void clear( Vector<VT,TF>& vector );
247
248template< typename VT, bool TF >
249constexpr void clear( Vector<VT,TF>&& vector );
250
251template< typename VT, bool TF >
252void resize( Vector<VT,TF>& vector, size_t n, bool preserve=true );
253
254template< typename VT, bool TF >
255void shrinkToFit( Vector<VT,TF>& vector );
256
257template< typename VT, bool TF >
258typename VT::ResultType evaluate( const Vector<VT,TF>& vector );
259
260template< bool B, typename VT, bool TF >
261decltype(auto) evaluateIf( const Vector<VT,TF>& vector );
262
263template< typename VT, bool TF >
264constexpr bool isEmpty( const Vector<VT,TF>& vector ) noexcept;
265
266template< typename VT1, bool TF1, typename VT2, bool TF2 >
267bool isSame( const Vector<VT1,TF1>& a, const Vector<VT2,TF2>& b ) noexcept;
269//*************************************************************************************************
270
271
272//*************************************************************************************************
281template< typename VT // Type of the vector
282 , bool TF > // Transpose flag of the vector
284{
285 return *vector;
286}
287//*************************************************************************************************
288
289
290//*************************************************************************************************
299template< typename VT // Type of the vector
300 , bool TF > // Transpose flag of the vector
302{
303 return *vector;
304}
305//*************************************************************************************************
306
307
308//*************************************************************************************************
315template< typename VT // Type of the vector
316 , bool TF > // Transpose flag of the vector
317BLAZE_ALWAYS_INLINE typename VT::Iterator begin( Vector<VT,TF>& vector )
318{
319 return (*vector).begin();
320}
321//*************************************************************************************************
322
323
324//*************************************************************************************************
331template< typename VT // Type of the vector
332 , bool TF > // Transpose flag of the vector
333BLAZE_ALWAYS_INLINE typename VT::ConstIterator begin( const Vector<VT,TF>& vector )
334{
335 return (*vector).begin();
336}
337//*************************************************************************************************
338
339
340//*************************************************************************************************
347template< typename VT // Type of the vector
348 , bool TF > // Transpose flag of the vector
349BLAZE_ALWAYS_INLINE typename VT::ConstIterator cbegin( const Vector<VT,TF>& vector )
350{
351 return (*vector).begin();
352}
353//*************************************************************************************************
354
355
356//*************************************************************************************************
363template< typename VT // Type of the vector
364 , bool TF > // Transpose flag of the vector
365BLAZE_ALWAYS_INLINE typename VT::Iterator end( Vector<VT,TF>& vector )
366{
367 return (*vector).end();
368}
369//*************************************************************************************************
370
371
372//*************************************************************************************************
379template< typename VT // Type of the vector
380 , bool TF > // Transpose flag of the vector
381BLAZE_ALWAYS_INLINE typename VT::ConstIterator end( const Vector<VT,TF>& vector )
382{
383 return (*vector).end();
384}
385//*************************************************************************************************
386
387
388//*************************************************************************************************
395template< typename VT // Type of the vector
396 , bool TF > // Transpose flag of the vector
397BLAZE_ALWAYS_INLINE typename VT::ConstIterator cend( const Vector<VT,TF>& vector )
398{
399 return (*vector).end();
400}
401//*************************************************************************************************
402
403
404//*************************************************************************************************
411template< typename VT // Type of the vector
412 , bool TF > // Transpose flag of the vector
413BLAZE_ALWAYS_INLINE constexpr size_t size( const Vector<VT,TF>& vector ) noexcept
414{
415 return (*vector).size();
416}
417//*************************************************************************************************
418
419
420//*************************************************************************************************
427template< typename VT // Type of the vector
428 , bool TF > // Transpose flag of the vector
429BLAZE_ALWAYS_INLINE size_t capacity( const Vector<VT,TF>& vector ) noexcept
430{
431 return (*vector).capacity();
432}
433//*************************************************************************************************
434
435
436//*************************************************************************************************
446template< typename VT // Type of the vector
447 , bool TF > // Transpose flag of the vector
449{
450 return (*vector).nonZeros();
451}
452//*************************************************************************************************
453
454
455//*************************************************************************************************
463template< typename VT // Type of the vector
464 , bool TF > // Transpose flag of the vector
465constexpr auto reset_backend( Vector<VT,TF>& vector )
466 -> DisableIf_t< IsZero_v<VT> >
467{
468 (*vector).reset();
469}
471//*************************************************************************************************
472
473
474//*************************************************************************************************
482template< typename VT // Type of the vector
483 , bool TF > // Transpose flag of the vector
484constexpr auto reset_backend( Vector<VT,TF>& vector )
485 -> EnableIf_t< IsZero_v<VT> >
486{
487 MAYBE_UNUSED( vector );
488}
490//*************************************************************************************************
491
492
493//*************************************************************************************************
500template< typename VT // Type of the vector
501 , bool TF > // Transpose flag of the vector
502constexpr void reset( Vector<VT,TF>& vector )
503{
504 reset_backend( *vector );
505}
506//*************************************************************************************************
507
508
509//*************************************************************************************************
516template< typename VT // Type of the vector
517 , bool TF > // Transpose flag of the vector
518constexpr void reset( Vector<VT,TF>&& vector )
519{
520 reset_backend( *vector );
521}
522//*************************************************************************************************
523
524
525//*************************************************************************************************
533template< typename VT // Type of the vector
534 , bool TF > // Transpose flag of the vector
535constexpr auto clear_backend( Vector<VT,TF>& vector )
536 -> DisableIf_t< IsClearable_v<VT> >
537{
538 (*vector).reset();
539}
541//*************************************************************************************************
542
543
544//*************************************************************************************************
552template< typename VT // Type of the vector
553 , bool TF > // Transpose flag of the vector
554constexpr auto clear_backend( Vector<VT,TF>& vector )
555 -> EnableIf_t< IsClearable_v<VT> >
556{
557 (*vector).clear();
558}
560//*************************************************************************************************
561
562
563//*************************************************************************************************
570template< typename VT // Type of the vector
571 , bool TF > // Transpose flag of the vector
572constexpr void clear( Vector<VT,TF>& vector )
573{
574 clear_backend( *vector );
575}
576//*************************************************************************************************
577
578
579//*************************************************************************************************
586template< typename VT // Type of the vector
587 , bool TF > // Transpose flag of the vector
588constexpr void clear( Vector<VT,TF>&& vector )
589{
590 clear_backend( *vector );
591}
592//*************************************************************************************************
593
594
595//*************************************************************************************************
609template< typename VT // Type of the vector
610 , bool TF > // Transpose flag of the vector
611BLAZE_ALWAYS_INLINE auto resize_backend( Vector<VT,TF>& vector, size_t n, bool preserve )
612 -> DisableIf_t< IsResizable_v<VT> >
613{
614 MAYBE_UNUSED( preserve );
615
616 if( (*vector).size() != n ) {
617 BLAZE_THROW_INVALID_ARGUMENT( "Vector cannot be resized" );
618 }
619}
621//*************************************************************************************************
622
623
624//*************************************************************************************************
636template< typename VT // Type of the vector
637 , bool TF > // Transpose flag of the vector
638BLAZE_ALWAYS_INLINE auto resize_backend( Vector<VT,TF>& vector, size_t n, bool preserve )
639 -> EnableIf_t< IsResizable_v<VT> >
640{
641 (*vector).resize( n, preserve );
642}
644//*************************************************************************************************
645
646
647//*************************************************************************************************
675template< typename VT // Type of the vector
676 , bool TF > // Transpose flag of the vector
677BLAZE_ALWAYS_INLINE void resize( Vector<VT,TF>& vector, size_t n, bool preserve )
678{
679 resize_backend( vector, n, preserve );
680}
681//*************************************************************************************************
682
683
684//*************************************************************************************************
692template< typename VT // Type of the vector
693 , bool TF > // Transpose flag of the vector
694BLAZE_ALWAYS_INLINE auto shrinkToFit_backend( Vector<VT,TF>& vector )
695 -> DisableIf_t< IsShrinkable_v<VT> >
696{
697 MAYBE_UNUSED( vector );
698}
700//*************************************************************************************************
701
702
703//*************************************************************************************************
711template< typename VT // Type of the vector
712 , bool TF > // Transpose flag of the vector
713BLAZE_ALWAYS_INLINE auto shrinkToFit_backend( Vector<VT,TF>& vector )
714 -> EnableIf_t< IsShrinkable_v<VT> >
715{
716 (*vector).shrinkToFit();
717}
719//*************************************************************************************************
720
721
722//*************************************************************************************************
735template< typename VT // Type of the vector
736 , bool TF > // Transpose flag of the vector
738{
739 shrinkToFit_backend( vector );
740}
741//*************************************************************************************************
742
743
744//*************************************************************************************************
794template< typename VT // Type of the vector
795 , bool TF > // Transpose flag of the vector
796inline typename VT::ResultType evaluate( const Vector<VT,TF>& vector )
797{
798 typename VT::ResultType tmp( *vector );
799 return tmp;
800}
801//*************************************************************************************************
802
803
804//*************************************************************************************************
815template< typename VT // Type of the vector
816 , bool TF > // Transpose flag of the vector
817inline decltype(auto) evaluateIf( FalseType, const Vector<VT,TF>& vector )
818{
819 return *vector;
820}
822//*************************************************************************************************
823
824
825//*************************************************************************************************
835template< typename VT // Type of the vector
836 , bool TF > // Transpose flag of the vector
837inline decltype(auto) evaluateIf( TrueType, const Vector<VT,TF>& vector )
838{
839 return evaluate( *vector );
840}
842//*************************************************************************************************
843
844
845//*************************************************************************************************
856template< bool B // Compile time condition
857 , typename VT // Type of the vector
858 , bool TF > // Transpose flag of the vector
859inline decltype(auto) evaluateIf( const Vector<VT,TF>& vector )
860{
861 return evaluateIf( BoolConstant<B>{}, *vector );
862}
863//*************************************************************************************************
864
865
866//*************************************************************************************************
876template< typename VT // Type of the vector
877 , bool TF > // Transpose flag of the vector
878BLAZE_ALWAYS_INLINE constexpr bool isEmpty( const Vector<VT,TF>& vector ) noexcept
879{
880 return size( *vector ) == 0UL;
881}
882//*************************************************************************************************
883
884
885//*************************************************************************************************
915template< typename VT1 // Type of the left-hand side vector
916 , bool TF1 // Transpose flag of the left-hand side vector
917 , typename VT2 // Type of the right-hand side vector
918 , bool TF2 > // Transpose flag of the right-hand side vector
920{
921 return ( IsSame_v<VT1,VT2> &&
922 reinterpret_cast<const void*>( &a ) == reinterpret_cast<const void*>( &b ) );
923}
924//*************************************************************************************************
925
926
927//*************************************************************************************************
942template< typename VT1 // Type of the left-hand side vector
943 , bool TF1 // Transpose flag of the left-hand side vector
944 , typename VT2 // Type of the right-hand side vector
945 , bool TF2 > // Transpose flag of the right-hand side vector
946BLAZE_ALWAYS_INLINE void assign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
947{
949
950 BLAZE_INTERNAL_ASSERT( (*lhs).size() == (*rhs).size(), "Invalid vector sizes" );
951 (*lhs).assign( *rhs );
952}
954//*************************************************************************************************
955
956
957//*************************************************************************************************
972template< typename VT1 // Type of the left-hand side vector
973 , bool TF1 // Transpose flag of the left-hand side vector
974 , typename VT2 // Type of the right-hand side vector
975 , bool TF2 > // Transpose flag of the right-hand side vector
976BLAZE_ALWAYS_INLINE void addAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
977{
979
980 BLAZE_INTERNAL_ASSERT( (*lhs).size() == (*rhs).size(), "Invalid vector sizes" );
981 (*lhs).addAssign( *rhs );
982}
984//*************************************************************************************************
985
986
987//*************************************************************************************************
1002template< typename VT1 // Type of the left-hand side vector
1003 , bool TF1 // Transpose flag of the left-hand side vector
1004 , typename VT2 // Type of the right-hand side vector
1005 , bool TF2 > // Transpose flag of the right-hand side vector
1006BLAZE_ALWAYS_INLINE void subAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
1007{
1009
1010 BLAZE_INTERNAL_ASSERT( (*lhs).size() == (*rhs).size(), "Invalid vector sizes" );
1011 (*lhs).subAssign( *rhs );
1012}
1014//*************************************************************************************************
1015
1016
1017//*************************************************************************************************
1032template< typename VT1 // Type of the left-hand side vector
1033 , bool TF1 // Transpose flag of the left-hand side vector
1034 , typename VT2 // Type of the right-hand side vector
1035 , bool TF2 > // Transpose flag of the right-hand side vector
1036BLAZE_ALWAYS_INLINE void multAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
1037{
1039
1040 BLAZE_INTERNAL_ASSERT( (*lhs).size() == (*rhs).size(), "Invalid vector sizes" );
1041 (*lhs).multAssign( *rhs );
1042}
1044//*************************************************************************************************
1045
1046
1047//*************************************************************************************************
1062template< typename VT1 // Type of the left-hand side vector
1063 , bool TF1 // Transpose flag of the left-hand side vector
1064 , typename VT2 // Type of the right-hand side vector
1065 , bool TF2 > // Transpose flag of the right-hand side vector
1066BLAZE_ALWAYS_INLINE void divAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
1067{
1069
1070 BLAZE_INTERNAL_ASSERT( (*lhs).size() == (*rhs).size(), "Invalid vector sizes" );
1071 (*lhs).divAssign( *rhs );
1072}
1074//*************************************************************************************************
1075
1076
1077//*************************************************************************************************
1092template< typename VT // Type of the vector
1093 , bool TF // Transpose flag
1094 , typename ET > // Type of the element
1095BLAZE_ALWAYS_INLINE bool trySet( const Vector<VT,TF>& vec, size_t index, const ET& value )
1096{
1097 BLAZE_INTERNAL_ASSERT( index < (*vec).size(), "Invalid vector access index" );
1098
1099 MAYBE_UNUSED( vec, index, value );
1100
1101 return true;
1102}
1104//*************************************************************************************************
1105
1106
1107//*************************************************************************************************
1123template< typename VT // Type of the vector
1124 , bool TF // Transpose flag
1125 , typename ET > // Type of the element
1127 trySet( const Vector<VT,TF>& vec, size_t index, size_t size, const ET& value )
1128{
1129 BLAZE_INTERNAL_ASSERT( index <= (*vec).size(), "Invalid vector access index" );
1130 BLAZE_INTERNAL_ASSERT( index + size <= (*vec).size(), "Invalid range size" );
1131
1132 MAYBE_UNUSED( vec, index, size, value );
1133
1134 return true;
1135}
1137//*************************************************************************************************
1138
1139
1140//*************************************************************************************************
1155template< typename VT // Type of the vector
1156 , bool TF // Transpose flag
1157 , typename ET > // Type of the element
1158BLAZE_ALWAYS_INLINE bool tryAdd( const Vector<VT,TF>& vec, size_t index, const ET& value )
1159{
1160 BLAZE_INTERNAL_ASSERT( index < (*vec).size(), "Invalid vector access index" );
1161
1162 MAYBE_UNUSED( vec, index, value );
1163
1164 return true;
1165}
1167//*************************************************************************************************
1168
1169
1170//*************************************************************************************************
1186template< typename VT // Type of the vector
1187 , bool TF // Transpose flag
1188 , typename ET > // Type of the element
1190 tryAdd( const Vector<VT,TF>& vec, size_t index, size_t size, const ET& value )
1191{
1192 BLAZE_INTERNAL_ASSERT( index <= (*vec).size(), "Invalid vector access index" );
1193 BLAZE_INTERNAL_ASSERT( index + size <= (*vec).size(), "Invalid range size" );
1194
1195 MAYBE_UNUSED( vec, index, size, value );
1196
1197 return true;
1198}
1200//*************************************************************************************************
1201
1202
1203//*************************************************************************************************
1218template< typename VT // Type of the vector
1219 , bool TF // Transpose flag
1220 , typename ET > // Type of the element
1221BLAZE_ALWAYS_INLINE bool trySub( const Vector<VT,TF>& vec, size_t index, const ET& value )
1222{
1223 BLAZE_INTERNAL_ASSERT( index < (*vec).size(), "Invalid vector access index" );
1224
1225 MAYBE_UNUSED( vec, index, value );
1226
1227 return true;
1228}
1230//*************************************************************************************************
1231
1232
1233//*************************************************************************************************
1249template< typename VT // Type of the vector
1250 , bool TF // Transpose flag
1251 , typename ET > // Type of the element
1253 trySub( const Vector<VT,TF>& vec, size_t index, size_t size, const ET& value )
1254{
1255 BLAZE_INTERNAL_ASSERT( index <= (*vec).size(), "Invalid vector access index" );
1256 BLAZE_INTERNAL_ASSERT( index + size <= (*vec).size(), "Invalid range size" );
1257
1258 MAYBE_UNUSED( vec, index, size, value );
1259
1260 return true;
1261}
1263//*************************************************************************************************
1264
1265
1266//*************************************************************************************************
1281template< typename VT // Type of the vector
1282 , bool TF // Transpose flag
1283 , typename ET > // Type of the element
1284BLAZE_ALWAYS_INLINE bool tryMult( const Vector<VT,TF>& vec, size_t index, const ET& value )
1285{
1286 BLAZE_INTERNAL_ASSERT( index < (*vec).size(), "Invalid vector access index" );
1287
1288 MAYBE_UNUSED( vec, index, value );
1289
1290 return true;
1291}
1293//*************************************************************************************************
1294
1295
1296//*************************************************************************************************
1312template< typename VT // Type of the vector
1313 , bool TF // Transpose flag
1314 , typename ET > // Type of the element
1316 tryMult( const Vector<VT,TF>& vec, size_t index, size_t size, const ET& value )
1317{
1318 BLAZE_INTERNAL_ASSERT( index <= (*vec).size(), "Invalid vector access index" );
1319 BLAZE_INTERNAL_ASSERT( index + size <= (*vec).size(), "Invalid range size" );
1320
1321 MAYBE_UNUSED( vec, index, size, value );
1322
1323 return true;
1324}
1326//*************************************************************************************************
1327
1328
1329//*************************************************************************************************
1344template< typename VT // Type of the vector
1345 , bool TF // Transpose flag
1346 , typename ET > // Type of the element
1347BLAZE_ALWAYS_INLINE bool tryDiv( const Vector<VT,TF>& vec, size_t index, const ET& value )
1348{
1349 BLAZE_INTERNAL_ASSERT( index < (*vec).size(), "Invalid vector access index" );
1350
1351 MAYBE_UNUSED( vec, index, value );
1352
1353 return true;
1354}
1356//*************************************************************************************************
1357
1358
1359//*************************************************************************************************
1375template< typename VT // Type of the vector
1376 , bool TF // Transpose flag
1377 , typename ET > // Type of the element
1379 tryDiv( const Vector<VT,TF>& vec, size_t index, size_t size, const ET& value )
1380{
1381 BLAZE_INTERNAL_ASSERT( index <= (*vec).size(), "Invalid vector access index" );
1382 BLAZE_INTERNAL_ASSERT( index + size <= (*vec).size(), "Invalid range size" );
1383
1384 MAYBE_UNUSED( vec, index, size, value );
1385
1386 return true;
1387}
1389//*************************************************************************************************
1390
1391
1392//*************************************************************************************************
1407template< typename VT // Type of the vector
1408 , bool TF > // Transpose flag
1409BLAZE_ALWAYS_INLINE bool tryShift( const Vector<VT,TF>& vec, size_t index, int count )
1410{
1411 BLAZE_INTERNAL_ASSERT( index < (*vec).size(), "Invalid vector access index" );
1412
1413 MAYBE_UNUSED( vec, index, count );
1414
1415 return true;
1416}
1418//*************************************************************************************************
1419
1420
1421//*************************************************************************************************
1437template< typename VT // Type of the vector
1438 , bool TF > // Transpose flag
1440 tryShift( const Vector<VT,TF>& vec, size_t index, size_t size, int count )
1441{
1442 BLAZE_INTERNAL_ASSERT( index <= (*vec).size(), "Invalid vector access index" );
1443 BLAZE_INTERNAL_ASSERT( index + size <= (*vec).size(), "Invalid range size" );
1444
1445 MAYBE_UNUSED( vec, index, size, count );
1446
1447 return true;
1448}
1450//*************************************************************************************************
1451
1452
1453//*************************************************************************************************
1468template< typename VT // Type of the vector
1469 , bool TF // Transpose flag
1470 , typename ET > // Type of the element
1471BLAZE_ALWAYS_INLINE bool tryBitand( const Vector<VT,TF>& vec, size_t index, const ET& value )
1472{
1473 BLAZE_INTERNAL_ASSERT( index < (*vec).size(), "Invalid vector access index" );
1474
1475 MAYBE_UNUSED( vec, index, value );
1476
1477 return true;
1478}
1480//*************************************************************************************************
1481
1482
1483//*************************************************************************************************
1499template< typename VT // Type of the vector
1500 , bool TF // Transpose flag
1501 , typename ET > // Type of the element
1503 tryBitand( const Vector<VT,TF>& vec, size_t index, size_t size, const ET& value )
1504{
1505 BLAZE_INTERNAL_ASSERT( index <= (*vec).size(), "Invalid vector access index" );
1506 BLAZE_INTERNAL_ASSERT( index + size <= (*vec).size(), "Invalid range size" );
1507
1508 MAYBE_UNUSED( vec, index, size, value );
1509
1510 return true;
1511}
1513//*************************************************************************************************
1514
1515
1516//*************************************************************************************************
1531template< typename VT // Type of the vector
1532 , bool TF // Transpose flag
1533 , typename ET > // Type of the element
1534BLAZE_ALWAYS_INLINE bool tryBitor( const Vector<VT,TF>& vec, size_t index, const ET& value )
1535{
1536 BLAZE_INTERNAL_ASSERT( index < (*vec).size(), "Invalid vector access index" );
1537
1538 MAYBE_UNUSED( vec, index, value );
1539
1540 return true;
1541}
1543//*************************************************************************************************
1544
1545
1546//*************************************************************************************************
1562template< typename VT // Type of the vector
1563 , bool TF // Transpose flag
1564 , typename ET > // Type of the element
1566 tryBitor( const Vector<VT,TF>& vec, size_t index, size_t size, const ET& value )
1567{
1568 BLAZE_INTERNAL_ASSERT( index <= (*vec).size(), "Invalid vector access index" );
1569 BLAZE_INTERNAL_ASSERT( index + size <= (*vec).size(), "Invalid range size" );
1570
1571 MAYBE_UNUSED( vec, index, size, value );
1572
1573 return true;
1574}
1576//*************************************************************************************************
1577
1578
1579//*************************************************************************************************
1594template< typename VT // Type of the vector
1595 , bool TF // Transpose flag
1596 , typename ET > // Type of the element
1597BLAZE_ALWAYS_INLINE bool tryBitxor( const Vector<VT,TF>& vec, size_t index, const ET& value )
1598{
1599 BLAZE_INTERNAL_ASSERT( index < (*vec).size(), "Invalid vector access index" );
1600
1601 MAYBE_UNUSED( vec, index, value );
1602
1603 return true;
1604}
1606//*************************************************************************************************
1607
1608
1609//*************************************************************************************************
1625template< typename VT // Type of the vector
1626 , bool TF // Transpose flag
1627 , typename ET > // Type of the element
1629 tryBitxor( const Vector<VT,TF>& vec, size_t index, size_t size, const ET& value )
1630{
1631 BLAZE_INTERNAL_ASSERT( index <= (*vec).size(), "Invalid vector access index" );
1632 BLAZE_INTERNAL_ASSERT( index + size <= (*vec).size(), "Invalid range size" );
1633
1634 MAYBE_UNUSED( vec, index, size, value );
1635
1636 return true;
1637}
1639//*************************************************************************************************
1640
1641
1642//*************************************************************************************************
1657template< typename VT1 // Type of the left-hand side vector
1658 , bool TF1 // Transpose flag of the left-hand side vector
1659 , typename VT2 // Type of the right-hand side vector
1660 , bool TF2 > // Transpose flag of the right-hand side vector
1661BLAZE_ALWAYS_INLINE bool tryAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1662{
1663 BLAZE_INTERNAL_ASSERT( index <= (*lhs).size(), "Invalid vector access index" );
1664 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= (*lhs).size(), "Invalid vector size" );
1665
1666 MAYBE_UNUSED( lhs, rhs, index );
1667
1668 return true;
1669}
1671//*************************************************************************************************
1672
1673
1674//*************************************************************************************************
1689template< typename VT1 // Type of the left-hand side vector
1690 , bool TF1 // Transpose flag of the left-hand side vector
1691 , typename VT2 // Type of the right-hand side vector
1692 , bool TF2 > // Transpose flag of the right-hand side vector
1693BLAZE_ALWAYS_INLINE bool tryAddAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1694{
1695 BLAZE_INTERNAL_ASSERT( index <= (*lhs).size(), "Invalid vector access index" );
1696 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= (*lhs).size(), "Invalid vector size" );
1697
1698 MAYBE_UNUSED( lhs, rhs, index );
1699
1700 return true;
1701}
1703//*************************************************************************************************
1704
1705
1706//*************************************************************************************************
1721template< typename VT1 // Type of the left-hand side vector
1722 , bool TF1 // Transpose flag of the left-hand side vector
1723 , typename VT2 // Type of the right-hand side vector
1724 , bool TF2 > // Transpose flag of the right-hand side vector
1725BLAZE_ALWAYS_INLINE bool trySubAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1726{
1727 BLAZE_INTERNAL_ASSERT( index <= (*lhs).size(), "Invalid vector access index" );
1728 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= (*lhs).size(), "Invalid vector size" );
1729
1730 MAYBE_UNUSED( lhs, rhs, index );
1731
1732 return true;
1733}
1735//*************************************************************************************************
1736
1737
1738//*************************************************************************************************
1753template< typename VT1 // Type of the left-hand side vector
1754 , bool TF1 // Transpose flag of the left-hand side vector
1755 , typename VT2 // Type of the right-hand side vector
1756 , bool TF2 > // Transpose flag of the right-hand side vector
1757BLAZE_ALWAYS_INLINE bool tryMultAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1758{
1759 BLAZE_INTERNAL_ASSERT( index <= (*lhs).size(), "Invalid vector access index" );
1760 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= (*lhs).size(), "Invalid vector size" );
1761
1762 MAYBE_UNUSED( lhs, rhs, index );
1763
1764 return true;
1765}
1767//*************************************************************************************************
1768
1769
1770//*************************************************************************************************
1785template< typename VT1 // Type of the left-hand side vector
1786 , bool TF1 // Transpose flag of the left-hand side vector
1787 , typename VT2 // Type of the right-hand side vector
1788 , bool TF2 > // Transpose flag of the right-hand side vector
1789BLAZE_ALWAYS_INLINE bool tryDivAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1790{
1791 BLAZE_INTERNAL_ASSERT( index <= (*lhs).size(), "Invalid vector access index" );
1792 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= (*lhs).size(), "Invalid vector size" );
1793
1794 MAYBE_UNUSED( lhs, rhs, index );
1795
1796 return true;
1797}
1799//*************************************************************************************************
1800
1801
1802//*************************************************************************************************
1817template< typename VT1 // Type of the left-hand side vector
1818 , bool TF1 // Transpose flag of the left-hand side vector
1819 , typename VT2 // Type of the right-hand side vector
1820 , bool TF2 > // Transpose flag of the right-hand side vector
1821BLAZE_ALWAYS_INLINE bool tryShiftAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1822{
1823 BLAZE_INTERNAL_ASSERT( index <= (*lhs).size(), "Invalid vector access index" );
1824 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= (*lhs).size(), "Invalid vector size" );
1825
1826 MAYBE_UNUSED( lhs, rhs, index );
1827
1828 return true;
1829}
1831//*************************************************************************************************
1832
1833
1834//*************************************************************************************************
1849template< typename VT1 // Type of the left-hand side vector
1850 , bool TF1 // Transpose flag of the left-hand side vector
1851 , typename VT2 // Type of the right-hand side vector
1852 , bool TF2 > // Transpose flag of the right-hand side vector
1853BLAZE_ALWAYS_INLINE bool tryBitandAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1854{
1855 BLAZE_INTERNAL_ASSERT( index <= (*lhs).size(), "Invalid vector access index" );
1856 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= (*lhs).size(), "Invalid vector size" );
1857
1858 MAYBE_UNUSED( lhs, rhs, index );
1859
1860 return true;
1861}
1863//*************************************************************************************************
1864
1865
1866//*************************************************************************************************
1881template< typename VT1 // Type of the left-hand side vector
1882 , bool TF1 // Transpose flag of the left-hand side vector
1883 , typename VT2 // Type of the right-hand side vector
1884 , bool TF2 > // Transpose flag of the right-hand side vector
1885BLAZE_ALWAYS_INLINE bool tryBitorAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1886{
1887 BLAZE_INTERNAL_ASSERT( index <= (*lhs).size(), "Invalid vector access index" );
1888 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= (*lhs).size(), "Invalid vector size" );
1889
1890 MAYBE_UNUSED( lhs, rhs, index );
1891
1892 return true;
1893}
1895//*************************************************************************************************
1896
1897
1898//*************************************************************************************************
1913template< typename VT1 // Type of the left-hand side vector
1914 , bool TF1 // Transpose flag of the left-hand side vector
1915 , typename VT2 // Type of the right-hand side vector
1916 , bool TF2 > // Transpose flag of the right-hand side vector
1917BLAZE_ALWAYS_INLINE bool tryBitxorAssign( const Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs, size_t index )
1918{
1919 BLAZE_INTERNAL_ASSERT( index <= (*lhs).size(), "Invalid vector access index" );
1920 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= (*lhs).size(), "Invalid vector size" );
1921
1922 MAYBE_UNUSED( lhs, rhs, index );
1923
1924 return true;
1925}
1927//*************************************************************************************************
1928
1929
1930//*************************************************************************************************
1945template< typename VT // Type of the vector
1946 , bool TF > // Transpose flag of the vector
1947BLAZE_ALWAYS_INLINE VT& derestrict( Vector<VT,TF>& vector )
1948{
1949 return *vector;
1950}
1952//*************************************************************************************************
1953
1954
1955//*************************************************************************************************
1969template< typename VT // Type of the vector
1970 , bool TF > // Transpose flag of the vector
1971BLAZE_ALWAYS_INLINE VT& unview( Vector<VT,TF>& vector )
1972{
1973 return *vector;
1974}
1976//*************************************************************************************************
1977
1978
1979//*************************************************************************************************
1993template< typename VT // Type of the vector
1994 , bool TF > // Transpose flag of the vector
1995BLAZE_ALWAYS_INLINE const VT& unview( const Vector<VT,TF>& vector )
1996{
1997 return *vector;
1998}
2000//*************************************************************************************************
2001
2002} // namespace blaze
2003
2004#endif
Header file for run time assertion macros.
Header file for the EnableIf class template.
Header file for the function trace functionality.
Header file for the IntegralConstant class template.
Header file for the IsClearable type trait.
Header file for the IsResizable type trait.
Header file for the IsSame and IsStrictlySame type traits.
Header file for the IsShrinkable type trait.
Deactivation of problematic macros.
Header file for the MAYBE_UNUSED function template.
Base class for N-dimensional vectors.
Definition: Vector.h:82
static constexpr bool transposeFlag
Transpose flag of the vector.
Definition: Vector.h:89
VT VectorType
Type of the vector.
Definition: Vector.h:85
BLAZE_ALWAYS_INLINE constexpr VT & operator~() noexcept
CRTP-based conversion operation for non-constant vectors.
Definition: Vector.h:137
constexpr VT & operator*() noexcept
CRTP-based conversion operation for non-constant vectors.
Definition: Vector.h:171
MT & crtp_cast(Matrix< MT, SO > &matrix)
CRTP-based conversion operation for non-constant matrices.
Definition: Matrix.h:479
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
BoolConstant< true > TrueType
Type traits base class.
Definition: IntegralConstant.h:132
BoolConstant< false > FalseType
Type/value traits base class.
Definition: IntegralConstant.h:121
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition: FunctionTrace.h:94
BLAZE_ALWAYS_INLINE size_t capacity(const Vector< VT, TF > &vector) noexcept
Returns the maximum capacity of the vector.
Definition: Vector.h:429
decltype(auto) evaluateIf(const Vector< VT, TF > &vector)
Conditional evaluation of the given vector expression.
Definition: Vector.h:859
BLAZE_ALWAYS_INLINE VT::ConstIterator cbegin(const Vector< VT, TF > &vector)
Returns an iterator to the first element of the given vector.
Definition: Vector.h:349
BLAZE_ALWAYS_INLINE VT::ConstIterator begin(const Vector< VT, TF > &vector)
Returns an iterator to the first element of the given vector.
Definition: Vector.h:333
BLAZE_ALWAYS_INLINE constexpr size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:413
BLAZE_ALWAYS_INLINE constexpr bool isEmpty(const Vector< VT, TF > &vector) noexcept
Checks if the given vector is empty.
Definition: Vector.h:878
BLAZE_ALWAYS_INLINE void resize(Vector< VT, TF > &vector, size_t n, bool preserve)
Changing the size of the vector.
Definition: Vector.h:677
BLAZE_ALWAYS_INLINE bool isSame(const Vector< VT1, TF1 > &a, const Vector< VT2, TF2 > &b) noexcept
Returns whether the two given vectors represent the same observable state.
Definition: Vector.h:919
VT::ResultType evaluate(const Vector< VT, TF > &vector)
Evaluates the given vector expression.
Definition: Vector.h:796
constexpr void clear(Vector< VT, TF > &&vector)
Clearing the given temporary vector.
Definition: Vector.h:588
constexpr void reset(Vector< VT, TF > &&vector)
Resetting the given temporary vector.
Definition: Vector.h:518
BLAZE_ALWAYS_INLINE void shrinkToFit(Vector< VT, TF > &vector)
Requesting the removal of unused capacity.
Definition: Vector.h:737
BLAZE_ALWAYS_INLINE VT::ConstIterator end(const Vector< VT, TF > &vector)
Returns an iterator just past the last element of the given vector.
Definition: Vector.h:381
BLAZE_ALWAYS_INLINE VT::ConstIterator cend(const Vector< VT, TF > &vector)
Returns an iterator just past the last element of the given vector.
Definition: Vector.h:397
BLAZE_ALWAYS_INLINE size_t nonZeros(const Vector< VT, TF > &vector)
Returns the number of non-zero elements in the vector.
Definition: Vector.h:448
Header file for the exception macros of the math module.
Generic wrapper for a compile time constant integral value.
Definition: IntegralConstant.h:74
System settings for the inline keywords.
Header file for the IsZero type trait.
Header file for basic type definitions.