Blaze  3.6
Elements.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_ELEMENTS_H_
36 #define _BLAZE_MATH_VIEWS_ELEMENTS_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <array>
44 #include <numeric>
45 #include <utility>
46 #include <vector>
47 #include <blaze/math/Aliases.h>
49 #include <blaze/math/Exception.h>
74 #include <blaze/math/views/Check.h>
78 #include <blaze/util/Assert.h>
79 #include <blaze/util/EnableIf.h>
82 #include <blaze/util/MaybeUnused.h>
83 #include <blaze/util/SmallArray.h>
85 #include <blaze/util/TypeList.h>
86 #include <blaze/util/Types.h>
89 
90 
91 namespace blaze {
92 
93 //=================================================================================================
94 //
95 // GLOBAL FUNCTIONS
96 //
97 //=================================================================================================
98 
99 //*************************************************************************************************
134 template< size_t I // First element index
135  , size_t... Is // Remaining element indices
136  , typename VT // Type of the vector
137  , bool TF // Transpose flag
138  , typename... REAs > // Optional arguments
139 inline decltype(auto) elements( Vector<VT,TF>& vector, REAs... args )
140 {
142 
143  using ReturnType = Elements_< VT, index_sequence<I,Is...> >;
144  return ReturnType( ~vector, args... );
145 }
146 //*************************************************************************************************
147 
148 
149 //*************************************************************************************************
184 template< size_t I // First element index
185  , size_t... Is // Remaining element indices
186  , typename VT // Type of the vector
187  , bool TF // Transpose flag
188  , typename... REAs > // Optional arguments
189 inline decltype(auto) elements( const Vector<VT,TF>& vector, REAs... args )
190 {
192 
193  using ReturnType = const Elements_< const VT, index_sequence<I,Is...> >;
194  return ReturnType( ~vector, args... );
195 }
196 //*************************************************************************************************
197 
198 
199 //*************************************************************************************************
213 template< size_t I // First element index
214  , size_t... Is // Remaining element indices
215  , typename VT // Type of the vector
216  , bool TF // Transpose flag
217  , typename... REAs > // Optional arguments
218 inline decltype(auto) elements( Vector<VT,TF>&& vector, REAs... args )
219 {
221 
222  using ReturnType = Elements_< VT, index_sequence<I,Is...> >;
223  return ReturnType( ~vector, args... );
224 }
225 //*************************************************************************************************
226 
227 
228 //*************************************************************************************************
267 template< typename VT // Type of the vector
268  , bool TF // Transpose flag
269  , typename T // Type of the element indices
270  , typename... REAs > // Optional arguments
271 inline decltype(auto) elements( Vector<VT,TF>& vector, T* indices, size_t n, REAs... args )
272 {
274 
275  using ReturnType = Elements_<VT>;
276  return ReturnType( ~vector, indices, n, args... );
277 }
278 //*************************************************************************************************
279 
280 
281 //*************************************************************************************************
320 template< typename VT // Type of the vector
321  , bool TF // Transpose flag
322  , typename T // Type of the element indices
323  , typename... REAs > // Optional arguments
324 inline decltype(auto) elements( const Vector<VT,TF>& vector, T* indices, size_t n, REAs... args )
325 {
327 
328  using ReturnType = const Elements_<const VT>;
329  return ReturnType( ~vector, indices, n, args... );
330 }
331 //*************************************************************************************************
332 
333 
334 //*************************************************************************************************
350 template< typename VT // Type of the vector
351  , bool TF // Transpose flag
352  , typename T // Type of the element indices
353  , typename... REAs > // Optional arguments
354 inline decltype(auto) elements( Vector<VT,TF>&& vector, T* indices, size_t n, REAs... args )
355 {
357 
358  using ReturnType = Elements_<VT>;
359  return ReturnType( ~vector, indices, n, args... );
360 }
361 //*************************************************************************************************
362 
363 
364 //*************************************************************************************************
401 template< typename VT // Type of the vector
402  , bool TF // Transpose flag
403  , typename P // Type of the index producer
404  , typename... REAs > // Optional arguments
405 inline decltype(auto) elements( Vector<VT,TF>& vector, P p, size_t n, REAs... args )
406 {
408 
409  using ReturnType = Elements_<VT,P>;
410  return ReturnType( ~vector, p, n, args... );
411 }
412 //*************************************************************************************************
413 
414 
415 //*************************************************************************************************
454 template< typename VT // Type of the vector
455  , bool TF // Transpose flag
456  , typename P // Type of the index producer
457  , typename... REAs > // Optional arguments
458 inline decltype(auto) elements( const Vector<VT,TF>& vector, P p, size_t n, REAs... args )
459 {
461 
462  using ReturnType = const Elements_<const VT,P>;
463  return ReturnType( ~vector, p, n, args... );
464 }
465 //*************************************************************************************************
466 
467 
468 //*************************************************************************************************
484 template< typename VT // Type of the vector
485  , bool TF // Transpose flag
486  , typename P // Type of the index producer
487  , typename... REAs > // Optional arguments
488 inline decltype(auto) elements( Vector<VT,TF>&& vector, P p, size_t n, REAs... args )
489 {
491 
492  using ReturnType = Elements_<VT,P>;
493  return ReturnType( ~vector, p, n, args... );
494 }
495 //*************************************************************************************************
496 
497 
498 //*************************************************************************************************
535 template< typename VT // Type of the vector
536  , size_t... Is // Element indices
537  , typename... REAs > // Optional arguments
538 inline decltype(auto) elements( VT&& vector, index_sequence<Is...> indices, REAs... args )
539 {
541 
542  MAYBE_UNUSED( indices );
543 
544  return elements<Is...>( std::forward<VT>( vector ), args... );
545 }
547 //*************************************************************************************************
548 
549 
550 //*************************************************************************************************
585 template< typename VT // Type of the vector
586  , typename T // Type of the element indices
587  , typename... REAs > // Optional arguments
588 inline decltype(auto) elements( VT&& vector, initializer_list<T> indices, REAs... args )
589 {
591 
592  return elements( std::forward<VT>( vector ), indices.begin(), indices.size(), args... );
593 }
594 //*************************************************************************************************
595 
596 
597 //*************************************************************************************************
634 template< typename VT // Type of the vector
635  , typename T // Type of the element indices
636  , size_t N // Number of indices
637  , typename... REAs > // Optional arguments
638 inline decltype(auto) elements( VT&& vector, const std::array<T,N>& indices, REAs... args )
639 {
641 
642  return elements( std::forward<VT>( vector ), indices.data(), N, args... );
643 }
644 //*************************************************************************************************
645 
646 
647 //*************************************************************************************************
684 template< typename VT // Type of the vector
685  , typename T // Type of the element indices
686  , typename... REAs > // Optional arguments
687 inline decltype(auto) elements( VT&& vector, const std::vector<T>& indices, REAs... args )
688 {
690 
691  return elements( std::forward<VT>( vector ), indices.data(), indices.size(), args... );
692 }
693 //*************************************************************************************************
694 
695 
696 //*************************************************************************************************
733 template< typename VT // Type of the vector
734  , typename T // Type of the element indices
735  , size_t N // Number of preallocated elements
736  , typename... REAs > // Optional arguments
737 inline decltype(auto) elements( VT&& vector, const SmallArray<T,N>& indices, REAs... args )
738 {
740 
741  return elements( std::forward<VT>( vector ), indices.data(), indices.size(), args... );
742 }
743 //*************************************************************************************************
744 
745 
746 //*************************************************************************************************
761 template< typename VT // Type of the vector
762  , typename T1 // First type of the pair of arguments
763  , typename T2 // Second type of the pair of arguments
764  , typename... REAs > // Optional arguments
765 inline decltype(auto) elements( VT&& vector, const std::pair<T1,T2>& pair, REAs... args )
766 {
768 
769  return elements( std::forward<VT>( vector ), pair.first, pair.second, args... );
770 }
772 //*************************************************************************************************
773 
774 
775 
776 
777 //=================================================================================================
778 //
779 // GLOBAL RESTRUCTURING FUNCTIONS
780 //
781 //=================================================================================================
782 
783 //*************************************************************************************************
795 template< size_t... CEAs // Compile time element arguments
796  , typename VT // Vector base type of the expression
797  , typename... REAs > // Runtime element arguments
798 inline decltype(auto) elements( const VecVecAddExpr<VT>& vector, REAs... args )
799 {
801 
802  return elements<CEAs...>( (~vector).leftOperand(), args... ) +
803  elements<CEAs...>( (~vector).rightOperand(), args... );
804 }
806 //*************************************************************************************************
807 
808 
809 //*************************************************************************************************
821 template< size_t... CEAs // Compile time element arguments
822  , typename VT // Vector base type of the expression
823  , typename... REAs > // Runtime element arguments
824 inline decltype(auto) elements( const VecVecSubExpr<VT>& vector, REAs... args )
825 {
827 
828  return elements<CEAs...>( (~vector).leftOperand(), args... ) -
829  elements<CEAs...>( (~vector).rightOperand(), args... );
830 }
832 //*************************************************************************************************
833 
834 
835 //*************************************************************************************************
847 template< size_t... CEAs // Compile time element arguments
848  , typename VT // Vector base type of the expression
849  , typename... REAs > // Runtime element arguments
850 inline decltype(auto) elements( const VecVecMultExpr<VT>& vector, REAs... args )
851 {
853 
854  return elements<CEAs...>( (~vector).leftOperand(), args... ) *
855  elements<CEAs...>( (~vector).rightOperand(), args... );
856 }
858 //*************************************************************************************************
859 
860 
861 //*************************************************************************************************
873 template< size_t I // First element index
874  , size_t... Is // Remaining element indices
875  , typename VT // Vector base type of the expression
876  , typename... REAs > // Optional arguments
877 inline decltype(auto) elements( const VecVecKronExpr<VT>& vector, REAs... args )
878 {
880 
881  decltype(auto) lhs( (~vector).leftOperand() );
882  decltype(auto) rhs( (~vector).rightOperand() );
883 
884  const size_t N( rhs.size() );
885 
886  const auto lhsIndices( [N]( size_t i ) {
887  static constexpr size_t indices[] = { I, Is... };
888  return indices[i] / N;
889  } );
890 
891  const auto rhsIndices( [N]( size_t i ) {
892  static constexpr size_t indices[] = { I, Is... };
893  return indices[i] % N;
894  } );
895 
896  return elements( lhs, lhsIndices, sizeof...(Is)+1UL, args... ) *
897  elements( rhs, rhsIndices, sizeof...(Is)+1UL, args... );
898 }
900 //*************************************************************************************************
901 
902 
903 //*************************************************************************************************
917 template< typename VT // Vector base type of the expression
918  , typename T // Type of the element indices
919  , typename... REAs > // Optional arguments
920 inline decltype(auto) elements( const VecVecKronExpr<VT>& vector, T* indices, size_t n, REAs... args )
921 {
923 
924  decltype(auto) lhs( (~vector).leftOperand() );
925  decltype(auto) rhs( (~vector).rightOperand() );
926 
927  const size_t N( rhs.size() );
928 
929  SmallArray<size_t,128UL> lhsIndices;
930  lhsIndices.reserve( n );
931 
932  for( size_t i=0UL; i<n; ++i ) {
933  lhsIndices.pushBack( indices[i] / N );
934  }
935 
936  SmallArray<size_t,128UL> rhsIndices;
937  rhsIndices.reserve( n );
938 
939  for( size_t i=0UL; i<n; ++i ) {
940  rhsIndices.pushBack( indices[i] % N );
941  }
942 
943  return elements( lhs, lhsIndices, n, args... ) * elements( rhs, rhsIndices, n, args... );
944 }
946 //*************************************************************************************************
947 
948 
949 //*************************************************************************************************
963 template< typename VT // Vector base type of the expression
964  , typename P // Type of the index producer
965  , typename... REAs > // Optional arguments
966 inline decltype(auto) elements( const VecVecKronExpr<VT>& vector, P p, size_t n, REAs... args )
967 {
969 
970  decltype(auto) lhs( (~vector).leftOperand() );
971  decltype(auto) rhs( (~vector).rightOperand() );
972 
973  const size_t N( rhs.size() );
974 
975  const auto lhsIndices( [p,N]( size_t i ) { return p(i) / N; } );
976  const auto rhsIndices( [p,N]( size_t i ) { return p(i) % N; } );
977 
978  return elements( lhs, lhsIndices, n, args... ) * elements( rhs, rhsIndices, n, args... );
979 }
981 //*************************************************************************************************
982 
983 
984 //*************************************************************************************************
996 template< size_t... CEAs // Compile time element arguments
997  , typename VT // Vector base type of the expression
998  , typename... REAs > // Runtime element arguments
999 inline decltype(auto) elements( const VecVecDivExpr<VT>& vector, REAs... args )
1000 {
1002 
1003  return elements<CEAs...>( (~vector).leftOperand(), args... ) /
1004  elements<CEAs...>( (~vector).rightOperand(), args... );
1005 }
1007 //*************************************************************************************************
1008 
1009 
1010 //*************************************************************************************************
1022 template< size_t... CEAs // Compile time element arguments
1023  , typename VT // Vector base type of the expression
1024  , typename... REAs > // Runtime element arguments
1025 inline decltype(auto) elements( const VecScalarMultExpr<VT>& vector, REAs... args )
1026 {
1028 
1029  return elements<CEAs...>( (~vector).leftOperand(), args... ) * (~vector).rightOperand();
1030 }
1032 //*************************************************************************************************
1033 
1034 
1035 //*************************************************************************************************
1047 template< size_t... CEAs // Compile time element arguments
1048  , typename VT // Vector base type of the expression
1049  , typename... REAs > // Runtime element arguments
1050 inline decltype(auto) elements( const VecScalarDivExpr<VT>& vector, REAs... args )
1051 {
1053 
1054  return elements<CEAs...>( (~vector).leftOperand(), args... ) / (~vector).rightOperand();
1055 }
1057 //*************************************************************************************************
1058 
1059 
1060 //*************************************************************************************************
1072 template< size_t... CEAs // Compile time element arguments
1073  , typename VT // Vector base type of the expression
1074  , typename... REAs > // Runtime element arguments
1075 inline decltype(auto) elements( const VecMapExpr<VT>& vector, REAs... args )
1076 {
1078 
1079  return map( elements<CEAs...>( (~vector).operand(), args... ), (~vector).operation() );
1080 }
1082 //*************************************************************************************************
1083 
1084 
1085 //*************************************************************************************************
1097 template< size_t... CEAs // Compile time element arguments
1098  , typename VT // Vector base type of the expression
1099  , typename... REAs > // Runtime element arguments
1100 inline decltype(auto) elements( const VecVecMapExpr<VT>& vector, REAs... args )
1101 {
1103 
1104  return map( elements<CEAs...>( (~vector).leftOperand(), args... ),
1105  elements<CEAs...>( (~vector).rightOperand(), args... ),
1106  (~vector).operation() );
1107 }
1109 //*************************************************************************************************
1110 
1111 
1112 //*************************************************************************************************
1124 template< size_t... CEAs // Compile time element arguments
1125  , typename VT // Vector base type of the expression
1126  , typename... REAs > // Runtime element arguments
1127 inline decltype(auto) elements( const VecEvalExpr<VT>& vector, REAs... args )
1128 {
1130 
1131  return eval( elements<CEAs...>( (~vector).operand(), args... ) );
1132 }
1134 //*************************************************************************************************
1135 
1136 
1137 //*************************************************************************************************
1149 template< size_t... CEAs // Compile time element arguments
1150  , typename VT // Vector base type of the expression
1151  , typename... REAs > // Runtime element arguments
1152 inline decltype(auto) elements( const VecSerialExpr<VT>& vector, REAs... args )
1153 {
1155 
1156  return serial( elements<CEAs...>( (~vector).operand(), args... ) );
1157 }
1159 //*************************************************************************************************
1160 
1161 
1162 //*************************************************************************************************
1174 template< size_t... CEAs // Compile time element arguments
1175  , typename VT // Vector base type of the expression
1176  , typename... REAs > // Runtime element arguments
1177 inline decltype(auto) elements( const VecTransExpr<VT>& vector, REAs... args )
1178 {
1180 
1181  return trans( elements<CEAs...>( (~vector).operand(), args... ) );
1182 }
1184 //*************************************************************************************************
1185 
1186 
1187 
1188 
1189 //=================================================================================================
1190 //
1191 // GLOBAL RESTRUCTURING FUNCTIONS (ELEMENTS)
1192 //
1193 //=================================================================================================
1194 
1195 //*************************************************************************************************
1207 template< size_t I // First required element index
1208  , size_t... Is // Remaining required element indices
1209  , typename VT // Type of the vector
1210  , typename... REAs // Optional element arguments
1211  , EnableIf_t< IsElements_v< RemoveReference_t<VT> > &&
1212  RemoveReference_t<VT>::compileTimeArgs >* = nullptr >
1213 inline decltype(auto) elements( VT&& e, REAs... args )
1214 {
1216 
1217  return elements( e.operand(), subsequence<I,Is...>( RemoveReference_t<VT>::idces() ), args... );
1218 }
1220 //*************************************************************************************************
1221 
1222 
1223 //*************************************************************************************************
1236 template< size_t I // First element index
1237  , size_t... Is // Remaining element indices
1238  , typename VT // Type of the vector
1239  , typename... REAs // Optional element arguments
1240  , EnableIf_t< IsElements_v< RemoveReference_t<VT> > &&
1241  !RemoveReference_t<VT>::compileTimeArgs >* = nullptr >
1242 inline decltype(auto) elements( VT&& e, REAs... args )
1243 {
1245 
1246  constexpr bool isChecked( !Contains_v< TypeList<REAs...>, Unchecked > );
1247 
1248  if( isChecked ) {
1249  static constexpr size_t indices[] = { I, Is... };
1250  for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1251  if( e.size() <= indices[i] ) {
1252  BLAZE_THROW_INVALID_ARGUMENT( "Invalid element access index" );
1253  }
1254  }
1255  }
1256 
1257  return elements( e.operand(), { e.idx(I), e.idx(Is)... }, args... );
1258 }
1260 //*************************************************************************************************
1261 
1262 
1263 //*************************************************************************************************
1278 template< typename VT // Type of the vector
1279  , typename T // Type of the element indices
1280  , typename... REAs // Optional element arguments
1281  , EnableIf_t< IsElements_v< RemoveReference_t<VT> > >* = nullptr >
1282 inline decltype(auto) elements( VT&& e, T* indices, size_t n, REAs... args )
1283 {
1285 
1286  constexpr bool isChecked( !Contains_v< TypeList<REAs...>, Unchecked > );
1287 
1288  if( isChecked ) {
1289  for( size_t i=0UL; i<n; ++i ) {
1290  if( e.size() <= size_t( indices[i] ) ) {
1291  BLAZE_THROW_INVALID_ARGUMENT( "Invalid element access index" );
1292  }
1293  }
1294  }
1295 
1296  SmallArray<size_t,128UL> newIndices;
1297  newIndices.reserve( n );
1298 
1299  for( size_t i=0UL; i<n; ++i ) {
1300  newIndices.pushBack( e.idx( indices[i] ) );
1301  }
1302 
1303  return elements( e.operand(), newIndices.data(), newIndices.size(), args... );
1304 }
1306 //*************************************************************************************************
1307 
1308 
1309 //*************************************************************************************************
1324 template< typename VT // Type of the vector
1325  , typename P // Type of the index producer
1326  , typename... REAs // Optional element arguments
1327  , EnableIf_t< IsElements_v< RemoveReference_t<VT> > && !IsPointer_v<P> >* = nullptr >
1328 inline decltype(auto) elements( VT&& e, P p, size_t n, REAs... args )
1329 {
1331 
1332  constexpr bool isChecked( !Contains_v< TypeList<REAs...>, Unchecked > );
1333 
1334  if( isChecked ) {
1335  for( size_t i=0UL; i<n; ++i ) {
1336  if( e.size() <= size_t( p(i) ) ) {
1337  BLAZE_THROW_INVALID_ARGUMENT( "Invalid element access index" );
1338  }
1339  }
1340  }
1341 
1342  SmallArray<size_t,128UL> newIndices;
1343  newIndices.reserve( n );
1344 
1345  for( size_t i=0UL; i<n; ++i ) {
1346  newIndices.pushBack( e.idx( p(i) ) );
1347  }
1348 
1349  return elements( e.operand(), newIndices.data(), newIndices.size(), args... );
1350 }
1352 //*************************************************************************************************
1353 
1354 
1355 
1356 
1357 //=================================================================================================
1358 //
1359 // GLOBAL RESTRUCTURING FUNCTIONS (SUBVECTOR)
1360 //
1361 //=================================================================================================
1362 
1363 //*************************************************************************************************
1375 template< AlignmentFlag AF // Alignment flag
1376  , size_t I // Index of the first subvector element
1377  , size_t N // Size of the subvector
1378  , typename VT // Type of the vector
1379  , typename... RSAs // Optional arguments
1380  , EnableIf_t< IsElements_v< RemoveReference_t<VT> > >* = nullptr >
1381 inline decltype(auto) subvector( VT&& e, RSAs... args )
1382 {
1384 
1385  return elements( std::forward<VT>( e ), make_shifted_index_sequence<I,N>(), args... );
1386 }
1388 //*************************************************************************************************
1389 
1390 
1391 //*************************************************************************************************
1405 template< AlignmentFlag AF // Alignment flag
1406  , typename VT // Type of the vector
1407  , typename... RSAs // Optional arguments
1408  , EnableIf_t< IsElements_v< RemoveReference_t<VT> > >* = nullptr >
1409 inline decltype(auto) subvector( VT&& e, size_t index, size_t size, RSAs... args )
1410 {
1412 
1413  SmallArray<size_t,128UL> indices( size );
1414  std::iota( indices.begin(), indices.end(), index );
1415 
1416  return elements( std::forward<VT>( e ), indices.data(), indices.size(), args... );
1417 }
1419 //*************************************************************************************************
1420 
1421 
1422 
1423 
1424 //=================================================================================================
1425 //
1426 // ELEMENTS OPERATORS
1427 //
1428 //=================================================================================================
1429 
1430 //*************************************************************************************************
1438 template< typename VT // Type of the vector
1439  , bool TF // Transpose flag
1440  , bool DF // Density flag
1441  , typename... CEAs > // Compile time element arguments
1442 inline void reset( Elements<VT,TF,DF,CEAs...>& e )
1443 {
1444  e.reset();
1445 }
1447 //*************************************************************************************************
1448 
1449 
1450 //*************************************************************************************************
1458 template< typename VT // Type of the vector
1459  , bool TF // Transpose flag
1460  , bool DF // Density flag
1461  , typename... CEAs > // Compile time element arguments
1462 inline void reset( Elements<VT,TF,DF,CEAs...>&& e )
1463 {
1464  e.reset();
1465 }
1467 //*************************************************************************************************
1468 
1469 
1470 //*************************************************************************************************
1478 template< typename VT // Type of the vector
1479  , bool TF // Transpose flag
1480  , bool DF // Density flag
1481  , typename... CEAs > // Compile time element arguments
1482 inline void clear( Elements<VT,TF,DF,CEAs...>& e )
1483 {
1484  e.reset();
1485 }
1487 //*************************************************************************************************
1488 
1489 
1490 //*************************************************************************************************
1498 template< typename VT // Type of the vector
1499  , bool TF // Transpose flag
1500  , bool DF // Density flag
1501  , typename... CEAs > // Compile time element arguments
1502 inline void clear( Elements<VT,TF,DF,CEAs...>&& e )
1503 {
1504  e.reset();
1505 }
1507 //*************************************************************************************************
1508 
1509 
1510 //*************************************************************************************************
1536 template< bool RF // Relaxation flag
1537  , typename VT // Type of the dense vector
1538  , bool TF // Transpose flag
1539  , typename... CEAs > // Compile time element arguments
1540 inline bool isDefault( const Elements<VT,TF,true,CEAs...>& e )
1541 {
1542  using blaze::isDefault;
1543 
1544  for( size_t i=0UL; i<e.size(); ++i )
1545  if( !isDefault<RF>( e[i] ) ) return false;
1546  return true;
1547 }
1549 //*************************************************************************************************
1550 
1551 
1552 //*************************************************************************************************
1578 template< bool RF // Relaxation flag
1579  , typename VT // Type of the sparse vector
1580  , bool TF // Transpose flag
1581  , typename... CEAs > // Compile time element arguments
1582 inline bool isDefault( const Elements<VT,TF,false,CEAs...>& e )
1583 {
1584  using blaze::isDefault;
1585 
1586  for( const auto& element : ~e )
1587  if( !isDefault<RF>( element.value() ) ) return false;
1588  return true;
1589 }
1591 //*************************************************************************************************
1592 
1593 
1594 //*************************************************************************************************
1612 template< typename VT // Type of the vector
1613  , bool TF // Transpose flag
1614  , bool DF // Density flag
1615  , typename... CEAs > // Compile time element arguments
1616 inline bool isIntact( const Elements<VT,TF,DF,CEAs...>& e ) noexcept
1617 {
1618  return ( e.size() <= e.operand().size() && isIntact( e.operand() ) );
1619 }
1621 //*************************************************************************************************
1622 
1623 
1624 //*************************************************************************************************
1638 template< typename VT // Type of the vector
1639  , bool TF // Transpose flag
1640  , bool DF // Density flag
1641  , typename... CEAs > // Compile time element arguments
1642 inline bool isSame( const Elements<VT,TF,DF,CEAs...>& a, const Vector<VT,TF>& b ) noexcept
1643 {
1644  if( !isSame( a.operand(), ~b ) || ( a.size() != (~b).size() ) )
1645  return false;
1646 
1647  for( size_t i=0UL; i<a.size(); ++i ) {
1648  if( a.idx(i) != i )
1649  return false;
1650  }
1651 
1652  return true;
1653 }
1655 //*************************************************************************************************
1656 
1657 
1658 //*************************************************************************************************
1672 template< typename VT // Type of the vector
1673  , bool TF // Transpose flag
1674  , bool DF // Density flag
1675  , typename... CEAs > // Compile time element arguments
1676 inline bool isSame( const Vector<VT,TF>& a, const Elements<VT,TF,DF,CEAs...>& b ) noexcept
1677 {
1678  return isSame( b, a );
1679 }
1681 //*************************************************************************************************
1682 
1683 
1684 //*************************************************************************************************
1698 template< typename VT1 // Type of the left-hand side vector
1699  , bool TF // Transpose flag
1700  , bool DF // Density flag
1701  , typename... CEAs // Compile time element arguments
1702  , typename VT2 // Type of the right-hand side vector
1703  , AlignmentFlag AF // Alignment flag
1704  , size_t... CSAs > // Compile time subvector arguments
1705 inline bool isSame( const Elements<VT1,TF,DF,CEAs...>& a, const Subvector<VT2,AF,TF,DF,CSAs...>& b ) noexcept
1706 {
1707  if( !isSame( a.operand(), b.operand() ) || ( a.size() != b.size() ) )
1708  return false;
1709 
1710  for( size_t i=0UL; i<a.size(); ++i ) {
1711  if( a.idx(i) != b.offset()+i )
1712  return false;
1713  }
1714 
1715  return true;
1716 }
1718 //*************************************************************************************************
1719 
1720 
1721 //*************************************************************************************************
1735 template< typename VT1 // Type of the left-hand side vector
1736  , AlignmentFlag AF // Alignment flag
1737  , bool TF // Transpose flag
1738  , bool DF // Density flag
1739  , size_t... CSAs // Compile time subvector arguments
1740  , typename VT2 // Type of the right-hand side vector
1741  , typename... CEAs > // Compile time element arguments
1742 inline bool isSame( const Subvector<VT1,AF,TF,DF,CSAs...>& a, const Elements<VT2,TF,DF,CEAs...>& b ) noexcept
1743 {
1744  return isSame( b, a );
1745 }
1747 //*************************************************************************************************
1748 
1749 
1750 //*************************************************************************************************
1763 template< typename VT1 // Type of the vector of the left-hand side selection of elements
1764  , bool TF1 // Transpose flag of the left-hand side selection of elements
1765  , bool DF1 // Density flag of the left-hand side selection of elements
1766  , typename... CEAs1 // Compile time element arguments of the left-hand side selection of elements
1767  , typename VT2 // Type of the vector of the right-hand side selection of elements
1768  , bool TF2 // Transpose flag of the right-hand side selection of elements
1769  , bool DF2 // Density flag of the right-hand side selection of elements
1770  , typename... CEAs2 > // Compile time element arguments of the right-hand side selection of elements
1771 inline bool isSame( const Elements<VT1,TF1,DF1,CEAs1...>& a,
1772  const Elements<VT2,TF2,DF2,CEAs2...>& b ) noexcept
1773 {
1774  if( !isSame( a.operand(), b.operand() ) || a.size() != b.size() )
1775  return false;
1776 
1777  for( size_t i=0UL; i<a.size(); ++i ) {
1778  if( a.idx(i) != b.idx(i) )
1779  return false;
1780  }
1781 
1782  return true;
1783 }
1785 //*************************************************************************************************
1786 
1787 
1788 //*************************************************************************************************
1803 template< typename VT // Type of the vector
1804  , bool TF // Transpose flag
1805  , bool DF // Density flag
1806  , typename... CEAs // Compile time element arguments
1807  , typename ET > // Type of the element
1808 inline bool trySet( const Elements<VT,TF,DF,CEAs...>& e, size_t index, const ET& value )
1809 {
1810  BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
1811 
1812  return trySet( e.operand(), e.idx(index), value );
1813 }
1815 //*************************************************************************************************
1816 
1817 
1818 //*************************************************************************************************
1834 template< typename VT // Type of the vector
1835  , bool TF // Transpose flag
1836  , bool DF // Density flag
1837  , typename... CEAs // Compile time element arguments
1838  , typename ET > // Type of the element
1840  trySet( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, const ET& value )
1841 {
1842  BLAZE_INTERNAL_ASSERT( index <= (~e).size(), "Invalid vector access index" );
1843  BLAZE_INTERNAL_ASSERT( index + size <= (~e).size(), "Invalid range size" );
1844 
1845  const size_t iend( index + size );
1846 
1847  for( size_t i=index; i<iend; ++i ) {
1848  if( !trySet( e.operand(), e.idx(i), value ) )
1849  return false;
1850  }
1851 
1852  return true;
1853 }
1855 //*************************************************************************************************
1856 
1857 
1858 //*************************************************************************************************
1873 template< typename VT // Type of the vector
1874  , bool TF // Transpose flag
1875  , bool DF // Density flag
1876  , typename... CEAs // Compile time element arguments
1877  , typename ET > // Type of the element
1878 inline bool tryAdd( const Elements<VT,TF,DF,CEAs...>& e, size_t index, const ET& value )
1879 {
1880  BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
1881 
1882  return tryAdd( e.operand(), e.idx(index), value );
1883 }
1885 //*************************************************************************************************
1886 
1887 
1888 //*************************************************************************************************
1904 template< typename VT // Type of the vector
1905  , bool TF // Transpose flag
1906  , bool DF // Density flag
1907  , typename... CEAs // Compile time element arguments
1908  , typename ET > // Type of the element
1910  tryAdd( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, const ET& value )
1911 {
1912  BLAZE_INTERNAL_ASSERT( index <= (~e).size(), "Invalid vector access index" );
1913  BLAZE_INTERNAL_ASSERT( index + size <= (~e).size(), "Invalid range size" );
1914 
1915  const size_t iend( index + size );
1916 
1917  for( size_t i=index; i<iend; ++i ) {
1918  if( !tryAdd( e.operand(), e.idx(i), value ) )
1919  return false;
1920  }
1921 
1922  return true;
1923 }
1925 //*************************************************************************************************
1926 
1927 
1928 //*************************************************************************************************
1943 template< typename VT // Type of the vector
1944  , bool TF // Transpose flag
1945  , bool DF // Density flag
1946  , typename... CEAs // Compile time element arguments
1947  , typename ET > // Type of the element
1948 inline bool trySub( const Elements<VT,TF,DF,CEAs...>& e, size_t index, const ET& value )
1949 {
1950  BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
1951 
1952  return trySub( e.operand(), e.idx(index), value );
1953 }
1955 //*************************************************************************************************
1956 
1957 
1958 //*************************************************************************************************
1975 template< typename VT // Type of the vector
1976  , bool TF // Transpose flag
1977  , bool DF // Density flag
1978  , typename... CEAs // Compile time element arguments
1979  , typename ET > // Type of the element
1981  trySub( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, const ET& value )
1982 {
1983  BLAZE_INTERNAL_ASSERT( index <= (~e).size(), "Invalid vector access index" );
1984  BLAZE_INTERNAL_ASSERT( index + size <= (~e).size(), "Invalid range size" );
1985 
1986  const size_t iend( index + size );
1987 
1988  for( size_t i=index; i<iend; ++i ) {
1989  if( !trySub( e.operand(), e.idx(i), value ) )
1990  return false;
1991  }
1992 
1993  return true;
1994 }
1996 //*************************************************************************************************
1997 
1998 
1999 //*************************************************************************************************
2014 template< typename VT // Type of the vector
2015  , bool TF // Transpose flag
2016  , bool DF // Density flag
2017  , typename... CEAs // Compile time element arguments
2018  , typename ET > // Type of the element
2019 inline bool tryMult( const Elements<VT,TF,DF,CEAs...>& e, size_t index, const ET& value )
2020 {
2021  BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
2022 
2023  return tryMult( e.operand(), e.idx(index), value );
2024 }
2026 //*************************************************************************************************
2027 
2028 
2029 //*************************************************************************************************
2045 template< typename VT // Type of the vector
2046  , bool TF // Transpose flag
2047  , bool DF // Density flag
2048  , typename... CEAs // Compile time element arguments
2049  , typename ET > // Type of the element
2051  tryMult( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, const ET& value )
2052 {
2053  BLAZE_INTERNAL_ASSERT( index <= (~e).size(), "Invalid vector access index" );
2054  BLAZE_INTERNAL_ASSERT( index + size <= (~e).size(), "Invalid range size" );
2055 
2056  const size_t iend( index + size );
2057 
2058  for( size_t i=index; i<iend; ++i ) {
2059  if( !tryMult( e.operand(), e.idx(i), value ) )
2060  return false;
2061  }
2062 
2063  return true;
2064 }
2066 //*************************************************************************************************
2067 
2068 
2069 //*************************************************************************************************
2084 template< typename VT // Type of the vector
2085  , bool TF // Transpose flag
2086  , bool DF // Density flag
2087  , typename... CEAs // Compile time element arguments
2088  , typename ET > // Type of the element
2089 inline bool tryDiv( const Elements<VT,TF,DF,CEAs...>& e, size_t index, const ET& value )
2090 {
2091  BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
2092 
2093  return tryDiv( e.operand(), e.idx(index), value );
2094 }
2096 //*************************************************************************************************
2097 
2098 
2099 //*************************************************************************************************
2115 template< typename VT // Type of the vector
2116  , bool TF // Transpose flag
2117  , bool DF // Density flag
2118  , typename... CEAs // Compile time element arguments
2119  , typename ET > // Type of the element
2121  tryDiv( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, const ET& value )
2122 {
2123  BLAZE_INTERNAL_ASSERT( index <= (~e).size(), "Invalid vector access index" );
2124  BLAZE_INTERNAL_ASSERT( index + size <= (~e).size(), "Invalid range size" );
2125 
2126  const size_t iend( index + size );
2127 
2128  for( size_t i=index; i<iend; ++i ) {
2129  if( !tryDiv( e.operand(), e.idx(i), value ) )
2130  return false;
2131  }
2132 
2133  return true;
2134 }
2136 //*************************************************************************************************
2137 
2138 
2139 //*************************************************************************************************
2154 template< typename VT // Type of the vector
2155  , bool TF // Transpose flag
2156  , bool DF // Density flag
2157  , typename... CEAs > // Compile time element arguments
2158 inline bool tryShift( const Elements<VT,TF,DF,CEAs...>& e, size_t index, int count )
2159 {
2160  BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
2161 
2162  return tryShift( e.operand(), e.idx(index), count );
2163 }
2165 //*************************************************************************************************
2166 
2167 
2168 //*************************************************************************************************
2184 template< typename VT // Type of the vector
2185  , bool TF // Transpose flag
2186  , bool DF // Density flag
2187  , typename... CEAs > // Compile time element arguments
2189  tryShift( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, int count )
2190 {
2191  BLAZE_INTERNAL_ASSERT( index <= (~e).size(), "Invalid vector access index" );
2192  BLAZE_INTERNAL_ASSERT( index + size <= (~e).size(), "Invalid range size" );
2193 
2194  const size_t iend( index + size );
2195 
2196  for( size_t i=index; i<iend; ++i ) {
2197  if( !tryShift( e.operand(), e.idx(i), count ) )
2198  return false;
2199  }
2200 
2201  return true;
2202 }
2204 //*************************************************************************************************
2205 
2206 
2207 //*************************************************************************************************
2223 template< typename VT // Type of the vector
2224  , bool TF // Transpose flag
2225  , bool DF // Density flag
2226  , typename... CEAs // Compile time element arguments
2227  , typename ET > // Type of the element
2228 inline bool tryBitand( const Elements<VT,TF,DF,CEAs...>& e, size_t index, const ET& value )
2229 {
2230  BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
2231 
2232  return tryBitand( e.operand(), e.idx(index), value );
2233 }
2235 //*************************************************************************************************
2236 
2237 
2238 //*************************************************************************************************
2255 template< typename VT // Type of the vector
2256  , bool TF // Transpose flag
2257  , bool DF // Density flag
2258  , typename... CEAs // Compile time element arguments
2259  , typename ET > // Type of the element
2261  tryBitand( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, const ET& value )
2262 {
2263  BLAZE_INTERNAL_ASSERT( index <= (~e).size(), "Invalid vector access index" );
2264  BLAZE_INTERNAL_ASSERT( index + size <= (~e).size(), "Invalid range size" );
2265 
2266  const size_t iend( index + size );
2267 
2268  for( size_t i=index; i<iend; ++i ) {
2269  if( !tryBitand( e.operand(), e.idx(i), value ) )
2270  return false;
2271  }
2272 
2273  return true;
2274 }
2276 //*************************************************************************************************
2277 
2278 
2279 //*************************************************************************************************
2295 template< typename VT // Type of the vector
2296  , bool TF // Transpose flag
2297  , bool DF // Density flag
2298  , typename... CEAs // Compile time element arguments
2299  , typename ET > // Type of the element
2300 inline bool tryBitor( const Elements<VT,TF,DF,CEAs...>& e, size_t index, const ET& value )
2301 {
2302  BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
2303 
2304  return tryBitor( e.operand(), e.idx(index), value );
2305 }
2307 //*************************************************************************************************
2308 
2309 
2310 //*************************************************************************************************
2327 template< typename VT // Type of the vector
2328  , bool TF // Transpose flag
2329  , bool DF // Density flag
2330  , typename... CEAs // Compile time element arguments
2331  , typename ET > // Type of the element
2333  tryBitor( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, const ET& value )
2334 {
2335  BLAZE_INTERNAL_ASSERT( index <= (~e).size(), "Invalid vector access index" );
2336  BLAZE_INTERNAL_ASSERT( index + size <= (~e).size(), "Invalid range size" );
2337 
2338  const size_t iend( index + size );
2339 
2340  for( size_t i=index; i<iend; ++i ) {
2341  if( !tryBitor( e.operand(), e.idx(i), value ) )
2342  return false;
2343  }
2344 
2345  return true;
2346 }
2348 //*************************************************************************************************
2349 
2350 
2351 //*************************************************************************************************
2367 template< typename VT // Type of the vector
2368  , bool TF // Transpose flag
2369  , bool DF // Density flag
2370  , typename... CEAs // Compile time element arguments
2371  , typename ET > // Type of the element
2372 inline bool tryBitxor( const Elements<VT,TF,DF,CEAs...>& e, size_t index, const ET& value )
2373 {
2374  BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
2375 
2376  return tryBitxor( e.operand(), e.idx(index), value );
2377 }
2379 //*************************************************************************************************
2380 
2381 
2382 //*************************************************************************************************
2399 template< typename VT // Type of the vector
2400  , bool TF // Transpose flag
2401  , bool DF // Density flag
2402  , typename... CEAs // Compile time element arguments
2403  , typename ET > // Type of the element
2405  tryBitxor( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, const ET& value )
2406 {
2407  BLAZE_INTERNAL_ASSERT( index <= (~e).size(), "Invalid vector access index" );
2408  BLAZE_INTERNAL_ASSERT( index + size <= (~e).size(), "Invalid range size" );
2409 
2410  const size_t iend( index + size );
2411 
2412  for( size_t i=index; i<iend; ++i ) {
2413  if( !tryBitxor( e.operand(), e.idx(i), value ) )
2414  return false;
2415  }
2416 
2417  return true;
2418 }
2420 //*************************************************************************************************
2421 
2422 
2423 //*************************************************************************************************
2438 template< typename VT1 // Type of the vector
2439  , bool TF // Transpose flag
2440  , bool DF // Density flag
2441  , typename... CEAs // Compile time element arguments
2442  , typename VT2 > // Type of the right-hand side vector
2443 inline bool tryAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2444  const Vector<VT2,TF>& rhs, size_t index )
2445 {
2446  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2447  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2448 
2449  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2450  if( !trySet( lhs.operand(), lhs.idx(i+index), (~rhs)[i] ) )
2451  return false;
2452  }
2453 
2454  return true;
2455 }
2457 //*************************************************************************************************
2458 
2459 
2460 //*************************************************************************************************
2476 template< typename VT1 // Type of the vector
2477  , bool TF // Transpose flag
2478  , bool DF // Density flag
2479  , typename... CEAs // Compile time element arguments
2480  , typename VT2 > // Type of the right-hand side vector
2481 inline bool tryAddAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2482  const Vector<VT2,TF>& rhs, size_t index )
2483 {
2484  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2485  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2486 
2487  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2488  if( !tryAdd( lhs.operand(), lhs.idx(i+index), (~rhs)[i] ) )
2489  return false;
2490  }
2491 
2492  return true;
2493 }
2495 //*************************************************************************************************
2496 
2497 
2498 //*************************************************************************************************
2514 template< typename VT1 // Type of the vector
2515  , bool TF // Transpose flag
2516  , bool DF // Density flag
2517  , typename... CEAs // Compile time element arguments
2518  , typename VT2 > // Type of the right-hand side vector
2519 inline bool trySubAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2520  const Vector<VT2,TF>& rhs, size_t index )
2521 {
2522  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2523  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2524 
2525  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2526  if( !trySub( lhs.operand(), lhs.idx(i+index), (~rhs)[i] ) )
2527  return false;
2528  }
2529 
2530  return true;
2531 }
2533 //*************************************************************************************************
2534 
2535 
2536 //*************************************************************************************************
2552 template< typename VT1 // Type of the vector
2553  , bool TF // Transpose flag
2554  , bool DF // Density flag
2555  , typename... CEAs // Compile time element arguments
2556  , typename VT2 > // Type of the right-hand side vector
2557 inline bool tryMultAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2558  const Vector<VT2,TF>& rhs, size_t index )
2559 {
2560  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2561  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2562 
2563  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2564  if( !tryMult( lhs.operand(), lhs.idx(i+index), (~rhs)[i] ) )
2565  return false;
2566  }
2567 
2568  return true;
2569 }
2571 //*************************************************************************************************
2572 
2573 
2574 //*************************************************************************************************
2590 template< typename VT1 // Type of the vector
2591  , bool TF // Transpose flag
2592  , bool DF // Density flag
2593  , typename... CEAs // Compile time element arguments
2594  , typename VT2 > // Type of the right-hand side vector
2595 inline bool tryDivAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2596  const Vector<VT2,TF>& rhs, size_t index )
2597 {
2598  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2599  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2600 
2601  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2602  if( !tryDiv( lhs.operand(), lhs.idx(i+index), (~rhs)[i] ) )
2603  return false;
2604  }
2605 
2606  return true;
2607 }
2609 //*************************************************************************************************
2610 
2611 
2612 //*************************************************************************************************
2628 template< typename VT1 // Type of the vector
2629  , bool TF // Transpose flag
2630  , bool DF // Density flag
2631  , typename... CEAs // Compile time element arguments
2632  , typename VT2 > // Type of the right-hand side vector
2633 inline bool tryShiftAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2634  const Vector<VT2,TF>& rhs, size_t index )
2635 {
2636  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2637  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2638 
2639  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2640  if( !tryShift( lhs.operand(), lhs.idx(i+index), (~rhs)[i] ) )
2641  return false;
2642  }
2643 
2644  return true;
2645 }
2647 //*************************************************************************************************
2648 
2649 
2650 //*************************************************************************************************
2666 template< typename VT1 // Type of the vector
2667  , bool TF // Transpose flag
2668  , bool DF // Density flag
2669  , typename... CEAs // Compile time element arguments
2670  , typename VT2 > // Type of the right-hand side vector
2671 inline bool tryBitandAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2672  const Vector<VT2,TF>& rhs, size_t index )
2673 {
2674  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2675  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2676 
2677  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2678  if( !tryBitand( lhs.operand(), lhs.idx(i+index), (~rhs)[i] ) )
2679  return false;
2680  }
2681 
2682  return true;
2683 }
2685 //*************************************************************************************************
2686 
2687 
2688 //*************************************************************************************************
2704 template< typename VT1 // Type of the vector
2705  , bool TF // Transpose flag
2706  , bool DF // Density flag
2707  , typename... CEAs // Compile time element arguments
2708  , typename VT2 > // Type of the right-hand side vector
2709 inline bool tryBitorAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2710  const Vector<VT2,TF>& rhs, size_t index )
2711 {
2712  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2713  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2714 
2715  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2716  if( !tryBitor( lhs.operand(), lhs.idx(i+index), (~rhs)[i] ) )
2717  return false;
2718  }
2719 
2720  return true;
2721 }
2723 //*************************************************************************************************
2724 
2725 
2726 //*************************************************************************************************
2742 template< typename VT1 // Type of the vector
2743  , bool TF // Transpose flag
2744  , bool DF // Density flag
2745  , typename... CEAs // Compile time element arguments
2746  , typename VT2 > // Type of the right-hand side vector
2747 inline bool tryBitxorAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2748  const Vector<VT2,TF>& rhs, size_t index )
2749 {
2750  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2751  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2752 
2753  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2754  if( !tryBitxor( lhs.operand(), lhs.idx(i+index), (~rhs)[i] ) )
2755  return false;
2756  }
2757 
2758  return true;
2759 }
2761 //*************************************************************************************************
2762 
2763 
2764 //*************************************************************************************************
2779 template< typename VT // Type of the vector
2780  , bool TF // Transpose flag
2781  , bool DF // Density flag
2782  , typename... CEAs > // Compile time element arguments
2783 inline decltype(auto) derestrict( Elements<VT,TF,DF,CEAs...>& e )
2784 {
2785  return elements( derestrict( e.operand() ), e.idces(), unchecked );
2786 }
2788 //*************************************************************************************************
2789 
2790 
2791 //*************************************************************************************************
2806 template< typename VT // Type of the vector
2807  , bool TF // Transpose flag
2808  , bool DF // Density flag
2809  , typename... CEAs > // Compile time element arguments
2810 inline decltype(auto) derestrict( Elements<VT,TF,DF,CEAs...>&& e )
2811 {
2812  return elements( derestrict( e.operand() ), e.idces(), unchecked );
2813 }
2815 //*************************************************************************************************
2816 
2817 
2818 
2819 
2820 //=================================================================================================
2821 //
2822 // SIZE SPECIALIZATIONS
2823 //
2824 //=================================================================================================
2825 
2826 //*************************************************************************************************
2828 template< typename VT, bool TF, bool DF, size_t I, size_t... Is, typename... CEAs >
2829 struct Size< Elements<VT,TF,DF,index_sequence<I,Is...>,CEAs...>, 0UL >
2830  : public Ptrdiff_t<1UL+sizeof...(Is)>
2831 {};
2833 //*************************************************************************************************
2834 
2835 
2836 
2837 
2838 //=================================================================================================
2839 //
2840 // MAXSIZE SPECIALIZATIONS
2841 //
2842 //=================================================================================================
2843 
2844 //*************************************************************************************************
2846 template< typename VT, bool TF, bool DF, size_t I, size_t... Is, typename... CEAs >
2847 struct MaxSize< Elements<VT,TF,DF,index_sequence<I,Is...>,CEAs...>, 0UL >
2848  : public Ptrdiff_t<1UL+sizeof...(Is)>
2849 {};
2851 //*************************************************************************************************
2852 
2853 
2854 
2855 
2856 //=================================================================================================
2857 //
2858 // ISRESTRICTED SPECIALIZATIONS
2859 //
2860 //=================================================================================================
2861 
2862 //*************************************************************************************************
2864 template< typename VT, bool TF, bool DF, typename... CEAs >
2865 struct IsRestricted< Elements<VT,TF,DF,CEAs...> >
2866  : public IsRestricted<VT>
2867 {};
2869 //*************************************************************************************************
2870 
2871 
2872 
2873 
2874 //=================================================================================================
2875 //
2876 // HASCONSTDATAACCESS SPECIALIZATIONS
2877 //
2878 //=================================================================================================
2879 
2880 //*************************************************************************************************
2882 template< typename VT, bool TF, typename... CEAs >
2883 struct HasConstDataAccess< Elements<VT,TF,true,CEAs...> >
2884  : public HasConstDataAccess<VT>
2885 {};
2887 //*************************************************************************************************
2888 
2889 
2890 
2891 
2892 //=================================================================================================
2893 //
2894 // HASMUTABLEDATAACCESS SPECIALIZATIONS
2895 //
2896 //=================================================================================================
2897 
2898 //*************************************************************************************************
2900 template< typename VT, bool TF, typename... CEAs >
2901 struct HasMutableDataAccess< Elements<VT,TF,true,CEAs...> >
2902  : public HasMutableDataAccess<VT>
2903 {};
2905 //*************************************************************************************************
2906 
2907 } // namespace blaze
2908 
2909 #endif
AlignmentFlag
Alignment flag for (un-)aligned vectors and matrices.Via these flags it is possible to specify subvec...
Definition: AlignmentFlag.h:62
#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.
Header file for the blaze::checked and blaze::unchecked instances.
Header file for the alignment flag values.
Header file for the VecVecDivExpr base class.
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.
IntegralConstant< ptrdiff_t, N > Ptrdiff_t
Compile time integral constant wrapper for ptrdiff_t.The Ptrdiff_t alias template represents an integ...
Definition: IntegralConstant.h:237
Header file for the serial shim.
Header file for the IsElements type trait.
Header file for the VecMapExpr base class.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
Header file for the VecScalarDivExpr base class.
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
decltype(auto) subvector(Vector< VT, TF > &, RSAs...)
Creating a view on a specific subvector of the given vector.
Definition: Subvector.h:154
Header file for the MAYBE_UNUSED function template.
Header file for the extended initializer_list functionality.
Index sequence type of the Blaze library.
Header file for the VecEvalExpr base class.
Header file for the VecScalarMultExpr base class.
Header file for the MaxSize type trait.
Header file for the VecVecMapExpr base class.
Elements specialization for sparse vectors.
Header file for the SmallArray implementation.
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
Compile time assertion.
Header file for the VecVecAddExpr base class.
Implementation of a dynamic array with small array optimization.The SmallArray class template is a hy...
Definition: SmallArray.h:81
constexpr bool Contains_v
Auxiliary variable template for the Contains type trait.The Contains_v variable template provides a c...
Definition: Contains.h:138
Header file for the VecVecKronExpr base class.
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
Header file for the implementation of the Elements base template.
decltype(auto) eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:786
decltype(auto) elements(Vector< VT, TF > &vector, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition: Elements.h:139
Header file for the exception macros of the math module.
Header file for the VecVecMultExpr base class.
Header file for the VecVecSubExpr base class.
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:615
Header file for the CrossExpr base class.
Header file for the HasConstDataAccess type trait.
Header file for the VecSerialExpr base class.
Header file for the VecTransExpr base class.
Header file for run time assertion macros.
Header file for the Unique class template.
Check< false > Unchecked
Type of the blaze::unchecked instance.blaze::Unchecked is the type of the blaze::unchecked instance,...
Definition: Check.h:96
Header file for the IsPointer type trait.
#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
Header file for the isDefault shim.
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
Header file for the integer_sequence and index_sequence aliases.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
Header file for the HasMutableDataAccess type trait.
Header file for the RemoveReference type trait.
Elements specialization for dense vectors.
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:198
Initializer list type of the Blaze library.
Header file for the IntegralConstant class template.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:635
Header file for the IsRestricted type trait.
Header file for the Vector CRTP base class.
Header file for the Size 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
Header file for the function trace functionality.
decltype(auto) map(const DenseMatrix< MT1, SO > &lhs, const DenseMatrix< MT2, SO > &rhs, OP op)
Evaluates the given binary operation on each single element of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1121