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>
70 #include <blaze/math/views/Check.h>
74 #include <blaze/util/Assert.h>
77 #include <blaze/util/SmallArray.h>
79 #include <blaze/util/TrueType.h>
80 #include <blaze/util/TypeList.h>
81 #include <blaze/util/Types.h>
83 
84 
85 namespace blaze {
86 
87 //=================================================================================================
88 //
89 // GLOBAL FUNCTIONS
90 //
91 //=================================================================================================
92 
93 //*************************************************************************************************
147 template< size_t I // Index of the first subvector element
148  , size_t N // Size of the subvector
149  , typename VT // Type of the vector
150  , bool TF // Transpose flag
151  , typename... RSAs > // Optional subvector arguments
152 inline decltype(auto) subvector( Vector<VT,TF>& vector, RSAs... args )
153 {
155 
156  return subvector<unaligned,I,N>( ~vector, args... );
157 }
158 //*************************************************************************************************
159 
160 
161 //*************************************************************************************************
215 template< size_t I // Index of the first subvector element
216  , size_t N // Size of the subvector
217  , typename VT // Type of the vector
218  , bool TF // Transpose flag
219  , typename... RSAs > // Optional subvector arguments
220 inline decltype(auto) subvector( const Vector<VT,TF>& vector, RSAs... args )
221 {
223 
224  return subvector<unaligned,I,N>( ~vector, args... );
225 }
226 //*************************************************************************************************
227 
228 
229 //*************************************************************************************************
243 template< size_t I // Index of the first subvector element
244  , size_t N // Size of the subvector
245  , typename VT // Type of the vector
246  , bool TF // Transpose flag
247  , typename... RSAs > // Optional subvector arguments
248 inline decltype(auto) subvector( Vector<VT,TF>&& vector, RSAs... args )
249 {
251 
252  return subvector<unaligned,I,N>( ~vector, args... );
253 }
254 //*************************************************************************************************
255 
256 
257 //*************************************************************************************************
323 template< AlignmentFlag AF // Alignment flag
324  , size_t I // Index of the first subvector element
325  , size_t N // Size of the subvector
326  , typename VT // Type of the vector
327  , bool TF // Transpose flag
328  , typename... RSAs > // Optional subvector arguments
329 inline decltype(auto) subvector( Vector<VT,TF>& vector, RSAs... args )
330 {
332 
333  using ReturnType = Subvector_<VT,AF,I,N>;
334  return ReturnType( ~vector, args... );
335 }
336 //*************************************************************************************************
337 
338 
339 //*************************************************************************************************
403 template< AlignmentFlag AF // Alignment flag
404  , size_t I // Index of the first subvector element
405  , size_t N // Size of the subvector
406  , typename VT // Type of the vector
407  , bool TF // Transpose flag
408  , typename... RSAs > // Optional subvector arguments
409 inline decltype(auto) subvector( const Vector<VT,TF>& vector, RSAs... args )
410 {
412 
413  using ReturnType = const Subvector_<const VT,AF,I,N>;
414  return ReturnType( ~vector, args... );
415 }
416 //*************************************************************************************************
417 
418 
419 //*************************************************************************************************
435 template< AlignmentFlag AF // Alignment flag
436  , size_t I // Index of the first subvector element
437  , size_t N // Size of the subvector
438  , typename VT // Type of the vector
439  , bool TF // Transpose flag
440  , typename... RSAs > // Optional subvector arguments
441 inline decltype(auto) subvector( Vector<VT,TF>&& vector, RSAs... args )
442 {
444 
445  using ReturnType = Subvector_<VT,AF,I,N>;
446  return ReturnType( ~vector, args... );
447 }
448 //*************************************************************************************************
449 
450 
451 //*************************************************************************************************
507 template< typename VT // Type of the vector
508  , bool TF // Transpose flag
509  , typename... RSAs > // Optional subvector arguments
510 inline decltype(auto) subvector( Vector<VT,TF>& vector, size_t index, size_t size, RSAs... args )
511 {
513 
514  return subvector<unaligned>( ~vector, index, size, args... );
515 }
516 //*************************************************************************************************
517 
518 
519 //*************************************************************************************************
575 template< typename VT // Type of the vector
576  , bool TF // Transpose flag
577  , typename... RSAs > // Optional subvector arguments
578 inline decltype(auto) subvector( const Vector<VT,TF>& vector, size_t index, size_t size, RSAs... args )
579 {
581 
582  return subvector<unaligned>( ~vector, index, size, args... );
583 }
584 //*************************************************************************************************
585 
586 
587 //*************************************************************************************************
603 template< typename VT // Type of the vector
604  , bool TF // Transpose flag
605  , typename... RSAs > // Optional subvector arguments
606 inline decltype(auto) subvector( Vector<VT,TF>&& vector, size_t index, size_t size, RSAs... args )
607 {
609 
610  return subvector<unaligned>( ~vector, index, size, args... );
611 }
612 //*************************************************************************************************
613 
614 
615 //*************************************************************************************************
683 template< AlignmentFlag AF // Alignment flag
684  , typename VT // Type of the vector
685  , bool TF // Transpose flag
686  , typename... RSAs > // Optional subvector arguments
687 inline decltype(auto) subvector( Vector<VT,TF>& vector, size_t index, size_t size, RSAs... args )
688 {
690 
691  using ReturnType = Subvector_<VT,AF>;
692  return ReturnType( ~vector, index, size, args... );
693 }
694 //*************************************************************************************************
695 
696 
697 //*************************************************************************************************
763 template< AlignmentFlag AF // Alignment flag
764  , typename VT // Type of the vector
765  , bool TF // Transpose flag
766  , typename... RSAs > // Optional subvector arguments
767 inline decltype(auto) subvector( const Vector<VT,TF>& vector, size_t index, size_t size, RSAs... args )
768 {
770 
771  using ReturnType = const Subvector_<const VT,AF>;
772  return ReturnType( ~vector, index, size, args... );
773 }
774 //*************************************************************************************************
775 
776 
777 //*************************************************************************************************
795 template< AlignmentFlag AF // Alignment flag
796  , typename VT // Type of the vector
797  , bool TF // Transpose flag
798  , typename... RSAs > // Optional subvector arguments
799 inline decltype(auto) subvector( Vector<VT,TF>&& vector, size_t index, size_t size, RSAs... args )
800 {
802 
803  using ReturnType = Subvector_<VT,AF>;
804  return ReturnType( ~vector, index, size, args... );
805 }
806 //*************************************************************************************************
807 
808 
809 
810 
811 //=================================================================================================
812 //
813 // GLOBAL RESTRUCTURING FUNCTIONS
814 //
815 //=================================================================================================
816 
817 //*************************************************************************************************
829 template< AlignmentFlag AF // Alignment flag
830  , size_t... CSAs // Compile time subvector arguments
831  , typename VT // Vector base type of the expression
832  , typename... RSAs > // Runtime subvector arguments
833 inline decltype(auto) subvector( const VecVecAddExpr<VT>& vector, RSAs... args )
834 {
836 
837  return subvector<AF,CSAs...>( (~vector).leftOperand(), args... ) +
838  subvector<AF,CSAs...>( (~vector).rightOperand(), args... );
839 }
841 //*************************************************************************************************
842 
843 
844 //*************************************************************************************************
856 template< AlignmentFlag AF // Alignment flag
857  , size_t... CSAs // Compile time subvector arguments
858  , typename VT // Vector base type of the expression
859  , typename... RSAs > // Runtime subvector arguments
860 inline decltype(auto) subvector( const VecVecSubExpr<VT>& vector, RSAs... args )
861 {
863 
864  return subvector<AF,CSAs...>( (~vector).leftOperand(), args... ) -
865  subvector<AF,CSAs...>( (~vector).rightOperand(), args... );
866 }
868 //*************************************************************************************************
869 
870 
871 //*************************************************************************************************
883 template< AlignmentFlag AF // Alignment flag
884  , size_t... CSAs // Compile time subvector arguments
885  , typename VT // Vector base type of the expression
886  , typename... RSAs > // Runtime subvector arguments
887 inline decltype(auto) subvector( const VecVecMultExpr<VT>& vector, RSAs... args )
888 {
890 
891  return subvector<AF,CSAs...>( (~vector).leftOperand(), args... ) *
892  subvector<AF,CSAs...>( (~vector).rightOperand(), args... );
893 }
895 //*************************************************************************************************
896 
897 
898 //*************************************************************************************************
910 template< AlignmentFlag AF // Alignment flag
911  , size_t... CSAs // Compile time subvector arguments
912  , typename VT // Vector base type of the expression
913  , typename... RSAs > // Runtime subvector arguments
914 inline decltype(auto) subvector( const VecVecDivExpr<VT>& vector, RSAs... args )
915 {
917 
918  return subvector<AF,CSAs...>( (~vector).leftOperand(), args... ) /
919  subvector<AF,CSAs...>( (~vector).rightOperand(), args... );
920 }
922 //*************************************************************************************************
923 
924 
925 //*************************************************************************************************
937 template< AlignmentFlag AF // Alignment flag
938  , size_t... CSAs // Compile time subvector arguments
939  , typename VT // Vector base type of the expression
940  , typename... RSAs > // Runtime subvector arguments
941 inline decltype(auto) subvector( const CrossExpr<VT>& vector, RSAs... args )
942 {
944 
945  using ReturnType = Subvector_< VectorType_t<VT>, AF, CSAs... >;
946  return ReturnType( ~vector, args... );
947 }
949 //*************************************************************************************************
950 
951 
952 //*************************************************************************************************
964 template< AlignmentFlag AF // Alignment flag
965  , size_t... CSAs // Compile time subvector arguments
966  , typename VT // Vector base type of the expression
967  , typename... RSAs > // Runtime subvector arguments
968 inline decltype(auto) subvector( const VecScalarMultExpr<VT>& vector, RSAs... args )
969 {
971 
972  return subvector<AF,CSAs...>( (~vector).leftOperand(), args... ) * (~vector).rightOperand();
973 }
975 //*************************************************************************************************
976 
977 
978 //*************************************************************************************************
990 template< AlignmentFlag AF // Alignment flag
991  , size_t... CSAs // Compile time subvector arguments
992  , typename VT // Vector base type of the expression
993  , typename... RSAs > // Runtime subvector arguments
994 inline decltype(auto) subvector( const VecScalarDivExpr<VT>& vector, RSAs... args )
995 {
997 
998  return subvector<AF,CSAs...>( (~vector).leftOperand(), args... ) / (~vector).rightOperand();
999 }
1001 //*************************************************************************************************
1002 
1003 
1004 //*************************************************************************************************
1016 template< AlignmentFlag AF // Alignment flag
1017  , size_t... CSAs // Compile time subvector arguments
1018  , typename VT // Vector base type of the expression
1019  , typename... RSAs > // Runtime subvector arguments
1020 inline decltype(auto) subvector( const VecMapExpr<VT>& vector, RSAs... args )
1021 {
1023 
1024  return map( subvector<AF,CSAs...>( (~vector).operand(), args... ), (~vector).operation() );
1025 }
1027 //*************************************************************************************************
1028 
1029 
1030 //*************************************************************************************************
1042 template< AlignmentFlag AF // Alignment flag
1043  , size_t... CSAs // Compile time subvector arguments
1044  , typename VT // Vector base type of the expression
1045  , typename... RSAs > // Runtime subvector arguments
1046 inline decltype(auto) subvector( const VecVecMapExpr<VT>& vector, RSAs... args )
1047 {
1049 
1050  return map( subvector<AF,CSAs...>( (~vector).leftOperand(), args... ),
1051  subvector<AF,CSAs...>( (~vector).rightOperand(), args... ),
1052  (~vector).operation() );
1053 }
1055 //*************************************************************************************************
1056 
1057 
1058 //*************************************************************************************************
1070 template< AlignmentFlag AF // Alignment flag
1071  , size_t... CSAs // Compile time subvector arguments
1072  , typename VT // Vector base type of the expression
1073  , typename... RSAs > // Runtime subvector arguments
1074 inline decltype(auto) subvector( const VecEvalExpr<VT>& vector, RSAs... args )
1075 {
1077 
1078  return eval( subvector<AF,CSAs...>( (~vector).operand(), args... ) );
1079 }
1081 //*************************************************************************************************
1082 
1083 
1084 //*************************************************************************************************
1096 template< AlignmentFlag AF // Alignment flag
1097  , size_t... CSAs // Compile time subvector arguments
1098  , typename VT // Vector base type of the expression
1099  , typename... RSAs > // Runtime subvector arguments
1100 inline decltype(auto) subvector( const VecSerialExpr<VT>& vector, RSAs... args )
1101 {
1103 
1104  return serial( subvector<AF,CSAs...>( (~vector).operand(), args... ) );
1105 }
1107 //*************************************************************************************************
1108 
1109 
1110 //*************************************************************************************************
1122 template< AlignmentFlag AF // Alignment flag
1123  , size_t... CSAs // Compile time subvector arguments
1124  , typename VT // Vector base type of the expression
1125  , typename... RSAs > // Runtime subvector arguments
1126 inline decltype(auto) subvector( const VecTransExpr<VT>& vector, RSAs... args )
1127 {
1129 
1130  return trans( subvector<AF,CSAs...>( (~vector).operand(), args... ) );
1131 }
1133 //*************************************************************************************************
1134 
1135 
1136 //*************************************************************************************************
1147 template< AlignmentFlag AF1 // Required alignment flag
1148  , size_t I1 // Required subvector offset
1149  , size_t N1 // Required size of the subvector
1150  , typename VT // Type of the vector
1151  , AlignmentFlag AF2 // Present alignment flag
1152  , bool TF // Transpose flag
1153  , bool DF // Density flag
1154  , size_t I2 // Present subvector offset
1155  , size_t N2 // Present size of the subvector
1156  , typename... RSAs > // Optional subvector arguments
1157 inline decltype(auto) subvector( Subvector<VT,AF2,TF,DF,I2,N2>& sv, RSAs... args )
1158 {
1160 
1161  BLAZE_STATIC_ASSERT_MSG( I1 + N1 <= N2, "Invalid subvector specification" );
1162 
1163  return subvector<AF1,I1+I2,N1>( sv.operand(), args... );
1164 }
1166 //*************************************************************************************************
1167 
1168 
1169 //*************************************************************************************************
1181 template< AlignmentFlag AF1 // Required alignment flag
1182  , size_t I1 // Required subvector offset
1183  , size_t N1 // Required size of the subvector
1184  , typename VT // Type of the vector
1185  , AlignmentFlag AF2 // Present alignment flag
1186  , bool TF // Transpose flag
1187  , bool DF // Density flag
1188  , size_t I2 // Present subvector offset
1189  , size_t N2 // Present size of the subvector
1190  , typename... RSAs > // Optional subvector arguments
1191 inline decltype(auto) subvector( const Subvector<VT,AF2,TF,DF,I2,N2>& sv, RSAs... args )
1192 {
1194 
1195  BLAZE_STATIC_ASSERT_MSG( I1 + N1 <= N2, "Invalid subvector specification" );
1196 
1197  return subvector<AF1,I1+I2,N1>( sv.operand(), args... );
1198 }
1200 //*************************************************************************************************
1201 
1202 
1203 //*************************************************************************************************
1215 template< AlignmentFlag AF1 // Required alignment flag
1216  , size_t I1 // Required subvector offset
1217  , size_t N1 // Required size of the subvector
1218  , typename VT // Type of the vector
1219  , AlignmentFlag AF2 // Present alignment flag
1220  , bool TF // Transpose flag
1221  , bool DF // Density flag
1222  , size_t I2 // Present subvector offset
1223  , size_t N2 // Present size of the subvector
1224  , typename... RSAs > // Optional subvector arguments
1225 inline decltype(auto) subvector( Subvector<VT,AF2,TF,DF,I2,N2>&& sv, RSAs... args )
1226 {
1228 
1229  BLAZE_STATIC_ASSERT_MSG( I1 + N1 <= N2, "Invalid subvector specification" );
1230 
1231  return subvector<AF1,I1+I2,N1>( sv.operand(), args... );
1232 }
1234 //*************************************************************************************************
1235 
1236 
1237 //*************************************************************************************************
1249 template< AlignmentFlag AF1 // Required alignment flag
1250  , size_t I // Index of the first subvector element
1251  , size_t N // Size of the subvector
1252  , typename VT // Type of the vector
1253  , AlignmentFlag AF2 // Present alignment flag
1254  , bool TF // Transpose flag
1255  , bool DF // Density flag
1256  , typename... RSAs > // Optional subvector arguments
1257 inline decltype(auto) subvector( Subvector<VT,AF2,TF,DF>& sv, RSAs... args )
1258 {
1260 
1261  constexpr bool isChecked( !Contains_v< TypeList<RSAs...>, Unchecked > );
1262 
1263  if( isChecked ) {
1264  if( I + N > sv.size() ) {
1265  BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
1266  }
1267  }
1268  else {
1269  BLAZE_USER_ASSERT( I + N <= sv.size(), "Invalid subvector specification" );
1270  }
1271 
1272  return subvector<AF1>( sv.operand(), sv.offset() + I, N, args... );
1273 }
1275 //*************************************************************************************************
1276 
1277 
1278 //*************************************************************************************************
1291 template< AlignmentFlag AF1 // Required alignment flag
1292  , size_t I // Index of the first subvector element
1293  , size_t N // Size of the subvector
1294  , typename VT // Type of the vector
1295  , AlignmentFlag AF2 // Present alignment flag
1296  , bool TF // Transpose flag
1297  , bool DF // Density flag
1298  , typename... RSAs > // Optional subvector arguments
1299 inline decltype(auto) subvector( const Subvector<VT,AF2,TF,DF>& sv, RSAs... args )
1300 {
1302 
1303  constexpr bool isChecked( !Contains_v< TypeList<RSAs...>, Unchecked > );
1304 
1305  if( isChecked ) {
1306  if( I + N > sv.size() ) {
1307  BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
1308  }
1309  }
1310  else {
1311  BLAZE_USER_ASSERT( I + N <= sv.size(), "Invalid subvector specification" );
1312  }
1313 
1314  return subvector<AF1>( sv.operand(), sv.offset() + I, N, args... );
1315 }
1317 //*************************************************************************************************
1318 
1319 
1320 //*************************************************************************************************
1333 template< AlignmentFlag AF1 // Required alignment flag
1334  , size_t I // Index of the first subvector element
1335  , size_t N // Size of the subvector
1336  , typename VT // Type of the vector
1337  , AlignmentFlag AF2 // Present alignment flag
1338  , bool TF // Transpose flag
1339  , bool DF // Density flag
1340  , typename... RSAs > // Optional subvector arguments
1341 inline decltype(auto) subvector( Subvector<VT,AF2,TF,DF>&& sv, RSAs... args )
1342 {
1344 
1345  constexpr bool isChecked( !Contains_v< TypeList<RSAs...>, Unchecked > );
1346 
1347  if( isChecked ) {
1348  if( I + N > sv.size() ) {
1349  BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
1350  }
1351  }
1352  else {
1353  BLAZE_USER_ASSERT( I + N <= sv.size(), "Invalid subvector specification" );
1354  }
1355 
1356  return subvector<AF1>( sv.operand(), sv.offset() + I, N, args... );
1357 }
1359 //*************************************************************************************************
1360 
1361 
1362 //*************************************************************************************************
1376 template< AlignmentFlag AF1 // Required alignment flag
1377  , typename VT // Type of the vector
1378  , AlignmentFlag AF2 // Present alignment flag
1379  , bool TF // Transpose flag
1380  , bool DF // Density flag
1381  , size_t... CSAs // Compile time subvector arguments
1382  , typename... RSAs > // Optional subvector arguments
1383 inline decltype(auto)
1384  subvector( Subvector<VT,AF2,TF,DF,CSAs...>& sv, size_t index, size_t size, RSAs... args )
1385 {
1387 
1388  constexpr bool isChecked( !Contains_v< TypeList<RSAs...>, Unchecked > );
1389 
1390  if( isChecked ) {
1391  if( index + size > sv.size() ) {
1392  BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
1393  }
1394  }
1395  else {
1396  BLAZE_USER_ASSERT( index + size <= sv.size(), "Invalid subvector specification" );
1397  }
1398 
1399  return subvector<AF1>( sv.operand(), sv.offset() + index, size, args... );
1400 }
1402 //*************************************************************************************************
1403 
1404 
1405 //*************************************************************************************************
1420 template< AlignmentFlag AF1 // Required alignment flag
1421  , typename VT // Type of the vector
1422  , AlignmentFlag AF2 // Present alignment flag
1423  , bool TF // Transpose flag
1424  , bool DF // Density flag
1425  , size_t... CSAs // Compile time subvector arguments
1426  , typename... RSAs > // Optional subvector arguments
1427 inline decltype(auto)
1428  subvector( const Subvector<VT,AF2,TF,DF,CSAs...>& sv, size_t index, size_t size, RSAs... args )
1429 {
1431 
1432  constexpr bool isChecked( !Contains_v< TypeList<RSAs...>, Unchecked > );
1433 
1434  if( isChecked ) {
1435  if( index + size > sv.size() ) {
1436  BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
1437  }
1438  }
1439  else {
1440  BLAZE_USER_ASSERT( index + size <= sv.size(), "Invalid subvector specification" );
1441  }
1442 
1443  return subvector<AF1>( sv.operand(), sv.offset() + index, size, args... );
1444 }
1446 //*************************************************************************************************
1447 
1448 
1449 //*************************************************************************************************
1464 template< AlignmentFlag AF1 // Required alignment flag
1465  , typename VT // Type of the vector
1466  , AlignmentFlag AF2 // Present alignment flag
1467  , bool TF // Transpose flag
1468  , bool DF // Density flag
1469  , size_t... CSAs // Compile time subvector arguments
1470  , typename... RSAs > // Optional subvector arguments
1471 inline decltype(auto)
1472  subvector( Subvector<VT,AF2,TF,DF,CSAs...>&& sv, size_t index, size_t size, RSAs... args )
1473 {
1475 
1476  constexpr bool isChecked( !Contains_v< TypeList<RSAs...>, Unchecked > );
1477 
1478  if( isChecked ) {
1479  if( index + size > sv.size() ) {
1480  BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
1481  }
1482  }
1483  else {
1484  BLAZE_USER_ASSERT( index + size <= sv.size(), "Invalid subvector specification" );
1485  }
1486 
1487  return subvector<AF1>( sv.operand(), sv.offset() + index, size, args... );
1488 }
1490 //*************************************************************************************************
1491 
1492 
1493 
1494 
1495 //=================================================================================================
1496 //
1497 // GLOBAL RESTRUCTURING FUNCTIONS (ELEMENTS)
1498 //
1499 //=================================================================================================
1500 
1501 //*************************************************************************************************
1513 template< size_t I1 // First element index
1514  , size_t... Is // Remaining element indices
1515  , typename VT // Type of the vector
1516  , AlignmentFlag AF // Alignment flag
1517  , bool TF // Transpose flag
1518  , bool DF // Density flag
1519  , size_t I2 // Index of the first subvector element
1520  , size_t N // Size of the subvector
1521  , typename... REAs > // Optional element arguments
1522 inline decltype(auto)
1523  elements( Subvector<VT,AF,TF,DF,I2,N>& sv, REAs... args )
1524 {
1526 
1527  return elements( sv.operand(), make_shifted_index_subsequence<I2,N,I1,Is...>(), args... );
1528 }
1530 //*************************************************************************************************
1531 
1532 
1533 //*************************************************************************************************
1545 template< size_t I1 // First element index
1546  , size_t... Is // Remaining element indices
1547  , typename VT // Type of the vector
1548  , AlignmentFlag AF // Alignment flag
1549  , bool TF // Transpose flag
1550  , bool DF // Density flag
1551  , size_t I2 // Index of the first subvector element
1552  , size_t N // Size of the subvector
1553  , typename... REAs > // Optional element arguments
1554 inline decltype(auto)
1555  elements( const Subvector<VT,AF,TF,DF,I2,N>& sv, REAs... args )
1556 {
1558 
1559  return elements( sv.operand(), make_shifted_index_subsequence<I2,N,I1,Is...>(), args... );
1560 }
1562 //*************************************************************************************************
1563 
1564 
1565 //*************************************************************************************************
1577 template< size_t I1 // First element index
1578  , size_t... Is // Remaining element indices
1579  , typename VT // Type of the vector
1580  , AlignmentFlag AF // Alignment flag
1581  , bool TF // Transpose flag
1582  , bool DF // Density flag
1583  , size_t I2 // Index of the first subvector element
1584  , size_t N // Size of the subvector
1585  , typename... REAs > // Optional element arguments
1586 inline decltype(auto)
1587  elements( Subvector<VT,AF,TF,DF,I2,N>&& sv, REAs... args )
1588 {
1590 
1591  return elements( sv.operand(), make_shifted_index_subsequence<I2,N,I1,Is...>(), args... );
1592 }
1594 //*************************************************************************************************
1595 
1596 
1597 //*************************************************************************************************
1610 template< size_t I // First element index
1611  , size_t... Is // Remaining element indices
1612  , typename VT // Type of the vector
1613  , AlignmentFlag AF // Alignment flag
1614  , bool TF // Transpose flag
1615  , bool DF // Density flag
1616  , typename... REAs > // Optional element arguments
1617 inline decltype(auto) elements( Subvector<VT,AF,TF,DF>& sv, REAs... args )
1618 {
1620 
1621  constexpr bool isChecked( !Contains_v< TypeList<REAs...>, Unchecked > );
1622 
1623  if( isChecked ) {
1624  static constexpr size_t indices[] = { I, Is... };
1625  for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1626  if( sv.size() <= indices[i] ) {
1627  BLAZE_THROW_INVALID_ARGUMENT( "Invalid elements specification" );
1628  }
1629  }
1630  }
1631 
1632  return elements( sv.operand(), { I+sv.offset(), Is+sv.offset()... }, args... );
1633 }
1635 //*************************************************************************************************
1636 
1637 
1638 //*************************************************************************************************
1651 template< size_t I // First element index
1652  , size_t... Is // Remaining element indices
1653  , typename VT // Type of the vector
1654  , AlignmentFlag AF // Alignment flag
1655  , bool TF // Transpose flag
1656  , bool DF // Density flag
1657  , typename... REAs > // Optional element arguments
1658 inline decltype(auto) elements( const Subvector<VT,AF,TF,DF>& sv, REAs... args )
1659 {
1661 
1662  constexpr bool isChecked( !Contains_v< TypeList<REAs...>, Unchecked > );
1663 
1664  if( isChecked ) {
1665  static constexpr size_t indices[] = { I, Is... };
1666  for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1667  if( sv.size() <= indices[i] ) {
1668  BLAZE_THROW_INVALID_ARGUMENT( "Invalid elements specification" );
1669  }
1670  }
1671  }
1672 
1673  return elements( sv.operand(), { I+sv.offset(), Is+sv.offset()... }, args... );
1674 }
1676 //*************************************************************************************************
1677 
1678 
1679 //*************************************************************************************************
1692 template< size_t I // First element index
1693  , size_t... Is // Remaining element indices
1694  , typename VT // Type of the vector
1695  , AlignmentFlag AF // Alignment flag
1696  , bool TF // Transpose flag
1697  , bool DF // Density flag
1698  , typename... REAs > // Optional element arguments
1699 inline decltype(auto) elements( Subvector<VT,AF,TF,DF>&& sv, REAs... args )
1700 {
1702 
1703  constexpr bool isChecked( !Contains_v< TypeList<REAs...>, Unchecked > );
1704 
1705  if( isChecked ) {
1706  static constexpr size_t indices[] = { I, Is... };
1707  for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1708  if( sv.size() <= indices[i] ) {
1709  BLAZE_THROW_INVALID_ARGUMENT( "Invalid elements specification" );
1710  }
1711  }
1712  }
1713 
1714  return elements( sv.operand(), { I+sv.offset(), Is+sv.offset()... }, args... );
1715 }
1717 //*************************************************************************************************
1718 
1719 
1720 //*************************************************************************************************
1735 template< typename VT // Type of the 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 T // Type of the element indices
1741  , typename... REAs > // Optional element arguments
1742 inline decltype(auto)
1743  elements( Subvector<VT,AF,TF,DF,CSAs...>& sv, const T* indices, size_t n, REAs... args )
1744 {
1746 
1747  constexpr bool isChecked( !Contains_v< TypeList<REAs...>, Unchecked > );
1748 
1749  if( isChecked ) {
1750  for( size_t i=0UL; i<n; ++i ) {
1751  if( sv.size() <= indices[i] ) {
1752  BLAZE_THROW_INVALID_ARGUMENT( "Invalid elements specification" );
1753  }
1754  }
1755  }
1756 
1757  SmallArray<size_t,128UL> newIndices( indices, indices+n );
1758  std::for_each( newIndices.begin(), newIndices.end(),
1759  [offset=sv.offset()]( size_t& index ){ index += offset; } );
1760 
1761  return elements( sv.operand(), newIndices.data(), n, args... );
1762 }
1764 //*************************************************************************************************
1765 
1766 
1767 //*************************************************************************************************
1782 template< typename VT // Type of the vector
1783  , AlignmentFlag AF // Alignment flag
1784  , bool TF // Transpose flag
1785  , bool DF // Density flag
1786  , size_t... CSAs // Compile time subvector arguments
1787  , typename T // Type of the element indices
1788  , typename... REAs > // Optional element arguments
1789 inline decltype(auto)
1790  elements( const Subvector<VT,AF,TF,DF,CSAs...>& sv, const T* indices, size_t n, REAs... args )
1791 {
1793 
1794  constexpr bool isChecked( !Contains_v< TypeList<REAs...>, Unchecked > );
1795 
1796  if( isChecked ) {
1797  for( size_t i=0UL; i<n; ++i ) {
1798  if( sv.size() <= indices[i] ) {
1799  BLAZE_THROW_INVALID_ARGUMENT( "Invalid elements specification" );
1800  }
1801  }
1802  }
1803 
1804  SmallArray<size_t,128UL> newIndices( indices, indices+n );
1805  std::for_each( newIndices.begin(), newIndices.end(),
1806  [offset=sv.offset()]( size_t& index ){ index += offset; } );
1807 
1808  return elements( sv.operand(), newIndices.data(), n, args... );
1809 }
1811 //*************************************************************************************************
1812 
1813 
1814 //*************************************************************************************************
1829 template< typename VT // Type of the vector
1830  , AlignmentFlag AF // Alignment flag
1831  , bool TF // Transpose flag
1832  , bool DF // Density flag
1833  , size_t... CSAs // Compile time subvector arguments
1834  , typename T // Type of the element indices
1835  , typename... REAs > // Optional element arguments
1836 inline decltype(auto)
1837  elements( Subvector<VT,AF,TF,DF,CSAs...>&& sv, const T* indices, size_t n, REAs... args )
1838 {
1840 
1841  constexpr bool isChecked( !Contains_v< TypeList<REAs...>, Unchecked > );
1842 
1843  if( isChecked ) {
1844  for( size_t i=0UL; i<n; ++i ) {
1845  if( sv.size() <= indices[i] ) {
1846  BLAZE_THROW_INVALID_ARGUMENT( "Invalid elements specification" );
1847  }
1848  }
1849  }
1850 
1851  SmallArray<size_t,128UL> newIndices( indices, indices+n );
1852  std::for_each( newIndices.begin(), newIndices.end(),
1853  [offset=sv.offset()]( size_t& index ){ index += offset; } );
1854 
1855  return elements( sv.operand(), newIndices.data(), n, args... );
1856 }
1858 //*************************************************************************************************
1859 
1860 
1861 
1862 
1863 //=================================================================================================
1864 //
1865 // SUBVECTOR OPERATORS
1866 //
1867 //=================================================================================================
1868 
1869 //*************************************************************************************************
1877 template< typename VT // Type of the vector
1878  , AlignmentFlag AF // Alignment flag
1879  , bool TF // Transpose flag
1880  , bool DF // Density flag
1881  , size_t... CSAs > // Compile time subvector arguments
1882 inline void reset( Subvector<VT,AF,TF,DF,CSAs...>& sv )
1883 {
1884  sv.reset();
1885 }
1887 //*************************************************************************************************
1888 
1889 
1890 //*************************************************************************************************
1898 template< typename VT // Type of the vector
1899  , AlignmentFlag AF // Alignment flag
1900  , bool TF // Transpose flag
1901  , bool DF // Density flag
1902  , size_t... CSAs > // Compile time subvector arguments
1903 inline void reset( Subvector<VT,AF,TF,DF,CSAs...>&& sv )
1904 {
1905  sv.reset();
1906 }
1908 //*************************************************************************************************
1909 
1910 
1911 //*************************************************************************************************
1919 template< typename VT // Type of the vector
1920  , AlignmentFlag AF // Alignment flag
1921  , bool TF // Transpose flag
1922  , bool DF // Density flag
1923  , size_t... CSAs > // Compile time subvector arguments
1924 inline void clear( Subvector<VT,AF,TF,DF,CSAs...>& sv )
1925 {
1926  sv.reset();
1927 }
1929 //*************************************************************************************************
1930 
1931 
1932 //*************************************************************************************************
1940 template< typename VT // Type of the vector
1941  , AlignmentFlag AF // Alignment flag
1942  , bool TF // Transpose flag
1943  , bool DF // Density flag
1944  , size_t... CSAs > // Compile time subvector arguments
1945 inline void clear( Subvector<VT,AF,TF,DF,CSAs...>&& sv )
1946 {
1947  sv.reset();
1948 }
1950 //*************************************************************************************************
1951 
1952 
1953 //*************************************************************************************************
1980 template< bool RF // Relaxation flag
1981  , typename VT // Type of the dense vector
1982  , AlignmentFlag AF // Alignment flag
1983  , bool TF // Transpose flag
1984  , size_t... CSAs > // Compile time subvector arguments
1985 inline bool isDefault( const Subvector<VT,AF,TF,true,CSAs...>& sv )
1986 {
1987  using blaze::isDefault;
1988 
1989  for( size_t i=0UL; i<sv.size(); ++i )
1990  if( !isDefault<RF>( sv[i] ) ) return false;
1991  return true;
1992 }
1994 //*************************************************************************************************
1995 
1996 
1997 //*************************************************************************************************
2024 template< bool RF // Relaxation flag
2025  , typename VT // Type of the sparse vector
2026  , AlignmentFlag AF // Alignment flag
2027  , bool TF // Transpose flag
2028  , size_t... CSAs > // Compile time subvector arguments
2029 inline bool isDefault( const Subvector<VT,AF,TF,false,CSAs...>& sv )
2030 {
2031  using blaze::isDefault;
2032 
2033  for( const auto& element : ~sv )
2034  if( !isDefault<RF>( element.value() ) ) return false;
2035  return true;
2036 }
2038 //*************************************************************************************************
2039 
2040 
2041 //*************************************************************************************************
2059 template< typename VT // Type of the vector
2060  , AlignmentFlag AF // Alignment flag
2061  , bool TF // Transpose flag
2062  , bool DF // Density flag
2063  , size_t... CSAs > // Compile time subvector arguments
2064 inline bool isIntact( const Subvector<VT,AF,TF,DF,CSAs...>& sv ) noexcept
2065 {
2066  return ( sv.offset() + sv.size() <= sv.operand().size() &&
2067  isIntact( sv.operand() ) );
2068 }
2070 //*************************************************************************************************
2071 
2072 
2073 //*************************************************************************************************
2086 template< typename VT // Type of the vector
2087  , AlignmentFlag AF // Alignment flag
2088  , bool TF // Transpose flag
2089  , bool DF // Density flag
2090  , size_t... CSAs > // Compile time subvector arguments
2091 inline bool isSame( const Subvector<VT,AF,TF,DF,CSAs...>& a, const Vector<VT,TF>& b ) noexcept
2092 {
2093  return ( isSame( a.operand(), ~b ) && ( a.size() == (~b).size() ) );
2094 }
2096 //*************************************************************************************************
2097 
2098 
2099 //*************************************************************************************************
2112 template< typename VT // Type of the vector
2113  , bool TF // Transpose flag
2114  , AlignmentFlag AF // Alignment flag
2115  , bool DF // Density flag
2116  , size_t... CSAs > // Compile time subvector arguments
2117 inline bool isSame( const Vector<VT,TF>& a, const Subvector<VT,AF,TF,DF,CSAs...>& b ) noexcept
2118 {
2119  return isSame( b, a );
2120 }
2122 //*************************************************************************************************
2123 
2124 
2125 //*************************************************************************************************
2138 template< typename VT1 // Type of the vector of the left-hand side subvector
2139  , AlignmentFlag AF1 // Alignment flag of the left-hand side subvector
2140  , bool TF1 // Transpose flag of the left-hand side subvector
2141  , bool DF1 // Density flag of the left-hand side subvector
2142  , size_t... CSAs1 // Compile time subvector arguments of the left-hand side subvector
2143  , typename VT2 // Type of the vector of the right-hand side subvector
2144  , AlignmentFlag AF2 // Alignment flag of the right-hand side subvector
2145  , bool TF2 // Transpose flag of the right-hand side subvector
2146  , bool DF2 // Density flag of the right-hand side subvector
2147  , size_t... CSAs2 > // Compile time subvector arguments of the right-hand side subvector
2148 inline bool isSame( const Subvector<VT1,AF1,TF1,DF1,CSAs1...>& a,
2149  const Subvector<VT2,AF2,TF2,DF2,CSAs2...>& b ) noexcept
2150 {
2151  return ( isSame( a.operand(), b.operand() ) &&
2152  ( a.offset() == b.offset() ) &&
2153  ( a.size() == b.size() ) );
2154 }
2156 //*************************************************************************************************
2157 
2158 
2159 //*************************************************************************************************
2174 template< typename VT // Type of the vector
2175  , AlignmentFlag AF // Alignment flag
2176  , bool TF // Transpose flag
2177  , bool DF // Density flag
2178  , size_t... CSAs // Compile time subvector arguments
2179  , typename ET > // Type of the element
2180 inline bool trySet( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
2181 {
2182  BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
2183 
2184  return trySet( sv.operand(), sv.offset()+index, value );
2185 }
2187 //*************************************************************************************************
2188 
2189 
2190 //*************************************************************************************************
2205 template< typename VT // Type of the vector
2206  , AlignmentFlag AF // Alignment flag
2207  , bool TF // Transpose flag
2208  , bool DF // Density flag
2209  , size_t... CSAs // Compile time subvector arguments
2210  , typename ET > // Type of the element
2211 inline bool tryAdd( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
2212 {
2213  BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
2214 
2215  return tryAdd( sv.operand(), sv.offset()+index, value );
2216 }
2218 //*************************************************************************************************
2219 
2220 
2221 //*************************************************************************************************
2236 template< typename VT // Type of the vector
2237  , AlignmentFlag AF // Alignment flag
2238  , bool TF // Transpose flag
2239  , bool DF // Density flag
2240  , size_t... CSAs // Compile time subvector arguments
2241  , typename ET > // Type of the element
2242 inline bool trySub( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
2243 {
2244  BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
2245 
2246  return trySub( sv.operand(), sv.offset()+index, value );
2247 }
2249 //*************************************************************************************************
2250 
2251 
2252 //*************************************************************************************************
2267 template< typename VT // Type of the vector
2268  , AlignmentFlag AF // Alignment flag
2269  , bool TF // Transpose flag
2270  , bool DF // Density flag
2271  , size_t... CSAs // Compile time subvector arguments
2272  , typename ET > // Type of the element
2273 inline bool tryMult( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
2274 {
2275  BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
2276 
2277  return tryMult( sv.operand(), sv.offset()+index, value );
2278 }
2280 //*************************************************************************************************
2281 
2282 
2283 //*************************************************************************************************
2299 template< typename VT // Type of the vector
2300  , AlignmentFlag AF // Alignment flag
2301  , bool TF // Transpose flag
2302  , bool DF // Density flag
2303  , size_t... CSAs // Compile time subvector arguments
2304  , typename ET > // Type of the element
2306  tryMult( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
2307 {
2308  BLAZE_INTERNAL_ASSERT( index <= (~sv).size(), "Invalid vector access index" );
2309  BLAZE_INTERNAL_ASSERT( index + size <= (~sv).size(), "Invalid range size" );
2310 
2311  return tryMult( sv.operand(), sv.offset()+index, size, value );
2312 }
2314 //*************************************************************************************************
2315 
2316 
2317 //*************************************************************************************************
2332 template< typename VT // Type of the vector
2333  , AlignmentFlag AF // Alignment flag
2334  , bool TF // Transpose flag
2335  , bool DF // Density flag
2336  , size_t... CSAs // Compile time subvector arguments
2337  , typename ET > // Type of the element
2338 inline bool tryDiv( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
2339 {
2340  BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
2341 
2342  return tryDiv( sv.operand(), sv.offset()+index, value );
2343 }
2345 //*************************************************************************************************
2346 
2347 
2348 //*************************************************************************************************
2364 template< typename VT // Type of the vector
2365  , AlignmentFlag AF // Alignment flag
2366  , bool TF // Transpose flag
2367  , bool DF // Density flag
2368  , size_t... CSAs // Compile time subvector arguments
2369  , typename ET > // Type of the element
2371  tryDiv( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
2372 {
2373  BLAZE_INTERNAL_ASSERT( index <= (~sv).size(), "Invalid vector access index" );
2374  BLAZE_INTERNAL_ASSERT( index + size <= (~sv).size(), "Invalid range size" );
2375 
2376  return tryDiv( sv.operand(), sv.offset()+index, size, value );
2377 }
2379 //*************************************************************************************************
2380 
2381 
2382 //*************************************************************************************************
2397 template< typename VT1 // Type of the vector
2398  , AlignmentFlag AF // Alignment flag
2399  , bool TF // Transpose flag
2400  , bool DF // Density flag
2401  , size_t... CSAs // Compile time subvector arguments
2402  , typename VT2 > // Type of the right-hand side vector
2403 inline bool tryAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2404  const Vector<VT2,TF>& rhs, size_t index )
2405 {
2406  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2407  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2408 
2409  return tryAssign( lhs.operand(), ~rhs, lhs.offset() + index );
2410 }
2412 //*************************************************************************************************
2413 
2414 
2415 //*************************************************************************************************
2430 template< typename VT1 // Type of the vector
2431  , AlignmentFlag AF // Alignment flag
2432  , bool TF // Transpose flag
2433  , bool DF // Density flag
2434  , size_t... CSAs // Compile time subvector arguments
2435  , typename VT2 > // Type of the right-hand side vector
2436 inline bool tryAddAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2437  const Vector<VT2,TF>& rhs, size_t index )
2438 {
2439  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2440  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2441 
2442  return tryAddAssign( lhs.operand(), ~rhs, lhs.offset() + index );
2443 }
2445 //*************************************************************************************************
2446 
2447 
2448 //*************************************************************************************************
2463 template< typename VT1 // Type of the vector
2464  , AlignmentFlag AF // Alignment flag
2465  , bool TF // Transpose flag
2466  , bool DF // Density flag
2467  , size_t... CSAs // Compile time subvector arguments
2468  , typename VT2 > // Type of the right-hand side vector
2469 inline bool trySubAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2470  const Vector<VT2,TF>& rhs, size_t index )
2471 {
2472  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2473  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2474 
2475  return trySubAssign( lhs.operand(), ~rhs, lhs.offset() + index );
2476 }
2478 //*************************************************************************************************
2479 
2480 
2481 //*************************************************************************************************
2496 template< typename VT1 // Type of the vector
2497  , AlignmentFlag AF // Alignment flag
2498  , bool TF // Transpose flag
2499  , bool DF // Density flag
2500  , size_t... CSAs // Compile time subvector arguments
2501  , typename VT2 > // Type of the right-hand side vector
2502 inline bool tryMultAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2503  const Vector<VT2,TF>& rhs, size_t index )
2504 {
2505  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2506  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2507 
2508  return tryMultAssign( lhs.operand(), ~rhs, lhs.offset() + index );
2509 }
2511 //*************************************************************************************************
2512 
2513 
2514 //*************************************************************************************************
2529 template< typename VT1 // Type of the vector
2530  , AlignmentFlag AF // Alignment flag
2531  , bool TF // Transpose flag
2532  , bool DF // Density flag
2533  , size_t... CSAs // Compile time subvector arguments
2534  , typename VT2 > // Type of the right-hand side vector
2535 inline bool tryDivAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2536  const Vector<VT2,TF>& rhs, size_t index )
2537 {
2538  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2539  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
2540 
2541  return tryDivAssign( lhs.operand(), ~rhs, lhs.offset() + index );
2542 }
2544 //*************************************************************************************************
2545 
2546 
2547 //*************************************************************************************************
2562 template< typename VT // Type of the vector
2563  , AlignmentFlag AF // Alignment flag
2564  , bool TF // Transpose flag
2565  , bool DF // Density flag
2566  , size_t I // Index of the first element
2567  , size_t N > // Number of elements
2568 inline decltype(auto) derestrict( Subvector<VT,AF,TF,DF,I,N>& sv )
2569 {
2570  return subvector<AF,I,N>( derestrict( sv.operand() ), unchecked );
2571 }
2573 //*************************************************************************************************
2574 
2575 
2576 //*************************************************************************************************
2591 template< typename VT // Type of the vector
2592  , AlignmentFlag AF // Alignment flag
2593  , bool TF // Transpose flag
2594  , bool DF // Density flag
2595  , size_t I // Index of the first element
2596  , size_t N > // Number of elements
2597 inline decltype(auto) derestrict( Subvector<VT,AF,TF,DF,I,N>&& sv )
2598 {
2599  return subvector<AF,I,N>( derestrict( sv.operand() ), unchecked );
2600 }
2602 //*************************************************************************************************
2603 
2604 
2605 //*************************************************************************************************
2620 template< typename VT // Type of the vector
2621  , AlignmentFlag AF // Alignment flag
2622  , bool TF // Transpose flag
2623  , bool DF > // Density flag
2624 inline decltype(auto) derestrict( Subvector<VT,AF,TF,DF>& sv )
2625 {
2626  return subvector<AF>( derestrict( sv.operand() ), sv.offset(), sv.size(), unchecked );
2627 }
2629 //*************************************************************************************************
2630 
2631 
2632 //*************************************************************************************************
2647 template< typename VT // Type of the vector
2648  , AlignmentFlag AF // Alignment flag
2649  , bool TF // Transpose flag
2650  , bool DF > // Density flag
2651 inline decltype(auto) derestrict( Subvector<VT,AF,TF,DF>&& sv )
2652 {
2653  return subvector<AF>( derestrict( sv.operand() ), sv.offset(), sv.size(), unchecked );
2654 }
2656 //*************************************************************************************************
2657 
2658 
2659 
2660 
2661 //=================================================================================================
2662 //
2663 // SIZE SPECIALIZATIONS
2664 //
2665 //=================================================================================================
2666 
2667 //*************************************************************************************************
2669 template< typename VT, AlignmentFlag AF, bool TF, bool DF, size_t I, size_t N >
2670 struct Size< Subvector<VT,AF,TF,DF,I,N>, 0UL >
2671  : public PtrdiffT<N>
2672 {};
2674 //*************************************************************************************************
2675 
2676 
2677 
2678 
2679 //=================================================================================================
2680 //
2681 // MAXSIZE SPECIALIZATIONS
2682 //
2683 //=================================================================================================
2684 
2685 //*************************************************************************************************
2687 template< typename VT, AlignmentFlag AF, bool TF, bool DF, size_t I, size_t N >
2688 struct MaxSize< Subvector<VT,AF,TF,DF,I,N>, 0UL >
2689  : public PtrdiffT<N>
2690 {};
2692 //*************************************************************************************************
2693 
2694 
2695 
2696 
2697 //=================================================================================================
2698 //
2699 // ISRESTRICTED SPECIALIZATIONS
2700 //
2701 //=================================================================================================
2702 
2703 //*************************************************************************************************
2705 template< typename VT, AlignmentFlag AF, bool TF, bool DF, size_t... CSAs >
2706 struct IsRestricted< Subvector<VT,AF,TF,DF,CSAs...> >
2707  : public IsRestricted<VT>
2708 {};
2710 //*************************************************************************************************
2711 
2712 
2713 
2714 
2715 //=================================================================================================
2716 //
2717 // HASCONSTDATAACCESS SPECIALIZATIONS
2718 //
2719 //=================================================================================================
2720 
2721 //*************************************************************************************************
2723 template< typename VT, AlignmentFlag AF, bool TF, size_t... CSAs >
2724 struct HasConstDataAccess< Subvector<VT,AF,TF,true,CSAs...> >
2725  : public HasConstDataAccess<VT>
2726 {};
2728 //*************************************************************************************************
2729 
2730 
2731 
2732 
2733 //=================================================================================================
2734 //
2735 // HASMUTABLEDATAACCESS SPECIALIZATIONS
2736 //
2737 //=================================================================================================
2738 
2739 //*************************************************************************************************
2741 template< typename VT, AlignmentFlag AF, bool TF, size_t... CSAs >
2742 struct HasMutableDataAccess< Subvector<VT,AF,TF,true,CSAs...> >
2743  : public HasMutableDataAccess<VT>
2744 {};
2746 //*************************************************************************************************
2747 
2748 
2749 
2750 
2751 //=================================================================================================
2752 //
2753 // ISALIGNED SPECIALIZATIONS
2754 //
2755 //=================================================================================================
2756 
2757 //*************************************************************************************************
2759 template< typename VT, bool TF, size_t... CSAs >
2760 struct IsAligned< Subvector<VT,aligned,TF,true,CSAs...> >
2761  : public TrueType
2762 {};
2764 //*************************************************************************************************
2765 
2766 
2767 
2768 
2769 //=================================================================================================
2770 //
2771 // ISCONTIGUOUS SPECIALIZATIONS
2772 //
2773 //=================================================================================================
2774 
2775 //*************************************************************************************************
2777 template< typename VT, AlignmentFlag AF, bool TF, size_t... CSAs >
2778 struct IsContiguous< Subvector<VT,AF,TF,true,CSAs...> >
2779  : public IsContiguous<VT>
2780 {};
2782 //*************************************************************************************************
2783 
2784 } // namespace blaze
2785 
2786 #endif
decltype(auto) subvector(Vector< VT, TF > &, RSAs...)
Creating a view on a specific subvector of the given vector.
Definition: Subvector.h:329
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, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
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.
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:591
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
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
#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:139
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:135
Header file for the exception macros of the math module.
Header file for the VecVecMultExpr base class.
Header file for the VecVecSubExpr base class.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
Header file for the CrossExpr base class.
Flag for aligned vectors and matrices.
Definition: AlignmentFlag.h:65
Header file for the HasConstDataAccess type trait.
IntegralConstant< ptrdiff_t, N > PtrdiffT
Compile time integral constant wrapper for ptrdiff_t.The PtrdiffT class template represents an integr...
Definition: PtrdiffT.h:72
Header file for the VecSerialExpr base class.
Header file for the PtrdiffT class template.
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:243
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.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
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:186
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
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, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the TrueType type/value trait base class.
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:1110