Blaze 3.9
Submatrix.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_VIEWS_SUBMATRIX_H_
36#define _BLAZE_MATH_VIEWS_SUBMATRIX_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <blaze/math/Aliases.h>
100#include <blaze/util/Assert.h>
101#include <blaze/util/EnableIf.h>
108#include <blaze/util/Types.h>
110
111
112namespace blaze {
113
114//=================================================================================================
115//
116// GLOBAL FUNCTIONS
117//
118//=================================================================================================
119
120//*************************************************************************************************
174template< size_t I // Index of the first row
175 , size_t J // Index of the first column
176 , size_t M // Number of rows
177 , size_t N // Number of columns
178 , typename MT // Type of the dense matrix
179 , bool SO // Storage order
180 , typename... RSAs > // Optional submatrix arguments
181inline decltype(auto) submatrix( Matrix<MT,SO>& matrix, RSAs... args )
182{
184
185 return submatrix<unaligned,I,J,M,N>( *matrix, args... );
186}
187//*************************************************************************************************
188
189
190//*************************************************************************************************
243template< size_t I // Index of the first row
244 , size_t J // Index of the first column
245 , size_t M // Number of rows
246 , size_t N // Number of columns
247 , typename MT // Type of the dense matrix
248 , bool SO // Storage order
249 , typename... RSAs > // Option submatrix arguments
250inline decltype(auto) submatrix( const Matrix<MT,SO>& matrix, RSAs... args )
251{
253
254 return submatrix<unaligned,I,J,M,N>( *matrix, args... );
255}
256//*************************************************************************************************
257
258
259//*************************************************************************************************
274template< size_t I // Index of the first row
275 , size_t J // Index of the first column
276 , size_t M // Number of rows
277 , size_t N // Number of columns
278 , typename MT // Type of the dense matrix
279 , bool SO // Storage order
280 , typename... RSAs > // Option submatrix arguments
281inline decltype(auto) submatrix( Matrix<MT,SO>&& matrix, RSAs... args )
282{
284
285 return submatrix<unaligned,I,J,M,N>( std::move( *matrix ), args... );
286}
287//*************************************************************************************************
288
289
290//*************************************************************************************************
356template< AlignmentFlag AF // Alignment flag
357 , size_t I // Index of the first row
358 , size_t J // Index of the first column
359 , size_t M // Number of rows
360 , size_t N // Number of columns
361 , typename MT // Type of the dense matrix
362 , bool SO // Storage order
363 , typename... RSAs > // Option submatrix arguments
364inline decltype(auto) submatrix( Matrix<MT,SO>& matrix, RSAs... args )
365{
367
368 using ReturnType = Submatrix_<MT,AF,I,J,M,N>;
369 return ReturnType( *matrix, args... );
370}
371//*************************************************************************************************
372
373
374//*************************************************************************************************
438template< AlignmentFlag AF // Alignment flag
439 , size_t I // Index of the first row
440 , size_t J // Index of the first column
441 , size_t M // Number of rows
442 , size_t N // Number of columns
443 , typename MT // Type of the dense matrix
444 , bool SO // Storage order
445 , typename... RSAs > // Option submatrix arguments
446inline decltype(auto) submatrix( const Matrix<MT,SO>& matrix, RSAs... args )
447{
449
450 using ReturnType = const Submatrix_<const MT,AF,I,J,M,N>;
451 return ReturnType( *matrix, args... );
452}
453//*************************************************************************************************
454
455
456//*************************************************************************************************
472template< AlignmentFlag AF // Alignment flag
473 , size_t I // Index of the first row
474 , size_t J // Index of the first column
475 , size_t M // Number of rows
476 , size_t N // Number of columns
477 , typename MT // Type of the dense matrix
478 , bool SO // Storage order
479 , typename... RSAs > // Option submatrix arguments
480inline decltype(auto) submatrix( Matrix<MT,SO>&& matrix, RSAs... args )
481{
483
484 using ReturnType = Submatrix_<MT,AF,I,J,M,N>;
485 return ReturnType( *matrix, args... );
486}
487//*************************************************************************************************
488
489
490//*************************************************************************************************
548template< typename MT // Type of the dense matrix
549 , bool SO // Storage order
550 , typename... RSAs > // Option submatrix arguments
551inline decltype(auto)
552 submatrix( Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n, RSAs... args )
553{
555
556 return submatrix<unaligned>( *matrix, row, column, m, n, args... );
557}
558//*************************************************************************************************
559
560
561//*************************************************************************************************
618template< typename MT // Type of the dense matrix
619 , bool SO // Storage order
620 , typename... RSAs > // Option submatrix arguments
621inline decltype(auto)
622 submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n, RSAs... args )
623{
625
626 return submatrix<unaligned>( *matrix, row, column, m, n, args... );
627}
628//*************************************************************************************************
629
630
631//*************************************************************************************************
650template< typename MT // Type of the dense matrix
651 , bool SO // Storage order
652 , typename... RSAs > // Option submatrix arguments
653inline decltype(auto)
654 submatrix( Matrix<MT,SO>&& matrix, size_t row, size_t column, size_t m, size_t n, RSAs... args )
655{
657
658 return submatrix<unaligned>( std::move( *matrix ), row, column, m, n, args... );
659}
660//*************************************************************************************************
661
662
663//*************************************************************************************************
733template< AlignmentFlag AF // Alignment flag
734 , typename MT // Type of the dense matrix
735 , bool SO // Storage order
736 , typename... RSAs > // Option submatrix arguments
737inline decltype(auto)
738 submatrix( Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n, RSAs... args )
739{
741
742 using ReturnType = Submatrix_<MT,AF>;
743 return ReturnType( *matrix, row, column, m, n, args... );
744}
745//*************************************************************************************************
746
747
748//*************************************************************************************************
816template< AlignmentFlag AF // Alignment flag
817 , typename MT // Type of the dense matrix
818 , bool SO // Storage order
819 , typename... RSAs > // Option submatrix arguments
820inline decltype(auto)
821 submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n, RSAs... args )
822{
824
825 using ReturnType = const Submatrix_<const MT,AF>;
826 return ReturnType( *matrix, row, column, m, n, args... );
827}
828//*************************************************************************************************
829
830
831//*************************************************************************************************
851template< AlignmentFlag AF // Alignment flag
852 , typename MT // Type of the dense matrix
853 , bool SO // Storage order
854 , typename... RSAs > // Option submatrix arguments
855inline decltype(auto)
856 submatrix( Matrix<MT,SO>&& matrix, size_t row, size_t column, size_t m, size_t n, RSAs... args )
857{
859
860 using ReturnType = Submatrix_<MT,AF>;
861 return ReturnType( *matrix, row, column, m, n, args... );
862}
863//*************************************************************************************************
864
865
866
867
868//=================================================================================================
869//
870// GLOBAL RESTRUCTURING FUNCTIONS
871//
872//=================================================================================================
873
874//*************************************************************************************************
887template< AlignmentFlag AF // Alignment flag
888 , size_t... CSAs // Compile time submatrix arguments
889 , typename MT // Matrix base type of the expression
890 , typename... RSAs > // Runtime submatrix arguments
891inline decltype(auto) submatrix( const MatMatAddExpr<MT>& matrix, RSAs... args )
892{
894
895 return submatrix<AF,CSAs...>( (*matrix).leftOperand(), args... ) +
896 submatrix<AF,CSAs...>( (*matrix).rightOperand(), args... );
897}
899//*************************************************************************************************
900
901
902//*************************************************************************************************
915template< AlignmentFlag AF // Alignment flag
916 , size_t... CSAs // Compile time submatrix arguments
917 , typename MT // Matrix base type of the expression
918 , typename... RSAs > // Runtime submatrix arguments
919inline decltype(auto) submatrix( const MatMatSubExpr<MT>& matrix, RSAs... args )
920{
922
923 return submatrix<AF,CSAs...>( (*matrix).leftOperand(), args... ) -
924 submatrix<AF,CSAs...>( (*matrix).rightOperand(), args... );
925}
927//*************************************************************************************************
928
929
930//*************************************************************************************************
943template< AlignmentFlag AF // Alignment flag
944 , size_t... CSAs // Compile time submatrix arguments
945 , typename MT // Matrix base type of the expression
946 , typename... RSAs > // Runtime submatrix arguments
947inline decltype(auto) submatrix( const SchurExpr<MT>& matrix, RSAs... args )
948{
950
951 return submatrix<AF,CSAs...>( (*matrix).leftOperand(), args... ) %
952 submatrix<AF,CSAs...>( (*matrix).rightOperand(), args... );
953}
955//*************************************************************************************************
956
957
958//*************************************************************************************************
971template< AlignmentFlag AF // Alignment flag
972 , size_t... CSAs // Compile time submatrix arguments
973 , typename MT // Matrix base type of the expression
974 , typename... RSAs > // Runtime submatrix arguments
975inline decltype(auto) submatrix( const MatMatMultExpr<MT>& matrix, RSAs... args )
976{
978
979 using MT1 = RemoveReference_t< LeftOperand_t< MatrixType_t<MT> > >;
980 using MT2 = RemoveReference_t< RightOperand_t< MatrixType_t<MT> > >;
981
982 const SubmatrixData<CSAs...> sd( args... );
983
984 decltype(auto) left ( (*matrix).leftOperand() );
985 decltype(auto) right( (*matrix).rightOperand() );
986
987 const size_t begin( max( ( IsUpper_v<MT1> )
988 ?( ( !AF && IsStrictlyUpper_v<MT1> )
989 ?( sd.row() + 1UL )
990 :( sd.row() ) )
991 :( 0UL )
992 , ( IsLower_v<MT2> )
993 ?( ( !AF && IsStrictlyLower_v<MT2> )
994 ?( sd.column() + 1UL )
995 :( sd.column() ) )
996 :( 0UL ) ) );
997 const size_t end( min( ( IsLower_v<MT1> )
998 ?( ( IsStrictlyLower_v<MT1> && sd.rows() > 0UL )
999 ?( sd.row() + sd.rows() - 1UL )
1000 :( sd.row() + sd.rows() ) )
1001 :( left.columns() )
1002 , ( IsUpper_v<MT2> )
1003 ?( ( IsStrictlyUpper_v<MT2> && sd.columns() > 0UL )
1004 ?( sd.column() + sd.columns() - 1UL )
1005 :( sd.column() + sd.columns() ) )
1006 :( left.columns() ) ) );
1007
1008 const size_t diff( ( begin < end )?( end - begin ):( 0UL ) );
1009
1010 return submatrix<AF>( left, sd.row(), begin, sd.rows(), diff ) *
1011 submatrix<AF>( right, begin, sd.column(), diff, sd.columns() );
1012}
1014//*************************************************************************************************
1015
1016
1017//*************************************************************************************************
1030template< AlignmentFlag AF // Alignment flag
1031 , size_t I // Index of the first row
1032 , size_t J // Index of the first column
1033 , size_t M // Number of rows
1034 , size_t N // Number of columns
1035 , typename MT // Matrix base type of the expression
1036 , typename... RSAs > // Optional submatrix arguments
1037inline decltype(auto) submatrix( const MatMatKronExpr<MT>& matrix, RSAs... args )
1038{
1040
1041 try {
1042 return columns( rows( *matrix, make_shifted_index_sequence<I,M>(), args... )
1043 , make_shifted_index_sequence<J,N>(), args... );
1044 }
1045 catch( ... ) {
1046 BLAZE_THROW_INVALID_ARGUMENT( "Invalid submatrix specification" );
1047 }
1048}
1050//*************************************************************************************************
1051
1052
1053//*************************************************************************************************
1070template< AlignmentFlag AF // Alignment flag
1071 , typename MT // Matrix base type of the expression
1072 , typename... RSAs > // Optional submatrix arguments
1073inline decltype(auto)
1074 submatrix( const MatMatKronExpr<MT>& matrix, size_t row, size_t column, size_t m, size_t n, RSAs... args )
1075{
1077
1078 try {
1079 return columns( rows( *matrix, [row]( size_t i ){ return i+row; }, m, args... )
1080 , [column]( size_t i ){ return i+column; }, n, args... );
1081 }
1082 catch( ... ) {
1083 BLAZE_THROW_INVALID_ARGUMENT( "Invalid submatrix specification" );
1084 }
1085}
1087//*************************************************************************************************
1088
1089
1090//*************************************************************************************************
1102template< AlignmentFlag AF // Alignment flag
1103 , size_t I // Index of the first row
1104 , size_t J // Index of the first column
1105 , size_t M // Number of rows
1106 , size_t N // Number of columns
1107 , typename MT // Matrix base type of the expression
1108 , typename... RSAs > // Runtime submatrix arguments
1109inline decltype(auto) submatrix( const VecTVecMultExpr<MT>& matrix, RSAs... args )
1110{
1112
1113 try {
1114 return subvector<AF,I,M>( (*matrix).leftOperand(), args... ) *
1115 subvector<AF,J,N>( (*matrix).rightOperand(), args... );
1116 }
1117 catch( ... ) {
1118 BLAZE_THROW_INVALID_ARGUMENT( "Invalid submatrix specification" );
1119 }
1120}
1122//*************************************************************************************************
1123
1124
1125//*************************************************************************************************
1141template< AlignmentFlag AF // Alignment flag
1142 , typename MT // Matrix base type of the expression
1143 , typename... RSAs > // Runtime submatrix arguments
1144inline decltype(auto)
1145 submatrix( const VecTVecMultExpr<MT>& matrix, size_t row, size_t column, size_t m, size_t n, RSAs... args )
1146{
1148
1149 try {
1150 return subvector<AF>( (*matrix).leftOperand(), row, m, args... ) *
1151 subvector<AF>( (*matrix).rightOperand(), column, n, args... );
1152 }
1153 catch( ... ) {
1154 BLAZE_THROW_INVALID_ARGUMENT( "Invalid submatrix specification" );
1155 }
1156}
1158//*************************************************************************************************
1159
1160
1161//*************************************************************************************************
1174template< AlignmentFlag AF // Alignment flag
1175 , size_t... CSAs // Compile time submatrix arguments
1176 , typename MT // Matrix base type of the expression
1177 , typename... RSAs > // Runtime submatrix arguments
1178inline decltype(auto) submatrix( const MatScalarMultExpr<MT>& matrix, RSAs... args )
1179{
1181
1182 return submatrix<AF,CSAs...>( (*matrix).leftOperand(), args... ) * (*matrix).rightOperand();
1183}
1185//*************************************************************************************************
1186
1187
1188//*************************************************************************************************
1201template< AlignmentFlag AF // Alignment flag
1202 , size_t... CSAs // Compile time submatrix arguments
1203 , typename MT // Matrix base type of the expression
1204 , typename... RSAs > // Runtime submatrix arguments
1205inline decltype(auto) submatrix( const MatScalarDivExpr<MT>& matrix, RSAs... args )
1206{
1208
1209 return submatrix<AF,CSAs...>( (*matrix).leftOperand(), args... ) / (*matrix).rightOperand();
1210}
1212//*************************************************************************************************
1213
1214
1215//*************************************************************************************************
1228template< AlignmentFlag AF // Alignment flag
1229 , size_t... CSAs // Compile time submatrix arguments
1230 , typename MT // Matrix base type of the expression
1231 , typename... RSAs > // Runtime submatrix arguments
1232inline decltype(auto) submatrix( const MatMapExpr<MT>& matrix, RSAs... args )
1233{
1235
1236 return map( submatrix<AF,CSAs...>( (*matrix).operand(), args... ), (*matrix).operation() );
1237}
1239//*************************************************************************************************
1240
1241
1242//*************************************************************************************************
1255template< AlignmentFlag AF // Alignment flag
1256 , size_t... CSAs // Compile time submatrix arguments
1257 , typename MT // Matrix base type of the expression
1258 , typename... RSAs > // Runtime submatrix arguments
1259inline decltype(auto) submatrix( const MatMatMapExpr<MT>& matrix, RSAs... args )
1260{
1262
1263 return map( submatrix<AF,CSAs...>( (*matrix).leftOperand(), args... ),
1264 submatrix<AF,CSAs...>( (*matrix).rightOperand(), args... ),
1265 (*matrix).operation() );
1266}
1268//*************************************************************************************************
1269
1270
1271//*************************************************************************************************
1283template< AlignmentFlag AF // Alignment flag
1284 , size_t I // Index of the first row
1285 , size_t J // Index of the first column
1286 , size_t M // Number of rows
1287 , size_t N // Number of columns
1288 , typename MT // Matrix base type of the expression
1289 , typename... RSAs > // Runtime submatrix arguments
1290inline decltype(auto) submatrix( const VecTVecMapExpr<MT>& matrix, RSAs... args )
1291{
1293
1294 try {
1295 return map( subvector<AF,I,M>( (*matrix).leftOperand(), args... ),
1296 subvector<AF,J,N>( (*matrix).rightOperand(), args... ),
1297 (*matrix).operation() );
1298 }
1299 catch( ... ) {
1300 BLAZE_THROW_INVALID_ARGUMENT( "Invalid submatrix specification" );
1301 }
1302}
1304//*************************************************************************************************
1305
1306
1307//*************************************************************************************************
1323template< AlignmentFlag AF // Alignment flag
1324 , typename MT // Matrix base type of the expression
1325 , typename... RSAs > // Runtime submatrix arguments
1326inline decltype(auto)
1327 submatrix( const VecTVecMapExpr<MT>& matrix, size_t row, size_t column, size_t m, size_t n, RSAs... args )
1328{
1330
1331 try {
1332 return map( subvector<AF>( (*matrix).leftOperand(), row, m, args... ),
1333 subvector<AF>( (*matrix).rightOperand(), column, n, args... ),
1334 (*matrix).operation() );
1335 }
1336 catch( ... ) {
1337 BLAZE_THROW_INVALID_ARGUMENT( "Invalid submatrix specification" );
1338 }
1339}
1341//*************************************************************************************************
1342
1343
1344//*************************************************************************************************
1357template< AlignmentFlag AF // Alignment flag
1358 , size_t... CSAs // Compile time submatrix arguments
1359 , typename MT // Matrix base type of the expression
1360 , typename... RSAs > // Runtime submatrix arguments
1361inline decltype(auto) submatrix( const MatEvalExpr<MT>& matrix, RSAs... args )
1362{
1364
1365 return eval( submatrix<AF,CSAs...>( (*matrix).operand(), args... ) );
1366}
1368//*************************************************************************************************
1369
1370
1371//*************************************************************************************************
1384template< AlignmentFlag AF // Alignment flag
1385 , size_t... CSAs // Compile time submatrix arguments
1386 , typename MT // Matrix base type of the expression
1387 , typename... RSAs > // Runtime submatrix arguments
1388inline decltype(auto) submatrix( const MatSerialExpr<MT>& matrix, RSAs... args )
1389{
1391
1392 return serial( submatrix<AF,CSAs...>( (*matrix).operand(), args... ) );
1393}
1395//*************************************************************************************************
1396
1397
1398//*************************************************************************************************
1411template< AlignmentFlag AF // Alignment flag
1412 , size_t... CSAs // Compile time submatrix arguments
1413 , typename MT // Matrix base type of the expression
1414 , typename... RSAs > // Runtime submatrix arguments
1415inline decltype(auto) submatrix( const MatNoAliasExpr<MT>& matrix, RSAs... args )
1416{
1418
1419 return noalias( submatrix<AF,CSAs...>( (*matrix).operand(), args... ) );
1420}
1422//*************************************************************************************************
1423
1424
1425//*************************************************************************************************
1438template< AlignmentFlag AF // Alignment flag
1439 , size_t... CSAs // Compile time submatrix arguments
1440 , typename MT // Matrix base type of the expression
1441 , typename... RSAs > // Runtime submatrix arguments
1442inline decltype(auto) submatrix( const MatNoSIMDExpr<MT>& matrix, RSAs... args )
1443{
1445
1446 return nosimd( submatrix<AF,CSAs...>( (*matrix).operand(), args... ) );
1447}
1449//*************************************************************************************************
1450
1451
1452//*************************************************************************************************
1465template< AlignmentFlag AF // Alignment flag
1466 , size_t... CSAs // Compile time submatrix arguments
1467 , typename MT // Matrix base type of the expression
1468 , typename... RSAs > // Runtime submatrix arguments
1469inline decltype(auto) submatrix( const DeclExpr<MT>& matrix, RSAs... args )
1470{
1472
1473 return submatrix<AF,CSAs...>( (*matrix).operand(), args... );
1474}
1476//*************************************************************************************************
1477
1478
1479//*************************************************************************************************
1492template< AlignmentFlag AF // Alignment flag
1493 , size_t I // Index of the first row
1494 , size_t J // Index of the first column
1495 , size_t M // Number of rows
1496 , size_t N // Number of columns
1497 , typename MT // Matrix base type of the expression
1498 , typename... RSAs > // Optional submatrix arguments
1499inline decltype(auto) submatrix( const MatTransExpr<MT>& matrix, RSAs... args )
1500{
1502
1503 return trans( submatrix<AF,J,I,N,M>( (*matrix).operand(), args... ) );
1504}
1506//*************************************************************************************************
1507
1508
1509//*************************************************************************************************
1526template< AlignmentFlag AF // Alignment flag
1527 , typename MT // Matrix base type of the expression
1528 , typename... RSAs > // Optional submatrix arguments
1529inline decltype(auto)
1530 submatrix( const MatTransExpr<MT>& matrix, size_t row, size_t column, size_t m, size_t n, RSAs... args )
1531{
1533
1534 return trans( submatrix<AF>( (*matrix).operand(), column, row, n, m, args... ) );
1535}
1537//*************************************************************************************************
1538
1539
1540//*************************************************************************************************
1553template< AlignmentFlag AF // Alignment flag
1554 , size_t I // Index of the first row
1555 , size_t J // Index of the first column
1556 , size_t M // Number of rows
1557 , size_t N // Number of columns
1558 , typename MT // Matrix base type of the expression
1559 , size_t... CEAs // Compile time expansion arguments
1560 , typename... RSAs > // Optional submatrix arguments
1561inline decltype(auto) submatrix( const VecExpandExpr<MT,CEAs...>& matrix, RSAs... args )
1562{
1564
1565 if( isChecked( args... ) ) {
1566 if( ( I + M > (*matrix).rows() ) || ( J + N > (*matrix).columns() ) ) {
1567 BLAZE_THROW_INVALID_ARGUMENT( "Invalid submatrix specification" );
1568 }
1569 }
1570 else {
1571 BLAZE_USER_ASSERT( I + M <= (*matrix).rows() , "Invalid submatrix specification" );
1572 BLAZE_USER_ASSERT( J + N <= (*matrix).columns(), "Invalid submatrix specification" );
1573 }
1574
1575 using VT = VectorType_t< RemoveReference_t< decltype( (*matrix).operand() ) > >;
1576
1577 constexpr bool TF( TransposeFlag_v<VT> );
1578
1579 constexpr size_t index ( TF ? J : I );
1580 constexpr size_t size ( TF ? N : M );
1581 constexpr size_t expansion( TF ? M : N );
1582
1583 return expand<expansion>( subvector<index,size>( (*matrix).operand(), unchecked ) );
1584}
1586//*************************************************************************************************
1587
1588
1589//*************************************************************************************************
1606template< AlignmentFlag AF // Alignment flag
1607 , typename MT // Matrix base type of the expression
1608 , size_t... CEAs // Compile time expansion arguments
1609 , typename... RSAs > // Optional submatrix arguments
1610inline decltype(auto)
1611 submatrix( const VecExpandExpr<MT,CEAs...>& matrix,
1612 size_t row, size_t column, size_t m, size_t n, RSAs... args )
1613{
1615
1616 if( isChecked( args... ) ) {
1617 if( ( row + m > (*matrix).rows() ) || ( column + n > (*matrix).columns() ) ) {
1618 BLAZE_THROW_INVALID_ARGUMENT( "Invalid submatrix specification" );
1619 }
1620 }
1621 else {
1622 BLAZE_USER_ASSERT( row + m <= (*matrix).rows() , "Invalid submatrix specification" );
1623 BLAZE_USER_ASSERT( column + n <= (*matrix).columns(), "Invalid submatrix specification" );
1624 }
1625
1626 using VT = VectorType_t< RemoveReference_t< decltype( (*matrix).operand() ) > >;
1627
1628 constexpr bool TF( TransposeFlag_v<VT> );
1629
1630 const size_t index ( TF ? column : row );
1631 const size_t size ( TF ? n : m );
1632 const size_t expansion( TF ? m : n );
1633
1634 return expand( subvector( (*matrix).operand(), index, size, unchecked ), expansion );
1635}
1637//*************************************************************************************************
1638
1639
1640//*************************************************************************************************
1653template< AlignmentFlag AF // Alignment flag
1654 , size_t I // Index of the first row
1655 , size_t J // Index of the first column
1656 , size_t M // Number of rows
1657 , size_t N // Number of columns
1658 , typename MT // Matrix base type of the expression
1659 , size_t... CRAs // Compile time repeater arguments
1660 , typename... RSAs > // Optional submatrix arguments
1661inline decltype(auto) submatrix( const MatRepeatExpr<MT,CRAs...>& matrix, RSAs... args )
1662{
1664
1665 if( isChecked( args... ) ) {
1666 if( ( I + M > (*matrix).rows() ) || ( J + N > (*matrix).columns() ) ) {
1667 BLAZE_THROW_INVALID_ARGUMENT( "Invalid submatrix specification" );
1668 }
1669 }
1670 else {
1671 BLAZE_USER_ASSERT( I + M <= (*matrix).rows() , "Invalid submatrix specification" );
1672 BLAZE_USER_ASSERT( J + N <= (*matrix).columns(), "Invalid submatrix specification" );
1673 }
1674
1675 const size_t M2 = (*matrix).operand().rows();
1676 const size_t N2 = (*matrix).operand().columns();
1677
1678 return columns( rows( (*matrix).operand(), [M2]( size_t i ){ return (i+I)%M2; }, M, args... )
1679 , [N2]( size_t i ){ return (i+J)%N2; }, N, unchecked );
1680}
1682//*************************************************************************************************
1683
1684
1685//*************************************************************************************************
1702template< AlignmentFlag AF // Alignment flag
1703 , typename MT // Matrix base type of the expression
1704 , size_t... CRAs // Compile time repeater arguments
1705 , typename... RSAs > // Optional submatrix arguments
1706inline decltype(auto)
1707 submatrix( const MatRepeatExpr<MT,CRAs...>& matrix,
1708 size_t row, size_t column, size_t m, size_t n, RSAs... args )
1709{
1711
1712 if( isChecked( args... ) ) {
1713 if( ( row + m > (*matrix).rows() ) || ( column + n > (*matrix).columns() ) ) {
1714 BLAZE_THROW_INVALID_ARGUMENT( "Invalid submatrix specification" );
1715 }
1716 }
1717 else {
1718 BLAZE_USER_ASSERT( row + m <= (*matrix).rows() , "Invalid submatrix specification" );
1719 BLAZE_USER_ASSERT( column + n <= (*matrix).columns(), "Invalid submatrix specification" );
1720 }
1721
1722 const size_t M = (*matrix).operand().rows();
1723 const size_t N = (*matrix).operand().columns();
1724
1725 return columns( rows( (*matrix).operand(), [row,M]( size_t i ){ return (i+row)%M; }, m, args... )
1726 , [column,N]( size_t i ){ return (i+column)%N; }, n, unchecked );
1727}
1729//*************************************************************************************************
1730
1731
1732
1733
1734//=================================================================================================
1735//
1736// GLOBAL RESTRUCTURING FUNCTIONS (SUBMATRIX)
1737//
1738//=================================================================================================
1739
1740//*************************************************************************************************
1751template< AlignmentFlag AF // Required alignment flag
1752 , size_t I // Required index of the first row
1753 , size_t J // Required index of the first column
1754 , size_t M // Required number of rows
1755 , size_t N // Required number of columns
1756 , typename MT // Type of the sparse submatrix
1757 , typename... RSAs // Optional submatrix arguments
1758 , EnableIf_t< IsSubmatrix_v< RemoveReference_t<MT> > &&
1759 RemoveReference_t<MT>::compileTimeArgs >* = nullptr >
1760inline decltype(auto) submatrix( MT&& sm, RSAs... args )
1761{
1763
1764 constexpr size_t I2( RemoveReference_t<MT>::row() );
1765 constexpr size_t J2( RemoveReference_t<MT>::column() );
1766 constexpr size_t M2( RemoveReference_t<MT>::rows() );
1767 constexpr size_t N2( RemoveReference_t<MT>::columns() );
1768
1769 BLAZE_STATIC_ASSERT_MSG( I + M <= M2, "Invalid submatrix specification" );
1770 BLAZE_STATIC_ASSERT_MSG( J + N <= N2, "Invalid submatrix specification" );
1771
1772 return submatrix<AF,I+I2,J+J2,M,N>( sm.operand(), args... );
1773}
1775//*************************************************************************************************
1776
1777
1778//*************************************************************************************************
1790template< AlignmentFlag AF // Required alignment flag
1791 , size_t I // Index of the first row
1792 , size_t J // Index of the first column
1793 , size_t M // Number of rows
1794 , size_t N // Number of columns
1795 , typename MT // Type of the sparse submatrix
1796 , typename... RSAs // Optional submatrix arguments
1797 , EnableIf_t< IsSubmatrix_v< RemoveReference_t<MT> > >* = nullptr >
1798inline decltype(auto) submatrix( MT&& sm, RSAs... args )
1799{
1801
1802 if( isChecked( args... ) ) {
1803 if( ( I + M > sm.rows() ) || ( J + N > sm.columns() ) ) {
1804 BLAZE_THROW_INVALID_ARGUMENT( "Invalid submatrix specification" );
1805 }
1806 }
1807 else {
1808 BLAZE_USER_ASSERT( I + M <= sm.rows() , "Invalid submatrix specification" );
1809 BLAZE_USER_ASSERT( J + N <= sm.columns(), "Invalid submatrix specification" );
1810 }
1811
1812 return submatrix<AF>( sm.operand(), sm.row() + I, sm.column() + J, M, N, unchecked );
1813}
1815//*************************************************************************************************
1816
1817
1818//*************************************************************************************************
1834template< AlignmentFlag AF // Required alignment flag
1835 , typename MT // Type of the sparse submatrix
1836 , typename... RSAs // Optional submatrix arguments
1837 , EnableIf_t< IsSubmatrix_v< RemoveReference_t<MT> > >* = nullptr >
1838inline decltype(auto) submatrix( MT&& sm, size_t row, size_t column, size_t m, size_t n, RSAs... args )
1839{
1841
1842 if( isChecked( args... ) ) {
1843 if( ( row + m > sm.rows() ) || ( column + n > sm.columns() ) ) {
1844 BLAZE_THROW_INVALID_ARGUMENT( "Invalid submatrix specification" );
1845 }
1846 }
1847 else {
1848 BLAZE_USER_ASSERT( row + m <= sm.rows() , "Invalid submatrix specification" );
1849 BLAZE_USER_ASSERT( column + n <= sm.columns(), "Invalid submatrix specification" );
1850 }
1851
1852 return submatrix<AF>( sm.operand(), sm.row() + row, sm.column() + column, m, n, unchecked );
1853}
1855//*************************************************************************************************
1856
1857
1858
1859
1860//=================================================================================================
1861//
1862// GLOBAL RESTRUCTURING FUNCTIONS (SUBVECTOR)
1863//
1864//=================================================================================================
1865
1866//*************************************************************************************************
1879template< AlignmentFlag AF // Alignment flag
1880 , size_t... CSAs // Compile time subvector arguments
1881 , typename VT // Vector base type of the expression
1882 , typename... RSAs > // Runtime subvector arguments
1883inline decltype(auto) subvector( const MatVecMultExpr<VT>& vector, RSAs... args )
1884{
1886
1887 using MT = RemoveReference_t< LeftOperand_t< VectorType_t<VT> > >;
1888
1889 const SubvectorData<CSAs...> sd( args... );
1890
1891 decltype(auto) left ( (*vector).leftOperand() );
1892 decltype(auto) right( (*vector).rightOperand() );
1893
1894 const size_t column( ( IsUpper_v<MT> )
1895 ?( ( !AF && IsStrictlyUpper_v<MT> )?( sd.offset() + 1UL ):( sd.offset() ) )
1896 :( 0UL ) );
1897 const size_t n( ( IsLower_v<MT> )
1898 ?( ( IsUpper_v<MT> )?( sd.size() )
1899 :( ( IsStrictlyLower_v<MT> && sd.size() > 0UL )
1900 ?( sd.offset() + sd.size() - 1UL )
1901 :( sd.offset() + sd.size() ) ) )
1902 :( ( IsUpper_v<MT> )?( left.columns() - column )
1903 :( left.columns() ) ) );
1904
1905 constexpr auto check( getCheck( args... ) );
1906
1907 try {
1908 return submatrix<AF>( left, sd.offset(), column, sd.size(), n, check ) *
1909 subvector<AF>( right, column, n, check );
1910 }
1911 catch( ... ) {
1912 BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
1913 }
1914}
1916//*************************************************************************************************
1917
1918
1919//*************************************************************************************************
1932template< AlignmentFlag AF // Alignment flag
1933 , size_t... CSAs // Compile time subvector arguments
1934 , typename VT // Vector base type of the expression
1935 , typename... RSAs > // Runtime subvector arguments
1936inline decltype(auto) subvector( const TVecMatMultExpr<VT>& vector, RSAs... args )
1937{
1939
1940 using MT = RemoveReference_t< RightOperand_t< VectorType_t<VT> > >;
1941
1942 const SubvectorData<CSAs...> sd( args... );
1943
1944 decltype(auto) left ( (*vector).leftOperand() );
1945 decltype(auto) right( (*vector).rightOperand() );
1946
1947 const size_t row( ( IsLower_v<MT> )
1948 ?( ( !AF && IsStrictlyLower_v<MT> )?( sd.offset() + 1UL ):( sd.offset() ) )
1949 :( 0UL ) );
1950 const size_t m( ( IsUpper_v<MT> )
1951 ?( ( IsLower_v<MT> )?( sd.size() )
1952 :( ( IsStrictlyUpper_v<MT> && sd.size() > 0UL )
1953 ?( sd.offset() + sd.size() - 1UL )
1954 :( sd.offset() + sd.size() ) ) )
1955 :( ( IsLower_v<MT> )?( right.rows() - row )
1956 :( right.rows() ) ) );
1957
1958 constexpr auto check( getCheck( args... ) );
1959
1960 try {
1961 return subvector<AF>( left, row, m, check ) *
1962 submatrix<AF>( right, row, sd.offset(), m, sd.size(), check );
1963 }
1964 catch( ... ) {
1965 BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
1966 }
1967}
1969//*************************************************************************************************
1970
1971
1972//*************************************************************************************************
1985template< AlignmentFlag AF // Alignment flag
1986 , size_t... CSAs // Compile time subvector arguments
1987 , typename VT // Vector base type of the expression
1988 , typename... RSAs > // Runtime subvector arguments
1989inline decltype(auto) subvector( const MatReduceExpr<VT,columnwise>& vector, RSAs... args )
1990{
1992
1993 const SubvectorData<CSAs...> sd( args... );
1994 const size_t M( (*vector).operand().rows() );
1995 constexpr auto check( getCheck( args... ) );
1996
1997 try {
1998 decltype(auto) sm( submatrix<AF>( (*vector).operand(), 0UL, sd.offset(), M, sd.size(), check ) );
1999 return reduce<columnwise>( sm, (*vector).operation() );
2000 }
2001 catch( ... ) {
2002 BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
2003 }
2004}
2006//*************************************************************************************************
2007
2008
2009//*************************************************************************************************
2022template< AlignmentFlag AF // Alignment flag
2023 , size_t... CSAs // Compile time subvector arguments
2024 , typename VT // Vector base type of the expression
2025 , typename... RSAs > // Runtime subvector arguments
2026inline decltype(auto) subvector( const MatReduceExpr<VT,rowwise>& vector, RSAs... args )
2027{
2029
2030 const SubvectorData<CSAs...> sd( args... );
2031 const size_t N( (*vector).operand().columns() );
2032 constexpr auto check( getCheck( args... ) );
2033
2034 try {
2035 decltype(auto) sm( submatrix<AF>( (*vector).operand(), sd.offset(), 0UL, sd.size(), N, check ) );
2036 return reduce<rowwise>( sm, (*vector).operation() );
2037 }
2038 catch( ... ) {
2039 BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
2040 }
2041}
2043//*************************************************************************************************
2044
2045
2046
2047
2048//=================================================================================================
2049//
2050// GLOBAL RESTRUCTURING FUNCTIONS (ROW)
2051//
2052//=================================================================================================
2053
2054//*************************************************************************************************
2065template< size_t I // Row index
2066 , typename MT // Type of the sparse submatrix
2067 , typename... RRAs // Optional row arguments
2068 , EnableIf_t< IsSubmatrix_v< RemoveReference_t<MT> > &&
2069 RemoveReference_t<MT>::compileTimeArgs >* = nullptr >
2070inline decltype(auto) row( MT&& sm, RRAs... args )
2071{
2073
2074 MAYBE_UNUSED( args... );
2075
2076 constexpr size_t I2( RemoveReference_t<MT>::row() );
2077 constexpr size_t J ( RemoveReference_t<MT>::column() );
2078 constexpr size_t M ( RemoveReference_t<MT>::rows() );
2079 constexpr size_t N ( RemoveReference_t<MT>::columns() );
2080
2081 BLAZE_STATIC_ASSERT_MSG( I < M, "Invalid row access index" );
2082
2083 return subvector<J,N>( row<I+I2>( sm.operand(), unchecked ), unchecked );
2084}
2086//*************************************************************************************************
2087
2088
2089//*************************************************************************************************
2102template< typename MT // Type of the sparse submatrix
2103 , typename... RRAs // Optional row arguments
2104 , EnableIf_t< IsSubmatrix_v< RemoveReference_t<MT> > &&
2105 RemoveReference_t<MT>::compileTimeArgs >* = nullptr >
2106inline decltype(auto) row( MT&& sm, size_t index, RRAs... args )
2107{
2109
2110 constexpr size_t I( RemoveReference_t<MT>::row() );
2111 constexpr size_t J( RemoveReference_t<MT>::column() );
2112 constexpr size_t M( RemoveReference_t<MT>::rows() );
2113 constexpr size_t N( RemoveReference_t<MT>::columns() );
2114
2115 if( isChecked( args... ) ) {
2116 if( ( index >= M ) ) {
2117 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
2118 }
2119 }
2120 else {
2121 BLAZE_USER_ASSERT( index < M, "Invalid row access index" );
2122 }
2123
2124 return subvector<J,N>( row( sm.operand(), I+index, unchecked ), unchecked );
2125}
2127//*************************************************************************************************
2128
2129
2130//*************************************************************************************************
2142template< size_t... CRAs // Compile time row arguments
2143 , typename MT // Type of the sparse submatrix
2144 , typename... RRAs // Runtime row arguments
2145 , EnableIf_t< IsSubmatrix_v< RemoveReference_t<MT> > &&
2146 !RemoveReference_t<MT>::compileTimeArgs >* = nullptr >
2147inline decltype(auto) row( MT&& sm, RRAs... args )
2148{
2150
2151 const RowData<CRAs...> rd( args... );
2152
2153 if( isChecked( args... ) ) {
2154 if( ( rd.row() >= sm.rows() ) ) {
2155 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
2156 }
2157 }
2158 else {
2159 BLAZE_USER_ASSERT( rd.row() < sm.rows(), "Invalid row access index" );
2160 }
2161
2162 const size_t index( rd.row() + sm.row() );
2163
2164 return subvector( row( sm.operand(), index, unchecked ), sm.column(), sm.columns(), unchecked );
2165}
2167//*************************************************************************************************
2168
2169
2170
2171
2172//=================================================================================================
2173//
2174// GLOBAL RESTRUCTURING FUNCTIONS (ROWS)
2175//
2176//=================================================================================================
2177
2178//*************************************************************************************************
2189template< size_t I // First row index
2190 , size_t... Is // Remaining row indices
2191 , typename MT // Type of the sparse submatrix
2192 , typename... RRAs // Optional row arguments
2193 , EnableIf_t< IsSubmatrix_v< RemoveReference_t<MT> > &&
2194 RemoveReference_t<MT>::compileTimeArgs >* = nullptr >
2195inline decltype(auto) rows( MT&& sm, RRAs... args )
2196{
2198
2199 constexpr size_t I2( RemoveReference_t<MT>::row() );
2200 constexpr size_t J ( RemoveReference_t<MT>::column() );
2201 constexpr size_t M ( RemoveReference_t<MT>::rows() );
2202 constexpr size_t N ( RemoveReference_t<MT>::columns() );
2203
2204 return submatrix<0UL,J,sizeof...(Is)+1UL,N>(
2205 rows( sm.operand(), make_shifted_index_subsequence<I2,M,I,Is...>(), args... ), unchecked );
2206}
2208//*************************************************************************************************
2209
2210
2211//*************************************************************************************************
2223template< size_t I // First row index
2224 , size_t... Is // Remaining row indices
2225 , typename MT // Type of the sparse submatrix
2226 , typename... RRAs // Optional row arguments
2227 , EnableIf_t< IsSubmatrix_v< RemoveReference_t<MT> > &&
2228 !RemoveReference_t<MT>::compileTimeArgs >* = nullptr >
2229inline decltype(auto) rows( MT&& sm, RRAs... args )
2230{
2232
2233 if( isChecked( args... ) ) {
2234 constexpr size_t indices[] = { I, Is... };
2235 for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
2236 if( sm.rows() <= indices[i] ) {
2237 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
2238 }
2239 }
2240 }
2241
2242 return submatrix( rows( sm.operand(), { I+sm.row(), Is+sm.row()... }, unchecked ),
2243 0UL, sm.column(), sizeof...(Is)+1UL, sm.columns(), unchecked );
2244}
2246//*************************************************************************************************
2247
2248
2249//*************************************************************************************************
2263template< typename MT // Type of the sparse submatrix
2264 , typename T // Type of the row indices
2265 , typename... RRAs // Optional row arguments
2266 , EnableIf_t< IsSubmatrix_v< RemoveReference_t<MT> > >* = nullptr >
2267inline decltype(auto) rows( MT&& sm, T* indices, size_t n, RRAs... args )
2268{
2270
2271 if( isChecked( args... ) ) {
2272 for( size_t i=0UL; i<n; ++i ) {
2273 if( sm.rows() <= size_t( indices[i] ) ) {
2274 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
2275 }
2276 }
2277 }
2278
2279 SmallArray<size_t,128UL> newIndices( indices, indices+n );
2280 std::for_each( newIndices.begin(), newIndices.end(),
2281 [row=sm.row()]( size_t& index ){ index += row; } );
2282
2283 return submatrix( rows( sm.operand(), newIndices.data(), n, unchecked ),
2284 0UL, sm.column(), n, sm.columns(), unchecked );
2285}
2287//*************************************************************************************************
2288
2289
2290//*************************************************************************************************
2304template< typename MT // Type of the sparse submatrix
2305 , typename P // Type of the index producer
2306 , typename... RRAs // Optional row arguments
2307 , EnableIf_t< IsSubmatrix_v< RemoveReference_t<MT> > >* = nullptr >
2308inline decltype(auto) rows( MT&& sm, P p, size_t n, RRAs... args )
2309{
2311
2312 if( isChecked( args... ) ) {
2313 for( size_t i=0UL; i<n; ++i ) {
2314 if( sm.rows() <= size_t( p(i) ) ) {
2315 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
2316 }
2317 }
2318 }
2319
2320 return submatrix( rows( sm.operand(), [p,offset=sm.row()]( size_t i ){ return p(i)+offset; }, n, unchecked ),
2321 0UL, sm.column(), n, sm.columns(), unchecked );
2322}
2324//*************************************************************************************************
2325
2326
2327
2328
2329//=================================================================================================
2330//
2331// GLOBAL RESTRUCTURING FUNCTIONS (COLUMN)
2332//
2333//=================================================================================================
2334
2335//*************************************************************************************************
2346template< size_t I // Column index
2347 , typename MT // Type of the sparse submatrix
2348 , typename... RCAs // Optional column arguments
2349 , EnableIf_t< IsSubmatrix_v< RemoveReference_t<MT> > &&
2350 RemoveReference_t<MT>::compileTimeArgs >* = nullptr >
2351inline decltype(auto) column( MT&& sm, RCAs... args )
2352{
2354
2355 MAYBE_UNUSED( args... );
2356
2357 constexpr size_t I2( RemoveReference_t<MT>::row() );
2358 constexpr size_t J ( RemoveReference_t<MT>::column() );
2359 constexpr size_t M ( RemoveReference_t<MT>::rows() );
2360 constexpr size_t N ( RemoveReference_t<MT>::columns() );
2361
2362 BLAZE_STATIC_ASSERT_MSG( I < N, "Invalid column access index" );
2363
2364 return subvector<I2,M>( column<I+J>( sm.operand(), unchecked ), unchecked );
2365}
2367//*************************************************************************************************
2368
2369
2370//*************************************************************************************************
2383template< typename MT // Type of the sparse submatrix
2384 , typename... RCAs // Optional column arguments
2385 , EnableIf_t< IsSubmatrix_v< RemoveReference_t<MT> > &&
2386 RemoveReference_t<MT>::compileTimeArgs >* = nullptr >
2387inline decltype(auto) column( MT&& sm, size_t index, RCAs... args )
2388{
2390
2391 constexpr size_t I( RemoveReference_t<MT>::row() );
2392 constexpr size_t J( RemoveReference_t<MT>::column() );
2393 constexpr size_t M( RemoveReference_t<MT>::rows() );
2394 constexpr size_t N( RemoveReference_t<MT>::columns() );
2395
2396 if( isChecked( args... ) ) {
2397 if( ( index >= N ) ) {
2398 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
2399 }
2400 }
2401 else {
2402 BLAZE_USER_ASSERT( index < N, "Invalid column access index" );
2403 }
2404
2405 return subvector<I,M>( column( sm.operand(), J+index, unchecked ), unchecked );
2406}
2408//*************************************************************************************************
2409
2410
2411//*************************************************************************************************
2423template< size_t... CCAs // Compile time column arguments
2424 , typename MT // Type of the sparse submatrixy
2425 , typename... RCAs // Runtime column arguments
2426 , EnableIf_t< IsSubmatrix_v< RemoveReference_t<MT> > &&
2427 !RemoveReference_t<MT>::compileTimeArgs >* = nullptr >
2428inline decltype(auto) column( MT&& sm, RCAs... args )
2429{
2431
2432 const ColumnData<CCAs...> cd( args... );
2433
2434 if( isChecked( args... ) ) {
2435 if( ( cd.column() >= sm.columns() ) ) {
2436 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
2437 }
2438 }
2439 else {
2440 BLAZE_USER_ASSERT( cd.column() < sm.columns(), "Invalid column access index" );
2441 }
2442
2443 const size_t index( cd.column() + sm.column() );
2444
2445 return subvector( column( sm.operand(), index, unchecked ), sm.row(), sm.rows(), unchecked );
2446}
2448//*************************************************************************************************
2449
2450
2451
2452
2453//=================================================================================================
2454//
2455// GLOBAL RESTRUCTURING FUNCTIONS (COLUMNS)
2456//
2457//=================================================================================================
2458
2459//*************************************************************************************************
2470template< size_t I // First column index
2471 , size_t... Is // Remaining column indices
2472 , typename MT // Type of the sparse submatrix
2473 , typename... RCAs // Optional column arguments
2474 , EnableIf_t< IsSubmatrix_v< RemoveReference_t<MT> > &&
2475 RemoveReference_t<MT>::compileTimeArgs >* = nullptr >
2476inline decltype(auto) columns( MT&& sm, RCAs... args )
2477{
2479
2480 constexpr size_t I2( RemoveReference_t<MT>::row() );
2481 constexpr size_t J ( RemoveReference_t<MT>::column() );
2482 constexpr size_t M ( RemoveReference_t<MT>::rows() );
2483 constexpr size_t N ( RemoveReference_t<MT>::columns() );
2484
2485 return submatrix<I2,0UL,M,sizeof...(Is)+1UL>(
2486 columns( sm.operand(), make_shifted_index_subsequence<J,N,I,Is...>(), args... ), unchecked );
2487}
2489//*************************************************************************************************
2490
2491
2492//*************************************************************************************************
2504template< size_t I // First column index
2505 , size_t... Is // Remaining column indices
2506 , typename MT // Type of the sparse submatrix
2507 , typename... RCAs // Optional column arguments
2508 , EnableIf_t< IsSubmatrix_v< RemoveReference_t<MT> > &&
2509 !RemoveReference_t<MT>::compileTimeArgs >* = nullptr >
2510inline decltype(auto) columns( MT&& sm, RCAs... args )
2511{
2513
2514 if( isChecked( args... ) ) {
2515 constexpr size_t indices[] = { I, Is... };
2516 for( size_t j=0UL; j<sizeof...(Is)+1UL; ++j ) {
2517 if( sm.columns() <= indices[j] ) {
2518 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
2519 }
2520 }
2521 }
2522
2523 return submatrix( columns( sm.operand(), { I+sm.column(), Is+sm.column()... }, unchecked ),
2524 sm.row(), 0UL, sm.rows(), sizeof...(Is)+1UL, unchecked );
2525}
2527//*************************************************************************************************
2528
2529
2530//*************************************************************************************************
2544template< typename MT // Type of the sparse submatrix
2545 , typename T // Type of the column indices
2546 , typename... RCAs // Optional column arguments
2547 , EnableIf_t< IsSubmatrix_v< RemoveReference_t<MT> > >* = nullptr >
2548inline decltype(auto) columns( MT&& sm, T* indices, size_t n, RCAs... args )
2549{
2551
2552 if( isChecked( args... ) ) {
2553 for( size_t j=0UL; j<n; ++j ) {
2554 if( sm.columns() <= size_t( indices[j] ) ) {
2555 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column specification" );
2556 }
2557 }
2558 }
2559
2560 SmallArray<size_t,128UL> newIndices( indices, indices+n );
2561 std::for_each( newIndices.begin(), newIndices.end(),
2562 [column=sm.column()]( size_t& index ){ index += column; } );
2563
2564 return submatrix( columns( sm.operand(), newIndices.data(), n, unchecked ),
2565 sm.row(), 0UL, sm.rows(), n, unchecked );
2566}
2568//*************************************************************************************************
2569
2570
2571//*************************************************************************************************
2585template< typename MT // Type of the sparse submatrix
2586 , typename P // Type of the index producer
2587 , typename... RCAs // Optional column arguments
2588 , EnableIf_t< IsSubmatrix_v< RemoveReference_t<MT> > >* = nullptr >
2589inline decltype(auto) columns( MT&& sm, P p, size_t n, RCAs... args )
2590{
2592
2593 if( isChecked( args... ) ) {
2594 for( size_t j=0UL; j<n; ++j ) {
2595 if( sm.columns() <= size_t( p(j) ) ) {
2596 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column specification" );
2597 }
2598 }
2599 }
2600
2601 return submatrix( columns( sm.operand(), [p,offset=sm.column()]( size_t i ){ return p(i)+offset; }, n, unchecked ),
2602 sm.row(), 0UL, sm.rows(), n, unchecked );
2603}
2605//*************************************************************************************************
2606
2607
2608
2609
2610//=================================================================================================
2611//
2612// SUBMATRIX OPERATORS
2613//
2614//=================================================================================================
2615
2616//*************************************************************************************************
2642template< RelaxationFlag RF // Relaxation flag
2643 , typename MT // Type of the dense matrix
2644 , AlignmentFlag AF // Alignment flag
2645 , bool SO // Storage order
2646 , size_t... CSAs > // Compile time submatrix arguments
2647inline bool isDefault( const Submatrix<MT,AF,SO,true,CSAs...>& sm )
2648{
2649 using blaze::isDefault;
2650
2651 if( SO == rowMajor ) {
2652 for( size_t i=0UL; i<(*sm).rows(); ++i )
2653 for( size_t j=0UL; j<(*sm).columns(); ++j )
2654 if( !isDefault<RF>( (*sm)(i,j) ) )
2655 return false;
2656 }
2657 else {
2658 for( size_t j=0UL; j<(*sm).columns(); ++j )
2659 for( size_t i=0UL; i<(*sm).rows(); ++i )
2660 if( !isDefault<RF>( (*sm)(i,j) ) )
2661 return false;
2662 }
2663
2664 return true;
2665}
2667//*************************************************************************************************
2668
2669
2670//*************************************************************************************************
2696template< RelaxationFlag RF // Relaxation flag
2697 , typename MT // Type of the sparse matrix
2698 , AlignmentFlag AF // Alignment flag
2699 , bool SO // Storage order
2700 , size_t... CSAs > // Compile time submatrix arguments
2701inline bool isDefault( const Submatrix<MT,AF,SO,false,CSAs...>& sm )
2702{
2703 using blaze::isDefault;
2704
2705 const size_t iend( ( SO == rowMajor)?( sm.rows() ):( sm.columns() ) );
2706
2707 for( size_t i=0UL; i<iend; ++i ) {
2708 for( auto element=sm.cbegin(i); element!=sm.cend(i); ++element )
2709 if( !isDefault<RF>( element->value() ) ) return false;
2710 }
2711
2712 return true;
2713}
2715//*************************************************************************************************
2716
2717
2718//*************************************************************************************************
2737template< typename MT // Type of the matrix
2738 , AlignmentFlag AF // Alignment flag
2739 , bool SO // Storage order
2740 , bool DF // Density flag
2741 , size_t... CSAs > // Compile time submatrix arguments
2742inline bool isIntact( const Submatrix<MT,AF,SO,DF,CSAs...>& sm ) noexcept
2743{
2744 return ( sm.row() + sm.rows() <= sm.operand().rows() &&
2745 sm.column() + sm.columns() <= sm.operand().columns() &&
2746 isIntact( sm.operand() ) );
2747}
2749//*************************************************************************************************
2750
2751
2752//*************************************************************************************************
2773template< typename MT // Type of the matrix
2774 , AlignmentFlag AF // Alignment flag
2775 , bool SO // Storage order
2776 , bool DF // Density flag
2777 , size_t... CSAs > // Compile time submatrix arguments
2778inline bool isSymmetric( const Submatrix<MT,AF,SO,DF,CSAs...>& sm )
2779{
2780 using BaseType = BaseType_t< Submatrix<MT,AF,SO,DF,CSAs...> >;
2781
2782 if( IsSymmetric_v<MT> && sm.row() == sm.column() && sm.rows() == sm.columns() )
2783 return true;
2784 else return isSymmetric( static_cast<const BaseType&>( sm ) );
2785}
2787//*************************************************************************************************
2788
2789
2790//*************************************************************************************************
2811template< typename MT // Type of the matrix
2812 , AlignmentFlag AF // Alignment flag
2813 , bool SO // Storage order
2814 , bool DF // Density flag
2815 , size_t... CSAs > // Compile time submatrix arguments
2816inline bool isHermitian( const Submatrix<MT,AF,SO,DF,CSAs...>& sm )
2817{
2818 using BaseType = BaseType_t< Submatrix<MT,AF,SO,DF,CSAs...> >;
2819
2820 if( IsHermitian_v<MT> && sm.row() == sm.column() && sm.rows() == sm.columns() )
2821 return true;
2822 else return isHermitian( static_cast<const BaseType&>( sm ) );
2823}
2825//*************************************************************************************************
2826
2827
2828//*************************************************************************************************
2859template< typename MT // Type of the matrix
2860 , AlignmentFlag AF // Alignment flag
2861 , bool SO // Storage order
2862 , bool DF // Density flag
2863 , size_t... CSAs > // Compile time submatrix arguments
2864inline bool isLower( const Submatrix<MT,AF,SO,DF,CSAs...>& sm )
2865{
2866 using BaseType = BaseType_t< Submatrix<MT,AF,SO,DF,CSAs...> >;
2867
2868 if( IsLower_v<MT> && sm.row() == sm.column() && sm.rows() == sm.columns() )
2869 return true;
2870 else return isLower( static_cast<const BaseType&>( sm ) );
2871}
2873//*************************************************************************************************
2874
2875
2876//*************************************************************************************************
2906template< typename MT // Type of the matrix
2907 , AlignmentFlag AF // Alignment flag
2908 , bool SO // Storage order
2909 , bool DF // Density flag
2910 , size_t... CSAs > // Compile time submatrix arguments
2911inline bool isUniLower( const Submatrix<MT,AF,SO,DF,CSAs...>& sm )
2912{
2913 using BaseType = BaseType_t< Submatrix<MT,AF,SO,DF,CSAs...> >;
2914
2915 if( IsUniLower_v<MT> && sm.row() == sm.column() && sm.rows() == sm.columns() )
2916 return true;
2917 else return isUniLower( static_cast<const BaseType&>( sm ) );
2918}
2920//*************************************************************************************************
2921
2922
2923//*************************************************************************************************
2953template< typename MT // Type of the matrix
2954 , AlignmentFlag AF // Alignment flag
2955 , bool SO // Storage order
2956 , bool DF // Density flag
2957 , size_t... CSAs > // Compile time submatrix arguments
2958inline bool isStrictlyLower( const Submatrix<MT,AF,SO,DF,CSAs...>& sm )
2959{
2960 using BaseType = BaseType_t< Submatrix<MT,AF,SO,DF,CSAs...> >;
2961
2962 if( IsStrictlyLower_v<MT> && sm.row() == sm.column() && sm.rows() == sm.columns() )
2963 return true;
2964 else return isStrictlyLower( static_cast<const BaseType&>( sm ) );
2965}
2967//*************************************************************************************************
2968
2969
2970//*************************************************************************************************
3001template< typename MT // Type of the matrix
3002 , AlignmentFlag AF // Alignment flag
3003 , bool SO // Storage order
3004 , bool DF // Density flag
3005 , size_t... CSAs > // Compile time submatrix arguments
3006inline bool isUpper( const Submatrix<MT,AF,SO,DF,CSAs...>& sm )
3007{
3008 using BaseType = BaseType_t< Submatrix<MT,AF,SO,DF,CSAs...> >;
3009
3010 if( IsUpper_v<MT> && sm.row() == sm.column() && sm.rows() == sm.columns() )
3011 return true;
3012 else return isUpper( static_cast<const BaseType&>( sm ) );
3013}
3015//*************************************************************************************************
3016
3017
3018//*************************************************************************************************
3048template< typename MT // Type of the matrix
3049 , AlignmentFlag AF // Alignment flag
3050 , bool SO // Storage order
3051 , bool DF // Density flag
3052 , size_t... CSAs > // Compile time submatrix arguments
3053inline bool isUniUpper( const Submatrix<MT,AF,SO,DF,CSAs...>& sm )
3054{
3055 using BaseType = BaseType_t< Submatrix<MT,AF,SO,DF,CSAs...> >;
3056
3057 if( IsUniUpper_v<MT> && sm.row() == sm.column() && sm.rows() == sm.columns() )
3058 return true;
3059 else return isUniUpper( static_cast<const BaseType&>( sm ) );
3060}
3062//*************************************************************************************************
3063
3064
3065//*************************************************************************************************
3095template< typename MT // Type of the matrix
3096 , AlignmentFlag AF // Alignment flag
3097 , bool SO // Storage order
3098 , bool DF // Density flag
3099 , size_t... CSAs > // Compile time submatrix arguments
3100inline bool isStrictlyUpper( const Submatrix<MT,AF,SO,DF,CSAs...>& sm )
3101{
3102 using BaseType = BaseType_t< Submatrix<MT,AF,SO,DF,CSAs...> >;
3103
3104 if( IsStrictlyUpper_v<MT> && sm.row() == sm.column() && sm.rows() == sm.columns() )
3105 return true;
3106 else return isStrictlyUpper( static_cast<const BaseType&>( sm ) );
3107}
3109//*************************************************************************************************
3110
3111
3112//*************************************************************************************************
3125template< typename MT // Type of the matrix
3126 , AlignmentFlag AF // Alignment flag
3127 , bool SO // Storage order
3128 , bool DF // Density flag
3129 , size_t... CSAs > // Compile time submatrix arguments
3130inline bool isSame( const Submatrix<MT,AF,SO,DF,CSAs...>& a, const Matrix<MT,SO>& b ) noexcept
3131{
3132 return ( isSame( a.operand(), *b ) &&
3133 ( a.rows() == (*b).rows() ) &&
3134 ( a.columns() == (*b).columns() ) );
3135}
3137//*************************************************************************************************
3138
3139
3140//*************************************************************************************************
3153template< typename MT // Type of the matrix
3154 , bool SO // Storage order
3155 , AlignmentFlag AF // Alignment flag
3156 , bool DF // Density flag
3157 , size_t... CSAs > // Compile time submatrix arguments
3158inline bool isSame( const Matrix<MT,SO>& a, const Submatrix<MT,AF,SO,DF,CSAs...>& b ) noexcept
3159{
3160 return ( isSame( *a, b.operand() ) &&
3161 ( (*a).rows() == b.rows() ) &&
3162 ( (*a).columns() == b.columns() ) );
3163}
3165//*************************************************************************************************
3166
3167
3168//*************************************************************************************************
3181template< typename MT1 // Type of the matrix of the left-hand side submatrix
3182 , AlignmentFlag AF1 // Alignment flag of the left-hand side submatrix
3183 , bool SO1 // Storage order of the left-hand side submatrix
3184 , bool DF1 // Density flag of the left-hand side submatrix
3185 , size_t... CSAs1 // Compile time submatrix arguments of the left-hand side submatrix
3186 , typename MT2 // Type of the matrix of the right-hand side submatrix
3187 , AlignmentFlag AF2 // Alignment flag of the right-hand side submatrix
3188 , bool SO2 // Storage order of the right-hand side submatrix
3189 , bool DF2 // Density flag of the right-hand side submatrix
3190 , size_t... CSAs2 > // Compile time submatrix arguments of the right-hand side submatrix
3191inline bool isSame( const Submatrix<MT1,AF1,SO1,DF1,CSAs1...>& a,
3192 const Submatrix<MT2,AF2,SO2,DF2,CSAs2...>& b ) noexcept
3193{
3194 return ( isSame( a.operand(), b.operand() ) &&
3195 ( a.row() == b.row() ) && ( a.column() == b.column() ) &&
3196 ( a.rows() == b.rows() ) && ( a.columns() == b.columns() ) );
3197}
3199//*************************************************************************************************
3200
3201
3202//*************************************************************************************************
3241template< InversionFlag IF // Inversion algorithm
3242 , typename MT // Type of the dense matrix
3243 , AlignmentFlag AF // Alignment flag
3244 , bool SO // Storage order
3245 , size_t... CSAs > // Compile time submatrix arguments
3246inline auto invert( Submatrix<MT,AF,SO,true,CSAs...>& sm )
3247 -> DisableIf_t< HasMutableDataAccess_v<MT> >
3248{
3249 using RT = ResultType_t< Submatrix<MT,AF,SO,true,CSAs...> >;
3250
3253
3254 RT tmp( sm );
3255 invert<IF>( tmp );
3256 sm = tmp;
3257}
3259//*************************************************************************************************
3260
3261
3262//*************************************************************************************************
3278template< typename MT // Type of the matrix
3279 , AlignmentFlag AF // Alignment flag
3280 , bool SO // Storage order
3281 , bool DF // Density flag
3282 , size_t... CSAs // Compile time submatrix arguments
3283 , typename ET > // Type of the element
3284inline bool trySet( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t i, size_t j, const ET& value )
3285{
3286 BLAZE_INTERNAL_ASSERT( i < sm.rows(), "Invalid row access index" );
3287 BLAZE_INTERNAL_ASSERT( j < sm.columns(), "Invalid column access index" );
3288
3289 return trySet( sm.operand(), sm.row()+i, sm.column()+j, value );
3290}
3292//*************************************************************************************************
3293
3294
3295//*************************************************************************************************
3313template< typename MT // Type of the matrix
3314 , AlignmentFlag AF // Alignment flag
3315 , bool SO // Storage order
3316 , bool DF // Density flag
3317 , size_t... CSAs // Compile time submatrix arguments
3318 , typename ET > // Type of the element
3320 trySet( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t row, size_t column, size_t m, size_t n, const ET& value )
3321{
3322 BLAZE_INTERNAL_ASSERT( row <= (*sm).rows(), "Invalid row access index" );
3323 BLAZE_INTERNAL_ASSERT( column <= (*sm).columns(), "Invalid column access index" );
3324 BLAZE_INTERNAL_ASSERT( row + m <= (*sm).rows(), "Invalid number of rows" );
3325 BLAZE_INTERNAL_ASSERT( column + n <= (*sm).columns(), "Invalid number of columns" );
3326
3327 return trySet( sm.operand(), sm.row()+row, sm.column()+column, m, n, value );
3328}
3330//*************************************************************************************************
3331
3332
3333//*************************************************************************************************
3349template< typename MT // Type of the matrix
3350 , AlignmentFlag AF // Alignment flag
3351 , bool SO // Storage order
3352 , bool DF // Density flag
3353 , size_t... CSAs // Compile time submatrix arguments
3354 , typename ET > // Type of the element
3355inline bool tryAdd( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t i, size_t j, const ET& value )
3356{
3357 BLAZE_INTERNAL_ASSERT( i < sm.rows(), "Invalid row access index" );
3358 BLAZE_INTERNAL_ASSERT( j < sm.columns(), "Invalid column access index" );
3359
3360 return tryAdd( sm.operand(), sm.row()+i, sm.column()+j, value );
3361}
3363//*************************************************************************************************
3364
3365
3366//*************************************************************************************************
3384template< typename MT // Type of the matrix
3385 , AlignmentFlag AF // Alignment flag
3386 , bool SO // Storage order
3387 , bool DF // Density flag
3388 , size_t... CSAs // Compile time submatrix arguments
3389 , typename ET > // Type of the element
3391 tryAdd( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t row, size_t column, size_t m, size_t n, const ET& value )
3392{
3393 BLAZE_INTERNAL_ASSERT( row <= (*sm).rows(), "Invalid row access index" );
3394 BLAZE_INTERNAL_ASSERT( column <= (*sm).columns(), "Invalid column access index" );
3395 BLAZE_INTERNAL_ASSERT( row + m <= (*sm).rows(), "Invalid number of rows" );
3396 BLAZE_INTERNAL_ASSERT( column + n <= (*sm).columns(), "Invalid number of columns" );
3397
3398 return tryAdd( sm.operand(), sm.row()+row, sm.column()+column, m, n, value );
3399}
3401//*************************************************************************************************
3402
3403
3404//*************************************************************************************************
3420template< typename MT // Type of the matrix
3421 , AlignmentFlag AF // Alignment flag
3422 , bool SO // Storage order
3423 , bool DF // Density flag
3424 , size_t... CSAs // Compile time submatrix arguments
3425 , typename ET > // Type of the element
3426inline bool trySub( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t i, size_t j, const ET& value )
3427{
3428 BLAZE_INTERNAL_ASSERT( i < sm.rows(), "Invalid row access index" );
3429 BLAZE_INTERNAL_ASSERT( j < sm.columns(), "Invalid column access index" );
3430
3431 return trySub( sm.operand(), sm.row()+i, sm.column()+j, value );
3432}
3434//*************************************************************************************************
3435
3436
3437//*************************************************************************************************
3455template< typename MT // Type of the matrix
3456 , AlignmentFlag AF // Alignment flag
3457 , bool SO // Storage order
3458 , bool DF // Density flag
3459 , size_t... CSAs // Compile time submatrix arguments
3460 , typename ET > // Type of the element
3462 trySub( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t row, size_t column, size_t m, size_t n, const ET& value )
3463{
3464 BLAZE_INTERNAL_ASSERT( row <= (*sm).rows(), "Invalid row access index" );
3465 BLAZE_INTERNAL_ASSERT( column <= (*sm).columns(), "Invalid column access index" );
3466 BLAZE_INTERNAL_ASSERT( row + m <= (*sm).rows(), "Invalid number of rows" );
3467 BLAZE_INTERNAL_ASSERT( column + n <= (*sm).columns(), "Invalid number of columns" );
3468
3469 return trySub( sm.operand(), sm.row()+row, sm.column()+column, m, n, value );
3470}
3472//*************************************************************************************************
3473
3474
3475//*************************************************************************************************
3491template< typename MT // Type of the matrix
3492 , AlignmentFlag AF // Alignment flag
3493 , bool SO // Storage order
3494 , bool DF // Density flag
3495 , size_t... CSAs // Compile time submatrix arguments
3496 , typename ET > // Type of the element
3497inline bool tryMult( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t i, size_t j, const ET& value )
3498{
3499 BLAZE_INTERNAL_ASSERT( i < sm.rows(), "Invalid row access index" );
3500 BLAZE_INTERNAL_ASSERT( j < sm.columns(), "Invalid column access index" );
3501
3502 return tryMult( sm.operand(), sm.row()+i, sm.column()+j, value );
3503}
3505//*************************************************************************************************
3506
3507
3508//*************************************************************************************************
3526template< typename MT // Type of the matrix
3527 , AlignmentFlag AF // Alignment flag
3528 , bool SO // Storage order
3529 , bool DF // Density flag
3530 , size_t... CSAs // Compile time submatrix arguments
3531 , typename ET > // Type of the element
3533 tryMult( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t row, size_t column, size_t m, size_t n, const ET& value )
3534{
3535 BLAZE_INTERNAL_ASSERT( row <= (*sm).rows(), "Invalid row access index" );
3536 BLAZE_INTERNAL_ASSERT( column <= (*sm).columns(), "Invalid column access index" );
3537 BLAZE_INTERNAL_ASSERT( row + m <= (*sm).rows(), "Invalid number of rows" );
3538 BLAZE_INTERNAL_ASSERT( column + n <= (*sm).columns(), "Invalid number of columns" );
3539
3540 return tryMult( sm.operand(), sm.row()+row, sm.column()+column, m, n, value );
3541}
3543//*************************************************************************************************
3544
3545
3546//*************************************************************************************************
3562template< typename MT // Type of the matrix
3563 , AlignmentFlag AF // Alignment flag
3564 , bool SO // Storage order
3565 , bool DF // Density flag
3566 , size_t... CSAs // Compile time submatrix arguments
3567 , typename ET > // Type of the element
3568inline bool tryDiv( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t i, size_t j, const ET& value )
3569{
3570 BLAZE_INTERNAL_ASSERT( i < sm.rows(), "Invalid row access index" );
3571 BLAZE_INTERNAL_ASSERT( j < sm.columns(), "Invalid column access index" );
3572
3573 return tryDiv( sm.operand(), sm.row()+i, sm.column()+j, value );
3574}
3576//*************************************************************************************************
3577
3578
3579//*************************************************************************************************
3597template< typename MT // Type of the matrix
3598 , AlignmentFlag AF // Alignment flag
3599 , bool SO // Storage order
3600 , bool DF // Density flag
3601 , size_t... CSAs // Compile time submatrix arguments
3602 , typename ET > // Type of the element
3604 tryDiv( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t row, size_t column, size_t m, size_t n, const ET& value )
3605{
3606 BLAZE_INTERNAL_ASSERT( row <= (*sm).rows(), "Invalid row access index" );
3607 BLAZE_INTERNAL_ASSERT( column <= (*sm).columns(), "Invalid column access index" );
3608 BLAZE_INTERNAL_ASSERT( row + m <= (*sm).rows(), "Invalid number of rows" );
3609 BLAZE_INTERNAL_ASSERT( column + n <= (*sm).columns(), "Invalid number of columns" );
3610
3611 return tryDiv( sm.operand(), sm.row()+row, sm.column()+column, m, n, value );
3612}
3614//*************************************************************************************************
3615
3616
3617//*************************************************************************************************
3633template< typename MT // Type of the matrix
3634 , AlignmentFlag AF // Alignment flag
3635 , bool SO // Storage order
3636 , bool DF // Density flag
3637 , size_t... CSAs > // Compile time submatrix arguments
3638inline bool tryShift( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t i, size_t j, int count )
3639{
3640 BLAZE_INTERNAL_ASSERT( i < sm.rows(), "Invalid row access index" );
3641 BLAZE_INTERNAL_ASSERT( j < sm.columns(), "Invalid column access index" );
3642
3643 return tryShift( sm.operand(), sm.row()+i, sm.column()+j, count );
3644}
3646//*************************************************************************************************
3647
3648
3649//*************************************************************************************************
3667template< typename MT // Type of the matrix
3668 , AlignmentFlag AF // Alignment flag
3669 , bool SO // Storage order
3670 , bool DF // Density flag
3671 , size_t... CSAs > // Compile time submatrix arguments
3673 tryShift( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t row, size_t column, size_t m, size_t n, int count )
3674{
3675 BLAZE_INTERNAL_ASSERT( row <= (*sm).rows(), "Invalid row access index" );
3676 BLAZE_INTERNAL_ASSERT( column <= (*sm).columns(), "Invalid column access index" );
3677 BLAZE_INTERNAL_ASSERT( row + m <= (*sm).rows(), "Invalid number of rows" );
3678 BLAZE_INTERNAL_ASSERT( column + n <= (*sm).columns(), "Invalid number of columns" );
3679
3680 return tryShift( sm.operand(), sm.row()+row, sm.column()+column, m, n, count );
3681}
3683//*************************************************************************************************
3684
3685
3686//*************************************************************************************************
3702template< typename MT // Type of the matrix
3703 , AlignmentFlag AF // Alignment flag
3704 , bool SO // Storage order
3705 , bool DF // Density flag
3706 , size_t... CSAs // Compile time submatrix arguments
3707 , typename ET > // Type of the element
3708inline bool tryBitand( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t i, size_t j, const ET& value )
3709{
3710 BLAZE_INTERNAL_ASSERT( i < sm.rows(), "Invalid row access index" );
3711 BLAZE_INTERNAL_ASSERT( j < sm.columns(), "Invalid column access index" );
3712
3713 return tryBitand( sm.operand(), sm.row()+i, sm.column()+j, value );
3714}
3716//*************************************************************************************************
3717
3718
3719//*************************************************************************************************
3737template< typename MT // Type of the matrix
3738 , AlignmentFlag AF // Alignment flag
3739 , bool SO // Storage order
3740 , bool DF // Density flag
3741 , size_t... CSAs // Compile time submatrix arguments
3742 , typename ET > // Type of the element
3744 tryBitand( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t row, size_t column, size_t m, size_t n, const ET& value )
3745{
3746 BLAZE_INTERNAL_ASSERT( row <= (*sm).rows(), "Invalid row access index" );
3747 BLAZE_INTERNAL_ASSERT( column <= (*sm).columns(), "Invalid column access index" );
3748 BLAZE_INTERNAL_ASSERT( row + m <= (*sm).rows(), "Invalid number of rows" );
3749 BLAZE_INTERNAL_ASSERT( column + n <= (*sm).columns(), "Invalid number of columns" );
3750
3751 return tryBitand( sm.operand(), sm.row()+row, sm.column()+column, m, n, value );
3752}
3754//*************************************************************************************************
3755
3756
3757//*************************************************************************************************
3773template< typename MT // Type of the matrix
3774 , AlignmentFlag AF // Alignment flag
3775 , bool SO // Storage order
3776 , bool DF // Density flag
3777 , size_t... CSAs // Compile time submatrix arguments
3778 , typename ET > // Type of the element
3779inline bool tryBitor( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t i, size_t j, const ET& value )
3780{
3781 BLAZE_INTERNAL_ASSERT( i < sm.rows(), "Invalid row access index" );
3782 BLAZE_INTERNAL_ASSERT( j < sm.columns(), "Invalid column access index" );
3783
3784 return tryBitor( sm.operand(), sm.row()+i, sm.column()+j, value );
3785}
3787//*************************************************************************************************
3788
3789
3790//*************************************************************************************************
3808template< typename MT // Type of the matrix
3809 , AlignmentFlag AF // Alignment flag
3810 , bool SO // Storage order
3811 , bool DF // Density flag
3812 , size_t... CSAs // Compile time submatrix arguments
3813 , typename ET > // Type of the element
3815 tryBitor( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t row, size_t column, size_t m, size_t n, const ET& value )
3816{
3817 BLAZE_INTERNAL_ASSERT( row <= (*sm).rows(), "Invalid row access index" );
3818 BLAZE_INTERNAL_ASSERT( column <= (*sm).columns(), "Invalid column access index" );
3819 BLAZE_INTERNAL_ASSERT( row + m <= (*sm).rows(), "Invalid number of rows" );
3820 BLAZE_INTERNAL_ASSERT( column + n <= (*sm).columns(), "Invalid number of columns" );
3821
3822 return tryBitor( sm.operand(), sm.row()+row, sm.column()+column, m, n, value );
3823}
3825//*************************************************************************************************
3826
3827
3828//*************************************************************************************************
3844template< typename MT // Type of the matrix
3845 , AlignmentFlag AF // Alignment flag
3846 , bool SO // Storage order
3847 , bool DF // Density flag
3848 , size_t... CSAs // Compile time submatrix arguments
3849 , typename ET > // Type of the element
3850inline bool tryBitxor( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t i, size_t j, const ET& value )
3851{
3852 BLAZE_INTERNAL_ASSERT( i < sm.rows(), "Invalid row access index" );
3853 BLAZE_INTERNAL_ASSERT( j < sm.columns(), "Invalid column access index" );
3854
3855 return tryBitxor( sm.operand(), sm.row()+i, sm.column()+j, value );
3856}
3858//*************************************************************************************************
3859
3860
3861//*************************************************************************************************
3879template< typename MT // Type of the matrix
3880 , AlignmentFlag AF // Alignment flag
3881 , bool SO // Storage order
3882 , bool DF // Density flag
3883 , size_t... CSAs // Compile time submatrix arguments
3884 , typename ET > // Type of the element
3886 tryBitxor( const Submatrix<MT,AF,SO,DF,CSAs...>& sm, size_t row, size_t column, size_t m, size_t n, const ET& value )
3887{
3888 BLAZE_INTERNAL_ASSERT( row <= (*sm).rows(), "Invalid row access index" );
3889 BLAZE_INTERNAL_ASSERT( column <= (*sm).columns(), "Invalid column access index" );
3890 BLAZE_INTERNAL_ASSERT( row + m <= (*sm).rows(), "Invalid number of rows" );
3891 BLAZE_INTERNAL_ASSERT( column + n <= (*sm).columns(), "Invalid number of columns" );
3892
3893 return tryBitxor( sm.operand(), sm.row()+row, sm.column()+column, m, n, value );
3894}
3896//*************************************************************************************************
3897
3898
3899//*************************************************************************************************
3915template< typename MT // Type of the matrix
3916 , AlignmentFlag AF // Alignment flag
3917 , bool SO // Storage order
3918 , bool DF // Density flag
3919 , size_t... CSAs // Compile time submatrix arguments
3920 , typename VT // Type of the right-hand side vector
3921 , bool TF > // Transpose flag of the right-hand side vector
3922inline bool tryAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
3923 const Vector<VT,TF>& rhs, size_t row, size_t column )
3924{
3925 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3926 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3927 BLAZE_INTERNAL_ASSERT( TF || ( row + (*rhs).size() <= lhs.rows() ), "Invalid number of rows" );
3928 BLAZE_INTERNAL_ASSERT( !TF || ( column + (*rhs).size() <= lhs.columns() ), "Invalid number of columns" );
3929
3930 return tryAssign( lhs.operand(), *rhs, lhs.row() + row, lhs.column() + column );
3931}
3933//*************************************************************************************************
3934
3935
3936//*************************************************************************************************
3953template< typename MT // Type of the matrix
3954 , AlignmentFlag AF // Alignment flag
3955 , bool SO // Storage order
3956 , bool DF // Density flag
3957 , size_t... CSAs // Compile time submatrix arguments
3958 , typename VT // Type of the right-hand side vector
3959 , bool TF > // Transpose flag of the right-hand side vector
3960inline bool tryAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
3961 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3962{
3963 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3964 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3965 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3966 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3967
3968 return tryAssign( lhs.operand(), *rhs, band + ptrdiff_t( lhs.column() - lhs.row() ),
3969 lhs.row() + row, lhs.column() + column );
3970}
3972//*************************************************************************************************
3973
3974
3975//*************************************************************************************************
3991template< typename MT1 // Type of the matrix
3992 , AlignmentFlag AF // Alignment flag
3993 , bool SO1 // Storage order
3994 , bool DF // Density flag
3995 , size_t... CSAs // Compile time submatrix arguments
3996 , typename MT2 // Type of the right-hand side matrix
3997 , bool SO2 > // Storage order of the right-hand side matrix
3998inline bool tryAssign( const Submatrix<MT1,AF,SO1,DF,CSAs...>& lhs,
3999 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
4000{
4001 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4002 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4003 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
4004 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
4005
4006 return tryAssign( lhs.operand(), *rhs, lhs.row() + row, lhs.column() + column );
4007}
4009//*************************************************************************************************
4010
4011
4012//*************************************************************************************************
4028template< typename MT // Type of the matrix
4029 , AlignmentFlag AF // Alignment flag
4030 , bool SO // Storage order
4031 , bool DF // Density flag
4032 , size_t... CSAs // Compile time submatrix arguments
4033 , typename VT // Type of the right-hand side vector
4034 , bool TF > // Transpose flag of the right-hand side vector
4035inline bool tryAddAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
4036 const Vector<VT,TF>& rhs, size_t row, size_t column )
4037{
4038 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4039 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4040 BLAZE_INTERNAL_ASSERT( TF || ( row + (*rhs).size() <= lhs.rows() ), "Invalid number of rows" );
4041 BLAZE_INTERNAL_ASSERT( !TF || ( column + (*rhs).size() <= lhs.columns() ), "Invalid number of columns" );
4042
4043 return tryAddAssign( lhs.operand(), *rhs, lhs.row() + row, lhs.column() + column );
4044}
4046//*************************************************************************************************
4047
4048
4049//*************************************************************************************************
4067template< typename MT // Type of the matrix
4068 , AlignmentFlag AF // Alignment flag
4069 , bool SO // Storage order
4070 , bool DF // Density flag
4071 , size_t... CSAs // Compile time submatrix arguments
4072 , typename VT // Type of the right-hand side vector
4073 , bool TF > // Transpose flag of the right-hand side vector
4074inline bool tryAddAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
4075 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
4076{
4077 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4078 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4079 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4080 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4081
4082 return tryAddAssign( lhs.operand(), *rhs, band + ptrdiff_t( lhs.column() - lhs.row() ),
4083 lhs.row() + row, lhs.column() + column );
4084}
4086//*************************************************************************************************
4087
4088
4089//*************************************************************************************************
4105template< typename MT1 // Type of the matrix
4106 , AlignmentFlag AF // Alignment flag
4107 , bool SO1 // Storage order
4108 , bool DF // Density flag
4109 , size_t... CSAs // Compile time submatrix arguments
4110 , typename MT2 // Type of the right-hand side matrix
4111 , bool SO2 > // Storage order of the right-hand side matrix
4112inline bool tryAddAssign( const Submatrix<MT1,AF,SO1,DF,CSAs...>& lhs,
4113 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
4114{
4115 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4116 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4117 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
4118 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
4119
4120 return tryAddAssign( lhs.operand(), *rhs, lhs.row() + row, lhs.column() + column );
4121}
4123//*************************************************************************************************
4124
4125
4126//*************************************************************************************************
4142template< typename MT // Type of the matrix
4143 , AlignmentFlag AF // Alignment flag
4144 , bool SO // Storage order
4145 , bool DF // Density flag
4146 , size_t... CSAs // Compile time submatrix arguments
4147 , typename VT // Type of the right-hand side vector
4148 , bool TF > // Transpose flag of the right-hand side vector
4149inline bool trySubAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
4150 const Vector<VT,TF>& rhs, size_t row, size_t column )
4151{
4152 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4153 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4154 BLAZE_INTERNAL_ASSERT( TF || ( row + (*rhs).size() <= lhs.rows() ), "Invalid number of rows" );
4155 BLAZE_INTERNAL_ASSERT( !TF || ( column + (*rhs).size() <= lhs.columns() ), "Invalid number of columns" );
4156
4157 return trySubAssign( lhs.operand(), *rhs, lhs.row() + row, lhs.column() + column );
4158}
4160//*************************************************************************************************
4161
4162
4163//*************************************************************************************************
4181template< typename MT // Type of the matrix
4182 , AlignmentFlag AF // Alignment flag
4183 , bool SO // Storage order
4184 , bool DF // Density flag
4185 , size_t... CSAs // Compile time submatrix arguments
4186 , typename VT // Type of the right-hand side vector
4187 , bool TF > // Transpose flag of the right-hand side vector
4188inline bool trySubAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
4189 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
4190{
4191 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4192 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4193 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4194 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4195
4196 return trySubAssign( lhs.operand(), *rhs, band + ptrdiff_t( lhs.column() - lhs.row() ),
4197 lhs.row() + row, lhs.column() + column );
4198}
4200//*************************************************************************************************
4201
4202
4203//*************************************************************************************************
4219template< typename MT1 // Type of the matrix
4220 , AlignmentFlag AF // Alignment flag
4221 , bool SO1 // Storage order
4222 , bool DF // Density flag
4223 , size_t... CSAs // Compile time submatrix arguments
4224 , typename MT2 // Type of the right-hand side matrix
4225 , bool SO2 > // Storage order of the right-hand side matrix
4226inline bool trySubAssign( const Submatrix<MT1,AF,SO1,DF,CSAs...>& lhs,
4227 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
4228{
4229 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4230 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4231 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
4232 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
4233
4234 return trySubAssign( lhs.operand(), *rhs, lhs.row() + row, lhs.column() + column );
4235}
4237//*************************************************************************************************
4238
4239
4240//*************************************************************************************************
4256template< typename MT // Type of the matrix
4257 , AlignmentFlag AF // Alignment flag
4258 , bool SO // Storage order
4259 , bool DF // Density flag
4260 , size_t... CSAs // Compile time submatrix arguments
4261 , typename VT // Type of the right-hand side vector
4262 , bool TF > // Transpose flag of the right-hand side vector
4263inline bool tryMultAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
4264 const Vector<VT,TF>& rhs, size_t row, size_t column )
4265{
4266 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4267 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4268 BLAZE_INTERNAL_ASSERT( TF || ( row + (*rhs).size() <= lhs.rows() ), "Invalid number of rows" );
4269 BLAZE_INTERNAL_ASSERT( !TF || ( column + (*rhs).size() <= lhs.columns() ), "Invalid number of columns" );
4270
4271 return tryMultAssign( lhs.operand(), *rhs, lhs.row() + row, lhs.column() + column );
4272}
4274//*************************************************************************************************
4275
4276
4277//*************************************************************************************************
4295template< typename MT // Type of the matrix
4296 , AlignmentFlag AF // Alignment flag
4297 , bool SO // Storage order
4298 , bool DF // Density flag
4299 , size_t... CSAs // Compile time submatrix arguments
4300 , typename VT // Type of the right-hand side vector
4301 , bool TF > // Transpose flag of the right-hand side vector
4302inline bool tryMultAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
4303 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
4304{
4305 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4306 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4307 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4308 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4309
4310 return tryMultAssign( lhs.operand(), *rhs, band + ptrdiff_t( lhs.column() - lhs.row() ),
4311 lhs.row() + row, lhs.column() + column );
4312}
4314//*************************************************************************************************
4315
4316
4317//*************************************************************************************************
4333template< typename MT1 // Type of the matrix
4334 , AlignmentFlag AF // Alignment flag
4335 , bool SO1 // Storage order
4336 , bool DF // Density flag
4337 , size_t... CSAs // Compile time submatrix arguments
4338 , typename MT2 // Type of the right-hand side matrix
4339 , bool SO2 > // Storage order of the right-hand side matrix
4340inline bool trySchurAssign( const Submatrix<MT1,AF,SO1,DF,CSAs...>& lhs,
4341 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
4342{
4343 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4344 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4345 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
4346 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
4347
4348 return trySchurAssign( lhs.operand(), *rhs, lhs.row() + row, lhs.column() + column );
4349}
4351//*************************************************************************************************
4352
4353
4354//*************************************************************************************************
4370template< typename MT // Type of the matrix
4371 , AlignmentFlag AF // Alignment flag
4372 , bool SO // Storage order
4373 , bool DF // Density flag
4374 , size_t... CSAs // Compile time submatrix arguments
4375 , typename VT // Type of the right-hand side vector
4376 , bool TF > // Transpose flag of the right-hand side vector
4377inline bool tryDivAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
4378 const Vector<VT,TF>& rhs, size_t row, size_t column )
4379{
4380 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4381 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4382 BLAZE_INTERNAL_ASSERT( TF || ( row + (*rhs).size() <= lhs.rows() ), "Invalid number of rows" );
4383 BLAZE_INTERNAL_ASSERT( !TF || ( column + (*rhs).size() <= lhs.columns() ), "Invalid number of columns" );
4384
4385 return tryDivAssign( lhs.operand(), *rhs, lhs.row() + row, lhs.column() + column );
4386}
4388//*************************************************************************************************
4389
4390
4391//*************************************************************************************************
4409template< typename MT // Type of the matrix
4410 , AlignmentFlag AF // Alignment flag
4411 , bool SO // Storage order
4412 , bool DF // Density flag
4413 , size_t... CSAs // Compile time submatrix arguments
4414 , typename VT // Type of the right-hand side vector
4415 , bool TF > // Transpose flag of the right-hand side vector
4416inline bool tryDivAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
4417 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
4418{
4419 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4420 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4421 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4422 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4423
4424 return tryDivAssign( lhs.operand(), *rhs, band + ptrdiff_t( lhs.column() - lhs.row() ),
4425 lhs.row() + row, lhs.column() + column );
4426}
4428//*************************************************************************************************
4429
4430
4431//*************************************************************************************************
4447template< typename MT // Type of the matrix
4448 , AlignmentFlag AF // Alignment flag
4449 , bool SO // Storage order
4450 , bool DF // Density flag
4451 , size_t... CSAs // Compile time submatrix arguments
4452 , typename VT // Type of the right-hand side vector
4453 , bool TF > // Transpose flag of the right-hand side vector
4454inline bool tryShiftAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
4455 const Vector<VT,TF>& rhs, size_t row, size_t column )
4456{
4457 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4458 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4459 BLAZE_INTERNAL_ASSERT( TF || ( row + (*rhs).size() <= lhs.rows() ), "Invalid number of rows" );
4460 BLAZE_INTERNAL_ASSERT( !TF || ( column + (*rhs).size() <= lhs.columns() ), "Invalid number of columns" );
4461
4462 return tryShiftAssign( lhs.operand(), *rhs, lhs.row() + row, lhs.column() + column );
4463}
4465//*************************************************************************************************
4466
4467
4468//*************************************************************************************************
4486template< typename MT // Type of the matrix
4487 , AlignmentFlag AF // Alignment flag
4488 , bool SO // Storage order
4489 , bool DF // Density flag
4490 , size_t... CSAs // Compile time submatrix arguments
4491 , typename VT // Type of the right-hand side vector
4492 , bool TF > // Transpose flag of the right-hand side vector
4493inline bool tryShiftAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
4494 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
4495{
4496 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4497 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4498 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4499 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4500
4501 return tryShiftAssign( lhs.operand(), *rhs, band + ptrdiff_t( lhs.column() - lhs.row() ),
4502 lhs.row() + row, lhs.column() + column );
4503}
4505//*************************************************************************************************
4506
4507
4508//*************************************************************************************************
4524template< typename MT1 // Type of the matrix
4525 , AlignmentFlag AF // Alignment flag
4526 , bool SO1 // Storage order
4527 , bool DF // Density flag
4528 , size_t... CSAs // Compile time submatrix arguments
4529 , typename MT2 // Type of the right-hand side matrix
4530 , bool SO2 > // Storage order of the right-hand side matrix
4531inline bool tryShiftAssign( const Submatrix<MT1,AF,SO1,DF,CSAs...>& lhs,
4532 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
4533{
4534 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4535 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4536 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
4537 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
4538
4539 return tryShiftAssign( lhs.operand(), *rhs, lhs.row() + row, lhs.column() + column );
4540}
4542//*************************************************************************************************
4543
4544
4545//*************************************************************************************************
4561template< typename MT // Type of the matrix
4562 , AlignmentFlag AF // Alignment flag
4563 , bool SO // Storage order
4564 , bool DF // Density flag
4565 , size_t... CSAs // Compile time submatrix arguments
4566 , typename VT // Type of the right-hand side vector
4567 , bool TF > // Transpose flag of the right-hand side vector
4568inline bool tryBitandAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
4569 const Vector<VT,TF>& rhs, size_t row, size_t column )
4570{
4571 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4572 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4573 BLAZE_INTERNAL_ASSERT( TF || ( row + (*rhs).size() <= lhs.rows() ), "Invalid number of rows" );
4574 BLAZE_INTERNAL_ASSERT( !TF || ( column + (*rhs).size() <= lhs.columns() ), "Invalid number of columns" );
4575
4576 return tryBitandAssign( lhs.operand(), *rhs, lhs.row() + row, lhs.column() + column );
4577}
4579//*************************************************************************************************
4580
4581
4582//*************************************************************************************************
4600template< typename MT // Type of the matrix
4601 , AlignmentFlag AF // Alignment flag
4602 , bool SO // Storage order
4603 , bool DF // Density flag
4604 , size_t... CSAs // Compile time submatrix arguments
4605 , typename VT // Type of the right-hand side vector
4606 , bool TF > // Transpose flag of the right-hand side vector
4607inline bool tryBitandAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
4608 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
4609{
4610 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4611 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4612 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4613 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4614
4615 return tryBitandAssign( lhs.operand(), *rhs, band + ptrdiff_t( lhs.column() - lhs.row() ),
4616 lhs.row() + row, lhs.column() + column );
4617}
4619//*************************************************************************************************
4620
4621
4622//*************************************************************************************************
4638template< typename MT1 // Type of the matrix
4639 , AlignmentFlag AF // Alignment flag
4640 , bool SO1 // Storage order
4641 , bool DF // Density flag
4642 , size_t... CSAs // Compile time submatrix arguments
4643 , typename MT2 // Type of the right-hand side matrix
4644 , bool SO2 > // Storage order of the right-hand side matrix
4645inline bool tryBitandAssign( const Submatrix<MT1,AF,SO1,DF,CSAs...>& lhs,
4646 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
4647{
4648 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4649 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4650 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
4651 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
4652
4653 return tryBitandAssign( lhs.operand(), *rhs, lhs.row() + row, lhs.column() + column );
4654}
4656//*************************************************************************************************
4657
4658
4659//*************************************************************************************************
4675template< typename MT // Type of the matrix
4676 , AlignmentFlag AF // Alignment flag
4677 , bool SO // Storage order
4678 , bool DF // Density flag
4679 , size_t... CSAs // Compile time submatrix arguments
4680 , typename VT // Type of the right-hand side vector
4681 , bool TF > // Transpose flag of the right-hand side vector
4682inline bool tryBitorAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
4683 const Vector<VT,TF>& rhs, size_t row, size_t column )
4684{
4685 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4686 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4687 BLAZE_INTERNAL_ASSERT( TF || ( row + (*rhs).size() <= lhs.rows() ), "Invalid number of rows" );
4688 BLAZE_INTERNAL_ASSERT( !TF || ( column + (*rhs).size() <= lhs.columns() ), "Invalid number of columns" );
4689
4690 return tryBitorAssign( lhs.operand(), *rhs, lhs.row() + row, lhs.column() + column );
4691}
4693//*************************************************************************************************
4694
4695
4696//*************************************************************************************************
4714template< typename MT // Type of the matrix
4715 , AlignmentFlag AF // Alignment flag
4716 , bool SO // Storage order
4717 , bool DF // Density flag
4718 , size_t... CSAs // Compile time submatrix arguments
4719 , typename VT // Type of the right-hand side vector
4720 , bool TF > // Transpose flag of the right-hand side vector
4721inline bool tryBitorAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
4722 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
4723{
4724 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4725 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4726 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4727 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4728
4729 return tryBitorAssign( lhs.operand(), *rhs, band + ptrdiff_t( lhs.column() - lhs.row() ),
4730 lhs.row() + row, lhs.column() + column );
4731}
4733//*************************************************************************************************
4734
4735
4736//*************************************************************************************************
4752template< typename MT1 // Type of the matrix
4753 , AlignmentFlag AF // Alignment flag
4754 , bool SO1 // Storage order
4755 , bool DF // Density flag
4756 , size_t... CSAs // Compile time submatrix arguments
4757 , typename MT2 // Type of the right-hand side matrix
4758 , bool SO2 > // Storage order of the right-hand side matrix
4759inline bool tryBitorAssign( const Submatrix<MT1,AF,SO1,DF,CSAs...>& lhs,
4760 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
4761{
4762 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4763 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4764 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
4765 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
4766
4767 return tryBitorAssign( lhs.operand(), *rhs, lhs.row() + row, lhs.column() + column );
4768}
4770//*************************************************************************************************
4771
4772
4773//*************************************************************************************************
4789template< typename MT // Type of the matrix
4790 , AlignmentFlag AF // Alignment flag
4791 , bool SO // Storage order
4792 , bool DF // Density flag
4793 , size_t... CSAs // Compile time submatrix arguments
4794 , typename VT // Type of the right-hand side vector
4795 , bool TF > // Transpose flag of the right-hand side vector
4796inline bool tryBitxorAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
4797 const Vector<VT,TF>& rhs, size_t row, size_t column )
4798{
4799 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4800 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4801 BLAZE_INTERNAL_ASSERT( TF || ( row + (*rhs).size() <= lhs.rows() ), "Invalid number of rows" );
4802 BLAZE_INTERNAL_ASSERT( !TF || ( column + (*rhs).size() <= lhs.columns() ), "Invalid number of columns" );
4803
4804 return tryBitxorAssign( lhs.operand(), *rhs, lhs.row() + row, lhs.column() + column );
4805}
4807//*************************************************************************************************
4808
4809
4810//*************************************************************************************************
4828template< typename MT // Type of the matrix
4829 , AlignmentFlag AF // Alignment flag
4830 , bool SO // Storage order
4831 , bool DF // Density flag
4832 , size_t... CSAs // Compile time submatrix arguments
4833 , typename VT // Type of the right-hand side vector
4834 , bool TF > // Transpose flag of the right-hand side vector
4835inline bool tryBitxorAssign( const Submatrix<MT,AF,SO,DF,CSAs...>& lhs,
4836 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
4837{
4838 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4839 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4840 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4841 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4842
4843 return tryBitxorAssign( lhs.operand(), *rhs, band + ptrdiff_t( lhs.column() - lhs.row() ),
4844 lhs.row() + row, lhs.column() + column );
4845}
4847//*************************************************************************************************
4848
4849
4850//*************************************************************************************************
4866template< typename MT1 // Type of the matrix
4867 , AlignmentFlag AF // Alignment flag
4868 , bool SO1 // Storage order
4869 , bool DF // Density flag
4870 , size_t... CSAs // Compile time submatrix arguments
4871 , typename MT2 // Type of the right-hand side matrix
4872 , bool SO2 > // Storage order of the right-hand side matrix
4873inline bool tryBitxorAssign( const Submatrix<MT1,AF,SO1,DF,CSAs...>& lhs,
4874 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
4875{
4876 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4877 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4878 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
4879 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
4880
4881 return tryBitxorAssign( lhs.operand(), *rhs, lhs.row() + row, lhs.column() + column );
4882}
4884//*************************************************************************************************
4885
4886
4887//*************************************************************************************************
4902template< typename MT // Type of the matrix
4903 , AlignmentFlag AF // Alignment flag
4904 , bool SO // Storage order
4905 , bool DF // Density flag
4906 , size_t I // Index of the first row
4907 , size_t J // Index of the first column
4908 , size_t M // Number of rows
4909 , size_t N > // Number of columns
4910inline decltype(auto) derestrict( Submatrix<MT,AF,SO,DF,I,J,M,N>& sm )
4911{
4912 return submatrix<AF,I,J,M,N>( derestrict( sm.operand() ), unchecked );
4913}
4915//*************************************************************************************************
4916
4917
4918//*************************************************************************************************
4933template< typename MT // Type of the matrix
4934 , AlignmentFlag AF // Alignment flag
4935 , bool SO // Storage order
4936 , bool DF // Density flag
4937 , size_t I // Index of the first row
4938 , size_t J // Index of the first column
4939 , size_t M // Number of rows
4940 , size_t N > // Number of columns
4941inline decltype(auto) derestrict( Submatrix<MT,AF,SO,DF,I,J,M,N>&& sm )
4942{
4943 return submatrix<AF,I,J,M,N>( derestrict( sm.operand() ), unchecked );
4944}
4946//*************************************************************************************************
4947
4948
4949//*************************************************************************************************
4964template< typename MT // Type of the matrix
4965 , AlignmentFlag AF // Alignment flag
4966 , bool SO // Storage order
4967 , bool DF > // Density flag
4968inline decltype(auto) derestrict( Submatrix<MT,AF,SO,DF>& sm )
4969{
4970 return submatrix<AF>( derestrict( sm.operand() ), sm.row(), sm.column(), sm.rows(), sm.columns(), unchecked );
4971}
4973//*************************************************************************************************
4974
4975
4976//*************************************************************************************************
4991template< typename MT // Type of the matrix
4992 , AlignmentFlag AF // Alignment flag
4993 , bool SO // Storage order
4994 , bool DF > // Density flag
4995inline decltype(auto) derestrict( Submatrix<MT,AF,SO,DF>&& sm )
4996{
4997 return submatrix<AF>( derestrict( sm.operand() ), sm.row(), sm.column(), sm.rows(), sm.columns(), unchecked );
4998}
5000//*************************************************************************************************
5001
5002
5003//*************************************************************************************************
5016template< typename MT // Type of the matrix
5017 , AlignmentFlag AF // Alignment flag
5018 , bool SO // Storage order
5019 , bool DF // Density flag
5020 , size_t... CSAs > // Compile time submatrix arguments
5021inline decltype(auto) unview( Submatrix<MT,AF,SO,DF,CSAs...>& sm )
5022{
5023 return sm.operand();
5024}
5026//*************************************************************************************************
5027
5028
5029//*************************************************************************************************
5042template< typename MT // Type of the matrix
5043 , AlignmentFlag AF // Alignment flag
5044 , bool SO // Storage order
5045 , bool DF // Density flag
5046 , size_t... CSAs > // Compile time submatrix arguments
5047inline decltype(auto) unview( const Submatrix<MT,AF,SO,DF,CSAs...>& sm )
5048{
5049 return sm.operand();
5050}
5052//*************************************************************************************************
5053
5054
5055
5056
5057//=================================================================================================
5058//
5059// SIZE SPECIALIZATIONS
5060//
5061//=================================================================================================
5062
5063//*************************************************************************************************
5065template< typename MT, AlignmentFlag AF, bool SO, bool DF, size_t I, size_t J, size_t M, size_t N >
5066struct Size< Submatrix<MT,AF,SO,DF,I,J,M,N>, 0UL >
5067 : public Ptrdiff_t< static_cast<ptrdiff_t>(M) >
5068{};
5069
5070template< typename MT, AlignmentFlag AF, bool SO, bool DF, size_t I, size_t J, size_t M, size_t N >
5071struct Size< Submatrix<MT,AF,SO,DF,I,J,M,N>, 1UL >
5072 : public Ptrdiff_t< static_cast<ptrdiff_t>(N) >
5073{};
5075//*************************************************************************************************
5076
5077
5078
5079
5080//=================================================================================================
5081//
5082// MAXSIZE SPECIALIZATIONS
5083//
5084//=================================================================================================
5085
5086//*************************************************************************************************
5088template< typename MT, AlignmentFlag AF, bool SO, bool DF, size_t I, size_t J, size_t M, size_t N >
5089struct MaxSize< Submatrix<MT,AF,SO,DF,I,J,M,N>, 0UL >
5090 : public Ptrdiff_t< static_cast<ptrdiff_t>(M) >
5091{};
5092
5093template< typename MT, AlignmentFlag AF, bool SO, bool DF, size_t I, size_t J, size_t M, size_t N >
5094struct MaxSize< Submatrix<MT,AF,SO,DF,I,J,M,N>, 1UL >
5095 : public Ptrdiff_t< static_cast<ptrdiff_t>(N) >
5096{};
5098//*************************************************************************************************
5099
5100
5101
5102
5103//=================================================================================================
5104//
5105// ISRESTRICTED SPECIALIZATIONS
5106//
5107//=================================================================================================
5108
5109//*************************************************************************************************
5111template< typename MT, AlignmentFlag AF, bool SO, bool DF, size_t... CSAs >
5112struct IsRestricted< Submatrix<MT,AF,SO,DF,CSAs...> >
5113 : public IsRestricted<MT>
5114{};
5116//*************************************************************************************************
5117
5118
5119
5120
5121//=================================================================================================
5122//
5123// HASCONSTDATAACCESS SPECIALIZATIONS
5124//
5125//=================================================================================================
5126
5127//*************************************************************************************************
5129template< typename MT, AlignmentFlag AF, bool SO, size_t... CSAs >
5130struct HasConstDataAccess< Submatrix<MT,AF,SO,true,CSAs...> >
5131 : public HasConstDataAccess<MT>
5132{};
5134//*************************************************************************************************
5135
5136
5137
5138
5139//=================================================================================================
5140//
5141// HASMUTABLEDATAACCESS SPECIALIZATIONS
5142//
5143//=================================================================================================
5144
5145//*************************************************************************************************
5147template< typename MT, AlignmentFlag AF, bool SO, size_t... CSAs >
5148struct HasMutableDataAccess< Submatrix<MT,AF,SO,true,CSAs...> >
5149 : public HasMutableDataAccess<MT>
5150{};
5152//*************************************************************************************************
5153
5154
5155
5156
5157//=================================================================================================
5158//
5159// ISALIGNED SPECIALIZATIONS
5160//
5161//=================================================================================================
5162
5163//*************************************************************************************************
5165template< typename MT, bool SO, size_t... CSAs >
5166struct IsAligned< Submatrix<MT,aligned,SO,true,CSAs...> >
5167 : public TrueType
5168{};
5170//*************************************************************************************************
5171
5172
5173
5174
5175//=================================================================================================
5176//
5177// ISCONTIGUOUS SPECIALIZATIONS
5178//
5179//=================================================================================================
5180
5181//*************************************************************************************************
5183template< typename MT, AlignmentFlag AF, bool SO, size_t... CSAs >
5184struct IsContiguous< Submatrix<MT,AF,SO,true,CSAs...> >
5185 : public IsContiguous<MT>
5186{};
5188//*************************************************************************************************
5189
5190
5191
5192
5193//=================================================================================================
5194//
5195// ISSYMMETRIC SPECIALIZATIONS
5196//
5197//=================================================================================================
5198
5199//*************************************************************************************************
5201template< typename MT, AlignmentFlag AF, bool SO, bool DF, size_t I, size_t J, size_t M, size_t N >
5202struct IsSymmetric< Submatrix<MT,AF,SO,DF,I,J,M,N> >
5203 : public BoolConstant< ( IsSymmetric_v<MT> && I == J && M == N ) >
5204{};
5206//*************************************************************************************************
5207
5208
5209
5210
5211//=================================================================================================
5212//
5213// ISHERMITIAN SPECIALIZATIONS
5214//
5215//=================================================================================================
5216
5217//*************************************************************************************************
5219template< typename MT, AlignmentFlag AF, bool SO, bool DF, size_t I, size_t J, size_t M, size_t N >
5220struct IsHermitian< Submatrix<MT,AF,SO,DF,I,J,M,N> >
5221 : public BoolConstant< ( IsHermitian_v<MT> && I == J && M == N ) >
5222{};
5224//*************************************************************************************************
5225
5226
5227
5228
5229//=================================================================================================
5230//
5231// ISLOWER SPECIALIZATIONS
5232//
5233//=================================================================================================
5234
5235//*************************************************************************************************
5237template< typename MT, AlignmentFlag AF, bool SO, bool DF, size_t I, size_t J, size_t M, size_t N >
5238struct IsLower< Submatrix<MT,AF,SO,DF,I,J,M,N> >
5239 : public BoolConstant< ( IsLower_v<MT> && I == J && M == N ) ||
5240 ( IsStrictlyLower_v<MT> && I == J+1UL && M == N ) >
5241{};
5243//*************************************************************************************************
5244
5245
5246
5247
5248//=================================================================================================
5249//
5250// ISUNILOWER SPECIALIZATIONS
5251//
5252//=================================================================================================
5253
5254//*************************************************************************************************
5256template< typename MT, AlignmentFlag AF, bool SO, bool DF, size_t I, size_t J, size_t M, size_t N >
5257struct IsUniLower< Submatrix<MT,AF,SO,DF,I,J,M,N> >
5258 : public BoolConstant< ( IsUniLower_v<MT> && I == J && M == N ) >
5259{};
5261//*************************************************************************************************
5262
5263
5264
5265
5266//=================================================================================================
5267//
5268// ISSTRICTLYLOWER SPECIALIZATIONS
5269//
5270//=================================================================================================
5271
5272//*************************************************************************************************
5274template< typename MT, AlignmentFlag AF, bool SO, bool DF, size_t I, size_t J, size_t M, size_t N >
5275struct IsStrictlyLower< Submatrix<MT,AF,SO,DF,I,J,M,N> >
5276 : public BoolConstant< ( IsLower_v<MT> && I < J && M == N ) ||
5277 ( IsStrictlyLower_v<MT> && I == J && M == N ) >
5278{};
5280//*************************************************************************************************
5281
5282
5283
5284
5285//=================================================================================================
5286//
5287// ISUPPER SPECIALIZATIONS
5288//
5289//=================================================================================================
5290
5291//*************************************************************************************************
5293template< typename MT, AlignmentFlag AF, bool SO, bool DF, size_t I, size_t J, size_t M, size_t N >
5294struct IsUpper< Submatrix<MT,AF,SO,DF,I,J,M,N> >
5295 : public BoolConstant< ( IsUpper_v<MT> && I == J && M == N ) ||
5296 ( IsStrictlyUpper_v<MT> && I+1UL == J && M == N ) >
5297{};
5299//*************************************************************************************************
5300
5301
5302
5303
5304//=================================================================================================
5305//
5306// ISUNIUPPER SPECIALIZATIONS
5307//
5308//=================================================================================================
5309
5310//*************************************************************************************************
5312template< typename MT, AlignmentFlag AF, bool SO, bool DF, size_t I, size_t J, size_t M, size_t N >
5313struct IsUniUpper< Submatrix<MT,AF,SO,DF,I,J,M,N> >
5314 : public BoolConstant< ( IsUniUpper_v<MT> && I == J && M == N ) >
5315{};
5317//*************************************************************************************************
5318
5319
5320
5321
5322//=================================================================================================
5323//
5324// ISSTRICTLYUPPER SPECIALIZATIONS
5325//
5326//=================================================================================================
5327
5328//*************************************************************************************************
5330template< typename MT, AlignmentFlag AF, bool SO, bool DF, size_t I, size_t J, size_t M, size_t N >
5331struct IsStrictlyUpper< Submatrix<MT,AF,SO,DF,I,J,M,N> >
5332 : public BoolConstant< ( IsUpper_v<MT> && I > J && M == N ) ||
5333 ( IsStrictlyUpper_v<MT> && I == J && M == N ) >
5334{};
5336//*************************************************************************************************
5337
5338} // namespace blaze
5339
5340#endif
Header file for auxiliary alias declarations.
typename T::VectorType VectorType_t
Alias declaration for nested VectorType type definitions.
Definition: Aliases.h:590
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition: Aliases.h:450
typename T::BaseType BaseType_t
Alias declaration for nested BaseType type definitions.
Definition: Aliases.h:90
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 implementation of the ColumnData class template.
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 dense matrix inversion flags.
Header file for the IsAligned type trait.
Header file for the IsContiguous type trait.
Header file for the isDefault shim.
Header file for the IsHermitian type trait.
Header file for the IsLower type trait.
Header file for the IsRestricted type trait.
Header file for the IsStrictlyLower type trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSubmatrix type trait.
Header file for the IsSymmetric type trait.
Header file for the IsUniLower type trait.
Header file for the IsUniUpper type trait.
Header file for the IsUpper type trait.
Header file for the MAYBE_UNUSED function template.
Constraint on the data type.
Header file for the reduction flags.
Header file for the relaxation flag enumeration.
Header file for the RemoveReference type trait.
Header file for the implementation of the RowData class template.
Header file for the SmallArray implementation.
Compile time assertion.
Base class for matrices.
Definition: Matrix.h:85
Pointer difference type of the Blaze library.
Size type of the Blaze library.
Constraint on the data type.
Header file for the DeclExpr base class.
Header file for the MatEvalExpr base class.
Header file for the MatMapExpr base class.
Header file for the MatMatAddExpr base class.
Header file for the MatMatKronExpr base class.
Header file for the MatMatMapExpr base class.
Header file for the MatMatMultExpr base class.
Header file for the MatMatSubExpr base class.
Header file for the MatNoAliasExpr base class.
Header file for the MatNoSIMDExpr base class.
Header file for the MatReduceExpr base class.
Header file for the MatRepeatExpr base class.
Header file for the MatScalarDivExpr base class.
Header file for the MatScalarMultExpr base class.
Header file for the MatSerialExpr base class.
Header file for the MatTransExpr base class.
Header file for the MatVecMultExpr base class.
Header file for the Matrix base class.
Header file for the SchurExpr base class.
Header file for the TVecMatMultExpr base class.
Header file for the VecExpandExpr base class.
Header file for the VecTVecMapExpr base class.
Header file for the VecTVecMultExpr base class.
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:140
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:137
decltype(auto) noalias(const DenseMatrix< MT, SO > &dm)
Forces the non-aliased evaluation of the given dense matrix expression dm.
Definition: DMatNoAliasExpr.h:679
bool isStrictlyLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly lower triangular matrix.
Definition: DenseMatrix.h:2096
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1339
decltype(auto) eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:790
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1375
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:1921
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:766
bool isUniLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower unitriangular matrix.
Definition: DenseMatrix.h:2009
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
bool isStrictlyUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly upper triangular matrix.
Definition: DenseMatrix.h:2363
bool isHermitian(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is Hermitian.
Definition: DenseMatrix.h:1534
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:1456
bool isUniUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper unitriangular matrix.
Definition: DenseMatrix.h:2276
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:2188
decltype(auto) expand(const DenseVector< VT, TF > &dv, size_t expansion)
Expansion of the given dense vector.
Definition: DVecExpandExpr.h:746
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
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:693
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition: RequiresEvaluation.h:81
#define BLAZE_CONSTRAINT_MUST_HAVE_MUTABLE_DATA_ACCESS(T)
Constraint on the data type.
Definition: MutableDataAccess.h:61
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition: RelaxationFlag.h:66
InversionFlag
Inversion flag.
Definition: InversionFlag.h:102
AlignmentFlag
Alignment flag for (un-)aligned vectors and matrices.
Definition: AlignmentFlag.h:63
@ aligned
Flag for aligned vectors and matrices.
Definition: AlignmentFlag.h:65
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:644
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:660
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
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:584
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:518
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:676
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:137
#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) submatrix(Matrix< MT, SO > &, RSAs...)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:181
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
typename RemoveReference< T >::Type RemoveReference_t
Auxiliary alias declaration for the RemoveReference type trait.
Definition: RemoveReference.h:95
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
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.
Definition: IntegralConstant.h:110
#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 auto getCheck(const T &a, const Ts &... args) noexcept
Extracting blaze::Check arguments from a given list of arguments.
Definition: Check.h:205
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 Size type trait.
Header file for the TransposeFlag type trait.
Header file for the serial shim.
Header file for basic type definitions.
Header file for the generic max algorithm.
Header file for the generic min algorithm.
Header file for the implementation of the Subvector view.
Header file for the implementation of the Submatrix base template.
Submatrix specialization for dense matrices.
Submatrix specialization for sparse matrices.