Rows.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_ROWS_H_
36 #define _BLAZE_MATH_VIEWS_ROWS_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <array>
44 #include <utility>
45 #include <vector>
46 #include <blaze/math/Aliases.h>
50 #include <blaze/math/Exception.h>
82 #include <blaze/math/views/Check.h>
88 #include <blaze/util/Assert.h>
89 #include <blaze/util/DisableIf.h>
90 #include <blaze/util/EnableIf.h>
93 #include <blaze/util/SmallArray.h>
94 #include <blaze/util/TypeList.h>
95 #include <blaze/util/Types.h>
97 #include <blaze/util/Unused.h>
98 
99 
100 namespace blaze {
101 
102 //=================================================================================================
103 //
104 // GLOBAL FUNCTIONS
105 //
106 //=================================================================================================
107 
108 //*************************************************************************************************
143 template< size_t I // First row index
144  , size_t... Is // Remaining row indices
145  , typename MT // Type of the matrix
146  , bool SO // Storage order
147  , typename... RRAs > // Optional arguments
148 inline decltype(auto) rows( Matrix<MT,SO>& matrix, RRAs... args )
149 {
151 
152  using ReturnType = Rows_< MT, index_sequence<I,Is...> >;
153  return ReturnType( ~matrix, args... );
154 }
155 //*************************************************************************************************
156 
157 
158 //*************************************************************************************************
193 template< size_t I // First row index
194  , size_t... Is // Remaining row indices
195  , typename MT // Type of the matrix
196  , bool SO // Storage order
197  , typename... RRAs > // Optional arguments
198 inline decltype(auto) rows( const Matrix<MT,SO>& matrix, RRAs... args )
199 {
201 
202  using ReturnType = const Rows_< const MT, index_sequence<I,Is...> >;
203  return ReturnType( ~matrix, args... );
204 }
205 //*************************************************************************************************
206 
207 
208 //*************************************************************************************************
222 template< size_t I // First row index
223  , size_t... Is // Remaining row indices
224  , typename MT // Type of the matrix
225  , bool SO // Storage order
226  , typename... RRAs > // Optional arguments
227 inline decltype(auto) rows( Matrix<MT,SO>&& matrix, RRAs... args )
228 {
230 
231  using ReturnType = Rows_< MT, index_sequence<I,Is...> >;
232  return ReturnType( ~matrix, args... );
233 }
234 //*************************************************************************************************
235 
236 
237 //*************************************************************************************************
276 template< typename MT // Type of the matrix
277  , bool SO // Storage order
278  , typename T // Type of the row indices
279  , typename... RRAs > // Optional arguments
280 inline decltype(auto) rows( Matrix<MT,SO>& matrix, const T* indices, size_t n, RRAs... args )
281 {
283 
284  using ReturnType = Rows_<MT>;
285  return ReturnType( ~matrix, indices, n, args... );
286 }
287 //*************************************************************************************************
288 
289 
290 //*************************************************************************************************
330 template< typename MT // Type of the matrix
331  , bool SO // Storage order
332  , typename T // Type of the row indices
333  , typename... RRAs > // Optional arguments
334 inline decltype(auto) rows( const Matrix<MT,SO>& matrix, const T* indices, size_t n, RRAs... args )
335 {
337 
338  using ReturnType = const Rows_<const MT>;
339  return ReturnType( ~matrix, indices, n, args... );
340 }
341 //*************************************************************************************************
342 
343 
344 //*************************************************************************************************
359 template< typename MT // Type of the matrix
360  , bool SO // Storage order
361  , typename T // Type of the row indices
362  , typename... RRAs > // Optional arguments
363 inline decltype(auto) rows( Matrix<MT,SO>&& matrix, const T* indices, size_t n, RRAs... args )
364 {
366 
367  using ReturnType = Rows_<MT>;
368  return ReturnType( ~matrix, indices, n, args... );
369 }
370 //*************************************************************************************************
371 
372 
373 //*************************************************************************************************
410 template< typename MT // Type of the matrix
411  , bool SO // Storage order
412  , typename P // Type of the index producer
413  , typename... RRAs // Optional arguments
414  , EnableIf_t< !IsPointer_v<P> >* = nullptr >
415 inline decltype(auto) rows( Matrix<MT,SO>& matrix, P p, size_t n, RRAs... args )
416 {
418 
419  using ReturnType = Rows_<MT,P>;
420  return ReturnType( ~matrix, p, n, args... );
421 }
422 //*************************************************************************************************
423 
424 
425 //*************************************************************************************************
463 template< typename MT // Type of the matrix
464  , bool SO // Storage order
465  , typename P // Type of the index producer
466  , typename... RRAs // Optional arguments
467  , EnableIf_t< !IsPointer_v<P> >* = nullptr >
468 inline decltype(auto) rows( const Matrix<MT,SO>& matrix, P p, size_t n, RRAs... args )
469 {
471 
472  using ReturnType = const Rows_<const MT,P>;
473  return ReturnType( ~matrix, p, n, args... );
474 }
475 //*************************************************************************************************
476 
477 
478 //*************************************************************************************************
493 template< typename MT // Type of the matrix
494  , bool SO // Storage order
495  , typename P // Type of the index producer
496  , typename... RRAs // Optional arguments
497  , EnableIf_t< !IsPointer_v<P> >* = nullptr >
498 inline decltype(auto) rows( Matrix<MT,SO>&& matrix, P p, size_t n, RRAs... args )
499 {
501 
502  using ReturnType = Rows_<MT,P>;
503  return ReturnType( ~matrix, p, n, args... );
504 }
505 //*************************************************************************************************
506 
507 
508 //*************************************************************************************************
545 template< typename MT // Type of the matrix
546  , size_t... Is // Row indices
547  , typename... RRAs > // Optional arguments
548 inline decltype(auto) rows( MT&& matrix, index_sequence<Is...> indices, RRAs... args )
549 {
551 
552  UNUSED_PARAMETER( indices );
553 
554  return rows<Is...>( std::forward<MT>( matrix ), args... );
555 }
556 //*************************************************************************************************
557 
558 
559 //*************************************************************************************************
595 template< typename MT // Type of the matrix
596  , typename T // Type of the row indices
597  , typename... RRAs > // Optional arguments
598 inline decltype(auto) rows( MT&& matrix, initializer_list<T> indices, RRAs... args )
599 {
601 
602  return rows( std::forward<MT>( matrix ), indices.begin(), indices.size(), args... );
603 }
604 //*************************************************************************************************
605 
606 
607 //*************************************************************************************************
645 template< typename MT // Type of the matrix
646  , typename T // Type of the row indices
647  , size_t N // Number of indices
648  , typename... RRAs > // Optional arguments
649 inline decltype(auto) rows( MT&& matrix, const std::array<T,N>& indices, RRAs... args )
650 {
652 
653  return rows( std::forward<MT>( matrix ), indices.data(), N, args... );
654 }
655 //*************************************************************************************************
656 
657 
658 //*************************************************************************************************
696 template< typename MT // Type of the matrix
697  , typename T // Type of the row indices
698  , typename... RRAs > // Optional arguments
699 inline decltype(auto) rows( MT&& matrix, const std::vector<T>& indices, RRAs... args )
700 {
702 
703  return rows( std::forward<MT>( matrix ), indices.data(), indices.size(), args... );
704 }
705 //*************************************************************************************************
706 
707 
708 //*************************************************************************************************
746 template< typename MT // Type of the matrix
747  , typename T // Type of the row indices
748  , size_t N // Number of preallocated elements
749  , typename... RRAs > // Optional arguments
750 inline decltype(auto) rows( MT&& matrix, const SmallArray<T,N>& indices, RRAs... args )
751 {
753 
754  return rows( std::forward<MT>( matrix ), indices.data(), indices.size(), args... );
755 }
756 //*************************************************************************************************
757 
758 
759 //*************************************************************************************************
775 template< typename MT // Type of the matrix
776  , typename T1 // First type of the pair of arguments
777  , typename T2 // Second type of the pair of arguments
778  , typename... RRAs > // Optional arguments
779 inline decltype(auto) rows( MT&& matrix, const std::pair<T1,T2>& pair, RRAs... args )
780 {
782 
783  return rows( std::forward<MT>( matrix ), pair.first, pair.second, args... );
784 }
786 //*************************************************************************************************
787 
788 
789 
790 
791 //=================================================================================================
792 //
793 // GLOBAL RESTRUCTURING FUNCTIONS
794 //
795 //=================================================================================================
796 
797 //*************************************************************************************************
809 template< typename... CRAs // Compile time row arguments
810  , typename MT // Matrix base type of the expression
811  , typename... RRAs // Runtime row arguments
812  , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
813 inline decltype(auto) rows( const MatMatAddExpr<MT>& matrix, RRAs... args )
814 {
816 
817  return rows<CRAs...>( (~matrix).leftOperand(), args... ) +
818  rows<CRAs...>( (~matrix).rightOperand(), args... );
819 }
821 //*************************************************************************************************
822 
823 
824 //*************************************************************************************************
836 template< typename... CRAs // Compile time row arguments
837  , typename MT // Matrix base type of the expression
838  , typename... RRAs // Runtime row arguments
839  , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
840 inline decltype(auto) rows( const MatMatSubExpr<MT>& matrix, RRAs... args )
841 {
843 
844  return rows<CRAs...>( (~matrix).leftOperand(), args... ) -
845  rows<CRAs...>( (~matrix).rightOperand(), args... );
846 }
848 //*************************************************************************************************
849 
850 
851 //*************************************************************************************************
863 template< typename... CRAs // Compile time row arguments
864  , typename MT // Matrix base type of the expression
865  , typename... RRAs // Runtime row arguments
866  , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
867 inline decltype(auto) rows( const SchurExpr<MT>& matrix, RRAs... args )
868 {
870 
871  return rows<CRAs...>( (~matrix).leftOperand(), args... ) %
872  rows<CRAs...>( (~matrix).rightOperand(), args... );
873 }
875 //*************************************************************************************************
876 
877 
878 //*************************************************************************************************
890 template< typename... CRAs // Compile time row arguments
891  , typename MT // Matrix base type of the expression
892  , typename... RRAs // Runtime row arguments
893  , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
894 inline decltype(auto) rows( const MatMatMultExpr<MT>& matrix, RRAs... args )
895 {
897 
898  return rows<CRAs...>( (~matrix).leftOperand(), args... ) * (~matrix).rightOperand();
899 }
901 //*************************************************************************************************
902 
903 
904 //*************************************************************************************************
916 template< typename... CRAs // Compile time row arguments
917  , typename MT // Matrix base type of the expression
918  , typename... RRAs // Runtime row arguments
919  , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
920 inline decltype(auto) rows( const VecTVecMultExpr<MT>& matrix, RRAs... args )
921 {
923 
924  return elements<CRAs...>( (~matrix).leftOperand(), args... ) * (~matrix).rightOperand();
925 }
927 //*************************************************************************************************
928 
929 
930 //*************************************************************************************************
942 template< typename... CRAs // Compile time row arguments
943  , typename MT // Matrix base type of the expression
944  , typename... RRAs // Runtime row arguments
945  , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
946 inline decltype(auto) rows( const MatScalarMultExpr<MT>& matrix, RRAs... args )
947 {
949 
950  return rows<CRAs...>( (~matrix).leftOperand(), args... ) * (~matrix).rightOperand();
951 }
953 //*************************************************************************************************
954 
955 
956 //*************************************************************************************************
968 template< typename... CRAs // Compile time row arguments
969  , typename MT // Matrix base type of the expression
970  , typename... RRAs // Runtime row arguments
971  , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
972 inline decltype(auto) rows( const MatScalarDivExpr<MT>& matrix, RRAs... args )
973 {
975 
976  return rows<CRAs...>( (~matrix).leftOperand(), args... ) / (~matrix).rightOperand();
977 }
979 //*************************************************************************************************
980 
981 
982 //*************************************************************************************************
994 template< typename... CRAs // Compile time row arguments
995  , typename MT // Matrix base type of the expression
996  , typename... RRAs // Runtime row arguments
997  , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
998 inline decltype(auto) rows( const MatMapExpr<MT>& matrix, RRAs... args )
999 {
1001 
1002  return map( rows<CRAs...>( (~matrix).operand(), args... ), (~matrix).operation() );
1003 }
1005 //*************************************************************************************************
1006 
1007 
1008 //*************************************************************************************************
1020 template< typename... CRAs // Compile time row arguments
1021  , typename MT // Matrix base type of the expression
1022  , typename... RRAs // Runtime row arguments
1023  , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
1024 inline decltype(auto) rows( const MatMatMapExpr<MT>& matrix, RRAs... args )
1025 {
1027 
1028  return map( rows<CRAs...>( (~matrix).leftOperand(), args... ),
1029  rows<CRAs...>( (~matrix).rightOperand(), args... ),
1030  (~matrix).operation() );
1031 }
1033 //*************************************************************************************************
1034 
1035 
1036 //*************************************************************************************************
1048 template< typename... CRAs // Compile time row arguments
1049  , typename MT // Matrix base type of the expression
1050  , typename... RRAs // Runtime row arguments
1051  , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
1052 inline decltype(auto) rows( const MatEvalExpr<MT>& matrix, RRAs... args )
1053 {
1055 
1056  return eval( rows<CRAs...>( (~matrix).operand(), args... ) );
1057 }
1059 //*************************************************************************************************
1060 
1061 
1062 //*************************************************************************************************
1074 template< typename... CRAs // Compile time row arguments
1075  , typename MT // Matrix base type of the expression
1076  , typename... RRAs // Runtime row arguments
1077  , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
1078 inline decltype(auto) rows( const MatSerialExpr<MT>& matrix, RRAs... args )
1079 {
1081 
1082  return serial( rows<CRAs...>( (~matrix).operand(), args... ) );
1083 }
1085 //*************************************************************************************************
1086 
1087 
1088 //*************************************************************************************************
1100 template< typename... CRAs // Compile time row arguments
1101  , typename MT // Matrix base type of the expression
1102  , typename... RRAs // Runtime row arguments
1103  , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
1104 inline decltype(auto) rows( const DeclExpr<MT>& matrix, RRAs... args )
1105 {
1107 
1108  return rows<CRAs...>( (~matrix).operand(), args... );
1109 }
1111 //*************************************************************************************************
1112 
1113 
1114 //*************************************************************************************************
1126 template< typename... CRAs // Compile time row arguments
1127  , typename MT // Matrix base type of the expression
1128  , typename... RRAs // Runtime row arguments
1129  , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
1130 inline decltype(auto) rows( const MatTransExpr<MT>& matrix, RRAs... args )
1131 {
1133 
1134  return trans( columns<CRAs...>( (~matrix).operand(), args... ) );
1135 }
1137 //*************************************************************************************************
1138 
1139 
1140 //*************************************************************************************************
1152 template< typename... CRAs // Compile time row arguments
1153  , typename MT // Matrix base type of the expression
1154  , size_t... CEAs // Compile time expansion arguments
1155  , typename... RRAs // Runtime row arguments
1156  , EnableIf_t< ( sizeof...( CRAs ) > 0UL ) &&
1157  IsRowMajorMatrix_v<MT> >* = nullptr >
1158 inline decltype(auto) rows( const VecExpandExpr<MT,CEAs...>& matrix, RRAs... args )
1159 {
1161 
1162  UNUSED_PARAMETER( args... );
1163 
1164  return expand< sizeof...( CRAs ) >( (~matrix).operand() );
1165 }
1167 //*************************************************************************************************
1168 
1169 
1170 //*************************************************************************************************
1182 template< typename... CRAs // Compile time row arguments
1183  , typename MT // Matrix base type of the expression
1184  , size_t... CEAs // Compile time expansion arguments
1185  , typename... RRAs // Runtime row arguments
1186  , EnableIf_t< ( sizeof...( CRAs ) == 0UL ) &&
1187  IsRowMajorMatrix_v<MT> >* = nullptr >
1188 inline decltype(auto) rows( const VecExpandExpr<MT,CEAs...>& matrix, RRAs... args )
1189 {
1191 
1192  const RowsData<CRAs...> rd( args... );
1193 
1194  return expand( (~matrix).operand(), rd.rows() );
1195 }
1197 //*************************************************************************************************
1198 
1199 
1200 //*************************************************************************************************
1212 template< typename... CRAs // Compile time row arguments
1213  , typename MT // Matrix base type of the expression
1214  , size_t... CEAs // Compile time expansion arguments
1215  , typename... RRAs // Runtime row arguments
1216  , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) &&
1217  !IsRowMajorMatrix_v<MT> >* = nullptr >
1218 inline decltype(auto) rows( const VecExpandExpr<MT,CEAs...>& matrix, RRAs... args )
1219 {
1221 
1222  return expand<CEAs...>( elements<CRAs...>( (~matrix).operand(), args... ), (~matrix).expansion() );
1223 }
1225 //*************************************************************************************************
1226 
1227 
1228 //*************************************************************************************************
1239 template< size_t I1 // First required row index
1240  , size_t... Is1 // Remaining required row indices
1241  , typename MT // Type of the matrix
1242  , bool SO // Storage order
1243  , bool DF // Density flag
1244  , bool SF // Symmetry flag
1245  , size_t I2 // First present row index
1246  , size_t... Is2 // Remaining present row indices
1247  , typename... CRAs // Compile time row arguments
1248  , typename... RRAs > // Optional row arguments
1249 inline decltype(auto) rows( Rows<MT,SO,DF,SF,index_sequence<I2,Is2...>,CRAs...>& r, RRAs... args )
1250 {
1252 
1253  static constexpr size_t indices[] = { I2, Is2... };
1254  return rows< indices[I1], indices[Is1]... >( r.operand(), args... );
1255 }
1257 //*************************************************************************************************
1258 
1259 
1260 //*************************************************************************************************
1272 template< size_t I1 // First required row index
1273  , size_t... Is1 // Remaining required row indices
1274  , typename MT // Type of the matrix
1275  , bool SO // Storage order
1276  , bool DF // Density flag
1277  , bool SF // Symmetry flag
1278  , size_t I2 // First present row index
1279  , size_t... Is2 // Remaining present row indices
1280  , typename... CRAs // Compile time row arguments
1281  , typename... RRAs > // Optional row arguments
1282 inline decltype(auto) rows( const Rows<MT,SO,DF,SF,index_sequence<I2,Is2...>,CRAs...>& r, RRAs... args )
1283 {
1285 
1286  static constexpr size_t indices[] = { I2, Is2... };
1287  return rows< indices[I1], indices[Is1]... >( r.operand(), args... );
1288 }
1290 //*************************************************************************************************
1291 
1292 
1293 //*************************************************************************************************
1305 template< size_t I1 // First required row index
1306  , size_t... Is1 // Remaining required row indices
1307  , typename MT // Type of the matrix
1308  , bool SO // Storage order
1309  , bool DF // Density flag
1310  , bool SF // Symmetry flag
1311  , size_t I2 // First present row index
1312  , size_t... Is2 // Remaining present row indices
1313  , typename... CRAs // Compile time row arguments
1314  , typename... RRAs > // Optional row arguments
1315 inline decltype(auto) rows( Rows<MT,SO,DF,SF,index_sequence<I2,Is2...>,CRAs...>&& r, RRAs... args )
1316 {
1318 
1319  static constexpr size_t indices[] = { I2, Is2... };
1320  return rows< indices[I1], indices[Is1]... >( r.operand(), args... );
1321 }
1323 //*************************************************************************************************
1324 
1325 
1326 //*************************************************************************************************
1338 template< size_t I // First required row index
1339  , size_t... Is // Remaining required row indices
1340  , typename MT // Type of the matrix
1341  , bool SO // Storage order
1342  , bool DF // Density flag
1343  , bool SF // Symmetry flag
1344  , typename... CRAs // Compile time row arguments
1345  , typename... RRAs > // Optional row arguments
1346 inline decltype(auto) rows( Rows<MT,SO,DF,SF,CRAs...>& r, RRAs... args )
1347 {
1349 
1350  constexpr bool isChecked( !Contains_v< TypeList<RRAs...>, Unchecked > );
1351 
1352  if( isChecked ) {
1353  static constexpr size_t indices[] = { I, Is... };
1354  for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1355  if( r.rows() <= indices[i] ) {
1356  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1357  }
1358  }
1359  }
1360 
1361  return rows( r.operand(), { r.idx(I), r.idx(Is)... }, args... );
1362 }
1364 //*************************************************************************************************
1365 
1366 
1367 //*************************************************************************************************
1380 template< size_t I // First required row index
1381  , size_t... Is // Remaining required row indices
1382  , typename MT // Type of the matrix
1383  , bool SO // Storage order
1384  , bool DF // Density flag
1385  , bool SF // Symmetry flag
1386  , typename... CRAs // Compile time row arguments
1387  , typename... RRAs > // Optional row arguments
1388 inline decltype(auto) rows( const Rows<MT,SO,DF,SF,CRAs...>& r, RRAs... args )
1389 {
1391 
1392  constexpr bool isChecked( !Contains_v< TypeList<RRAs...>, Unchecked > );
1393 
1394  if( isChecked ) {
1395  static constexpr size_t indices[] = { I, Is... };
1396  for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1397  if( r.rows() <= indices[i] ) {
1398  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1399  }
1400  }
1401  }
1402 
1403  return rows( r.operand(), { r.idx(I), r.idx(Is)... }, args... );
1404 }
1406 //*************************************************************************************************
1407 
1408 
1409 //*************************************************************************************************
1422 template< size_t I // First required row index
1423  , size_t... Is // Remaining required row indices
1424  , typename MT // Type of the matrix
1425  , bool SO // Storage order
1426  , bool DF // Density flag
1427  , bool SF // Symmetry flag
1428  , typename... CRAs // Compile time row arguments
1429  , typename... RRAs > // Optional row arguments
1430 inline decltype(auto) rows( Rows<MT,SO,DF,SF,CRAs...>&& r, RRAs... args )
1431 {
1433 
1434  constexpr bool isChecked( !Contains_v< TypeList<RRAs...>, Unchecked > );
1435 
1436  if( isChecked ) {
1437  static constexpr size_t indices[] = { I, Is... };
1438  for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1439  if( r.rows() <= indices[i] ) {
1440  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1441  }
1442  }
1443  }
1444 
1445  return rows( r.operand(), { r.idx(I), r.idx(Is)... }, args... );
1446 }
1448 //*************************************************************************************************
1449 
1450 
1451 //*************************************************************************************************
1465 template< typename MT // Type of the matrix
1466  , bool SO // Storage order
1467  , bool DF // Density flag
1468  , bool SF // Symmetry flag
1469  , typename... CRAs // Compile time row arguments
1470  , typename T // Type of the row indices
1471  , typename... RRAs > // Optional row arguments
1472 inline decltype(auto) rows( Rows<MT,SO,DF,SF,CRAs...>& r, const T* indices, size_t n, RRAs... args )
1473 {
1475 
1476  constexpr bool isChecked( !Contains_v< TypeList<RRAs...>, Unchecked > );
1477 
1478  if( isChecked ) {
1479  for( size_t i=0UL; i<n; ++i ) {
1480  if( r.rows() <= size_t( indices[i] ) ) {
1481  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1482  }
1483  }
1484  }
1485 
1486  SmallArray<size_t,128UL> newIndices;
1487  newIndices.reserve( n );
1488 
1489  for( size_t i=0UL; i<n; ++i ) {
1490  newIndices.pushBack( r.idx( indices[i] ) );
1491  }
1492 
1493  return rows( r.operand(), newIndices.data(), newIndices.size(), args... );
1494 }
1496 //*************************************************************************************************
1497 
1498 
1499 //*************************************************************************************************
1514 template< typename MT // Type of the matrix
1515  , bool SO // Storage order
1516  , bool DF // Density flag
1517  , bool SF // Symmetry flag
1518  , typename... CRAs // Compile time row arguments
1519  , typename T // Type of the row indices
1520  , typename... RRAs > // Optional row arguments
1521 inline decltype(auto) rows( const Rows<MT,SO,DF,SF,CRAs...>& r, const T* indices, size_t n, RRAs... args )
1522 {
1524 
1525  constexpr bool isChecked( !Contains_v< TypeList<RRAs...>, Unchecked > );
1526 
1527  if( isChecked ) {
1528  for( size_t i=0UL; i<n; ++i ) {
1529  if( r.rows() <= size_t( indices[i] ) ) {
1530  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1531  }
1532  }
1533  }
1534 
1535  SmallArray<size_t,128UL> newIndices;
1536  newIndices.reserve( n );
1537 
1538  for( size_t i=0UL; i<n; ++i ) {
1539  newIndices.pushBack( r.idx( indices[i] ) );
1540  }
1541 
1542  return rows( r.operand(), newIndices.data(), newIndices.size(), args... );
1543 }
1545 //*************************************************************************************************
1546 
1547 
1548 //*************************************************************************************************
1563 template< typename MT // Type of the matrix
1564  , bool SO // Storage order
1565  , bool DF // Density flag
1566  , bool SF // Symmetry flag
1567  , typename... CRAs // Compile time row arguments
1568  , typename T // Type of the row indices
1569  , typename... RRAs > // Optional row arguments
1570 inline decltype(auto) rows( Rows<MT,SO,DF,SF,CRAs...>&& r, const T* indices, size_t n, RRAs... args )
1571 {
1573 
1574  constexpr bool isChecked( !Contains_v< TypeList<RRAs...>, Unchecked > );
1575 
1576  if( isChecked ) {
1577  for( size_t i=0UL; i<n; ++i ) {
1578  if( r.rows() <= size_t( indices[i] ) ) {
1579  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1580  }
1581  }
1582  }
1583 
1584  SmallArray<size_t,128UL> newIndices;
1585  newIndices.reserve( n );
1586 
1587  for( size_t i=0UL; i<n; ++i ) {
1588  newIndices.pushBack( r.idx( indices[i] ) );
1589  }
1590 
1591  return rows( r.operand(), newIndices.data(), newIndices.size(), args... );
1592 }
1594 //*************************************************************************************************
1595 
1596 
1597 //*************************************************************************************************
1611 template< typename MT // Type of the matrix
1612  , bool SO // Storage order
1613  , bool DF // Density flag
1614  , bool SF // Symmetry flag
1615  , typename... CRAs // Compile time row arguments
1616  , typename P // Type of the index producer
1617  , typename... RRAs > // Optional row arguments
1618 inline decltype(auto) rows( Rows<MT,SO,DF,SF,CRAs...>& r, P p, size_t n, RRAs... args )
1619 {
1621 
1622  constexpr bool isChecked( !Contains_v< TypeList<RRAs...>, Unchecked > );
1623 
1624  if( isChecked ) {
1625  for( size_t i=0UL; i<n; ++i ) {
1626  if( r.rows() <= size_t( p(i) ) ) {
1627  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1628  }
1629  }
1630  }
1631 
1632  SmallArray<size_t,128UL> newIndices;
1633  newIndices.reserve( n );
1634 
1635  for( size_t i=0UL; i<n; ++i ) {
1636  newIndices.pushBack( r.idx( p(i) ) );
1637  }
1638 
1639  return rows( r.operand(), newIndices.data(), newIndices.size(), args... );
1640 }
1642 //*************************************************************************************************
1643 
1644 
1645 //*************************************************************************************************
1660 template< typename MT // Type of the matrix
1661  , bool SO // Storage order
1662  , bool DF // Density flag
1663  , bool SF // Symmetry flag
1664  , typename... CRAs // Compile time row arguments
1665  , typename P // Type of the index producer
1666  , typename... RRAs > // Optional row arguments
1667 inline decltype(auto) rows( const Rows<MT,SO,DF,SF,CRAs...>& r, P p, size_t n, RRAs... args )
1668 {
1670 
1671  constexpr bool isChecked( !Contains_v< TypeList<RRAs...>, Unchecked > );
1672 
1673  if( isChecked ) {
1674  for( size_t i=0UL; i<n; ++i ) {
1675  if( r.rows() <= size_t( p(i) ) ) {
1676  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1677  }
1678  }
1679  }
1680 
1681  SmallArray<size_t,128UL> newIndices;
1682  newIndices.reserve( n );
1683 
1684  for( size_t i=0UL; i<n; ++i ) {
1685  newIndices.pushBack( r.idx( p(i) ) );
1686  }
1687 
1688  return rows( r.operand(), newIndices.data(), newIndices.size(), args... );
1689 }
1691 //*************************************************************************************************
1692 
1693 
1694 //*************************************************************************************************
1709 template< typename MT // Type of the matrix
1710  , bool SO // Storage order
1711  , bool DF // Density flag
1712  , bool SF // Symmetry flag
1713  , typename... CRAs // Compile time row arguments
1714  , typename P // Type of the index producer
1715  , typename... RRAs > // Optional row arguments
1716 inline decltype(auto) rows( Rows<MT,SO,DF,SF,CRAs...>&& r, P p, size_t n, RRAs... args )
1717 {
1719 
1720  constexpr bool isChecked( !Contains_v< TypeList<RRAs...>, Unchecked > );
1721 
1722  if( isChecked ) {
1723  for( size_t i=0UL; i<n; ++i ) {
1724  if( r.rows() <= size_t( p(i) ) ) {
1725  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1726  }
1727  }
1728  }
1729 
1730  SmallArray<size_t,128UL> newIndices;
1731  newIndices.reserve( n );
1732 
1733  for( size_t i=0UL; i<n; ++i ) {
1734  newIndices.pushBack( r.idx( p(i) ) );
1735  }
1736 
1737  return rows( r.operand(), newIndices.data(), newIndices.size(), args... );
1738 }
1740 //*************************************************************************************************
1741 
1742 
1743 
1744 
1745 //=================================================================================================
1746 //
1747 // GLOBAL RESTRUCTURING FUNCTIONS (ELEMENTS)
1748 //
1749 //=================================================================================================
1750 
1751 //*************************************************************************************************
1763 template< size_t... CEAs // Compile time element arguments
1764  , typename VT // Vector base type of the expression
1765  , typename... REAs > // Runtime element arguments
1766 inline decltype(auto) elements( const MatVecMultExpr<VT>& vector, REAs... args )
1767 {
1769 
1770  return rows<CEAs...>( (~vector).leftOperand(), args... ) * (~vector).rightOperand();
1771 }
1773 //*************************************************************************************************
1774 
1775 
1776 //*************************************************************************************************
1789 template< size_t... CEAs // Compile time element arguments
1790  , typename VT // Vector base type of the expression
1791  , typename... REAs > // Runtime element arguments
1792 inline decltype(auto) elements( const MatReduceExpr<VT,rowwise>& vector, REAs... args )
1793 {
1795 
1796  return reduce<rowwise>( rows<CEAs...>( (~vector).operand(), args... ), (~vector).operation() );
1797 }
1799 //*************************************************************************************************
1800 
1801 
1802 
1803 
1804 //=================================================================================================
1805 //
1806 // GLOBAL RESTRUCTURING FUNCTIONS (ROW)
1807 //
1808 //=================================================================================================
1809 
1810 //*************************************************************************************************
1821 template< size_t I1 // Row index
1822  , typename MT // Type of the matrix
1823  , bool SO // Storage order
1824  , bool DF // Density flag
1825  , bool SF // Symmetry flag
1826  , size_t I2 // First row index
1827  , size_t... Is // Remaining row indices
1828  , typename... CRAs // Compile time row arguments
1829  , typename... RRAs > // Optional row arguments
1830 inline decltype(auto) row( Rows<MT,SO,DF,SF,index_sequence<I2,Is...>,CRAs...>& rows, RRAs... args )
1831 {
1833 
1834  static constexpr size_t indices[] = { I2, Is... };
1835  return row<indices[I1]>( rows.operand(), args... );
1836 }
1838 //*************************************************************************************************
1839 
1840 
1841 //*************************************************************************************************
1853 template< size_t I1 // Row index
1854  , typename MT // Type of the matrix
1855  , bool SO // Storage order
1856  , bool DF // Density flag
1857  , bool SF // Symmetry flag
1858  , size_t I2 // First row index
1859  , size_t... Is // Remaining row indices
1860  , typename... CRAs // Compile time row arguments
1861  , typename... RRAs > // Optional row arguments
1862 inline decltype(auto) row( const Rows<MT,SO,DF,SF,index_sequence<I2,Is...>,CRAs...>& rows, RRAs... args )
1863 {
1865 
1866  static constexpr size_t indices[] = { I2, Is... };
1867  return row<indices[I1]>( rows.operand(), args... );
1868 }
1870 //*************************************************************************************************
1871 
1872 
1873 //*************************************************************************************************
1885 template< size_t I1 // Row index
1886  , typename MT // Type of the matrix
1887  , bool SO // Storage order
1888  , bool DF // Density flag
1889  , bool SF // Symmetry flag
1890  , size_t I2 // First row index
1891  , size_t... Is // Remaining row indices
1892  , typename... CRAs // Compile time row arguments
1893  , typename... RRAs > // Optional row arguments
1894 inline decltype(auto) row( Rows<MT,SO,DF,SF,index_sequence<I2,Is...>,CRAs...>&& rows, RRAs... args )
1895 {
1897 
1898  static constexpr size_t indices[] = { I2, Is... };
1899  return row<indices[I1]>( rows.operand(), args... );
1900 }
1902 //*************************************************************************************************
1903 
1904 
1905 //*************************************************************************************************
1917 template< size_t... CRAs1 // Compile time row arguments
1918  , typename MT // Type of the matrix
1919  , bool SO // Storage order
1920  , bool DF // Density flag
1921  , bool SF // Symmetry flag
1922  , typename... CRAs2 // Compile time row arguments
1923  , typename... RRAs > // Runtime row arguments
1924 inline decltype(auto) row( Rows<MT,SO,DF,SF,CRAs2...>& rows, RRAs... args )
1925 {
1927 
1928  const RowData<CRAs1...> rd( args... );
1929 
1930  constexpr bool isChecked( !Contains_v< TypeList<RRAs...>, Unchecked > );
1931 
1932  if( isChecked ) {
1933  if( rows.rows() <= rd.row() ) {
1934  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1935  }
1936  }
1937 
1938  return row( rows.operand(), rows.idx( rd.row() ), args... );
1939 }
1941 //*************************************************************************************************
1942 
1943 
1944 //*************************************************************************************************
1957 template< size_t... CRAs1 // Compile time row arguments
1958  , typename MT // Type of the matrix
1959  , bool SO // Storage order
1960  , bool DF // Density flag
1961  , bool SF // Symmetry flag
1962  , typename... CRAs2 // Compile time row arguments
1963  , typename... RRAs > // Runtime row arguments
1964 inline decltype(auto) row( const Rows<MT,SO,DF,SF,CRAs2...>& rows, RRAs... args )
1965 {
1967 
1968  const RowData<CRAs1...> rd( args... );
1969 
1970  constexpr bool isChecked( !Contains_v< TypeList<RRAs...>, Unchecked > );
1971 
1972  if( isChecked ) {
1973  if( rows.rows() <= rd.row() ) {
1974  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1975  }
1976  }
1977 
1978  return row( rows.operand(), rows.idx( rd.row() ), args... );
1979 }
1981 //*************************************************************************************************
1982 
1983 
1984 //*************************************************************************************************
1997 template< size_t... CRAs1 // Compile time row arguments
1998  , typename MT // Type of the matrix
1999  , bool SO // Storage order
2000  , bool DF // Density flag
2001  , bool SF // Symmetry flag
2002  , typename... CRAs2 // Compile time row arguments
2003  , typename... RRAs > // Runtime row arguments
2004 inline decltype(auto) row( Rows<MT,SO,DF,SF,CRAs2...>&& rows, RRAs... args )
2005 {
2007 
2008  const RowData<CRAs1...> rd( args... );
2009 
2010  constexpr bool isChecked( !Contains_v< TypeList<RRAs...>, Unchecked > );
2011 
2012  if( isChecked ) {
2013  if( rows.rows() <= rd.row() ) {
2014  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
2015  }
2016  }
2017 
2018  return row( rows.operand(), rows.idx( rd.row() ), args... );
2019 }
2021 //*************************************************************************************************
2022 
2023 
2024 
2025 
2026 //=================================================================================================
2027 //
2028 // GLOBAL RESTRUCTURING FUNCTIONS (COLUMN)
2029 //
2030 //=================================================================================================
2031 
2032 //*************************************************************************************************
2043 template< size_t... CCAs // Compile time column arguments
2044  , typename MT // Type of the matrix
2045  , bool SO // Storage order
2046  , bool DF // Density flag
2047  , bool SF // Symmetry flag
2048  , size_t I // First row index
2049  , size_t... Is // Remaining row indices
2050  , typename... CRAs // Compile time row arguments
2051  , typename... RCAs > // Runtime column arguments
2052 inline decltype(auto) column( Rows<MT,SO,DF,SF,index_sequence<I,Is...>,CRAs...>& rows, RCAs... args )
2053 {
2055 
2056  return elements<I,Is...>( column<CCAs...>( rows.operand(), args... ) );
2057 }
2059 //*************************************************************************************************
2060 
2061 
2062 //*************************************************************************************************
2074 template< size_t... CCAs // Compile time column arguments
2075  , typename MT // Type of the matrix
2076  , bool SO // Storage order
2077  , bool DF // Density flag
2078  , bool SF // Symmetry flag
2079  , size_t I // First row index
2080  , size_t... Is // Remaining row indices
2081  , typename... CRAs // Compile time row arguments
2082  , typename... RCAs > // Runtime column arguments
2083 inline decltype(auto) column( const Rows<MT,SO,DF,SF,index_sequence<I,Is...>,CRAs...>& rows, RCAs... args )
2084 {
2086 
2087  return elements<I,Is...>( column<CCAs...>( rows.operand(), args... ) );
2088 }
2090 //*************************************************************************************************
2091 
2092 
2093 //*************************************************************************************************
2105 template< size_t... CCAs // Compile time column arguments
2106  , typename MT // Type of the matrix
2107  , bool SO // Storage order
2108  , bool DF // Density flag
2109  , bool SF // Symmetry flag
2110  , size_t I // First row index
2111  , size_t... Is // Remaining row indices
2112  , typename... CRAs // Compile time row arguments
2113  , typename... RCAs > // Runtime column arguments
2114 inline decltype(auto) column( Rows<MT,SO,DF,SF,index_sequence<I,Is...>,CRAs...>&& rows, RCAs... args )
2115 {
2117 
2118  return elements<I,Is...>( column<CCAs...>( rows.operand(), args... ) );
2119 }
2121 //*************************************************************************************************
2122 
2123 
2124 //*************************************************************************************************
2135 template< size_t... CCAs // Compile time column arguments
2136  , typename MT // Type of the matrix
2137  , bool SO // Storage order
2138  , bool DF // Density flag
2139  , bool SF // Symmetry flag
2140  , typename... CRAs // Compile time row arguments
2141  , typename... RCAs > // Runtime column arguments
2142 inline decltype(auto) column( Rows<MT,SO,DF,SF,CRAs...>& rows, RCAs... args )
2143 {
2145 
2146  return elements( column<CCAs...>( rows.operand(), args... ), rows.idces() );
2147 }
2149 //*************************************************************************************************
2150 
2151 
2152 //*************************************************************************************************
2164 template< size_t... CCAs // Compile time column arguments
2165  , typename MT // Type of the matrix
2166  , bool SO // Storage order
2167  , bool DF // Density flag
2168  , bool SF // Symmetry flag
2169  , typename... CRAs // Compile time row arguments
2170  , typename... RCAs > // Runtime column arguments
2171 inline decltype(auto) column( const Rows<MT,SO,DF,SF,CRAs...>& rows, RCAs... args )
2172 {
2174 
2175  return elements( column<CCAs...>( rows.operand(), args... ), rows.idces() );
2176 }
2178 //*************************************************************************************************
2179 
2180 
2181 //*************************************************************************************************
2193 template< size_t... CCAs // Compile time column arguments
2194  , typename MT // Type of the matrix
2195  , bool SO // Storage order
2196  , bool DF // Density flag
2197  , bool SF // Symmetry flag
2198  , typename... CRAs // Compile time row arguments
2199  , typename... RCAs > // Runtime column arguments
2200 inline decltype(auto) column( Rows<MT,SO,DF,SF,CRAs...>&& rows, RCAs... args )
2201 {
2203 
2204  return elements( column<CCAs...>( rows.operand(), args... ), rows.idces() );
2205 }
2207 //*************************************************************************************************
2208 
2209 
2210 
2211 
2212 //=================================================================================================
2213 //
2214 // ROWS OPERATORS
2215 //
2216 //=================================================================================================
2217 
2218 //*************************************************************************************************
2226 template< typename MT // Type of the matrix
2227  , bool SO // Storage order
2228  , bool DF // Density flag
2229  , bool SF // Symmetry flag
2230  , typename... CRAs > // Compile time row arguments
2231 inline void reset( Rows<MT,SO,DF,SF,CRAs...>& rows )
2232 {
2233  rows.reset();
2234 }
2236 //*************************************************************************************************
2237 
2238 
2239 //*************************************************************************************************
2247 template< typename MT // Type of the matrix
2248  , bool SO // Storage order
2249  , bool DF // Density flag
2250  , bool SF // Symmetry flag
2251  , typename... CRAs > // Compile time row arguments
2252 inline void reset( Rows<MT,SO,DF,SF,CRAs...>&& rows )
2253 {
2254  rows.reset();
2255 }
2257 //*************************************************************************************************
2258 
2259 
2260 //*************************************************************************************************
2272 template< typename MT // Type of the matrix
2273  , bool SO // Storage order
2274  , bool DF // Density flag
2275  , bool SF // Symmetry flag
2276  , typename... CRAs > // Compile time row arguments
2277 inline void reset( Rows<MT,SO,DF,SF,CRAs...>& rows, size_t i )
2278 {
2279  rows.reset( i );
2280 }
2282 //*************************************************************************************************
2283 
2284 
2285 //*************************************************************************************************
2295 template< typename MT // Type of the matrix
2296  , bool SO // Storage order
2297  , bool DF // Density flag
2298  , bool SF // Symmetry flag
2299  , typename... CRAs > // Compile time row arguments
2300 inline void clear( Rows<MT,SO,DF,SF,CRAs...>& rows )
2301 {
2302  rows.reset();
2303 }
2305 //*************************************************************************************************
2306 
2307 
2308 //*************************************************************************************************
2318 template< typename MT // Type of the matrix
2319  , bool SO // Storage order
2320  , bool DF // Density flag
2321  , bool SF // Symmetry flag
2322  , typename... CRAs > // Compile time row arguments
2323 inline void clear( Rows<MT,SO,DF,SF,CRAs...>&& rows )
2324 {
2325  rows.reset();
2326 }
2328 //*************************************************************************************************
2329 
2330 
2331 //*************************************************************************************************
2357 template< bool RF // Relaxation flag
2358  , typename MT // Type of the dense matrix
2359  , bool SO // Storage order
2360  , bool SF // Symmetry flag
2361  , typename... CRAs > // Compile time row arguments
2362 inline bool isDefault( const Rows<MT,SO,true,SF,CRAs...>& rows )
2363 {
2364  using blaze::isDefault;
2365 
2366  if( SO == true ) {
2367  for( size_t i=0UL; i<rows.rows(); ++i )
2368  for( size_t j=0UL; j<rows.columns(); ++j )
2369  if( !isDefault<RF>( rows(i,j) ) )
2370  return false;
2371  }
2372  else {
2373  for( size_t j=0UL; j<rows.columns(); ++j )
2374  for( size_t i=0UL; i<rows.rows(); ++i )
2375  if( !isDefault<RF>( rows(i,j) ) )
2376  return false;
2377  }
2378 
2379  return true;
2380 }
2382 //*************************************************************************************************
2383 
2384 
2385 //*************************************************************************************************
2411 template< bool RF // Relaxation flag
2412  , typename MT // Type of the dense matrix
2413  , bool SO // Storage order
2414  , bool SF // Symmetry flag
2415  , typename... CRAs > // Compile time row arguments
2416 inline bool isDefault( const Rows<MT,SO,false,SF,CRAs...>& rows )
2417 {
2418  using blaze::isDefault;
2419 
2420  for( size_t i=0UL; i<rows.rows(); ++i ) {
2421  for( auto element=rows.cbegin(i); element!=rows.cend(i); ++element )
2422  if( !isDefault<RF>( element->value() ) ) return false;
2423  }
2424 
2425  return true;
2426 }
2428 //*************************************************************************************************
2429 
2430 
2431 //*************************************************************************************************
2450 template< typename MT // Type of the matrix
2451  , bool SO // Storage order
2452  , bool DF // Density flag
2453  , bool SF // Symmetry flag
2454  , typename... CRAs > // Compile time row arguments
2455 inline bool isIntact( const Rows<MT,SO,DF,SF,CRAs...>& rows ) noexcept
2456 {
2457  return ( rows.rows() <= rows.operand().rows() &&
2458  rows.columns() == rows.operand().columns() &&
2459  isIntact( rows.operand() ) );
2460 }
2462 //*************************************************************************************************
2463 
2464 
2465 //*************************************************************************************************
2478 template< typename MT // Type of the matrix
2479  , bool SO1 // Storage order of the left-hand side row selection
2480  , bool DF // Density flag
2481  , bool SF // Symmetry flag
2482  , typename... CRAs // Compile time row arguments
2483  , bool SO2 > // Storage order of the right-hand side matrix
2484 inline bool isSame( const Rows<MT,SO1,DF,SF,CRAs...>& a, const Matrix<MT,SO2>& b ) noexcept
2485 {
2486  if( !isSame( a.operand(), ~b ) || ( a.rows() != (~b).rows() ) || ( a.columns() != (~b).columns() ) )
2487  return false;
2488 
2489  for( size_t i=0UL; i<a.rows(); ++i ) {
2490  if( a.idx(i) != i )
2491  return false;
2492  }
2493 
2494  return true;
2495 }
2497 //*************************************************************************************************
2498 
2499 
2500 //*************************************************************************************************
2513 template< typename MT // Type of the matrix
2514  , bool SO1 // Storage order of the left-hand side matrix
2515  , bool DF // Density flag
2516  , bool SF // Symmetry flag
2517  , typename... CRAs // Compile time row arguments
2518  , bool SO2 > // Storage order of the right-hand side row selection
2519 inline bool isSame( const Matrix<MT,SO1>& a, const Rows<MT,SO2,DF,SF,CRAs...>& b ) noexcept
2520 {
2521  return isSame( b, a );
2522 }
2524 //*************************************************************************************************
2525 
2526 
2527 //*************************************************************************************************
2540 template< typename MT // Type of the matrix
2541  , bool SO1 // Storage order of the left-hand side row selection
2542  , bool DF // Density flag
2543  , bool SF // Symmetry flag
2544  , typename... CRAs // Compile time row arguments
2545  , AlignmentFlag AF // Alignment flag
2546  , bool SO2 // Storage order of the right-hand side submatrix
2547  , size_t... CSAs > // Compile time submatrix arguments
2548 inline bool isSame( const Rows<MT,SO1,DF,SF,CRAs...>& a, const Submatrix<MT,AF,SO2,DF,CSAs...>& b ) noexcept
2549 {
2550  if( !isSame( a.operand(), b.operand() ) || ( a.rows() != (~b).rows() ) || ( a.columns() != (~b).columns() ) )
2551  return false;
2552 
2553  for( size_t i=0UL; i<a.rows(); ++i ) {
2554  if( a.idx(i) != b.row()+i )
2555  return false;
2556  }
2557 
2558  return true;
2559 }
2561 //*************************************************************************************************
2562 
2563 
2564 //*************************************************************************************************
2577 template< typename MT // Type of the matrix
2578  , AlignmentFlag AF // Alignment flag
2579  , bool SO1 // Storage order of the left-hand side submatrix
2580  , bool DF // Density flag
2581  , size_t... CSAs // Compile time submatrix arguments
2582  , bool SO2 // Storage order of the right-hand side row selection
2583  , bool SF // Symmetry flag
2584  , typename... CRAs > // Compile time row arguments
2585 inline bool isSame( const Submatrix<MT,AF,SO1,DF,CSAs...>& a, const Rows<MT,SO2,DF,SF,CRAs...>& b ) noexcept
2586 {
2587  return isSame( b, a );
2588 }
2590 //*************************************************************************************************
2591 
2592 
2593 //*************************************************************************************************
2606 template< typename MT // Type of the matrix
2607  , bool SO // Storage order
2608  , bool DF // Density flag
2609  , bool SF // Symmetry flag
2610  , typename... CRAs1 // Compile time row arguments of the left-hand side row selection
2611  , typename... CRAs2 > // Compile time row arguments of the right-hand side row selection
2612 inline bool isSame( const Rows<MT,SO,DF,SF,CRAs1...>& a,
2613  const Rows<MT,SO,DF,SF,CRAs2...>& b ) noexcept
2614 {
2615  if( !isSame( a.operand(), b.operand() ) || a.rows() != b.rows() || a.columns() != b.columns() )
2616  return false;
2617 
2618  for( size_t i=0UL; i<a.rows(); ++i ) {
2619  if( a.idx(i) != b.idx(i) )
2620  return false;
2621  }
2622 
2623  return true;
2624 }
2626 //*************************************************************************************************
2627 
2628 
2629 //*************************************************************************************************
2668 template< InversionFlag IF // Inversion algorithm
2669  , typename MT // Type of the dense matrix
2670  , bool SO // Storage order
2671  , bool SF // Symmetry flag
2672  , typename... CRAs > // Compile time row arguments
2673 inline auto invert( Rows<MT,SO,true,SF,CRAs...>& r )
2674  -> DisableIf_t< HasMutableDataAccess_v<MT> >
2675 {
2676  using RT = ResultType_t< Rows<MT,SO,true,SF,CRAs...> >;
2677 
2680 
2681  RT tmp( r );
2682  invert<IF>( tmp );
2683  r = tmp;
2684 }
2686 //*************************************************************************************************
2687 
2688 
2689 //*************************************************************************************************
2705 template< typename MT // Type of the matrix
2706  , bool SO // Storage order
2707  , bool DF // Density flag
2708  , bool SF // Symmetry flag
2709  , typename... CRAs // Compile time row arguments
2710  , typename ET > // Type of the element
2711 inline bool trySet( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
2712 {
2713  BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2714  BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2715 
2716  return trySet( r.operand(), r.idx(i), j, value );
2717 }
2719 //*************************************************************************************************
2720 
2721 
2722 //*************************************************************************************************
2738 template< typename MT // Type of the matrix
2739  , bool SO // Storage order
2740  , bool DF // Density flag
2741  , bool SF // Symmetry flag
2742  , typename... CRAs // Compile time row arguments
2743  , typename ET > // Type of the element
2744 inline bool tryAdd( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
2745 {
2746  BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2747  BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2748 
2749  return tryAdd( r.operand(), r.idx(i), j, value );
2750 }
2752 //*************************************************************************************************
2753 
2754 
2755 //*************************************************************************************************
2771 template< typename MT // Type of the matrix
2772  , bool SO // Storage order
2773  , bool DF // Density flag
2774  , bool SF // Symmetry flag
2775  , typename... CRAs // Compile time row arguments
2776  , typename ET > // Type of the element
2777 inline bool trySub( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
2778 {
2779  BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2780  BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2781 
2782  return trySub( r.operand(), r.idx(i), j, value );
2783 }
2785 //*************************************************************************************************
2786 
2787 
2788 //*************************************************************************************************
2804 template< typename MT // Type of the matrix
2805  , bool SO // Storage order
2806  , bool DF // Density flag
2807  , bool SF // Symmetry flag
2808  , typename... CRAs // Compile time row arguments
2809  , typename ET > // Type of the element
2810 inline bool tryMult( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
2811 {
2812  BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2813  BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2814 
2815  return tryMult( r.operand(), r.idx(i), j, value );
2816 }
2818 //*************************************************************************************************
2819 
2820 
2821 //*************************************************************************************************
2839 template< typename MT // Type of the matrix
2840  , bool SO // Storage order
2841  , bool DF // Density flag
2842  , bool SF // Symmetry flag
2843  , typename... CRAs // Compile time row arguments
2844  , typename ET > // Type of the element
2846  tryMult( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t row, size_t column, size_t m, size_t n, const ET& value )
2847 {
2848  BLAZE_INTERNAL_ASSERT( row <= (~r).rows(), "Invalid row access index" );
2849  BLAZE_INTERNAL_ASSERT( column <= (~r).columns(), "Invalid column access index" );
2850  BLAZE_INTERNAL_ASSERT( row + m <= (~r).rows(), "Invalid number of rows" );
2851  BLAZE_INTERNAL_ASSERT( column + n <= (~r).columns(), "Invalid number of columns" );
2852 
2853  const size_t iend( row + m );
2854 
2855  for( size_t i=row; i<iend; ++i ) {
2856  if( !tryMult( r.operand(), r.idx(i), column, m, n, value ) )
2857  return false;
2858  }
2859 
2860  return true;
2861 }
2863 //*************************************************************************************************
2864 
2865 
2866 //*************************************************************************************************
2882 template< typename MT // Type of the matrix
2883  , bool SO // Storage order
2884  , bool DF // Density flag
2885  , bool SF // Symmetry flag
2886  , typename... CRAs // Compile time row arguments
2887  , typename ET > // Type of the element
2888 inline bool tryDiv( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
2889 {
2890  BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2891  BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2892 
2893  return tryDiv( r.operand(), r.idx(i), j, value );
2894 }
2896 //*************************************************************************************************
2897 
2898 
2899 //*************************************************************************************************
2917 template< typename MT // Type of the matrix
2918  , bool SO // Storage order
2919  , bool DF // Density flag
2920  , bool SF // Symmetry flag
2921  , typename... CRAs // Compile time row arguments
2922  , typename ET > // Type of the element
2924  tryDiv( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t row, size_t column, size_t m, size_t n, const ET& value )
2925 {
2926  BLAZE_INTERNAL_ASSERT( row <= (~r).rows(), "Invalid row access index" );
2927  BLAZE_INTERNAL_ASSERT( column <= (~r).columns(), "Invalid column access index" );
2928  BLAZE_INTERNAL_ASSERT( row + m <= (~r).rows(), "Invalid number of rows" );
2929  BLAZE_INTERNAL_ASSERT( column + n <= (~r).columns(), "Invalid number of columns" );
2930 
2931  const size_t iend( row + m );
2932 
2933  for( size_t i=row; i<iend; ++i ) {
2934  if( !tryDiv( r.operand(), r.idx(i), column, m, n, value ) )
2935  return false;
2936  }
2937 
2938  return true;
2939 }
2941 //*************************************************************************************************
2942 
2943 
2944 //*************************************************************************************************
2960 template< typename MT // Type of the matrix
2961  , bool SO // Storage order
2962  , bool DF // Density flag
2963  , bool SF // Symmetry flag
2964  , typename... CRAs // Compile time row arguments
2965  , typename VT > // Type of the right-hand side vector
2966 inline bool tryAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
2967  const Vector<VT,false>& rhs, size_t row, size_t column )
2968 {
2969  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2970  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2971  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
2972 
2973  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2974  if( !trySet( lhs.operand(), lhs.idx( row+i ), column, (~rhs)[i] ) )
2975  return false;
2976  }
2977 
2978  return true;
2979 }
2981 //*************************************************************************************************
2982 
2983 
2984 //*************************************************************************************************
3000 template< typename MT // Type of the matrix
3001  , bool SO // Storage order
3002  , bool DF // Density flag
3003  , bool SF // Symmetry flag
3004  , typename... CRAs // Compile time row arguments
3005  , typename VT > // Type of the right-hand side vector
3006 inline bool tryAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3007  const Vector<VT,true>& rhs, size_t row, size_t column )
3008 {
3009  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3010  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3011  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3012 
3013  return tryAssign( lhs.operand(), ~rhs, lhs.idx( row ), column );
3014 }
3016 //*************************************************************************************************
3017 
3018 
3019 //*************************************************************************************************
3036 template< typename MT // Type of the matrix
3037  , bool SO // Storage order
3038  , bool DF // Density flag
3039  , bool SF // Symmetry flag
3040  , typename... CRAs // Compile time row arguments
3041  , typename VT // Type of the right-hand side vector
3042  , bool TF > // Transpose flag of the right-hand side vector
3043 inline bool tryAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3044  const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3045 {
3047 
3048  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3049  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3050  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3051  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3052 
3053  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3054  if( !trySet( lhs.operand(), lhs.idx( row+i ), column+i, (~rhs)[i] ) )
3055  return false;
3056  }
3057 
3058  return true;
3059 }
3061 //*************************************************************************************************
3062 
3063 
3064 //*************************************************************************************************
3080 template< typename MT1 // Type of the matrix
3081  , bool SO1 // Storage order
3082  , bool DF // Density flag
3083  , bool SF // Symmetry flag
3084  , typename... CRAs // Compile time row arguments
3085  , typename MT2 // Type of the right-hand side matrix
3086  , bool SO2 > // Storage order of the right-hand side matrix
3087 inline bool tryAssign( const Rows<MT1,SO1,DF,SF,CRAs...>& lhs,
3088  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3089 {
3090  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3091  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3092  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
3093  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3094 
3095  for( size_t i=0UL; i<(~rhs).rows(); ++i ) {
3096  if( !tryAssign( lhs.operand(), blaze::row( ~rhs, i, unchecked ), lhs.idx( row+i ), column ) )
3097  return false;
3098  }
3099 
3100  return true;
3101 }
3103 //*************************************************************************************************
3104 
3105 
3106 //*************************************************************************************************
3124 template< typename MT // Type of the matrix
3125  , bool SO // Storage order
3126  , bool DF // Density flag
3127  , bool SF // Symmetry flag
3128  , typename... CRAs // Compile time row arguments
3129  , typename VT > // Type of the right-hand side vector
3130 inline bool tryAddAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3131  const Vector<VT,false>& rhs, size_t row, size_t column )
3132 {
3133  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3134  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3135  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3136 
3137  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3138  if( !tryAdd( lhs.operand(), lhs.idx( row+i ), column, (~rhs)[i] ) )
3139  return false;
3140  }
3141 
3142  return true;
3143 }
3145 //*************************************************************************************************
3146 
3147 
3148 //*************************************************************************************************
3164 template< typename MT // Type of the matrix
3165  , bool SO // Storage order
3166  , bool DF // Density flag
3167  , bool SF // Symmetry flag
3168  , typename... CRAs // Compile time row arguments
3169  , typename VT > // Type of the right-hand side vector
3170 inline bool tryAddAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3171  const Vector<VT,true>& rhs, size_t row, size_t column )
3172 {
3173  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3174  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3175  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3176 
3177  return tryAddAssign( lhs.operand(), ~rhs, lhs.idx( row ), column );
3178 }
3180 //*************************************************************************************************
3181 
3182 
3183 //*************************************************************************************************
3201 template< typename MT // Type of the matrix
3202  , bool SO // Storage order
3203  , bool DF // Density flag
3204  , bool SF // Symmetry flag
3205  , typename... CRAs // Compile time row arguments
3206  , typename VT // Type of the right-hand side vector
3207  , bool TF > // Transpose flag of the right-hand side vector
3208 inline bool tryAddAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3209  const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3210 {
3212 
3213  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3214  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3215  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3216  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3217 
3218  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3219  if( !tryAdd( lhs.operand(), lhs.idx( row+i ), column+i, (~rhs)[i] ) )
3220  return false;
3221  }
3222 
3223  return true;
3224 }
3226 //*************************************************************************************************
3227 
3228 
3229 //*************************************************************************************************
3245 template< typename MT1 // Type of the matrix
3246  , bool SO1 // Storage order
3247  , bool DF // Density flag
3248  , bool SF // Symmetry flag
3249  , typename... CRAs // Compile time row arguments
3250  , typename MT2 // Type of the right-hand side matrix
3251  , bool SO2 > // Storage order of the right-hand side matrix
3252 inline bool tryAddAssign( const Rows<MT1,SO1,DF,SF,CRAs...>& lhs,
3253  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3254 {
3255  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3256  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3257  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
3258  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3259 
3260  for( size_t i=0UL; i<(~rhs).rows(); ++i ) {
3261  if( !tryAddAssign( lhs.operand(), blaze::row( ~rhs, i, unchecked ), lhs.idx( row+i ), column ) )
3262  return false;
3263  }
3264 
3265  return true;
3266 }
3268 //*************************************************************************************************
3269 
3270 
3271 //*************************************************************************************************
3288 template< typename MT // Type of the matrix
3289  , bool SO // Storage order
3290  , bool DF // Density flag
3291  , bool SF // Symmetry flag
3292  , typename... CRAs // Compile time row arguments
3293  , typename VT > // Type of the right-hand side vector
3294 inline bool trySubAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3295  const Vector<VT,false>& rhs, size_t row, size_t column )
3296 {
3297  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3298  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3299  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3300 
3301  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3302  if( !trySub( lhs.operand(), lhs.idx( row+i ), column, (~rhs)[i] ) )
3303  return false;
3304  }
3305 
3306  return true;
3307 }
3309 //*************************************************************************************************
3310 
3311 
3312 //*************************************************************************************************
3329 template< typename MT // Type of the matrix
3330  , bool SO // Storage order
3331  , bool DF // Density flag
3332  , bool SF // Symmetry flag
3333  , typename... CRAs // Compile time row arguments
3334  , typename VT > // Type of the right-hand side vector
3335 inline bool trySubAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3336  const Vector<VT,true>& rhs, size_t row, size_t column )
3337 {
3338  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3339  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3340  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3341 
3342  return trySubAssign( lhs.operand(), ~rhs, lhs.idx( row ), column );
3343 }
3345 //*************************************************************************************************
3346 
3347 
3348 //*************************************************************************************************
3366 template< typename MT // Type of the matrix
3367  , bool SO // Storage order
3368  , bool DF // Density flag
3369  , bool SF // Symmetry flag
3370  , typename... CRAs // Compile time row arguments
3371  , typename VT // Type of the right-hand side vector
3372  , bool TF > // Transpose flag of the right-hand side vector
3373 inline bool trySubAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3374  const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3375 {
3377 
3378  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3379  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3380  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3381  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3382 
3383  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3384  if( !trySub( lhs.operand(), lhs.idx( row+i ), column+i, (~rhs)[i] ) )
3385  return false;
3386  }
3387 
3388  return true;
3389 }
3391 //*************************************************************************************************
3392 
3393 
3394 //*************************************************************************************************
3410 template< typename MT1 // Type of the matrix
3411  , bool SO1 // Storage order
3412  , bool DF // Density flag
3413  , bool SF // Symmetry flag
3414  , typename... CRAs // Compile time row arguments
3415  , typename MT2 // Type of the right-hand side matrix
3416  , bool SO2 > // Storage order of the right-hand side matrix
3417 inline bool trySubAssign( const Rows<MT1,SO1,DF,SF,CRAs...>& lhs,
3418  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3419 {
3420  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3421  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3422  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
3423  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3424 
3425  for( size_t i=0UL; i<(~rhs).rows(); ++i ) {
3426  if( !trySubAssign( lhs.operand(), blaze::row( ~rhs, i, unchecked ), lhs.idx( row+i ), column ) )
3427  return false;
3428  }
3429 
3430  return true;
3431 }
3433 //*************************************************************************************************
3434 
3435 
3436 //*************************************************************************************************
3454 template< typename MT // Type of the matrix
3455  , bool SO // Storage order
3456  , bool DF // Density flag
3457  , bool SF // Symmetry flag
3458  , typename... CRAs // Compile time row arguments
3459  , typename VT > // Type of the right-hand side vector
3460 inline bool tryMultAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3461  const Vector<VT,false>& rhs, size_t row, size_t column )
3462 {
3463  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3464  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3465  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3466 
3467  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3468  if( !tryMult( lhs.operand(), lhs.idx( row+i ), column, (~rhs)[i] ) )
3469  return false;
3470  }
3471 
3472  return true;
3473 }
3475 //*************************************************************************************************
3476 
3477 
3478 //*************************************************************************************************
3495 template< typename MT // Type of the matrix
3496  , bool SO // Storage order
3497  , bool DF // Density flag
3498  , bool SF // Symmetry flag
3499  , typename... CRAs // Compile time row arguments
3500  , typename VT > // Type of the right-hand side vector
3501 inline bool tryMultAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3502  const Vector<VT,true>& rhs, size_t row, size_t column )
3503 {
3504  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3505  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3506  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3507 
3508  return tryMultAssign( lhs.operand(), ~rhs, lhs.idx( row ), column );
3509 }
3511 //*************************************************************************************************
3512 
3513 
3514 //*************************************************************************************************
3532 template< typename MT // Type of the matrix
3533  , bool SO // Storage order
3534  , bool DF // Density flag
3535  , bool SF // Symmetry flag
3536  , typename... CRAs // Compile time row arguments
3537  , typename VT // Type of the right-hand side vector
3538  , bool TF > // Transpose flag of the right-hand side vector
3539 inline bool tryMultAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3540  const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3541 {
3543 
3544  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3545  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3546  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3547  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3548 
3549  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3550  if( !tryMult( lhs.operand(), lhs.idx( row+i ), column+i, (~rhs)[i] ) )
3551  return false;
3552  }
3553 
3554  return true;
3555 }
3557 //*************************************************************************************************
3558 
3559 
3560 //*************************************************************************************************
3577 template< typename MT1 // Type of the matrix
3578  , bool SO1 // Storage order
3579  , bool DF // Density flag
3580  , bool SF // Symmetry flag
3581  , typename... CRAs // Compile time row arguments
3582  , typename MT2 // Type of the right-hand side matrix
3583  , bool SO2 > // Storage order of the right-hand side matrix
3584 inline bool trySchurAssign( const Rows<MT1,SO1,DF,SF,CRAs...>& lhs,
3585  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3586 {
3587  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3588  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3589  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
3590  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3591 
3592  for( size_t i=0UL; i<(~rhs).rows(); ++i ) {
3593  if( !tryMultAssign( lhs.operand(), blaze::row( ~rhs, i, unchecked ), lhs.idx( row+i ), column ) )
3594  return false;
3595  }
3596 
3597  return true;
3598 }
3600 //*************************************************************************************************
3601 
3602 
3603 //*************************************************************************************************
3621 template< typename MT // Type of the matrix
3622  , bool SO // Storage order
3623  , bool DF // Density flag
3624  , bool SF // Symmetry flag
3625  , typename... CRAs // Compile time row arguments
3626  , typename VT > // Type of the right-hand side vector
3627 inline bool tryDivAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3628  const Vector<VT,false>& rhs, size_t row, size_t column )
3629 {
3630  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3631  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3632  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3633 
3634  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3635  if( !tryDiv( lhs.operand(), lhs.idx( row+i ), column, (~rhs)[i] ) )
3636  return false;
3637  }
3638 
3639  return true;
3640 }
3642 //*************************************************************************************************
3643 
3644 
3645 //*************************************************************************************************
3661 template< typename MT // Type of the matrix
3662  , bool SO // Storage order
3663  , bool DF // Density flag
3664  , bool SF // Symmetry flag
3665  , typename... CRAs // Compile time row arguments
3666  , typename VT > // Type of the right-hand side vector
3667 inline bool tryDivAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3668  const Vector<VT,true>& rhs, size_t row, size_t column )
3669 {
3670  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3671  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3672  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3673 
3674  return tryDivAssign( lhs.operand(), ~rhs, lhs.idx( row ), column );
3675 }
3677 //*************************************************************************************************
3678 
3679 
3680 //*************************************************************************************************
3698 template< typename MT // Type of the matrix
3699  , bool SO // Storage order
3700  , bool DF // Density flag
3701  , bool SF // Symmetry flag
3702  , typename... CRAs // Compile time row arguments
3703  , typename VT // Type of the right-hand side vector
3704  , bool TF > // Transpose flag of the right-hand side vector
3705 inline bool tryDivAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3706  const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3707 {
3709 
3710  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3711  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3712  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3713  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3714 
3715  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3716  if( !tryDiv( lhs.operand(), lhs.idx( row+i ), column+i, (~rhs)[i] ) )
3717  return false;
3718  }
3719 
3720  return true;
3721 }
3723 //*************************************************************************************************
3724 
3725 
3726 //*************************************************************************************************
3741 template< typename MT // Type of the matrix
3742  , bool SO // Storage order
3743  , bool DF // Density flag
3744  , bool SF // Symmetry flag
3745  , typename... CRAs > // Compile time row arguments
3746 inline decltype(auto) derestrict( Rows<MT,SO,DF,SF,CRAs...>& r )
3747 {
3748  return rows( derestrict( r.operand() ), r.idces(), unchecked );
3749 }
3751 //*************************************************************************************************
3752 
3753 
3754 //*************************************************************************************************
3769 template< typename MT // Type of the matrix
3770  , bool SO // Storage order
3771  , bool DF // Density flag
3772  , bool SF // Symmetry flag
3773  , typename... CRAs > // Compile time row arguments
3774 inline decltype(auto) derestrict( Rows<MT,SO,DF,SF,CRAs...>&& r )
3775 {
3776  return rows( derestrict( r.operand() ), r.idces(), unchecked );
3777 }
3779 //*************************************************************************************************
3780 
3781 
3782 
3783 
3784 //=================================================================================================
3785 //
3786 // SIZE SPECIALIZATIONS
3787 //
3788 //=================================================================================================
3789 
3790 //*************************************************************************************************
3792 template< typename MT, bool SO, bool DF, bool SF, size_t I, size_t... Is, typename... CRAs >
3793 struct Size< Rows<MT,SO,DF,SF,index_sequence<I,Is...>,CRAs...>, 0UL >
3794  : public PtrdiffT<1UL+sizeof...(Is)>
3795 {};
3796 
3797 template< typename MT, bool SO, bool DF, bool SF, typename... CRAs >
3798 struct Size< Rows<MT,SO,DF,SF,CRAs...>, 1UL >
3799  : public Size<MT,1UL>
3800 {};
3802 //*************************************************************************************************
3803 
3804 
3805 
3806 
3807 //=================================================================================================
3808 //
3809 // MAXSIZE SPECIALIZATIONS
3810 //
3811 //=================================================================================================
3812 
3813 //*************************************************************************************************
3815 template< typename MT, bool SO, bool DF, bool SF, size_t I, size_t... Is, typename... CRAs >
3816 struct MaxSize< Rows<MT,SO,DF,SF,index_sequence<I,Is...>,CRAs...>, 0UL >
3817  : public PtrdiffT<1UL+sizeof...(Is)>
3818 {};
3819 
3820 template< typename MT, bool SO, bool DF, bool SF, typename... CRAs >
3821 struct MaxSize< Rows<MT,SO,DF,SF,CRAs...>, 1UL >
3822  : public MaxSize<MT,1UL>
3823 {};
3825 //*************************************************************************************************
3826 
3827 
3828 
3829 
3830 //=================================================================================================
3831 //
3832 // ISRESTRICTED SPECIALIZATIONS
3833 //
3834 //=================================================================================================
3835 
3836 //*************************************************************************************************
3838 template< typename MT, bool SO, bool DF, bool SF, typename... CRAs >
3839 struct IsRestricted< Rows<MT,SO,DF,SF,CRAs...> >
3840  : public IsRestricted<MT>
3841 {};
3843 //*************************************************************************************************
3844 
3845 
3846 
3847 
3848 //=================================================================================================
3849 //
3850 // HASCONSTDATAACCESS SPECIALIZATIONS
3851 //
3852 //=================================================================================================
3853 
3854 //*************************************************************************************************
3856 template< typename MT, bool SO, bool SF, typename... CRAs >
3857 struct HasConstDataAccess< Rows<MT,SO,true,SF,CRAs...> >
3858  : public HasConstDataAccess<MT>
3859 {};
3861 //*************************************************************************************************
3862 
3863 
3864 
3865 
3866 //=================================================================================================
3867 //
3868 // HASMUTABLEDATAACCESS SPECIALIZATIONS
3869 //
3870 //=================================================================================================
3871 
3872 //*************************************************************************************************
3874 template< typename MT, bool SO, bool SF, typename... CRAs >
3875 struct HasMutableDataAccess< Rows<MT,SO,true,SF,CRAs...> >
3876  : public HasMutableDataAccess<MT>
3877 {};
3879 //*************************************************************************************************
3880 
3881 
3882 
3883 
3884 //=================================================================================================
3885 //
3886 // ISALIGNED SPECIALIZATIONS
3887 //
3888 //=================================================================================================
3889 
3890 //*************************************************************************************************
3892 template< typename MT, bool SO, bool SF, typename... CRAs >
3893 struct IsAligned< Rows<MT,SO,true,SF,CRAs...> >
3894  : public IsAligned<MT>
3895 {};
3897 //*************************************************************************************************
3898 
3899 } // namespace blaze
3900 
3901 #endif
AlignmentFlag
Alignment flag for (un-)aligned vectors and matrices.Via these flags it is possible to specify subvec...
Definition: AlignmentFlag.h:62
Rows specialization for sparse matrices.
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Header file for the blaze::checked and blaze::unchecked instances.
Header file for the implementation of the RowData class template.
Header file for the alignment flag values.
Header file for the UNUSED_PARAMETER function template.
#define BLAZE_CONSTRAINT_MUST_HAVE_MUTABLE_DATA_ACCESS(T)
Constraint on the data type.In case the given data type T does not provide low-level data access to m...
Definition: MutableDataAccess.h:61
bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:992
Header file for basic type definitions.
Header file for the MatReduceExpr base class.
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
Header file for the serial shim.
Header file for the MatTransExpr base class.
Header file for the dense matrix inversion flags.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
Header file for the MatEvalExpr base class.
Header file for the MatMatMultExpr base class.
Header file for the extended initializer_list functionality.
Index sequence type of the Blaze library.
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
STL namespace.
Header file for the MaxSize type trait.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
Header file for the matrix storage order types.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:775
Header file for the MatMapExpr base class.
Header file for the DisableIf class template.
Header file for the SmallArray implementation.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Implementation of a dynamic array with small array optimization.The SmallArray class template is a hy...
Definition: SmallArray.h:81
Header file for the MatMatSubExpr base class.
constexpr bool Contains_v
Auxiliary variable template for the Contains type trait.The Contains_v variable template provides a c...
Definition: Contains.h:139
Header file for the IsAligned type trait.
decltype(auto) eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:786
decltype(auto) elements(Vector< VT, TF > &vector, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition: Elements.h:135
Header file for the exception macros of the math module.
Constraint on the data type.
Constraint on the data type.
Header file for the MatSerialExpr base class.
Header file for the VecTVecMultExpr base class.
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:135
Header file for the HasConstDataAccess type trait.
IntegralConstant< ptrdiff_t, N > PtrdiffT
Compile time integral constant wrapper for ptrdiff_t.The PtrdiffT class template represents an integr...
Definition: PtrdiffT.h:72
Header file for the DeclExpr base class.
Header file for the Matrix base class.
Header file for the PtrdiffT class template.
Header file for all forward declarations for views.
Header file for the MatScalarMultExpr base class.
Header file for run time assertion macros.
Header file for the Unique class template.
Check< false > Unchecked
Type of the blaze::unchecked instance.blaze::Unchecked is the type of the blaze::unchecked instance...
Definition: Check.h:96
Header file for the SchurExpr base class.
decltype(auto) expand(const DenseVector< VT, TF > &dv, size_t expansion)
Expansion of the given dense vector.
Definition: DVecExpandExpr.h:739
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
Header file for the IsPointer type trait.
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
Header file for the isDefault shim.
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:109
Header file for the integer_sequence and index_sequence aliases.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
Header file for the HasMutableDataAccess type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
Header file for the MatMatAddExpr base class.
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
Header file for the VecExpandExpr base class.
constexpr size_t rowwise
Reduction flag for row-wise reduction operations.
Definition: ReductionFlag.h:70
Header file for the IsRowMajorMatrix type trait.
Header file for the MatMatMapExpr base class.
Initializer list type of the Blaze library.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
Rows specialization for dense matrices.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
Header file for the MatScalarDivExpr base class.
Header file for the MatVecMultExpr base class.
Header file for the implementation of the Rows base template.
Header file for the IsRestricted type trait.
Header file for the Size type trait.
InversionFlag
Inversion flag.The InversionFlag type enumeration represents the different types of matrix inversion ...
Definition: InversionFlag.h:101
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the reduction flags.
Header file for the function trace functionality.
decltype(auto) map(const DenseMatrix< MT1, SO > &lhs, const DenseMatrix< MT2, SO > &rhs, OP op)
Evaluates the given binary operation on each single element of the dense matrices lhs and rhs...
Definition: DMatDMatMapExpr.h:1110