Blaze 3.9
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>
80#include <blaze/util/Assert.h>
81#include <blaze/util/EnableIf.h>
87#include <blaze/util/Types.h>
89
90
91namespace blaze {
92
93//=================================================================================================
94//
95// GLOBAL FUNCTIONS
96//
97//=================================================================================================
98
99//*************************************************************************************************
153template< size_t I // Index of the first subvector element
154 , size_t N // Size of the subvector
155 , typename VT // Type of the vector
156 , bool TF // Transpose flag
157 , typename... RSAs > // Optional subvector arguments
158inline decltype(auto) subvector( Vector<VT,TF>& vector, RSAs... args )
159{
161
162 return subvector<unaligned,I,N>( *vector, args... );
163}
164//*************************************************************************************************
165
166
167//*************************************************************************************************
221template< size_t I // Index of the first subvector element
222 , size_t N // Size of the subvector
223 , typename VT // Type of the vector
224 , bool TF // Transpose flag
225 , typename... RSAs > // Optional subvector arguments
226inline decltype(auto) subvector( const Vector<VT,TF>& vector, RSAs... args )
227{
229
230 return subvector<unaligned,I,N>( *vector, args... );
231}
232//*************************************************************************************************
233
234
235//*************************************************************************************************
249template< size_t I // Index of the first subvector element
250 , size_t N // Size of the subvector
251 , typename VT // Type of the vector
252 , bool TF // Transpose flag
253 , typename... RSAs > // Optional subvector arguments
254inline decltype(auto) subvector( Vector<VT,TF>&& vector, RSAs... args )
255{
257
258 return subvector<unaligned,I,N>( std::move( *vector ), args... );
259}
260//*************************************************************************************************
261
262
263//*************************************************************************************************
329template< AlignmentFlag AF // Alignment flag
330 , size_t I // Index of the first subvector element
331 , size_t N // Size of the subvector
332 , typename VT // Type of the vector
333 , bool TF // Transpose flag
334 , typename... RSAs > // Optional subvector arguments
335inline decltype(auto) subvector( Vector<VT,TF>& vector, RSAs... args )
336{
338
339 using ReturnType = Subvector_<VT,AF,I,N>;
340 return ReturnType( *vector, args... );
341}
342//*************************************************************************************************
343
344
345//*************************************************************************************************
409template< AlignmentFlag AF // Alignment flag
410 , size_t I // Index of the first subvector element
411 , size_t N // Size of the subvector
412 , typename VT // Type of the vector
413 , bool TF // Transpose flag
414 , typename... RSAs > // Optional subvector arguments
415inline decltype(auto) subvector( const Vector<VT,TF>& vector, RSAs... args )
416{
418
419 using ReturnType = const Subvector_<const VT,AF,I,N>;
420 return ReturnType( *vector, args... );
421}
422//*************************************************************************************************
423
424
425//*************************************************************************************************
441template< AlignmentFlag AF // Alignment flag
442 , size_t I // Index of the first subvector element
443 , size_t N // Size of the subvector
444 , typename VT // Type of the vector
445 , bool TF // Transpose flag
446 , typename... RSAs > // Optional subvector arguments
447inline decltype(auto) subvector( Vector<VT,TF>&& vector, RSAs... args )
448{
450
451 using ReturnType = Subvector_<VT,AF,I,N>;
452 return ReturnType( *vector, args... );
453}
454//*************************************************************************************************
455
456
457//*************************************************************************************************
513template< typename VT // Type of the vector
514 , bool TF // Transpose flag
515 , typename... RSAs > // Optional subvector arguments
516inline decltype(auto) subvector( Vector<VT,TF>& vector, size_t index, size_t size, RSAs... args )
517{
519
520 return subvector<unaligned>( *vector, index, size, args... );
521}
522//*************************************************************************************************
523
524
525//*************************************************************************************************
581template< typename VT // Type of the vector
582 , bool TF // Transpose flag
583 , typename... RSAs > // Optional subvector arguments
584inline decltype(auto) subvector( const Vector<VT,TF>& vector, size_t index, size_t size, RSAs... args )
585{
587
588 return subvector<unaligned>( *vector, index, size, args... );
589}
590//*************************************************************************************************
591
592
593//*************************************************************************************************
609template< typename VT // Type of the vector
610 , bool TF // Transpose flag
611 , typename... RSAs > // Optional subvector arguments
612inline decltype(auto) subvector( Vector<VT,TF>&& vector, size_t index, size_t size, RSAs... args )
613{
615
616 return subvector<unaligned>( std::move( *vector ), index, size, args... );
617}
618//*************************************************************************************************
619
620
621//*************************************************************************************************
689template< AlignmentFlag AF // Alignment flag
690 , typename VT // Type of the vector
691 , bool TF // Transpose flag
692 , typename... RSAs > // Optional subvector arguments
693inline decltype(auto) subvector( Vector<VT,TF>& vector, size_t index, size_t size, RSAs... args )
694{
696
697 using ReturnType = Subvector_<VT,AF>;
698 return ReturnType( *vector, index, size, args... );
699}
700//*************************************************************************************************
701
702
703//*************************************************************************************************
769template< AlignmentFlag AF // Alignment flag
770 , typename VT // Type of the vector
771 , bool TF // Transpose flag
772 , typename... RSAs > // Optional subvector arguments
773inline decltype(auto) subvector( const Vector<VT,TF>& vector, size_t index, size_t size, RSAs... args )
774{
776
777 using ReturnType = const Subvector_<const VT,AF>;
778 return ReturnType( *vector, index, size, args... );
779}
780//*************************************************************************************************
781
782
783//*************************************************************************************************
801template< AlignmentFlag AF // Alignment flag
802 , typename VT // Type of the vector
803 , bool TF // Transpose flag
804 , typename... RSAs > // Optional subvector arguments
805inline decltype(auto) subvector( Vector<VT,TF>&& vector, size_t index, size_t size, RSAs... args )
806{
808
809 using ReturnType = Subvector_<VT,AF>;
810 return ReturnType( *vector, index, size, args... );
811}
812//*************************************************************************************************
813
814
815
816
817//=================================================================================================
818//
819// GLOBAL RESTRUCTURING FUNCTIONS
820//
821//=================================================================================================
822
823//*************************************************************************************************
836template< AlignmentFlag AF // Alignment flag
837 , size_t... CSAs // Compile time subvector arguments
838 , typename VT // Vector base type of the expression
839 , typename... RSAs > // Runtime subvector arguments
840inline decltype(auto) subvector( const VecVecAddExpr<VT>& vector, RSAs... args )
841{
843
844 return subvector<AF,CSAs...>( (*vector).leftOperand(), args... ) +
845 subvector<AF,CSAs...>( (*vector).rightOperand(), args... );
846}
848//*************************************************************************************************
849
850
851//*************************************************************************************************
864template< AlignmentFlag AF // Alignment flag
865 , size_t... CSAs // Compile time subvector arguments
866 , typename VT // Vector base type of the expression
867 , typename... RSAs > // Runtime subvector arguments
868inline decltype(auto) subvector( const VecVecSubExpr<VT>& vector, RSAs... args )
869{
871
872 return subvector<AF,CSAs...>( (*vector).leftOperand(), args... ) -
873 subvector<AF,CSAs...>( (*vector).rightOperand(), args... );
874}
876//*************************************************************************************************
877
878
879//*************************************************************************************************
892template< AlignmentFlag AF // Alignment flag
893 , size_t... CSAs // Compile time subvector arguments
894 , typename VT // Vector base type of the expression
895 , typename... RSAs > // Runtime subvector arguments
896inline decltype(auto) subvector( const VecVecMultExpr<VT>& vector, RSAs... args )
897{
899
900 return subvector<AF,CSAs...>( (*vector).leftOperand(), args... ) *
901 subvector<AF,CSAs...>( (*vector).rightOperand(), args... );
902}
904//*************************************************************************************************
905
906
907//*************************************************************************************************
920template< AlignmentFlag AF // Alignment flag
921 , size_t I // Index of the first subvector element
922 , size_t N // Size of the subvector
923 , typename VT // Vector base type of the expression
924 , typename... RSAs > // Optional subvector arguments
925inline decltype(auto) subvector( const VecVecKronExpr<VT>& vector, RSAs... args )
926{
928
929 try {
930 return elements( *vector, make_shifted_index_sequence<I,N>(), args... );
931 }
932 catch( ... ) {
933 BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
934 }
935}
937//*************************************************************************************************
938
939
940//*************************************************************************************************
955template< AlignmentFlag AF // Alignment flag
956 , typename VT // Vector base type of the expression
957 , typename... RSAs > // Optional subvector arguments
958inline decltype(auto) subvector( const VecVecKronExpr<VT>& vector, size_t index, size_t size, RSAs... args )
959{
961
962 try {
963 return elements( *vector, [index]( size_t i ){ return i+index; }, size, args... );
964 }
965 catch( ... ) {
966 BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
967 }
968}
970//*************************************************************************************************
971
972
973//*************************************************************************************************
986template< AlignmentFlag AF // Alignment flag
987 , size_t... CSAs // Compile time subvector arguments
988 , typename VT // Vector base type of the expression
989 , typename... RSAs > // Runtime subvector arguments
990inline decltype(auto) subvector( const VecVecDivExpr<VT>& vector, RSAs... args )
991{
993
994 return subvector<AF,CSAs...>( (*vector).leftOperand(), args... ) /
995 subvector<AF,CSAs...>( (*vector).rightOperand(), args... );
996}
998//*************************************************************************************************
999
1000
1001//*************************************************************************************************
1014template< AlignmentFlag AF // Alignment flag
1015 , size_t... CSAs // Compile time subvector arguments
1016 , typename VT // Vector base type of the expression
1017 , typename... RSAs > // Runtime subvector arguments
1018inline decltype(auto) subvector( const CrossExpr<VT>& vector, RSAs... args )
1019{
1021
1022 using ReturnType = Subvector_< VectorType_t<VT>, unaligned, CSAs... >;
1023 return ReturnType( *vector, args... );
1024}
1026//*************************************************************************************************
1027
1028
1029//*************************************************************************************************
1042template< 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
1046inline decltype(auto) subvector( const VecScalarMultExpr<VT>& vector, RSAs... args )
1047{
1049
1050 return subvector<AF,CSAs...>( (*vector).leftOperand(), args... ) * (*vector).rightOperand();
1051}
1053//*************************************************************************************************
1054
1055
1056//*************************************************************************************************
1069template< AlignmentFlag AF // Alignment flag
1070 , size_t... CSAs // Compile time subvector arguments
1071 , typename VT // Vector base type of the expression
1072 , typename... RSAs > // Runtime subvector arguments
1073inline decltype(auto) subvector( const VecScalarDivExpr<VT>& vector, RSAs... args )
1074{
1076
1077 return subvector<AF,CSAs...>( (*vector).leftOperand(), args... ) / (*vector).rightOperand();
1078}
1080//*************************************************************************************************
1081
1082
1083//*************************************************************************************************
1096template< 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
1100inline decltype(auto) subvector( const VecMapExpr<VT>& vector, RSAs... args )
1101{
1103
1104 return map( subvector<AF,CSAs...>( (*vector).operand(), args... ), (*vector).operation() );
1105}
1107//*************************************************************************************************
1108
1109
1110//*************************************************************************************************
1123template< AlignmentFlag AF // Alignment flag
1124 , size_t... CSAs // Compile time subvector arguments
1125 , typename VT // Vector base type of the expression
1126 , typename... RSAs > // Runtime subvector arguments
1127inline decltype(auto) subvector( const VecVecMapExpr<VT>& vector, RSAs... args )
1128{
1130
1131 return map( subvector<AF,CSAs...>( (*vector).leftOperand(), args... ),
1132 subvector<AF,CSAs...>( (*vector).rightOperand(), args... ),
1133 (*vector).operation() );
1134}
1136//*************************************************************************************************
1137
1138
1139//*************************************************************************************************
1152template< 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
1156inline decltype(auto) subvector( const VecEvalExpr<VT>& vector, RSAs... args )
1157{
1159
1160 return eval( subvector<AF,CSAs...>( (*vector).operand(), args... ) );
1161}
1163//*************************************************************************************************
1164
1165
1166//*************************************************************************************************
1179template< AlignmentFlag AF // Alignment flag
1180 , size_t... CSAs // Compile time subvector arguments
1181 , typename VT // Vector base type of the expression
1182 , typename... RSAs > // Runtime subvector arguments
1183inline decltype(auto) subvector( const VecSerialExpr<VT>& vector, RSAs... args )
1184{
1186
1187 return serial( subvector<AF,CSAs...>( (*vector).operand(), args... ) );
1188}
1190//*************************************************************************************************
1191
1192
1193//*************************************************************************************************
1206template< AlignmentFlag AF // Alignment flag
1207 , size_t... CSAs // Compile time subvector arguments
1208 , typename VT // Vector base type of the expression
1209 , typename... RSAs > // Runtime subvector arguments
1210inline decltype(auto) subvector( const VecNoAliasExpr<VT>& vector, RSAs... args )
1211{
1213
1214 return noalias( subvector<AF,CSAs...>( (*vector).operand(), args... ) );
1215}
1217//*************************************************************************************************
1218
1219
1220//*************************************************************************************************
1233template< AlignmentFlag AF // Alignment flag
1234 , size_t... CSAs // Compile time subvector arguments
1235 , typename VT // Vector base type of the expression
1236 , typename... RSAs > // Runtime subvector arguments
1237inline decltype(auto) subvector( const VecNoSIMDExpr<VT>& vector, RSAs... args )
1238{
1240
1241 return nosimd( subvector<AF,CSAs...>( (*vector).operand(), args... ) );
1242}
1244//*************************************************************************************************
1245
1246
1247//*************************************************************************************************
1260template< AlignmentFlag AF // Alignment flag
1261 , size_t... CSAs // Compile time subvector arguments
1262 , typename VT // Vector base type of the expression
1263 , typename... RSAs > // Runtime subvector arguments
1264inline decltype(auto) subvector( const VecTransExpr<VT>& vector, RSAs... args )
1265{
1267
1268 return trans( subvector<AF,CSAs...>( (*vector).operand(), args... ) );
1269}
1271//*************************************************************************************************
1272
1273
1274//*************************************************************************************************
1287template< AlignmentFlag AF // Alignment flag
1288 , size_t I // Index of the first subvector element
1289 , size_t N // Size of the subvector
1290 , typename VT // Vector base type of the expression
1291 , size_t... CRAs // Compile time repeater arguments
1292 , typename... RSAs > // Optional subvector arguments
1293inline decltype(auto) subvector( const VecRepeatExpr<VT,CRAs...>& vector, RSAs... args )
1294{
1296
1297 if( isChecked( args... ) ) {
1298 if( I + N > (*vector).size() ) {
1299 BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
1300 }
1301 }
1302 else {
1303 BLAZE_USER_ASSERT( I + N <= (*vector).size(), "Invalid subvector specification" );
1304 }
1305
1306 const size_t n = (*vector).operand().size();
1307
1308 return elements( (*vector).operand(), [n]( size_t i ) { return (i+I)%n; }, N, unchecked );
1309}
1311//*************************************************************************************************
1312
1313
1314//*************************************************************************************************
1329template< AlignmentFlag AF // Alignment flag
1330 , typename VT // Vector base type of the expression
1331 , size_t... CRAs // Compile time repeater arguments
1332 , typename... RSAs > // Optional subvector arguments
1333inline decltype(auto)
1334 subvector( const VecRepeatExpr<VT,CRAs...>& vector, size_t index, size_t size, RSAs... args )
1335{
1337
1338 if( isChecked( args... ) ) {
1339 if( index + size > (*vector).size() ) {
1340 BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
1341 }
1342 }
1343 else {
1344 BLAZE_USER_ASSERT( index + size <= (*vector).size(), "Invalid subvector specification" );
1345 }
1346
1347 const size_t n = (*vector).operand().size();
1348
1349 return elements( (*vector).operand(), [index,n]( size_t i ) { return (i+index)%n; }, size, unchecked );
1350}
1352//*************************************************************************************************
1353
1354
1355
1356
1357//=================================================================================================
1358//
1359// GLOBAL RESTRUCTURING FUNCTIONS (SUBVECTOR)
1360//
1361//=================================================================================================
1362
1363//*************************************************************************************************
1374template< AlignmentFlag AF // Required alignment flag
1375 , size_t I // Required subvector offset
1376 , size_t N // Required size of the subvector
1377 , typename VT // Type of the vector
1378 , typename... RSAs // Optional subvector arguments
1379 , EnableIf_t< IsSubvector_v< RemoveReference_t<VT> > &&
1380 RemoveReference_t<VT>::compileTimeArgs >* = nullptr >
1381inline decltype(auto) subvector( VT&& sv, RSAs... args )
1382{
1384
1385 constexpr size_t I2( RemoveReference_t<VT>::offset() );
1386 constexpr size_t N2( RemoveReference_t<VT>::size() );
1387
1388 BLAZE_STATIC_ASSERT_MSG( I + N <= N2, "Invalid subvector specification" );
1389
1390 return subvector<AF,I+I2,N>( sv.operand(), args... );
1391}
1393//*************************************************************************************************
1394
1395
1396//*************************************************************************************************
1408template< AlignmentFlag AF // Required alignment flag
1409 , size_t I // Index of the first subvector element
1410 , size_t N // Size of the subvector
1411 , typename VT // Type of the vector
1412 , typename... RSAs // Optional subvector arguments
1413 , EnableIf_t< IsSubvector_v< RemoveReference_t<VT> > &&
1414 !RemoveReference_t<VT>::compileTimeArgs >* = nullptr >
1415inline decltype(auto) subvector( VT&& sv, RSAs... args )
1416{
1418
1419 if( isChecked( args... ) ) {
1420 if( I + N > sv.size() ) {
1421 BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
1422 }
1423 }
1424 else {
1425 BLAZE_USER_ASSERT( I + N <= sv.size(), "Invalid subvector specification" );
1426 }
1427
1428 return subvector<AF>( sv.operand(), sv.offset() + I, N, args... );
1429}
1431//*************************************************************************************************
1432
1433
1434//*************************************************************************************************
1448template< AlignmentFlag AF // Required alignment flag
1449 , typename VT // Type of the vector
1450 , typename... RSAs // Optional subvector arguments
1451 , EnableIf_t< IsSubvector_v< RemoveReference_t<VT> > >* = nullptr >
1452inline decltype(auto)
1453 subvector( VT&& sv, size_t index, size_t size, RSAs... args )
1454{
1456
1457 if( isChecked( args... ) ) {
1458 if( index + size > sv.size() ) {
1459 BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
1460 }
1461 }
1462 else {
1463 BLAZE_USER_ASSERT( index + size <= sv.size(), "Invalid subvector specification" );
1464 }
1465
1466 return subvector<AF>( sv.operand(), sv.offset() + index, size, args... );
1467}
1469//*************************************************************************************************
1470
1471
1472
1473
1474//=================================================================================================
1475//
1476// GLOBAL RESTRUCTURING FUNCTIONS (ELEMENTS)
1477//
1478//=================================================================================================
1479
1480//*************************************************************************************************
1492template< size_t I // First element index
1493 , size_t... Is // Remaining element indices
1494 , typename VT // Type of the vector
1495 , typename... REAs // Optional element arguments
1496 , EnableIf_t< IsSubvector_v< RemoveReference_t<VT> > &&
1497 RemoveReference_t<VT>::compileTimeArgs >* = nullptr >
1498inline decltype(auto) elements( VT&& sv, REAs... args )
1499{
1501
1502 constexpr size_t I2 = RemoveReference_t<VT>::offset();
1503 constexpr size_t N = RemoveReference_t<VT>::size();
1504
1505 return elements( sv.operand(), make_shifted_index_subsequence<I2,N,I,Is...>(), args... );
1506}
1508//*************************************************************************************************
1509
1510
1511//*************************************************************************************************
1524template< size_t I // First element index
1525 , size_t... Is // Remaining element indices
1526 , typename VT // Type of the vector
1527 , typename... REAs // Optional element arguments
1528 , EnableIf_t< IsSubvector_v< RemoveReference_t<VT> > &&
1529 !RemoveReference_t<VT>::compileTimeArgs >* = nullptr >
1530inline decltype(auto) elements( VT&& sv, REAs... args )
1531{
1533
1534 if( isChecked( args... ) ) {
1535 constexpr size_t indices[] = { I, Is... };
1536 for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1537 if( sv.size() <= indices[i] ) {
1538 BLAZE_THROW_INVALID_ARGUMENT( "Invalid element access index" );
1539 }
1540 }
1541 }
1542
1543 return elements( sv.operand(), { I+sv.offset(), Is+sv.offset()... }, args... );
1544}
1546//*************************************************************************************************
1547
1548
1549//*************************************************************************************************
1564template< typename VT // Type of the vector
1565 , typename T // Type of the element indices
1566 , typename... REAs // Optional element arguments
1567 , EnableIf_t< IsSubvector_v< RemoveReference_t<VT> > >* = nullptr >
1568inline decltype(auto) elements( VT&& sv, T* indices, size_t n, REAs... args )
1569{
1571
1572 if( isChecked( args... ) ) {
1573 for( size_t i=0UL; i<n; ++i ) {
1574 if( sv.size() <= size_t( indices[i] ) ) {
1575 BLAZE_THROW_INVALID_ARGUMENT( "Invalid element access index" );
1576 }
1577 }
1578 }
1579
1580 SmallArray<size_t,128UL> newIndices( indices, indices+n );
1581 std::for_each( newIndices.begin(), newIndices.end(),
1582 [offset=sv.offset()]( size_t& index ){ index += offset; } );
1583
1584 return elements( sv.operand(), newIndices.data(), n, args... );
1585}
1587//*************************************************************************************************
1588
1589
1590//*************************************************************************************************
1605template< typename VT // Type of the vector
1606 , typename P // Type of the index producer
1607 , typename... REAs // Optional element arguments
1608 , EnableIf_t< IsSubvector_v< RemoveReference_t<VT> > >* = nullptr >
1609inline decltype(auto) elements( VT&& sv, P p, size_t n, REAs... args )
1610{
1612
1613 if( isChecked( args... ) ) {
1614 for( size_t i=0UL; i<n; ++i ) {
1615 if( sv.size() <= size_t( p(i) ) ) {
1616 BLAZE_THROW_INVALID_ARGUMENT( "Invalid element access index" );
1617 }
1618 }
1619 }
1620
1621 return elements( sv.operand(), [p,offset=sv.offset()]( size_t i ){ return p(i)+offset; }, n, args... );
1622}
1624//*************************************************************************************************
1625
1626
1627
1628
1629//=================================================================================================
1630//
1631// SUBVECTOR OPERATORS
1632//
1633//=================================================================================================
1634
1635//*************************************************************************************************
1662template< RelaxationFlag RF // Relaxation flag
1663 , typename VT // Type of the dense vector
1664 , AlignmentFlag AF // Alignment flag
1665 , bool TF // Transpose flag
1666 , size_t... CSAs > // Compile time subvector arguments
1667inline bool isDefault( const Subvector<VT,AF,TF,true,CSAs...>& sv )
1668{
1669 using blaze::isDefault;
1670
1671 for( size_t i=0UL; i<sv.size(); ++i )
1672 if( !isDefault<RF>( sv[i] ) ) return false;
1673 return true;
1674}
1676//*************************************************************************************************
1677
1678
1679//*************************************************************************************************
1706template< RelaxationFlag RF // Relaxation flag
1707 , typename VT // Type of the sparse vector
1708 , AlignmentFlag AF // Alignment flag
1709 , bool TF // Transpose flag
1710 , size_t... CSAs > // Compile time subvector arguments
1711inline bool isDefault( const Subvector<VT,AF,TF,false,CSAs...>& sv )
1712{
1713 using blaze::isDefault;
1714
1715 for( const auto& element : *sv )
1716 if( !isDefault<RF>( element.value() ) ) return false;
1717 return true;
1718}
1720//*************************************************************************************************
1721
1722
1723//*************************************************************************************************
1741template< typename VT // Type of the vector
1742 , AlignmentFlag AF // Alignment flag
1743 , bool TF // Transpose flag
1744 , bool DF // Density flag
1745 , size_t... CSAs > // Compile time subvector arguments
1746inline bool isIntact( const Subvector<VT,AF,TF,DF,CSAs...>& sv ) noexcept
1747{
1748 return ( sv.offset() + sv.size() <= sv.operand().size() &&
1749 isIntact( sv.operand() ) );
1750}
1752//*************************************************************************************************
1753
1754
1755//*************************************************************************************************
1768template< typename VT // Type of the vector
1769 , AlignmentFlag AF // Alignment flag
1770 , bool TF // Transpose flag
1771 , bool DF // Density flag
1772 , size_t... CSAs > // Compile time subvector arguments
1773inline bool isSame( const Subvector<VT,AF,TF,DF,CSAs...>& a, const Vector<VT,TF>& b ) noexcept
1774{
1775 return ( isSame( a.operand(), *b ) && ( a.size() == (*b).size() ) );
1776}
1778//*************************************************************************************************
1779
1780
1781//*************************************************************************************************
1794template< typename VT // Type of the vector
1795 , bool TF // Transpose flag
1796 , AlignmentFlag AF // Alignment flag
1797 , bool DF // Density flag
1798 , size_t... CSAs > // Compile time subvector arguments
1799inline bool isSame( const Vector<VT,TF>& a, const Subvector<VT,AF,TF,DF,CSAs...>& b ) noexcept
1800{
1801 return isSame( b, a );
1802}
1804//*************************************************************************************************
1805
1806
1807//*************************************************************************************************
1820template< typename VT1 // Type of the vector of the left-hand side subvector
1821 , AlignmentFlag AF1 // Alignment flag of the left-hand side subvector
1822 , bool TF1 // Transpose flag of the left-hand side subvector
1823 , bool DF1 // Density flag of the left-hand side subvector
1824 , size_t... CSAs1 // Compile time subvector arguments of the left-hand side subvector
1825 , typename VT2 // Type of the vector of the right-hand side subvector
1826 , AlignmentFlag AF2 // Alignment flag of the right-hand side subvector
1827 , bool TF2 // Transpose flag of the right-hand side subvector
1828 , bool DF2 // Density flag of the right-hand side subvector
1829 , size_t... CSAs2 > // Compile time subvector arguments of the right-hand side subvector
1830inline bool isSame( const Subvector<VT1,AF1,TF1,DF1,CSAs1...>& a,
1831 const Subvector<VT2,AF2,TF2,DF2,CSAs2...>& b ) noexcept
1832{
1833 return ( isSame( a.operand(), b.operand() ) &&
1834 ( a.offset() == b.offset() ) &&
1835 ( a.size() == b.size() ) );
1836}
1838//*************************************************************************************************
1839
1840
1841//*************************************************************************************************
1856template< typename VT // Type of the vector
1857 , AlignmentFlag AF // Alignment flag
1858 , bool TF // Transpose flag
1859 , bool DF // Density flag
1860 , size_t... CSAs // Compile time subvector arguments
1861 , typename ET > // Type of the element
1862inline bool trySet( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
1863{
1864 BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
1865
1866 return trySet( sv.operand(), sv.offset()+index, value );
1867}
1869//*************************************************************************************************
1870
1871
1872//*************************************************************************************************
1888template< typename VT // Type of the vector
1889 , AlignmentFlag AF // Alignment flag
1890 , bool TF // Transpose flag
1891 , bool DF // Density flag
1892 , size_t... CSAs // Compile time subvector arguments
1893 , typename ET > // Type of the element
1895 trySet( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
1896{
1897 BLAZE_INTERNAL_ASSERT( index <= (*sv).size(), "Invalid vector access index" );
1898 BLAZE_INTERNAL_ASSERT( index + size <= (*sv).size(), "Invalid range size" );
1899
1900 return trySet( sv.operand(), sv.offset()+index, size, value );
1901}
1903//*************************************************************************************************
1904
1905
1906//*************************************************************************************************
1921template< typename VT // Type of the vector
1922 , AlignmentFlag AF // Alignment flag
1923 , bool TF // Transpose flag
1924 , bool DF // Density flag
1925 , size_t... CSAs // Compile time subvector arguments
1926 , typename ET > // Type of the element
1927inline bool tryAdd( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
1928{
1929 BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
1930
1931 return tryAdd( sv.operand(), sv.offset()+index, value );
1932}
1934//*************************************************************************************************
1935
1936
1937//*************************************************************************************************
1953template< typename VT // Type of the vector
1954 , AlignmentFlag AF // Alignment flag
1955 , bool TF // Transpose flag
1956 , bool DF // Density flag
1957 , size_t... CSAs // Compile time subvector arguments
1958 , typename ET > // Type of the element
1960 tryAdd( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
1961{
1962 BLAZE_INTERNAL_ASSERT( index <= (*sv).size(), "Invalid vector access index" );
1963 BLAZE_INTERNAL_ASSERT( index + size <= (*sv).size(), "Invalid range size" );
1964
1965 return tryAdd( sv.operand(), sv.offset()+index, size, value );
1966}
1968//*************************************************************************************************
1969
1970
1971//*************************************************************************************************
1986template< typename VT // Type of the vector
1987 , AlignmentFlag AF // Alignment flag
1988 , bool TF // Transpose flag
1989 , bool DF // Density flag
1990 , size_t... CSAs // Compile time subvector arguments
1991 , typename ET > // Type of the element
1992inline bool trySub( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
1993{
1994 BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
1995
1996 return trySub( sv.operand(), sv.offset()+index, value );
1997}
1999//*************************************************************************************************
2000
2001
2002//*************************************************************************************************
2018template< typename VT // Type of the vector
2019 , AlignmentFlag AF // Alignment flag
2020 , bool TF // Transpose flag
2021 , bool DF // Density flag
2022 , size_t... CSAs // Compile time subvector arguments
2023 , typename ET > // Type of the element
2025 trySub( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
2026{
2027 BLAZE_INTERNAL_ASSERT( index <= (*sv).size(), "Invalid vector access index" );
2028 BLAZE_INTERNAL_ASSERT( index + size <= (*sv).size(), "Invalid range size" );
2029
2030 return trySub( sv.operand(), sv.offset()+index, size, value );
2031}
2033//*************************************************************************************************
2034
2035
2036//*************************************************************************************************
2051template< typename VT // Type of the vector
2052 , AlignmentFlag AF // Alignment flag
2053 , bool TF // Transpose flag
2054 , bool DF // Density flag
2055 , size_t... CSAs // Compile time subvector arguments
2056 , typename ET > // Type of the element
2057inline bool tryMult( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
2058{
2059 BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
2060
2061 return tryMult( sv.operand(), sv.offset()+index, value );
2062}
2064//*************************************************************************************************
2065
2066
2067//*************************************************************************************************
2083template< typename VT // Type of the vector
2084 , AlignmentFlag AF // Alignment flag
2085 , bool TF // Transpose flag
2086 , bool DF // Density flag
2087 , size_t... CSAs // Compile time subvector arguments
2088 , typename ET > // Type of the element
2090 tryMult( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
2091{
2092 BLAZE_INTERNAL_ASSERT( index <= (*sv).size(), "Invalid vector access index" );
2093 BLAZE_INTERNAL_ASSERT( index + size <= (*sv).size(), "Invalid range size" );
2094
2095 return tryMult( sv.operand(), sv.offset()+index, size, value );
2096}
2098//*************************************************************************************************
2099
2100
2101//*************************************************************************************************
2116template< typename VT // Type of the vector
2117 , AlignmentFlag AF // Alignment flag
2118 , bool TF // Transpose flag
2119 , bool DF // Density flag
2120 , size_t... CSAs // Compile time subvector arguments
2121 , typename ET > // Type of the element
2122inline bool tryDiv( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
2123{
2124 BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
2125
2126 return tryDiv( sv.operand(), sv.offset()+index, value );
2127}
2129//*************************************************************************************************
2130
2131
2132//*************************************************************************************************
2148template< typename VT // Type of the vector
2149 , AlignmentFlag AF // Alignment flag
2150 , bool TF // Transpose flag
2151 , bool DF // Density flag
2152 , size_t... CSAs // Compile time subvector arguments
2153 , typename ET > // Type of the element
2155 tryDiv( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
2156{
2157 BLAZE_INTERNAL_ASSERT( index <= (*sv).size(), "Invalid vector access index" );
2158 BLAZE_INTERNAL_ASSERT( index + size <= (*sv).size(), "Invalid range size" );
2159
2160 return tryDiv( sv.operand(), sv.offset()+index, size, value );
2161}
2163//*************************************************************************************************
2164
2165
2166//*************************************************************************************************
2181template< typename VT // Type of the vector
2182 , AlignmentFlag AF // Alignment flag
2183 , bool TF // Transpose flag
2184 , bool DF // Density flag
2185 , size_t... CSAs > // Compile time subvector arguments
2186inline bool tryShift( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, int count )
2187{
2188 BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
2189
2190 return tryShift( sv.operand(), sv.offset()+index, count );
2191}
2193//*************************************************************************************************
2194
2195
2196//*************************************************************************************************
2212template< typename VT // Type of the vector
2213 , AlignmentFlag AF // Alignment flag
2214 , bool TF // Transpose flag
2215 , bool DF // Density flag
2216 , size_t... CSAs > // Compile time subvector arguments
2218 tryShift( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, int count )
2219{
2220 BLAZE_INTERNAL_ASSERT( index <= (*sv).size(), "Invalid vector access index" );
2221 BLAZE_INTERNAL_ASSERT( index + size <= (*sv).size(), "Invalid range size" );
2222
2223 return tryShift( sv.operand(), sv.offset()+index, size, count );
2224}
2226//*************************************************************************************************
2227
2228
2229//*************************************************************************************************
2244template< typename VT // Type of the vector
2245 , AlignmentFlag AF // Alignment flag
2246 , bool TF // Transpose flag
2247 , bool DF // Density flag
2248 , size_t... CSAs // Compile time subvector arguments
2249 , typename ET > // Type of the element
2250inline bool tryBitand( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
2251{
2252 BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
2253
2254 return tryBitand( sv.operand(), sv.offset()+index, value );
2255}
2257//*************************************************************************************************
2258
2259
2260//*************************************************************************************************
2276template< typename VT // Type of the vector
2277 , AlignmentFlag AF // Alignment flag
2278 , bool TF // Transpose flag
2279 , bool DF // Density flag
2280 , size_t... CSAs // Compile time subvector arguments
2281 , typename ET > // Type of the element
2283 tryBitand( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
2284{
2285 BLAZE_INTERNAL_ASSERT( index <= (*sv).size(), "Invalid vector access index" );
2286 BLAZE_INTERNAL_ASSERT( index + size <= (*sv).size(), "Invalid range size" );
2287
2288 return tryBitand( sv.operand(), sv.offset()+index, size, value );
2289}
2291//*************************************************************************************************
2292
2293
2294//*************************************************************************************************
2309template< typename VT // Type of the vector
2310 , AlignmentFlag AF // Alignment flag
2311 , bool TF // Transpose flag
2312 , bool DF // Density flag
2313 , size_t... CSAs // Compile time subvector arguments
2314 , typename ET > // Type of the element
2315inline bool tryBitor( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
2316{
2317 BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
2318
2319 return tryBitor( sv.operand(), sv.offset()+index, value );
2320}
2322//*************************************************************************************************
2323
2324
2325//*************************************************************************************************
2341template< typename VT // Type of the vector
2342 , AlignmentFlag AF // Alignment flag
2343 , bool TF // Transpose flag
2344 , bool DF // Density flag
2345 , size_t... CSAs // Compile time subvector arguments
2346 , typename ET > // Type of the element
2348 tryBitor( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
2349{
2350 BLAZE_INTERNAL_ASSERT( index <= (*sv).size(), "Invalid vector access index" );
2351 BLAZE_INTERNAL_ASSERT( index + size <= (*sv).size(), "Invalid range size" );
2352
2353 return tryBitor( sv.operand(), sv.offset()+index, size, value );
2354}
2356//*************************************************************************************************
2357
2358
2359//*************************************************************************************************
2374template< typename VT // Type of the vector
2375 , AlignmentFlag AF // Alignment flag
2376 , bool TF // Transpose flag
2377 , bool DF // Density flag
2378 , size_t... CSAs // Compile time subvector arguments
2379 , typename ET > // Type of the element
2380inline bool tryBitxor( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, const ET& value )
2381{
2382 BLAZE_INTERNAL_ASSERT( index < sv.size(), "Invalid vector access index" );
2383
2384 return tryBitxor( sv.operand(), sv.offset()+index, value );
2385}
2387//*************************************************************************************************
2388
2389
2390//*************************************************************************************************
2406template< typename VT // Type of the vector
2407 , AlignmentFlag AF // Alignment flag
2408 , bool TF // Transpose flag
2409 , bool DF // Density flag
2410 , size_t... CSAs // Compile time subvector arguments
2411 , typename ET > // Type of the element
2413 tryBitxor( const Subvector<VT,AF,TF,DF,CSAs...>& sv, size_t index, size_t size, const ET& value )
2414{
2415 BLAZE_INTERNAL_ASSERT( index <= (*sv).size(), "Invalid vector access index" );
2416 BLAZE_INTERNAL_ASSERT( index + size <= (*sv).size(), "Invalid range size" );
2417
2418 return tryBitxor( sv.operand(), sv.offset()+index, size, value );
2419}
2421//*************************************************************************************************
2422
2423
2424//*************************************************************************************************
2439template< typename VT1 // Type of the vector
2440 , AlignmentFlag AF // Alignment flag
2441 , bool TF // Transpose flag
2442 , bool DF // Density flag
2443 , size_t... CSAs // Compile time subvector arguments
2444 , typename VT2 > // Type of the right-hand side vector
2445inline bool tryAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2446 const Vector<VT2,TF>& rhs, size_t index )
2447{
2448 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2449 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2450
2451 return tryAssign( lhs.operand(), *rhs, lhs.offset() + index );
2452}
2454//*************************************************************************************************
2455
2456
2457//*************************************************************************************************
2472template< typename VT1 // Type of the vector
2473 , AlignmentFlag AF // Alignment flag
2474 , bool TF // Transpose flag
2475 , bool DF // Density flag
2476 , size_t... CSAs // Compile time subvector arguments
2477 , typename VT2 > // Type of the right-hand side vector
2478inline bool tryAddAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2479 const Vector<VT2,TF>& rhs, size_t index )
2480{
2481 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2482 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2483
2484 return tryAddAssign( lhs.operand(), *rhs, lhs.offset() + index );
2485}
2487//*************************************************************************************************
2488
2489
2490//*************************************************************************************************
2505template< typename VT1 // Type of the vector
2506 , AlignmentFlag AF // Alignment flag
2507 , bool TF // Transpose flag
2508 , bool DF // Density flag
2509 , size_t... CSAs // Compile time subvector arguments
2510 , typename VT2 > // Type of the right-hand side vector
2511inline bool trySubAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2512 const Vector<VT2,TF>& rhs, size_t index )
2513{
2514 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2515 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2516
2517 return trySubAssign( lhs.operand(), *rhs, lhs.offset() + index );
2518}
2520//*************************************************************************************************
2521
2522
2523//*************************************************************************************************
2538template< typename VT1 // Type of the vector
2539 , AlignmentFlag AF // Alignment flag
2540 , bool TF // Transpose flag
2541 , bool DF // Density flag
2542 , size_t... CSAs // Compile time subvector arguments
2543 , typename VT2 > // Type of the right-hand side vector
2544inline bool tryMultAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2545 const Vector<VT2,TF>& rhs, size_t index )
2546{
2547 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2548 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2549
2550 return tryMultAssign( lhs.operand(), *rhs, lhs.offset() + index );
2551}
2553//*************************************************************************************************
2554
2555
2556//*************************************************************************************************
2571template< typename VT1 // Type of the vector
2572 , AlignmentFlag AF // Alignment flag
2573 , bool TF // Transpose flag
2574 , bool DF // Density flag
2575 , size_t... CSAs // Compile time subvector arguments
2576 , typename VT2 > // Type of the right-hand side vector
2577inline bool tryDivAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2578 const Vector<VT2,TF>& rhs, size_t index )
2579{
2580 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2581 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2582
2583 return tryDivAssign( lhs.operand(), *rhs, lhs.offset() + index );
2584}
2586//*************************************************************************************************
2587
2588
2589//*************************************************************************************************
2604template< typename VT1 // Type of the vector
2605 , AlignmentFlag AF // Alignment flag
2606 , bool TF // Transpose flag
2607 , bool DF // Density flag
2608 , size_t... CSAs // Compile time subvector arguments
2609 , typename VT2 > // Type of the right-hand side vector
2610inline bool tryShiftAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2611 const Vector<VT2,TF>& rhs, size_t index )
2612{
2613 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2614 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2615
2616 return tryShiftAssign( lhs.operand(), *rhs, lhs.offset() + index );
2617}
2619//*************************************************************************************************
2620
2621
2622//*************************************************************************************************
2637template< typename VT1 // Type of the vector
2638 , AlignmentFlag AF // Alignment flag
2639 , bool TF // Transpose flag
2640 , bool DF // Density flag
2641 , size_t... CSAs // Compile time subvector arguments
2642 , typename VT2 > // Type of the right-hand side vector
2643inline bool tryBitandAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2644 const Vector<VT2,TF>& rhs, size_t index )
2645{
2646 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2647 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2648
2649 return tryBitandAssign( lhs.operand(), *rhs, lhs.offset() + index );
2650}
2652//*************************************************************************************************
2653
2654
2655//*************************************************************************************************
2670template< typename VT1 // Type of the vector
2671 , AlignmentFlag AF // Alignment flag
2672 , bool TF // Transpose flag
2673 , bool DF // Density flag
2674 , size_t... CSAs // Compile time subvector arguments
2675 , typename VT2 > // Type of the right-hand side vector
2676inline bool tryBitorAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2677 const Vector<VT2,TF>& rhs, size_t index )
2678{
2679 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2680 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2681
2682 return tryBitorAssign( lhs.operand(), *rhs, lhs.offset() + index );
2683}
2685//*************************************************************************************************
2686
2687
2688//*************************************************************************************************
2703template< typename VT1 // Type of the vector
2704 , AlignmentFlag AF // Alignment flag
2705 , bool TF // Transpose flag
2706 , bool DF // Density flag
2707 , size_t... CSAs // Compile time subvector arguments
2708 , typename VT2 > // Type of the right-hand side vector
2709inline bool tryBitxorAssign( const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2710 const Vector<VT2,TF>& rhs, size_t index )
2711{
2712 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2713 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2714
2715 return tryBitxorAssign( lhs.operand(), *rhs, lhs.offset() + index );
2716}
2718//*************************************************************************************************
2719
2720
2721//*************************************************************************************************
2736template< typename VT // Type of the vector
2737 , AlignmentFlag AF // Alignment flag
2738 , bool TF // Transpose flag
2739 , bool DF // Density flag
2740 , size_t I // Index of the first element
2741 , size_t N > // Number of elements
2742inline decltype(auto) derestrict( Subvector<VT,AF,TF,DF,I,N>& sv )
2743{
2744 return subvector<AF,I,N>( derestrict( sv.operand() ), unchecked );
2745}
2747//*************************************************************************************************
2748
2749
2750//*************************************************************************************************
2765template< typename VT // Type of the vector
2766 , AlignmentFlag AF // Alignment flag
2767 , bool TF // Transpose flag
2768 , bool DF // Density flag
2769 , size_t I // Index of the first element
2770 , size_t N > // Number of elements
2771inline decltype(auto) derestrict( Subvector<VT,AF,TF,DF,I,N>&& sv )
2772{
2773 return subvector<AF,I,N>( derestrict( sv.operand() ), unchecked );
2774}
2776//*************************************************************************************************
2777
2778
2779//*************************************************************************************************
2794template< typename VT // Type of the vector
2795 , AlignmentFlag AF // Alignment flag
2796 , bool TF // Transpose flag
2797 , bool DF > // Density flag
2798inline decltype(auto) derestrict( Subvector<VT,AF,TF,DF>& sv )
2799{
2800 return subvector<AF>( derestrict( sv.operand() ), sv.offset(), sv.size(), unchecked );
2801}
2803//*************************************************************************************************
2804
2805
2806//*************************************************************************************************
2821template< typename VT // Type of the vector
2822 , AlignmentFlag AF // Alignment flag
2823 , bool TF // Transpose flag
2824 , bool DF > // Density flag
2825inline decltype(auto) derestrict( Subvector<VT,AF,TF,DF>&& sv )
2826{
2827 return subvector<AF>( derestrict( sv.operand() ), sv.offset(), sv.size(), unchecked );
2828}
2830//*************************************************************************************************
2831
2832
2833//*************************************************************************************************
2846template< typename VT // Type of the vector
2847 , AlignmentFlag AF // Alignment flag
2848 , bool TF // Transpose flag
2849 , bool DF // Density flag
2850 , size_t... CSAs > // Compile time subvector arguments
2851inline decltype(auto) unview( Subvector<VT,AF,TF,DF,CSAs...>& sv )
2852{
2853 return sv.operand();
2854}
2856//*************************************************************************************************
2857
2858
2859//*************************************************************************************************
2872template< typename VT // Type of the vector
2873 , AlignmentFlag AF // Alignment flag
2874 , bool TF // Transpose flag
2875 , bool DF // Density flag
2876 , size_t... CSAs > // Compile time subvector arguments
2877inline decltype(auto) unview( const Subvector<VT,AF,TF,DF,CSAs...>& sv )
2878{
2879 return sv.operand();
2880}
2882//*************************************************************************************************
2883
2884
2885
2886
2887//=================================================================================================
2888//
2889// SIZE SPECIALIZATIONS
2890//
2891//=================================================================================================
2892
2893//*************************************************************************************************
2895template< typename VT, AlignmentFlag AF, bool TF, bool DF, size_t I, size_t N >
2896struct Size< Subvector<VT,AF,TF,DF,I,N>, 0UL >
2897 : public Ptrdiff_t< static_cast<ptrdiff_t>(N) >
2898{};
2900//*************************************************************************************************
2901
2902
2903
2904
2905//=================================================================================================
2906//
2907// MAXSIZE SPECIALIZATIONS
2908//
2909//=================================================================================================
2910
2911//*************************************************************************************************
2913template< typename VT, AlignmentFlag AF, bool TF, bool DF, size_t I, size_t N >
2914struct MaxSize< Subvector<VT,AF,TF,DF,I,N>, 0UL >
2915 : public Ptrdiff_t< static_cast<ptrdiff_t>(N) >
2916{};
2918//*************************************************************************************************
2919
2920
2921
2922
2923//=================================================================================================
2924//
2925// ISRESTRICTED SPECIALIZATIONS
2926//
2927//=================================================================================================
2928
2929//*************************************************************************************************
2931template< typename VT, AlignmentFlag AF, bool TF, bool DF, size_t... CSAs >
2932struct IsRestricted< Subvector<VT,AF,TF,DF,CSAs...> >
2933 : public IsRestricted<VT>
2934{};
2936//*************************************************************************************************
2937
2938
2939
2940
2941//=================================================================================================
2942//
2943// HASCONSTDATAACCESS SPECIALIZATIONS
2944//
2945//=================================================================================================
2946
2947//*************************************************************************************************
2949template< typename VT, AlignmentFlag AF, bool TF, size_t... CSAs >
2950struct HasConstDataAccess< Subvector<VT,AF,TF,true,CSAs...> >
2951 : public HasConstDataAccess<VT>
2952{};
2954//*************************************************************************************************
2955
2956
2957
2958
2959//=================================================================================================
2960//
2961// HASMUTABLEDATAACCESS SPECIALIZATIONS
2962//
2963//=================================================================================================
2964
2965//*************************************************************************************************
2967template< typename VT, AlignmentFlag AF, bool TF, size_t... CSAs >
2968struct HasMutableDataAccess< Subvector<VT,AF,TF,true,CSAs...> >
2969 : public HasMutableDataAccess<VT>
2970{};
2972//*************************************************************************************************
2973
2974
2975
2976
2977//=================================================================================================
2978//
2979// ISALIGNED SPECIALIZATIONS
2980//
2981//=================================================================================================
2982
2983//*************************************************************************************************
2985template< typename VT, bool TF, size_t... CSAs >
2986struct IsAligned< Subvector<VT,aligned,TF,true,CSAs...> >
2987 : public TrueType
2988{};
2990//*************************************************************************************************
2991
2992
2993
2994
2995//=================================================================================================
2996//
2997// ISCONTIGUOUS SPECIALIZATIONS
2998//
2999//=================================================================================================
3000
3001//*************************************************************************************************
3003template< typename VT, AlignmentFlag AF, bool TF, size_t... CSAs >
3004struct IsContiguous< Subvector<VT,AF,TF,true,CSAs...> >
3005 : public IsContiguous<VT>
3006{};
3008//*************************************************************************************************
3009
3010} // namespace blaze
3011
3012#endif
Header file for auxiliary alias declarations.
Header file for the alignment flag enumeration.
Header file for run time assertion macros.
Header file for the blaze::checked and blaze::unchecked instances.
Header file for the EnableIf class template.
Header file for the function trace functionality.
Header file for the HasConstDataAccess type trait.
Header file for the HasMutableDataAccess type trait.
Header file for the integer_sequence and index_sequence aliases.
Header file for the IntegralConstant class template.
Header file for the IsAligned type trait.
Header file for the IsContiguous type trait.
Header file for the isDefault shim.
Header file for the IsRestricted type trait.
Header file for the IsSubvector type trait.
Deactivation of problematic macros.
Header file for the MaxSize type trait.
Header file for the relaxation flag enumeration.
Header file for the RemoveReference type trait.
Header file for the SmallArray implementation.
Compile time assertion.
Base class for N-dimensional vectors.
Definition: Vector.h:82
Size type of the Blaze library.
Header file for the CrossExpr base class.
Header file for the VecEvalExpr base class.
Header file for the VecMapExpr base class.
Header file for the VecNoAliasExpr base class.
Header file for the VecNoSIMDExpr base class.
Header file for the VecRepeatExpr base class.
Header file for the VecScalarDivExpr base class.
Header file for the VecScalarMultExpr base class.
Header file for the VecSerialExpr base class.
Header file for the VecTransExpr base class.
Header file for the VecVecAddExpr base class.
Header file for the VecVecDivExpr base class.
Header file for the VecVecKronExpr base class.
Header file for the VecVecMapExpr base class.
Header file for the VecVecMultExpr base class.
Header file for the VecVecSubExpr base class.
Header file for the Vector CRTP base class.
decltype(auto) noalias(const DenseMatrix< MT, SO > &dm)
Forces the non-aliased evaluation of the given dense matrix expression dm.
Definition: DMatNoAliasExpr.h:679
decltype(auto) eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:790
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:766
decltype(auto) map(const DenseMatrix< MT1, SO > &lhs, const DenseMatrix< MT2, SO > &rhs, OP op)
Elementwise evaluation of the given binary operation on each single element of the dense matrices lhs...
Definition: DMatDMatMapExpr.h:1144
decltype(auto) nosimd(const DenseMatrix< MT, SO > &dm)
Disables the SIMD evaluation of the given dense matrix expression dm.
Definition: DMatNoSIMDExpr.h:717
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:207
bool isDefault(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the given diagonal matrix is in default state.
Definition: DiagonalMatrix.h:169
decltype(auto) elements(Vector< VT, TF > &vector, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition: Elements.h:143
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition: RelaxationFlag.h:66
AlignmentFlag
Alignment flag for (un-)aligned vectors and matrices.
Definition: AlignmentFlag.h:63
@ unaligned
Flag for unaligned vectors and matrices.
Definition: AlignmentFlag.h:64
@ aligned
Flag for aligned vectors and matrices.
Definition: AlignmentFlag.h:65
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:1424
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:676
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.
Definition: Assert.h:117
#define BLAZE_STATIC_ASSERT_MSG(expr, msg)
Compile time assertion macro.
Definition: StaticAssert.h:123
decltype(auto) subvector(Vector< VT, TF > &, RSAs...)
Creating a view on a specific subvector of the given vector.
Definition: Subvector.h:158
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
BoolConstant< true > TrueType
Type traits base class.
Definition: IntegralConstant.h:132
IntegralConstant< ptrdiff_t, N > Ptrdiff_t
Compile time integral constant wrapper for ptrdiff_t.
Definition: IntegralConstant.h:237
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition: FunctionTrace.h:94
constexpr bool isChecked(const Ts &... args)
Extracting blaze::Check arguments from a given list of arguments.
Definition: Check.h:225
constexpr Unchecked unchecked
Global Unchecked instance.
Definition: Check.h:146
Header file for the exception macros of the math module.
Header file for the Size type trait.
Header file for the serial shim.
Header file for basic type definitions.
Header file for the implementation of the Subvector base template.
Subvector specialization for dense vectors.
Subvector specialization for sparse vectors.