Blaze  3.6
Subvector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_SUBVECTOR_H_
36 #define _BLAZE_MATH_VIEWS_SUBVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <blaze/math/Aliases.h>
46 #include <blaze/math/Exception.h>
72 #include <blaze/math/views/Check.h>
76 #include <blaze/util/Assert.h>
77 #include <blaze/util/EnableIf.h>
80 #include <blaze/util/SmallArray.h>
82 #include <blaze/util/TypeList.h>
83 #include <blaze/util/Types.h>
85 
86 
87 namespace blaze {
88 
89 //=================================================================================================
90 //
91 // GLOBAL FUNCTIONS
92 //
93 //=================================================================================================
94 
95 //*************************************************************************************************
149 template< size_t I // Index of the first subvector element
150  , size_t N // Size of the subvector
151  , typename VT // Type of the vector
152  , bool TF // Transpose flag
153  , typename... RSAs > // Optional subvector arguments
154 inline decltype(auto) subvector( Vector<VT,TF>& vector, RSAs... args )
155 {
157 
158  return subvector<unaligned,I,N>( ~vector, args... );
159 }
160 //*************************************************************************************************
161 
162 
163 //*************************************************************************************************
217 template< size_t I // Index of the first subvector element
218  , size_t N // Size of the subvector
219  , typename VT // Type of the vector
220  , bool TF // Transpose flag
221  , typename... RSAs > // Optional subvector arguments
222 inline decltype(auto) subvector( const Vector<VT,TF>& vector, RSAs... args )
223 {
225 
226  return subvector<unaligned,I,N>( ~vector, args... );
227 }
228 //*************************************************************************************************
229 
230 
231 //*************************************************************************************************
245 template< size_t I // Index of the first subvector element
246  , size_t N // Size of the subvector
247  , typename VT // Type of the vector
248  , bool TF // Transpose flag
249  , typename... RSAs > // Optional subvector arguments
250 inline decltype(auto) subvector( Vector<VT,TF>&& vector, RSAs... args )
251 {
253 
254  return subvector<unaligned,I,N>( std::move( ~vector ), args... );
255 }
256 //*************************************************************************************************
257 
258 
259 //*************************************************************************************************
325 template< AlignmentFlag AF // Alignment flag
326  , size_t I // Index of the first subvector element
327  , size_t N // Size of the subvector
328  , typename VT // Type of the vector
329  , bool TF // Transpose flag
330  , typename... RSAs > // Optional subvector arguments
331 inline decltype(auto) subvector( Vector<VT,TF>& vector, RSAs... args )
332 {
334 
335  using ReturnType = Subvector_<VT,AF,I,N>;
336  return ReturnType( ~vector, args... );
337 }
338 //*************************************************************************************************
339 
340 
341 //*************************************************************************************************
405 template< AlignmentFlag AF // Alignment flag
406  , size_t I // Index of the first subvector element
407  , size_t N // Size of the subvector
408  , typename VT // Type of the vector
409  , bool TF // Transpose flag
410  , typename... RSAs > // Optional subvector arguments
411 inline decltype(auto) subvector( const Vector<VT,TF>& vector, RSAs... args )
412 {
414 
415  using ReturnType = const Subvector_<const VT,AF,I,N>;
416  return ReturnType( ~vector, args... );
417 }
418 //*************************************************************************************************
419 
420 
421 //*************************************************************************************************
437 template< AlignmentFlag AF // Alignment flag
438  , size_t I // Index of the first subvector element
439  , size_t N // Size of the subvector
440  , typename VT // Type of the vector
441  , bool TF // Transpose flag
442  , typename... RSAs > // Optional subvector arguments
443 inline decltype(auto) subvector( Vector<VT,TF>&& vector, RSAs... args )
444 {
446 
447  using ReturnType = Subvector_<VT,AF,I,N>;
448  return ReturnType( ~vector, args... );
449 }
450 //*************************************************************************************************
451 
452 
453 //*************************************************************************************************
509 template< typename VT // Type of the vector
510  , bool TF // Transpose flag
511  , typename... RSAs > // Optional subvector arguments
512 inline decltype(auto) subvector( Vector<VT,TF>& vector, size_t index, size_t size, RSAs... args )
513 {
515 
516  return subvector<unaligned>( ~vector, index, size, args... );
517 }
518 //*************************************************************************************************
519 
520 
521 //*************************************************************************************************
577 template< typename VT // Type of the vector
578  , bool TF // Transpose flag
579  , typename... RSAs > // Optional subvector arguments
580 inline decltype(auto) subvector( const Vector<VT,TF>& vector, size_t index, size_t size, RSAs... args )
581 {
583 
584  return subvector<unaligned>( ~vector, index, size, args... );
585 }
586 //*************************************************************************************************
587 
588 
589 //*************************************************************************************************
605 template< typename VT // Type of the vector
606  , bool TF // Transpose flag
607  , typename... RSAs > // Optional subvector arguments
608 inline decltype(auto) subvector( Vector<VT,TF>&& vector, size_t index, size_t size, RSAs... args )
609 {
611 
612  return subvector<unaligned>( std::move( ~vector ), index, size, args... );
613 }
614 //*************************************************************************************************
615 
616 
617 //*************************************************************************************************
685 template< AlignmentFlag AF // Alignment flag
686  , typename VT // Type of the vector
687  , bool TF // Transpose flag
688  , typename... RSAs > // Optional subvector arguments
689 inline decltype(auto) subvector( Vector<VT,TF>& vector, size_t index, size_t size, RSAs... args )
690 {
692 
693  using ReturnType = Subvector_<VT,AF>;
694  return ReturnType( ~vector, index, size, args... );
695 }
696 //*************************************************************************************************
697 
698 
699 //*************************************************************************************************
765 template< AlignmentFlag AF // Alignment flag
766  , typename VT // Type of the vector
767  , bool TF // Transpose flag
768  , typename... RSAs > // Optional subvector arguments
769 inline decltype(auto) subvector( const Vector<VT,TF>& vector, size_t index, size_t size, RSAs... args )
770 {
772 
773  using ReturnType = const Subvector_<const VT,AF>;
774  return ReturnType( ~vector, index, size, args... );
775 }
776 //*************************************************************************************************
777 
778 
779 //*************************************************************************************************
797 template< AlignmentFlag AF // Alignment flag
798  , typename VT // Type of the vector
799  , bool TF // Transpose flag
800  , typename... RSAs > // Optional subvector arguments
801 inline decltype(auto) subvector( Vector<VT,TF>&& vector, size_t index, size_t size, RSAs... args )
802 {
804 
805  using ReturnType = Subvector_<VT,AF>;
806  return ReturnType( ~vector, index, size, args... );
807 }
808 //*************************************************************************************************
809 
810 
811 
812 
813 //=================================================================================================
814 //
815 // GLOBAL RESTRUCTURING FUNCTIONS
816 //
817 //=================================================================================================
818 
819 //*************************************************************************************************
831 template< AlignmentFlag AF // Alignment flag
832  , size_t... CSAs // Compile time subvector arguments
833  , typename VT // Vector base type of the expression
834  , typename... RSAs > // Runtime subvector arguments
835 inline decltype(auto) subvector( const VecVecAddExpr<VT>& vector, RSAs... args )
836 {
838 
839  return subvector<AF,CSAs...>( (~vector).leftOperand(), args... ) +
840  subvector<AF,CSAs...>( (~vector).rightOperand(), args... );
841 }
843 //*************************************************************************************************
844 
845 
846 //*************************************************************************************************
858 template< AlignmentFlag AF // Alignment flag
859  , size_t... CSAs // Compile time subvector arguments
860  , typename VT // Vector base type of the expression
861  , typename... RSAs > // Runtime subvector arguments
862 inline decltype(auto) subvector( const VecVecSubExpr<VT>& vector, RSAs... args )
863 {
865 
866  return subvector<AF,CSAs...>( (~vector).leftOperand(), args... ) -
867  subvector<AF,CSAs...>( (~vector).rightOperand(), args... );
868 }
870 //*************************************************************************************************
871 
872 
873 //*************************************************************************************************
885 template< AlignmentFlag AF // Alignment flag
886  , size_t... CSAs // Compile time subvector arguments
887  , typename VT // Vector base type of the expression
888  , typename... RSAs > // Runtime subvector arguments
889 inline decltype(auto) subvector( const VecVecMultExpr<VT>& vector, RSAs... args )
890 {
892 
893  return subvector<AF,CSAs...>( (~vector).leftOperand(), args... ) *
894  subvector<AF,CSAs...>( (~vector).rightOperand(), args... );
895 }
897 //*************************************************************************************************
898 
899 
900 //*************************************************************************************************
912 template< AlignmentFlag AF // Alignment flag
913  , size_t I // Index of the first subvector element
914  , size_t N // Size of the subvector
915  , typename VT // Vector base type of the expression
916  , typename... RSAs > // Optional subvector arguments
917 inline decltype(auto) subvector( const VecVecKronExpr<VT>& vector, RSAs... args )
918 {
920 
921  return elements( ~vector, make_shifted_index_sequence<I,N>(), args... );
922 }
924 //*************************************************************************************************
925 
926 
927 //*************************************************************************************************
941 template< AlignmentFlag AF // Alignment flag
942  , typename VT // Vector base type of the expression
943  , typename... RSAs > // Optional subvector arguments
944 inline decltype(auto) subvector( const VecVecKronExpr<VT>& vector, size_t index, size_t size, RSAs... args )
945 {
947 
948  return elements( ~vector, [index]( size_t i ){ return i+index; }, size, args... );
949 }
951 //*************************************************************************************************
952 
953 
954 //*************************************************************************************************
966 template< AlignmentFlag AF // Alignment flag
967  , size_t... CSAs // Compile time subvector arguments
968  , typename VT // Vector base type of the expression
969  , typename... RSAs > // Runtime subvector arguments
970 inline decltype(auto) subvector( const VecVecDivExpr<VT>& vector, RSAs... args )
971 {
973 
974  return subvector<AF,CSAs...>( (~vector).leftOperand(), args... ) /
975  subvector<AF,CSAs...>( (~vector).rightOperand(), args... );
976 }
978 //*************************************************************************************************
979 
980 
981 //*************************************************************************************************
993 template< AlignmentFlag AF // Alignment flag
994  , size_t... CSAs // Compile time subvector arguments
995  , typename VT // Vector base type of the expression
996  , typename... RSAs > // Runtime subvector arguments
997 inline decltype(auto) subvector( const CrossExpr<VT>& vector, RSAs... args )
998 {
1000 
1001  using ReturnType = Subvector_< VectorType_t<VT>, unaligned, CSAs... >;
1002  return ReturnType( ~vector, args... );
1003 }
1005 //*************************************************************************************************
1006 
1007 
1008 //*************************************************************************************************
1020 template< AlignmentFlag AF // Alignment flag
1021  , size_t... CSAs // Compile time subvector arguments
1022  , typename VT // Vector base type of the expression
1023  , typename... RSAs > // Runtime subvector arguments
1024 inline decltype(auto) subvector( const VecScalarMultExpr<VT>& vector, RSAs... args )
1025 {
1027 
1028  return subvector<AF,CSAs...>( (~vector).leftOperand(), args... ) * (~vector).rightOperand();
1029 }
1031 //*************************************************************************************************
1032 
1033 
1034 //*************************************************************************************************
1046 template< AlignmentFlag AF // Alignment flag
1047  , size_t... CSAs // Compile time subvector arguments
1048  , typename VT // Vector base type of the expression
1049  , typename... RSAs > // Runtime subvector arguments
1050 inline decltype(auto) subvector( const VecScalarDivExpr<VT>& vector, RSAs... args )
1051 {
1053 
1054  return subvector<AF,CSAs...>( (~vector).leftOperand(), args... ) / (~vector).rightOperand();
1055 }
1057 //*************************************************************************************************
1058 
1059 
1060 //*************************************************************************************************
1072 template< AlignmentFlag AF // Alignment flag
1073  , size_t... CSAs // Compile time subvector arguments
1074  , typename VT // Vector base type of the expression
1075  , typename... RSAs > // Runtime subvector arguments
1076 inline decltype(auto) subvector( const VecMapExpr<VT>& vector, RSAs... args )
1077 {
1079 
1080  return map( subvector<AF,CSAs...>( (~vector).operand(), args... ), (~vector).operation() );
1081 }
1083 //*************************************************************************************************
1084 
1085 
1086 //*************************************************************************************************
1098 template< AlignmentFlag AF // Alignment flag
1099  , size_t... CSAs // Compile time subvector arguments
1100  , typename VT // Vector base type of the expression
1101  , typename... RSAs > // Runtime subvector arguments
1102 inline decltype(auto) subvector( const VecVecMapExpr<VT>& vector, RSAs... args )
1103 {
1105 
1106  return map( subvector<AF,CSAs...>( (~vector).leftOperand(), args... ),
1107  subvector<AF,CSAs...>( (~vector).rightOperand(), args... ),
1108  (~vector).operation() );
1109 }
1111 //*************************************************************************************************
1112 
1113 
1114 //*************************************************************************************************
1126 template< AlignmentFlag AF // Alignment flag
1127  , size_t... CSAs // Compile time subvector arguments
1128  , typename VT // Vector base type of the expression
1129  , typename... RSAs > // Runtime subvector arguments
1130 inline decltype(auto) subvector( const VecEvalExpr<VT>& vector, RSAs... args )
1131 {
1133 
1134  return eval( subvector<AF,CSAs...>( (~vector).operand(), args... ) );
1135 }
1137 //*************************************************************************************************
1138 
1139 
1140 //*************************************************************************************************
1152 template< AlignmentFlag AF // Alignment flag
1153  , size_t... CSAs // Compile time subvector arguments
1154  , typename VT // Vector base type of the expression
1155  , typename... RSAs > // Runtime subvector arguments
1156 inline decltype(auto) subvector( const VecSerialExpr<VT>& vector, RSAs... args )
1157 {
1159 
1160  return serial( subvector<AF,CSAs...>( (~vector).operand(), args... ) );
1161 }
1163 //*************************************************************************************************
1164 
1165 
1166 //*************************************************************************************************
1178 template< AlignmentFlag AF // Alignment flag
1179  , size_t... CSAs // Compile time subvector arguments
1180  , typename VT // Vector base type of the expression
1181  , typename... RSAs > // Runtime subvector arguments
1182 inline decltype(auto) subvector( const VecTransExpr<VT>& vector, RSAs... args )
1183 {
1185 
1186  return trans( subvector<AF,CSAs...>( (~vector).operand(), args... ) );
1187 }
1189 //*************************************************************************************************
1190 
1191 
1192 
1193 
1194 //=================================================================================================
1195 //
1196 // GLOBAL RESTRUCTURING FUNCTIONS (SUBVECTOR)
1197 //
1198 //=================================================================================================
1199 
1200 //*************************************************************************************************
1211 template< AlignmentFlag AF // Required alignment flag
1212  , size_t I // Required subvector offset
1213  , size_t N // Required size of the subvector
1214  , typename VT // Type of the vector
1215  , typename... RSAs // Optional subvector arguments
1216  , EnableIf_t< IsSubvector_v< RemoveReference_t<VT> > &&
1217  RemoveReference_t<VT>::compileTimeArgs >* = nullptr >
1218 inline decltype(auto) subvector( VT&& sv, RSAs... args )
1219 {
1221 
1222  constexpr size_t I2( RemoveReference_t<VT>::offset() );
1223  constexpr size_t N2( RemoveReference_t<VT>::size() );
1224 
1225  BLAZE_STATIC_ASSERT_MSG( I + N <= N2, "Invalid subvector specification" );
1226 
1227  return subvector<AF,I+I2,N>( sv.operand(), args... );
1228 }
1230 //*************************************************************************************************
1231 
1232 
1233 //*************************************************************************************************
1245 template< AlignmentFlag AF // Required alignment flag
1246  , size_t I // Index of the first subvector element
1247  , size_t N // Size of the subvector
1248  , typename VT // Type of the vector
1249  , typename... RSAs // Optional subvector arguments
1250  , EnableIf_t< IsSubvector_v< RemoveReference_t<VT> > &&
1251  !RemoveReference_t<VT>::compileTimeArgs >* = nullptr >
1252 inline decltype(auto) subvector( VT&& sv, RSAs... args )
1253 {
1255 
1256  constexpr bool isChecked( !Contains_v< TypeList<RSAs...>, Unchecked > );
1257 
1258  if( isChecked ) {
1259  if( I + N > sv.size() ) {
1260  BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
1261  }
1262  }
1263  else {
1264  BLAZE_USER_ASSERT( I + N <= sv.size(), "Invalid subvector specification" );
1265  }
1266 
1267  return subvector<AF>( sv.operand(), sv.offset() + I, N, args... );
1268 }
1270 //*************************************************************************************************
1271 
1272 
1273 //*************************************************************************************************
1287 template< AlignmentFlag AF // Required alignment flag
1288  , typename VT // Type of the vector
1289  , typename... RSAs // Optional subvector arguments
1290  , EnableIf_t< IsSubvector_v< RemoveReference_t<VT> > >* = nullptr >
1291 inline decltype(auto)
1292  subvector( VT&& sv, size_t index, size_t size, RSAs... args )
1293 {
1295 
1296  constexpr bool isChecked( !Contains_v< TypeList<RSAs...>, Unchecked > );
1297 
1298  if( isChecked ) {
1299  if( index + size > sv.size() ) {
1300  BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
1301  }
1302  }
1303  else {
1304  BLAZE_USER_ASSERT( index + size <= sv.size(), "Invalid subvector specification" );
1305  }
1306 
1307  return subvector<AF>( sv.operand(), sv.offset() + index, size, args... );
1308 }
1310 //*************************************************************************************************
1311 
1312 
1313 
1314 
1315 //=================================================================================================
1316 //
1317 // GLOBAL RESTRUCTURING FUNCTIONS (ELEMENTS)
1318 //
1319 //=================================================================================================
1320 
1321 //*************************************************************************************************
1333 template< size_t I // First element index
1334  , size_t... Is // Remaining element indices
1335  , typename VT // Type of the vector
1336  , typename... REAs // Optional element arguments
1337  , EnableIf_t< IsSubvector_v< RemoveReference_t<VT> > &&
1338  RemoveReference_t<VT>::compileTimeArgs >* = nullptr >
1339 inline decltype(auto) elements( VT&& sv, REAs... args )
1340 {
1342 
1343  constexpr size_t I2 = RemoveReference_t<VT>::offset();
1344  constexpr size_t N = RemoveReference_t<VT>::size();
1345 
1346  return elements( sv.operand(), make_shifted_index_subsequence<I2,N,I,Is...>(), args... );
1347 }
1349 //*************************************************************************************************
1350 
1351 
1352 //*************************************************************************************************
1365 template< size_t I // First element index
1366  , size_t... Is // Remaining element indices
1367  , typename VT // Type of the vector
1368  , typename... REAs // Optional element arguments
1369  , EnableIf_t< IsSubvector_v< RemoveReference_t<VT> > &&
1370  !RemoveReference_t<VT>::compileTimeArgs >* = nullptr >
1371 inline decltype(auto) elements( VT&& sv, REAs... args )
1372 {
1374 
1375  constexpr bool isChecked( !Contains_v< TypeList<REAs...>, Unchecked > );
1376 
1377  if( isChecked ) {
1378  static constexpr size_t indices[] = { I, Is... };
1379  for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1380  if( sv.size() <= indices[i] ) {
1381  BLAZE_THROW_INVALID_ARGUMENT( "Invalid elements specification" );
1382  }
1383  }
1384  }
1385 
1386  return elements( sv.operand(), { I+sv.offset(), Is+sv.offset()... }, args... );
1387 }
1389 //*************************************************************************************************
1390 
1391 
1392 //*************************************************************************************************
1407 template< typename VT // Type of the vector
1408  , typename T // Type of the element indices
1409  , typename... REAs // Optional element arguments
1410  , EnableIf_t< IsSubvector_v< RemoveReference_t<VT> > >* = nullptr >
1411 inline decltype(auto) elements( VT&& sv, T* indices, size_t n, REAs... args )
1412 {
1414 
1415  constexpr bool isChecked( !Contains_v< TypeList<REAs...>, Unchecked > );
1416 
1417  if( isChecked ) {
1418  for( size_t i=0UL; i<n; ++i ) {
1419  if( sv.size() <= indices[i] ) {
1420  BLAZE_THROW_INVALID_ARGUMENT( "Invalid elements specification" );
1421  }
1422  }
1423  }
1424 
1425  SmallArray<size_t,128UL> newIndices( indices, indices+n );
1426  std::for_each( newIndices.begin(), newIndices.end(),
1427  [offset=sv.offset()]( size_t& index ){ index += offset; } );
1428 
1429  return elements( sv.operand(), newIndices.data(), n, args... );
1430 }
1432 //*************************************************************************************************
1433 
1434 
1435 //*************************************************************************************************
1450 template< typename VT // Type of the vector
1451  , typename P // Type of the index producer
1452  , typename... REAs // Optional element arguments
1453  , EnableIf_t< IsSubvector_v< RemoveReference_t<VT> > >* = nullptr >
1454 inline decltype(auto) elements( VT&& sv, P p, size_t n, REAs... args )
1455 {
1457 
1458  constexpr bool isChecked( !Contains_v< TypeList<REAs...>, Unchecked > );
1459 
1460  if( isChecked ) {
1461  for( size_t i=0UL; i<n; ++i ) {
1462  if( sv.size() <= p(i) ) {
1463  BLAZE_THROW_INVALID_ARGUMENT( "Invalid elements specification" );
1464  }
1465  }
1466  }
1467 
1468  return elements( sv.operand(), [p,offset=sv.offset()]( size_t i ){ return p(i)+offset; }, n, args... );
1469 }
1471 //*************************************************************************************************
1472 
1473 
1474 
1475 
1476 //=================================================================================================
1477 //
1478 // SUBVECTOR OPERATORS
1479 //
1480 //=================================================================================================
1481 
1482 //*************************************************************************************************
1490 template< typename VT // Type of the vector
1491  , AlignmentFlag AF // Alignment flag
1492  , bool TF // Transpose flag
1493  , bool DF // Density flag
1494  , size_t... CSAs > // Compile time subvector arguments
1495 inline void reset( Subvector<VT,AF,TF,DF,CSAs...>& sv )
1496 {
1497  sv.reset();
1498 }
1500 //*************************************************************************************************
1501 
1502 
1503 //*************************************************************************************************
1511 template< typename VT // Type of the vector
1512  , AlignmentFlag AF // Alignment flag
1513  , bool TF // Transpose flag
1514  , bool DF // Density flag
1515  , size_t... CSAs > // Compile time subvector arguments
1516 inline void reset( Subvector<VT,AF,TF,DF,CSAs...>&& sv )
1517 {
1518  sv.reset();
1519 }
1521 //*************************************************************************************************
1522 
1523 
1524 //*************************************************************************************************
1532 template< typename VT // Type of the vector
1533  , AlignmentFlag AF // Alignment flag
1534  , bool TF // Transpose flag
1535  , bool DF // Density flag
1536  , size_t... CSAs > // Compile time subvector arguments
1537 inline void clear( Subvector<VT,AF,TF,DF,CSAs...>& sv )
1538 {
1539  sv.reset();
1540 }
1542 //*************************************************************************************************
1543 
1544 
1545 //*************************************************************************************************
1553 template< typename VT // Type of the vector
1554  , AlignmentFlag AF // Alignment flag
1555  , bool TF // Transpose flag
1556  , bool DF // Density flag
1557  , size_t... CSAs > // Compile time subvector arguments
1558 inline void clear( Subvector<VT,AF,TF,DF,CSAs...>&& sv )
1559 {
1560  sv.reset();
1561 }
1563 //*************************************************************************************************
1564 
1565 
1566 //*************************************************************************************************
1593 template< bool RF // Relaxation flag
1594  , typename VT // Type of the dense vector
1595  , AlignmentFlag AF // Alignment flag
1596  , bool TF // Transpose flag
1597  , size_t... CSAs > // Compile time subvector arguments
1598 inline bool isDefault( const Subvector<VT,AF,TF,true,CSAs...>& sv )
1599 {
1600  using blaze::isDefault;
1601 
1602  for( size_t i=0UL; i<sv.size(); ++i )
1603  if( !isDefault<RF>( sv[i] ) ) return false;
1604  return true;
1605 }
1607 //*************************************************************************************************
1608 
1609 
1610 //*************************************************************************************************
1637 template< bool RF // Relaxation flag
1638  , typename VT // Type of the sparse vector
1639  , AlignmentFlag AF // Alignment flag
1640  , bool TF // Transpose flag
1641  , size_t... CSAs > // Compile time subvector arguments
1642 inline bool isDefault( const Subvector<VT,AF,TF,false,CSAs...>& sv )
1643 {
1644  using blaze::isDefault;
1645 
1646  for( const auto& element : ~sv )
1647  if( !isDefault<RF>( element.value() ) ) return false;
1648  return true;
1649 }
1651 //*************************************************************************************************
1652 
1653 
1654 //*************************************************************************************************
1672 template< typename VT // Type of the vector
1673  , AlignmentFlag AF // Alignment flag
1674  , bool TF // Transpose flag
1675  , bool DF // Density flag
1676  , size_t... CSAs > // Compile time subvector arguments
1677 inline bool isIntact( const Subvector<VT,AF,TF,DF,CSAs...>& sv ) noexcept
1678 {
1679  return ( sv.offset() + sv.size() <= sv.operand().size() &&
1680  isIntact( sv.operand() ) );
1681 }
1683 //*************************************************************************************************
1684 
1685 
1686 //*************************************************************************************************
1699 template< typename VT // Type of the vector
1700  , AlignmentFlag AF // Alignment flag
1701  , bool TF // Transpose flag
1702  , bool DF // Density flag
1703  , size_t... CSAs > // Compile time subvector arguments
1704 inline bool isSame( const Subvector<VT,AF,TF,DF,CSAs...>& a, const Vector<VT,TF>& b ) noexcept
1705 {
1706  return ( isSame( a.operand(), ~b ) && ( a.size() == (~b).size() ) );
1707 }
1709 //*************************************************************************************************
1710 
1711 
1712 //*************************************************************************************************
1725 template< typename VT // Type of the vector
1726  , bool TF // Transpose flag
1727  , AlignmentFlag AF // Alignment flag
1728  , bool DF // Density flag
1729  , size_t... CSAs > // Compile time subvector arguments
1730 inline bool isSame( const Vector<VT,TF>& a, const Subvector<VT,AF,TF,DF,CSAs...>& b ) noexcept
1731 {
1732  return isSame( b, a );
1733 }
1735 //*************************************************************************************************
1736 
1737 
1738 //*************************************************************************************************
1751 template< typename VT1 // Type of the vector of the left-hand side subvector
1752  , AlignmentFlag AF1 // Alignment flag of the left-hand side subvector
1753  , bool TF1 // Transpose flag of the left-hand side subvector
1754  , bool DF1 // Density flag of the left-hand side subvector
1755  , size_t... CSAs1 // Compile time subvector arguments of the left-hand side subvector
1756  , typename VT2 // Type of the vector of the right-hand side subvector
1757  , AlignmentFlag AF2 // Alignment flag of the right-hand side subvector
1758  , bool TF2 // Transpose flag of the right-hand side subvector
1759  , bool DF2 // Density flag of the right-hand side subvector
1760  , size_t... CSAs2 > // Compile time subvector arguments of the right-hand side subvector
1761 inline bool isSame( const Subvector<VT1,AF1,TF1,DF1,CSAs1...>& a,
1762  const Subvector<VT2,AF2,TF2,DF2,CSAs2...>& b ) noexcept
1763 {
1764  return ( isSame( a.operand(), b.operand() ) &&
1765  ( a.offset() == b.offset() ) &&
1766  ( a.size() == b.size() ) );
1767 }
1769 //*************************************************************************************************
1770 
1771 
1772 //*************************************************************************************************
1787 template< typename VT // Type of the vector
1788  , AlignmentFlag AF // Alignment flag
1789  , bool TF // Transpose flag
1790  , bool DF // Density flag
1791  , size_t... CSAs // Compile time subvector arguments
1792  , typename ET > // Type of the element
1793 inline bool trySet( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
1794 {
1795  BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
1796 
1797  return trySet( sv.operand(), sv.offset()+index, value );
1798 }
1800 //*************************************************************************************************
1801 
1802 
1803 //*************************************************************************************************
1819 template< typename VT // Type of the vector
1820  , AlignmentFlag AF // Alignment flag
1821  , bool TF // Transpose flag
1822  , bool DF // Density flag
1823  , size_t... CSAs // Compile time subvector arguments
1824  , typename ET > // Type of the element
1826  trySet( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
1827 {
1828  BLAZE_INTERNAL_ASSERT( index <= (~sv).size(), "Invalid vector access index" );
1829  BLAZE_INTERNAL_ASSERT( index + size <= (~sv).size(), "Invalid range size" );
1830 
1831  return trySet( sv.operand(), sv.offset()+index, size, value );
1832 }
1834 //*************************************************************************************************
1835 
1836 
1837 //*************************************************************************************************
1852 template< typename VT // Type of the vector
1853  , AlignmentFlag AF // Alignment flag
1854  , bool TF // Transpose flag
1855  , bool DF // Density flag
1856  , size_t... CSAs // Compile time subvector arguments
1857  , typename ET > // Type of the element
1858 inline bool tryAdd( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
1859 {
1860  BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
1861 
1862  return tryAdd( sv.operand(), sv.offset()+index, value );
1863 }
1865 //*************************************************************************************************
1866 
1867 
1868 //*************************************************************************************************
1884 template< typename VT // Type of the vector
1885  , AlignmentFlag AF // Alignment flag
1886  , bool TF // Transpose flag
1887  , bool DF // Density flag
1888  , size_t... CSAs // Compile time subvector arguments
1889  , typename ET > // Type of the element
1891  tryAdd( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
1892 {
1893  BLAZE_INTERNAL_ASSERT( index <= (~sv).size(), "Invalid vector access index" );
1894  BLAZE_INTERNAL_ASSERT( index + size <= (~sv).size(), "Invalid range size" );
1895 
1896  return tryAdd( sv.operand(), sv.offset()+index, size, value );
1897 }
1899 //*************************************************************************************************
1900 
1901 
1902 //*************************************************************************************************
1917 template< typename VT // Type of the vector
1918  , AlignmentFlag AF // Alignment flag
1919  , bool TF // Transpose flag
1920  , bool DF // Density flag
1921  , size_t... CSAs // Compile time subvector arguments
1922  , typename ET > // Type of the element
1923 inline bool trySub( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
1924 {
1925  BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
1926 
1927  return trySub( sv.operand(), sv.offset()+index, value );
1928 }
1930 //*************************************************************************************************
1931 
1932 
1933 //*************************************************************************************************
1949 template< typename VT // Type of the vector
1950  , AlignmentFlag AF // Alignment flag
1951  , bool TF // Transpose flag
1952  , bool DF // Density flag
1953  , size_t... CSAs // Compile time subvector arguments
1954  , typename ET > // Type of the element
1956  trySub( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
1957 {
1958  BLAZE_INTERNAL_ASSERT( index <= (~sv).size(), "Invalid vector access index" );
1959  BLAZE_INTERNAL_ASSERT( index + size <= (~sv).size(), "Invalid range size" );
1960 
1961  return trySub( sv.operand(), sv.offset()+index, size, value );
1962 }
1964 //*************************************************************************************************
1965 
1966 
1967 //*************************************************************************************************
1982 template< typename VT // Type of the vector
1983  , AlignmentFlag AF // Alignment flag
1984  , bool TF // Transpose flag
1985  , bool DF // Density flag
1986  , size_t... CSAs // Compile time subvector arguments
1987  , typename ET > // Type of the element
1988 inline bool tryMult( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
1989 {
1990  BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
1991 
1992  return tryMult( sv.operand(), sv.offset()+index, value );
1993 }
1995 //*************************************************************************************************
1996 
1997 
1998 //*************************************************************************************************
2014 template< typename VT // Type of the vector
2015  , AlignmentFlag AF // Alignment flag
2016  , bool TF // Transpose flag
2017  , bool DF // Density flag
2018  , size_t... CSAs // Compile time subvector arguments
2019  , typename ET > // Type of the element
2021  tryMult( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
2022 {
2023  BLAZE_INTERNAL_ASSERT( index <= (~sv).size(), "Invalid vector access index" );
2024  BLAZE_INTERNAL_ASSERT( index + size <= (~sv).size(), "Invalid range size" );
2025 
2026  return tryMult( sv.operand(), sv.offset()+index, size, value );
2027 }
2029 //*************************************************************************************************
2030 
2031 
2032 //*************************************************************************************************
2047 template< typename VT // Type of the vector
2048  , AlignmentFlag AF // Alignment flag
2049  , bool TF // Transpose flag
2050  , bool DF // Density flag
2051  , size_t... CSAs // Compile time subvector arguments
2052  , typename ET > // Type of the element
2053 inline bool tryDiv( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
2054 {
2055  BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
2056 
2057  return tryDiv( sv.operand(), sv.offset()+index, value );
2058 }
2060 //*************************************************************************************************
2061 
2062 
2063 //*************************************************************************************************
2079 template< typename VT // Type of the vector
2080  , AlignmentFlag AF // Alignment flag
2081  , bool TF // Transpose flag
2082  , bool DF // Density flag
2083  , size_t... CSAs // Compile time subvector arguments
2084  , typename ET > // Type of the element
2086  tryDiv( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
2087 {
2088  BLAZE_INTERNAL_ASSERT( index <= (~sv).size(), "Invalid vector access index" );
2089  BLAZE_INTERNAL_ASSERT( index + size <= (~sv).size(), "Invalid range size" );
2090 
2091  return tryDiv( sv.operand(), sv.offset()+index, size, value );
2092 }
2094 //*************************************************************************************************
2095 
2096 
2097 //*************************************************************************************************
2112 template< typename VT // Type of the vector
2113  , AlignmentFlag AF // Alignment flag
2114  , bool TF // Transpose flag
2115  , bool DF // Density flag
2116  , size_t... CSAs > // Compile time subvector arguments
2117 inline bool tryShift( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, int count )
2118 {
2119  BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
2120 
2121  return tryShift( sv.operand(), sv.offset()+index, count );
2122 }
2124 //*************************************************************************************************
2125 
2126 
2127 //*************************************************************************************************
2143 template< typename VT // Type of the vector
2144  , AlignmentFlag AF // Alignment flag
2145  , bool TF // Transpose flag
2146  , bool DF // Density flag
2147  , size_t... CSAs > // Compile time subvector arguments
2149  tryShift( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, int count )
2150 {
2151  BLAZE_INTERNAL_ASSERT( index <= (~sv).size(), "Invalid vector access index" );
2152  BLAZE_INTERNAL_ASSERT( index + size <= (~sv).size(), "Invalid range size" );
2153 
2154  return tryShift( sv.operand(), sv.offset()+index, size, count );
2155 }
2157 //*************************************************************************************************
2158 
2159 
2160 //*************************************************************************************************
2175 template< typename VT // Type of the vector
2176  , AlignmentFlag AF // Alignment flag
2177  , bool TF // Transpose flag
2178  , bool DF // Density flag
2179  , size_t... CSAs // Compile time subvector arguments
2180  , typename ET > // Type of the element
2181 inline bool tryBitand( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
2182 {
2183  BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
2184 
2185  return tryBitand( sv.operand(), sv.offset()+index, value );
2186 }
2188 //*************************************************************************************************
2189 
2190 
2191 //*************************************************************************************************
2207 template< typename VT // Type of the vector
2208  , AlignmentFlag AF // Alignment flag
2209  , bool TF // Transpose flag
2210  , bool DF // Density flag
2211  , size_t... CSAs // Compile time subvector arguments
2212  , typename ET > // Type of the element
2214  tryBitand( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
2215 {
2216  BLAZE_INTERNAL_ASSERT( index <= (~sv).size(), "Invalid vector access index" );
2217  BLAZE_INTERNAL_ASSERT( index + size <= (~sv).size(), "Invalid range size" );
2218 
2219  return tryBitand( sv.operand(), sv.offset()+index, size, value );
2220 }
2222 //*************************************************************************************************
2223 
2224 
2225 //*************************************************************************************************
2240 template< typename VT // Type of the vector
2241  , AlignmentFlag AF // Alignment flag
2242  , bool TF // Transpose flag
2243  , bool DF // Density flag
2244  , size_t... CSAs // Compile time subvector arguments
2245  , typename ET > // Type of the element
2246 inline bool tryBitor( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
2247 {
2248  BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
2249 
2250  return tryBitor( sv.operand(), sv.offset()+index, value );
2251 }
2253 //*************************************************************************************************
2254 
2255 
2256 //*************************************************************************************************
2272 template< typename VT // Type of the vector
2273  , AlignmentFlag AF // Alignment flag
2274  , bool TF // Transpose flag
2275  , bool DF // Density flag
2276  , size_t... CSAs // Compile time subvector arguments
2277  , typename ET > // Type of the element
2279  tryBitor( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
2280 {
2281  BLAZE_INTERNAL_ASSERT( index <= (~sv).size(), "Invalid vector access index" );
2282  BLAZE_INTERNAL_ASSERT( index + size <= (~sv).size(), "Invalid range size" );
2283 
2284  return tryBitor( sv.operand(), sv.offset()+index, size, value );
2285 }
2287 //*************************************************************************************************
2288 
2289 
2290 //*************************************************************************************************
2305 template< typename VT // Type of the vector
2306  , AlignmentFlag AF // Alignment flag
2307  , bool TF // Transpose flag
2308  , bool DF // Density flag
2309  , size_t... CSAs // Compile time subvector arguments
2310  , typename ET > // Type of the element
2311 inline bool tryBitxor( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
2312 {
2313  BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
2314 
2315  return tryBitxor( sv.operand(), sv.offset()+index, value );
2316 }
2318 //*************************************************************************************************
2319 
2320 
2321 //*************************************************************************************************
2337 template< typename VT // Type of the vector
2338  , AlignmentFlag AF // Alignment flag
2339  , bool TF // Transpose flag
2340  , bool DF // Density flag
2341  , size_t... CSAs // Compile time subvector arguments
2342  , typename ET > // Type of the element
2344  tryBitxor( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
2345 {
2346  BLAZE_INTERNAL_ASSERT( index <= (~sv).size(), "Invalid vector access index" );
2347  BLAZE_INTERNAL_ASSERT( index + size <= (~sv).size(), "Invalid range size" );
2348 
2349  return tryBitxor( sv.operand(), sv.offset()+index, size, value );
2350 }
2352 //*************************************************************************************************
2353 
2354 
2355 //*************************************************************************************************
2370 template< typename VT1 // Type of the vector
2371  , AlignmentFlag AF // Alignment flag
2372  , bool TF // Transpose flag
2373  , bool DF // Density flag
2374  , size_t... CSAs // Compile time subvector arguments
2375  , typename VT2 > // Type of the right-hand side vector
2376 inline bool tryAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2377  const Vector<VT2,TF>& rhs, size_t index )
2378 {
2379  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2380  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2381 
2382  return tryAssign( lhs.operand(), ~rhs, lhs.offset() + index );
2383 }
2385 //*************************************************************************************************
2386 
2387 
2388 //*************************************************************************************************
2403 template< typename VT1 // Type of the vector
2404  , AlignmentFlag AF // Alignment flag
2405  , bool TF // Transpose flag
2406  , bool DF // Density flag
2407  , size_t... CSAs // Compile time subvector arguments
2408  , typename VT2 > // Type of the right-hand side vector
2409 inline bool tryAddAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2410  const Vector<VT2,TF>& rhs, size_t index )
2411 {
2412  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2413  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2414 
2415  return tryAddAssign( lhs.operand(), ~rhs, lhs.offset() + index );
2416 }
2418 //*************************************************************************************************
2419 
2420 
2421 //*************************************************************************************************
2436 template< typename VT1 // Type of the vector
2437  , AlignmentFlag AF // Alignment flag
2438  , bool TF // Transpose flag
2439  , bool DF // Density flag
2440  , size_t... CSAs // Compile time subvector arguments
2441  , typename VT2 > // Type of the right-hand side vector
2442 inline bool trySubAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2443  const Vector<VT2,TF>& rhs, size_t index )
2444 {
2445  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2446  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2447 
2448  return trySubAssign( lhs.operand(), ~rhs, lhs.offset() + index );
2449 }
2451 //*************************************************************************************************
2452 
2453 
2454 //*************************************************************************************************
2469 template< typename VT1 // Type of the vector
2470  , AlignmentFlag AF // Alignment flag
2471  , bool TF // Transpose flag
2472  , bool DF // Density flag
2473  , size_t... CSAs // Compile time subvector arguments
2474  , typename VT2 > // Type of the right-hand side vector
2475 inline bool tryMultAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2476  const Vector<VT2,TF>& rhs, size_t index )
2477 {
2478  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2479  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2480 
2481  return tryMultAssign( lhs.operand(), ~rhs, lhs.offset() + index );
2482 }
2484 //*************************************************************************************************
2485 
2486 
2487 //*************************************************************************************************
2502 template< typename VT1 // Type of the vector
2503  , AlignmentFlag AF // Alignment flag
2504  , bool TF // Transpose flag
2505  , bool DF // Density flag
2506  , size_t... CSAs // Compile time subvector arguments
2507  , typename VT2 > // Type of the right-hand side vector
2508 inline bool tryDivAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2509  const Vector<VT2,TF>& rhs, size_t index )
2510 {
2511  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2512  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2513 
2514  return tryDivAssign( lhs.operand(), ~rhs, lhs.offset() + index );
2515 }
2517 //*************************************************************************************************
2518 
2519 
2520 //*************************************************************************************************
2535 template< typename VT1 // Type of the vector
2536  , AlignmentFlag AF // Alignment flag
2537  , bool TF // Transpose flag
2538  , bool DF // Density flag
2539  , size_t... CSAs // Compile time subvector arguments
2540  , typename VT2 > // Type of the right-hand side vector
2541 inline bool tryShiftAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2542  const Vector<VT2,TF>& rhs, size_t index )
2543 {
2544  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2545  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2546 
2547  return tryShiftAssign( lhs.operand(), ~rhs, lhs.offset() + index );
2548 }
2550 //*************************************************************************************************
2551 
2552 
2553 //*************************************************************************************************
2568 template< typename VT1 // Type of the vector
2569  , AlignmentFlag AF // Alignment flag
2570  , bool TF // Transpose flag
2571  , bool DF // Density flag
2572  , size_t... CSAs // Compile time subvector arguments
2573  , typename VT2 > // Type of the right-hand side vector
2574 inline bool tryBitandAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2575  const Vector<VT2,TF>& rhs, size_t index )
2576 {
2577  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2578  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2579 
2580  return tryBitandAssign( lhs.operand(), ~rhs, lhs.offset() + index );
2581 }
2583 //*************************************************************************************************
2584 
2585 
2586 //*************************************************************************************************
2601 template< typename VT1 // Type of the vector
2602  , AlignmentFlag AF // Alignment flag
2603  , bool TF // Transpose flag
2604  , bool DF // Density flag
2605  , size_t... CSAs // Compile time subvector arguments
2606  , typename VT2 > // Type of the right-hand side vector
2607 inline bool tryBitorAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2608  const Vector<VT2,TF>& rhs, size_t index )
2609 {
2610  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2611  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2612 
2613  return tryBitorAssign( lhs.operand(), ~rhs, lhs.offset() + index );
2614 }
2616 //*************************************************************************************************
2617 
2618 
2619 //*************************************************************************************************
2634 template< typename VT1 // Type of the vector
2635  , AlignmentFlag AF // Alignment flag
2636  , bool TF // Transpose flag
2637  , bool DF // Density flag
2638  , size_t... CSAs // Compile time subvector arguments
2639  , typename VT2 > // Type of the right-hand side vector
2640 inline bool tryBitxorAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2641  const Vector<VT2,TF>& rhs, size_t index )
2642 {
2643  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2644  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2645 
2646  return tryBitxorAssign( lhs.operand(), ~rhs, lhs.offset() + index );
2647 }
2649 //*************************************************************************************************
2650 
2651 
2652 //*************************************************************************************************
2667 template< typename VT // Type of the vector
2668  , AlignmentFlag AF // Alignment flag
2669  , bool TF // Transpose flag
2670  , bool DF // Density flag
2671  , size_t I // Index of the first element
2672  , size_t N > // Number of elements
2673 inline decltype(auto) derestrict( Subvector<VT,AF,TF,DF,I,N>& sv )
2674 {
2675  return subvector<AF,I,N>( derestrict( sv.operand() ), unchecked );
2676 }
2678 //*************************************************************************************************
2679 
2680 
2681 //*************************************************************************************************
2696 template< typename VT // Type of the vector
2697  , AlignmentFlag AF // Alignment flag
2698  , bool TF // Transpose flag
2699  , bool DF // Density flag
2700  , size_t I // Index of the first element
2701  , size_t N > // Number of elements
2702 inline decltype(auto) derestrict( Subvector<VT,AF,TF,DF,I,N>&& sv )
2703 {
2704  return subvector<AF,I,N>( derestrict( sv.operand() ), unchecked );
2705 }
2707 //*************************************************************************************************
2708 
2709 
2710 //*************************************************************************************************
2725 template< typename VT // Type of the vector
2726  , AlignmentFlag AF // Alignment flag
2727  , bool TF // Transpose flag
2728  , bool DF > // Density flag
2729 inline decltype(auto) derestrict( Subvector<VT,AF,TF,DF>& sv )
2730 {
2731  return subvector<AF>( derestrict( sv.operand() ), sv.offset(), sv.size(), unchecked );
2732 }
2734 //*************************************************************************************************
2735 
2736 
2737 //*************************************************************************************************
2752 template< typename VT // Type of the vector
2753  , AlignmentFlag AF // Alignment flag
2754  , bool TF // Transpose flag
2755  , bool DF > // Density flag
2756 inline decltype(auto) derestrict( Subvector<VT,AF,TF,DF>&& sv )
2757 {
2758  return subvector<AF>( derestrict( sv.operand() ), sv.offset(), sv.size(), unchecked );
2759 }
2761 //*************************************************************************************************
2762 
2763 
2764 
2765 
2766 //=================================================================================================
2767 //
2768 // SIZE SPECIALIZATIONS
2769 //
2770 //=================================================================================================
2771 
2772 //*************************************************************************************************
2774 template< typename VT, AlignmentFlag AF, bool TF, bool DF, size_t I, size_t N >
2775 struct Size< Subvector<VT,AF,TF,DF,I,N>, 0UL >
2776  : public Ptrdiff_t<N>
2777 {};
2779 //*************************************************************************************************
2780 
2781 
2782 
2783 
2784 //=================================================================================================
2785 //
2786 // MAXSIZE SPECIALIZATIONS
2787 //
2788 //=================================================================================================
2789 
2790 //*************************************************************************************************
2792 template< typename VT, AlignmentFlag AF, bool TF, bool DF, size_t I, size_t N >
2793 struct MaxSize< Subvector<VT,AF,TF,DF,I,N>, 0UL >
2794  : public Ptrdiff_t<N>
2795 {};
2797 //*************************************************************************************************
2798 
2799 
2800 
2801 
2802 //=================================================================================================
2803 //
2804 // ISRESTRICTED SPECIALIZATIONS
2805 //
2806 //=================================================================================================
2807 
2808 //*************************************************************************************************
2810 template< typename VT, AlignmentFlag AF, bool TF, bool DF, size_t... CSAs >
2811 struct IsRestricted< Subvector<VT,AF,TF,DF,CSAs...> >
2812  : public IsRestricted<VT>
2813 {};
2815 //*************************************************************************************************
2816 
2817 
2818 
2819 
2820 //=================================================================================================
2821 //
2822 // HASCONSTDATAACCESS SPECIALIZATIONS
2823 //
2824 //=================================================================================================
2825 
2826 //*************************************************************************************************
2828 template< typename VT, AlignmentFlag AF, bool TF, size_t... CSAs >
2829 struct HasConstDataAccess< Subvector<VT,AF,TF,true,CSAs...> >
2830  : public HasConstDataAccess<VT>
2831 {};
2833 //*************************************************************************************************
2834 
2835 
2836 
2837 
2838 //=================================================================================================
2839 //
2840 // HASMUTABLEDATAACCESS SPECIALIZATIONS
2841 //
2842 //=================================================================================================
2843 
2844 //*************************************************************************************************
2846 template< typename VT, AlignmentFlag AF, bool TF, size_t... CSAs >
2847 struct HasMutableDataAccess< Subvector<VT,AF,TF,true,CSAs...> >
2848  : public HasMutableDataAccess<VT>
2849 {};
2851 //*************************************************************************************************
2852 
2853 
2854 
2855 
2856 //=================================================================================================
2857 //
2858 // ISALIGNED SPECIALIZATIONS
2859 //
2860 //=================================================================================================
2861 
2862 //*************************************************************************************************
2864 template< typename VT, bool TF, size_t... CSAs >
2865 struct IsAligned< Subvector<VT,aligned,TF,true,CSAs...> >
2866  : public TrueType
2867 {};
2869 //*************************************************************************************************
2870 
2871 
2872 
2873 
2874 //=================================================================================================
2875 //
2876 // ISCONTIGUOUS SPECIALIZATIONS
2877 //
2878 //=================================================================================================
2879 
2880 //*************************************************************************************************
2882 template< typename VT, AlignmentFlag AF, bool TF, size_t... CSAs >
2883 struct IsContiguous< Subvector<VT,AF,TF,true,CSAs...> >
2884  : public IsContiguous<VT>
2885 {};
2887 //*************************************************************************************************
2888 
2889 } // namespace blaze
2890 
2891 #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.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression,...
Definition: Assert.h:117
Header file for 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.
Subvector specialization for sparse vectors.
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
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: IntegralConstant.h:132
#define BLAZE_STATIC_ASSERT_MSG(expr, msg)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:123
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.
Subvector specialization for dense 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.
Header file for the implementation of the Subvector base template.
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 IsSubvector type trait.
Header file for the VecVecKronExpr base class.
Header file for the IsAligned type trait.
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.
Flag for aligned vectors and matrices.
Definition: AlignmentFlag.h:65
Header file for the HasConstDataAccess type trait.
Header file for the VecSerialExpr base class.
Header file for the VecTransExpr base class.
decltype(subsequence< Is... >(shift< Offset >(make_index_sequence< N >()))) make_shifted_index_subsequence
Auxiliary alias declaration for the setup of shifted index subsequences.The make_shifted_index_subseq...
Definition: IntegerSequence.h:248
Header file for run time assertion macros.
Header file for the Unique class template.
Header file for the IsContiguous type trait.
Check< false > Unchecked
Type of the blaze::unchecked instance.blaze::Unchecked is the type of the blaze::unchecked instance,...
Definition: Check.h:96
#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.
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
Flag for unaligned vectors and matrices.
Definition: AlignmentFlag.h:64
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