Blaze 3.9
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>
94#include <blaze/util/Assert.h>
95#include <blaze/util/EnableIf.h>
101#include <blaze/util/Types.h>
104
105
106namespace blaze {
107
108//=================================================================================================
109//
110// GLOBAL FUNCTIONS
111//
112//=================================================================================================
113
114//*************************************************************************************************
149template< size_t I // First row index
150 , size_t... Is // Remaining row indices
151 , typename MT // Type of the matrix
152 , bool SO // Storage order
153 , typename... RRAs > // Optional arguments
154inline decltype(auto) rows( Matrix<MT,SO>& matrix, RRAs... args )
155{
157
158 using ReturnType = Rows_< MT, index_sequence<I,Is...> >;
159 return ReturnType( *matrix, args... );
160}
161//*************************************************************************************************
162
163
164//*************************************************************************************************
199template< size_t I // First row index
200 , size_t... Is // Remaining row indices
201 , typename MT // Type of the matrix
202 , bool SO // Storage order
203 , typename... RRAs > // Optional arguments
204inline decltype(auto) rows( const Matrix<MT,SO>& matrix, RRAs... args )
205{
207
208 using ReturnType = const Rows_< const MT, index_sequence<I,Is...> >;
209 return ReturnType( *matrix, args... );
210}
211//*************************************************************************************************
212
213
214//*************************************************************************************************
228template< size_t I // First row index
229 , size_t... Is // Remaining row indices
230 , typename MT // Type of the matrix
231 , bool SO // Storage order
232 , typename... RRAs > // Optional arguments
233inline decltype(auto) rows( Matrix<MT,SO>&& matrix, RRAs... args )
234{
236
237 using ReturnType = Rows_< MT, index_sequence<I,Is...> >;
238 return ReturnType( *matrix, args... );
239}
240//*************************************************************************************************
241
242
243//*************************************************************************************************
282template< typename MT // Type of the matrix
283 , bool SO // Storage order
284 , typename T // Type of the row indices
285 , typename... RRAs > // Optional arguments
286inline decltype(auto) rows( Matrix<MT,SO>& matrix, T* indices, size_t n, RRAs... args )
287{
289
290 using ReturnType = Rows_<MT>;
291 return ReturnType( *matrix, indices, n, args... );
292}
293//*************************************************************************************************
294
295
296//*************************************************************************************************
336template< typename MT // Type of the matrix
337 , bool SO // Storage order
338 , typename T // Type of the row indices
339 , typename... RRAs > // Optional arguments
340inline decltype(auto) rows( const Matrix<MT,SO>& matrix, T* indices, size_t n, RRAs... args )
341{
343
344 using ReturnType = const Rows_<const MT>;
345 return ReturnType( *matrix, indices, n, args... );
346}
347//*************************************************************************************************
348
349
350//*************************************************************************************************
365template< typename MT // Type of the matrix
366 , bool SO // Storage order
367 , typename T // Type of the row indices
368 , typename... RRAs > // Optional arguments
369inline decltype(auto) rows( Matrix<MT,SO>&& matrix, T* indices, size_t n, RRAs... args )
370{
372
373 using ReturnType = Rows_<MT>;
374 return ReturnType( *matrix, indices, n, args... );
375}
376//*************************************************************************************************
377
378
379//*************************************************************************************************
416template< typename MT // Type of the matrix
417 , bool SO // Storage order
418 , typename P // Type of the index producer
419 , typename... RRAs > // Optional arguments
420inline decltype(auto) rows( Matrix<MT,SO>& matrix, P p, size_t n, RRAs... args )
421{
423
424 using ReturnType = Rows_<MT,P>;
425 return ReturnType( *matrix, p, n, args... );
426}
427//*************************************************************************************************
428
429
430//*************************************************************************************************
468template< typename MT // Type of the matrix
469 , bool SO // Storage order
470 , typename P // Type of the index producer
471 , typename... RRAs > // Optional arguments
472inline decltype(auto) rows( const Matrix<MT,SO>& matrix, P p, size_t n, RRAs... args )
473{
475
476 using ReturnType = const Rows_<const MT,P>;
477 return ReturnType( *matrix, p, n, args... );
478}
479//*************************************************************************************************
480
481
482//*************************************************************************************************
497template< typename MT // Type of the matrix
498 , bool SO // Storage order
499 , typename P // Type of the index producer
500 , typename... RRAs > // Optional arguments
501inline decltype(auto) rows( Matrix<MT,SO>&& matrix, P p, size_t n, RRAs... args )
502{
504
505 using ReturnType = Rows_<MT,P>;
506 return ReturnType( *matrix, p, n, args... );
507}
508//*************************************************************************************************
509
510
511//*************************************************************************************************
548template< typename MT // Type of the matrix
549 , size_t... Is // Row indices
550 , typename... RRAs > // Optional arguments
551inline decltype(auto) rows( MT&& matrix, index_sequence<Is...> indices, RRAs... args )
552{
554
555 MAYBE_UNUSED( indices );
556
557 return rows<Is...>( std::forward<MT>( matrix ), args... );
558}
559//*************************************************************************************************
560
561
562//*************************************************************************************************
598template< typename MT // Type of the matrix
599 , typename T // Type of the row indices
600 , typename... RRAs > // Optional arguments
601inline decltype(auto) rows( MT&& matrix, initializer_list<T> indices, RRAs... args )
602{
604
605 return rows( std::forward<MT>( matrix ), indices.begin(), indices.size(), args... );
606}
607//*************************************************************************************************
608
609
610//*************************************************************************************************
648template< typename MT // Type of the matrix
649 , typename T // Type of the row indices
650 , size_t N // Number of indices
651 , typename... RRAs > // Optional arguments
652inline decltype(auto) rows( MT&& matrix, const std::array<T,N>& indices, RRAs... args )
653{
655
656 return rows( std::forward<MT>( matrix ), indices.data(), N, args... );
657}
658//*************************************************************************************************
659
660
661//*************************************************************************************************
699template< typename MT // Type of the matrix
700 , typename T // Type of the row indices
701 , typename... RRAs > // Optional arguments
702inline decltype(auto) rows( MT&& matrix, const std::vector<T>& indices, RRAs... args )
703{
705
706 return rows( std::forward<MT>( matrix ), indices.data(), indices.size(), args... );
707}
708//*************************************************************************************************
709
710
711//*************************************************************************************************
749template< typename MT // Type of the matrix
750 , typename T // Type of the row indices
751 , size_t N // Number of preallocated elements
752 , typename... RRAs > // Optional arguments
753inline decltype(auto) rows( MT&& matrix, const SmallArray<T,N>& indices, RRAs... args )
754{
756
757 return rows( std::forward<MT>( matrix ), indices.data(), indices.size(), args... );
758}
759//*************************************************************************************************
760
761
762//*************************************************************************************************
778template< typename MT // Type of the matrix
779 , typename T1 // First type of the pair of arguments
780 , typename T2 // Second type of the pair of arguments
781 , typename... RRAs > // Optional arguments
782inline decltype(auto) rows( MT&& matrix, const std::pair<T1,T2>& pair, RRAs... args )
783{
785
786 return rows( std::forward<MT>( matrix ), pair.first, pair.second, args... );
787}
789//*************************************************************************************************
790
791
792
793
794//=================================================================================================
795//
796// GLOBAL RESTRUCTURING FUNCTIONS
797//
798//=================================================================================================
799
800//*************************************************************************************************
813template< size_t... CRAs // Compile time row arguments
814 , typename MT // Matrix base type of the expression
815 , typename... RRAs // Runtime row arguments
816 , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
817inline decltype(auto) rows( const MatMatAddExpr<MT>& matrix, RRAs... args )
818{
820
821 return rows<CRAs...>( (*matrix).leftOperand(), args... ) +
822 rows<CRAs...>( (*matrix).rightOperand(), args... );
823}
825//*************************************************************************************************
826
827
828//*************************************************************************************************
841template< size_t... CRAs // Compile time row arguments
842 , typename MT // Matrix base type of the expression
843 , typename... RRAs // Runtime row arguments
844 , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
845inline decltype(auto) rows( const MatMatSubExpr<MT>& matrix, RRAs... args )
846{
848
849 return rows<CRAs...>( (*matrix).leftOperand(), args... ) -
850 rows<CRAs...>( (*matrix).rightOperand(), args... );
851}
853//*************************************************************************************************
854
855
856//*************************************************************************************************
869template< size_t... CRAs // Compile time row arguments
870 , typename MT // Matrix base type of the expression
871 , typename... RRAs // Runtime row arguments
872 , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
873inline decltype(auto) rows( const SchurExpr<MT>& matrix, RRAs... args )
874{
876
877 return rows<CRAs...>( (*matrix).leftOperand(), args... ) %
878 rows<CRAs...>( (*matrix).rightOperand(), args... );
879}
881//*************************************************************************************************
882
883
884//*************************************************************************************************
897template< size_t... CRAs // Compile time row arguments
898 , typename MT // Matrix base type of the expression
899 , typename... RRAs // Runtime row arguments
900 , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
901inline decltype(auto) rows( const MatMatMultExpr<MT>& matrix, RRAs... args )
902{
904
905 return rows<CRAs...>( (*matrix).leftOperand(), args... ) * (*matrix).rightOperand();
906}
908//*************************************************************************************************
909
910
911//*************************************************************************************************
924template< size_t I // First row index
925 , size_t... Is // Remaining row indices
926 , typename MT // Matrix base type of the expression
927 , typename... RRAs > // Optional arguments
928inline decltype(auto) rows( const MatMatKronExpr<MT>& matrix, RRAs... args )
929{
931
932 decltype(auto) lhs( (*matrix).leftOperand() );
933 decltype(auto) rhs( (*matrix).rightOperand() );
934
935 const size_t M( rhs.rows() );
936 const size_t N( rhs.columns() );
937
938 const auto lhsRows( [M]( size_t i ) {
939 constexpr size_t indices[] = { I, Is... };
940 return indices[i] / M;
941 } );
942
943 const auto rhsRows( [M]( size_t i ) {
944 constexpr size_t indices[] = { I, Is... };
945 return indices[i] % M;
946 } );
947
948 const auto lhsColumns( [N]( size_t i ){ return i / N; } );
949 const auto rhsColumns( [N]( size_t i ){ return i % N; } );
950
951 return columns( rows( lhs, lhsRows, sizeof...(Is)+1UL, args... ), lhsColumns, (*matrix).columns(), args... ) %
952 columns( rows( rhs, rhsRows, sizeof...(Is)+1UL, args... ), rhsColumns, (*matrix).columns(), args... );
953}
955//*************************************************************************************************
956
957
958//*************************************************************************************************
973template< typename MT // Matrix base type of the expression
974 , typename T // Type of the row indices
975 , typename... RRAs > // Optional arguments
976inline decltype(auto) rows( const MatMatKronExpr<MT>& matrix, T* indices, size_t n, RRAs... args )
977{
979
980 decltype(auto) lhs( (*matrix).leftOperand() );
981 decltype(auto) rhs( (*matrix).rightOperand() );
982
983 const size_t M( rhs.rows() );
984 const size_t N( rhs.columns() );
985
986 SmallArray<size_t,128UL> lhsRows;
987 lhsRows.reserve( n );
988
989 for( size_t i=0UL; i<n; ++i ) {
990 lhsRows.pushBack( indices[i] / M );
991 }
992
993 SmallArray<size_t,128UL> rhsRows;
994 rhsRows.reserve( n );
995
996 for( size_t i=0UL; i<n; ++i ) {
997 rhsRows.pushBack( indices[i] % M );
998 }
999
1000 const auto lhsColumns( [N]( size_t i ){ return i / N; } );
1001 const auto rhsColumns( [N]( size_t i ){ return i % N; } );
1002
1003 return columns( rows( lhs, lhsRows, n, args... ), lhsColumns, (*matrix).columns(), args... ) %
1004 columns( rows( rhs, rhsRows, n, args... ), rhsColumns, (*matrix).columns(), args... );
1005}
1007//*************************************************************************************************
1008
1009
1010//*************************************************************************************************
1025template< typename MT // Matrix base type of the expression
1026 , typename P // Type of the index producer
1027 , typename... RRAs > // Optional arguments
1028inline decltype(auto) rows( const MatMatKronExpr<MT>& matrix, P p, size_t n, RRAs... args )
1029{
1031
1032 decltype(auto) lhs( (*matrix).leftOperand() );
1033 decltype(auto) rhs( (*matrix).rightOperand() );
1034
1035 const size_t M( rhs.rows() );
1036 const size_t N( rhs.columns() );
1037
1038 const auto lhsRows( [p,M]( size_t i ) { return p(i) / M; } );
1039 const auto rhsRows( [p,M]( size_t i ) { return p(i) % M; } );
1040
1041 const auto lhsColumns( [N]( size_t i ){ return i / N; } );
1042 const auto rhsColumns( [N]( size_t i ){ return i % N; } );
1043
1044 return columns( rows( lhs, lhsRows, n, args... ), lhsColumns, (*matrix).columns(), args... ) %
1045 columns( rows( rhs, rhsRows, n, args... ), rhsColumns, (*matrix).columns(), args... );
1046}
1048//*************************************************************************************************
1049
1050
1051//*************************************************************************************************
1064template< size_t... CRAs // Compile time row arguments
1065 , typename MT // Matrix base type of the expression
1066 , typename... RRAs // Runtime row arguments
1067 , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
1068inline decltype(auto) rows( const VecTVecMultExpr<MT>& matrix, RRAs... args )
1069{
1071
1072 try {
1073 return elements<CRAs...>( (*matrix).leftOperand(), args... ) * (*matrix).rightOperand();
1074 }
1075 catch( ... ) {
1076 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1077 }
1078}
1080//*************************************************************************************************
1081
1082
1083//*************************************************************************************************
1096template< size_t... CRAs // Compile time row arguments
1097 , typename MT // Matrix base type of the expression
1098 , typename... RRAs // Runtime row arguments
1099 , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
1100inline decltype(auto) rows( const MatScalarMultExpr<MT>& matrix, RRAs... args )
1101{
1103
1104 return rows<CRAs...>( (*matrix).leftOperand(), args... ) * (*matrix).rightOperand();
1105}
1107//*************************************************************************************************
1108
1109
1110//*************************************************************************************************
1123template< size_t... CRAs // Compile time row arguments
1124 , typename MT // Matrix base type of the expression
1125 , typename... RRAs // Runtime row arguments
1126 , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
1127inline decltype(auto) rows( const MatScalarDivExpr<MT>& matrix, RRAs... args )
1128{
1130
1131 return rows<CRAs...>( (*matrix).leftOperand(), args... ) / (*matrix).rightOperand();
1132}
1134//*************************************************************************************************
1135
1136
1137//*************************************************************************************************
1150template< size_t... CRAs // Compile time row arguments
1151 , typename MT // Matrix base type of the expression
1152 , typename... RRAs // Runtime row arguments
1153 , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
1154inline decltype(auto) rows( const MatMapExpr<MT>& matrix, RRAs... args )
1155{
1157
1158 return map( rows<CRAs...>( (*matrix).operand(), args... ), (*matrix).operation() );
1159}
1161//*************************************************************************************************
1162
1163
1164//*************************************************************************************************
1177template< size_t... CRAs // Compile time row arguments
1178 , typename MT // Matrix base type of the expression
1179 , typename... RRAs // Runtime row arguments
1180 , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
1181inline decltype(auto) rows( const MatMatMapExpr<MT>& matrix, RRAs... args )
1182{
1184
1185 return map( rows<CRAs...>( (*matrix).leftOperand(), args... ),
1186 rows<CRAs...>( (*matrix).rightOperand(), args... ),
1187 (*matrix).operation() );
1188}
1190//*************************************************************************************************
1191
1192
1193//*************************************************************************************************
1206template< size_t... CRAs // Compile time row arguments
1207 , typename MT // Matrix base type of the expression
1208 , typename... RRAs // Runtime row arguments
1209 , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
1210inline decltype(auto) rows( const VecTVecMapExpr<MT>& matrix, RRAs... args )
1211{
1213
1214 try {
1215 return map( elements<CRAs...>( (*matrix).leftOperand(), args... ),
1216 (*matrix).rightOperand(), (*matrix).operation() );
1217 }
1218 catch( ... ) {
1219 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1220 }
1221}
1223//*************************************************************************************************
1224
1225
1226//*************************************************************************************************
1239template< size_t... CRAs // Compile time row arguments
1240 , typename MT // Matrix base type of the expression
1241 , typename... RRAs // Runtime row arguments
1242 , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
1243inline decltype(auto) rows( const MatEvalExpr<MT>& matrix, RRAs... args )
1244{
1246
1247 return eval( rows<CRAs...>( (*matrix).operand(), args... ) );
1248}
1250//*************************************************************************************************
1251
1252
1253//*************************************************************************************************
1266template< size_t... CRAs // Compile time row arguments
1267 , typename MT // Matrix base type of the expression
1268 , typename... RRAs // Runtime row arguments
1269 , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
1270inline decltype(auto) rows( const MatSerialExpr<MT>& matrix, RRAs... args )
1271{
1273
1274 return serial( rows<CRAs...>( (*matrix).operand(), args... ) );
1275}
1277//*************************************************************************************************
1278
1279
1280//*************************************************************************************************
1293template< size_t... CRAs // Compile time row arguments
1294 , typename MT // Matrix base type of the expression
1295 , typename... RRAs // Runtime row arguments
1296 , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
1297inline decltype(auto) rows( const MatNoAliasExpr<MT>& matrix, RRAs... args )
1298{
1300
1301 return noalias( rows<CRAs...>( (*matrix).operand(), args... ) );
1302}
1304//*************************************************************************************************
1305
1306
1307//*************************************************************************************************
1320template< size_t... CRAs // Compile time row arguments
1321 , typename MT // Matrix base type of the expression
1322 , typename... RRAs // Runtime row arguments
1323 , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
1324inline decltype(auto) rows( const MatNoSIMDExpr<MT>& matrix, RRAs... args )
1325{
1327
1328 return nosimd( rows<CRAs...>( (*matrix).operand(), args... ) );
1329}
1331//*************************************************************************************************
1332
1333
1334//*************************************************************************************************
1347template< size_t... CRAs // Compile time row arguments
1348 , typename MT // Matrix base type of the expression
1349 , typename... RRAs // Runtime row arguments
1350 , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
1351inline decltype(auto) rows( const DeclExpr<MT>& matrix, RRAs... args )
1352{
1354
1355 return rows<CRAs...>( (*matrix).operand(), args... );
1356}
1358//*************************************************************************************************
1359
1360
1361//*************************************************************************************************
1374template< size_t... CRAs // Compile time row arguments
1375 , typename MT // Matrix base type of the expression
1376 , typename... RRAs // Runtime row arguments
1377 , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) >* = nullptr >
1378inline decltype(auto) rows( const MatTransExpr<MT>& matrix, RRAs... args )
1379{
1381
1382 try {
1383 return trans( columns<CRAs...>( (*matrix).operand(), args... ) );
1384 }
1385 catch( ... ) {
1386 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1387 }
1388}
1390//*************************************************************************************************
1391
1392
1393//*************************************************************************************************
1406template< size_t... CRAs // Compile time row arguments
1407 , typename MT // Matrix base type of the expression
1408 , size_t... CEAs // Compile time expansion arguments
1409 , typename... RRAs // Runtime row arguments
1410 , EnableIf_t< ( sizeof...( CRAs ) > 0UL ) &&
1411 IsRowMajorMatrix_v<MT> >* = nullptr >
1412inline decltype(auto) rows( const VecExpandExpr<MT,CEAs...>& matrix, RRAs... args )
1413{
1415
1416 if( isChecked( args... ) ) {
1417 constexpr size_t indices[] = { CRAs... };
1418 for( size_t i=0UL; i<sizeof...(CRAs); ++i ) {
1419 if( (*matrix).rows() <= indices[i] ) {
1420 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1421 }
1422 }
1423 }
1424
1425 return expand< sizeof...( CRAs ) >( (*matrix).operand() );
1426}
1428//*************************************************************************************************
1429
1430
1431//*************************************************************************************************
1446template< typename MT // Matrix base type of the expression
1447 , size_t... CEAs // Compile time expansion arguments
1448 , typename T // Type of the row indices or index producer
1449 , typename... RRAs // Runtime row arguments
1450 , EnableIf_t< IsRowMajorMatrix_v<MT> >* = nullptr >
1451inline decltype(auto) rows( const VecExpandExpr<MT,CEAs...>& matrix, T* indices, size_t n, RRAs... args )
1452{
1454
1455 if( isChecked( args... ) ) {
1456 for( size_t i=0UL; i<n; ++i ) {
1457 if( (*matrix).rows() <= size_t( indices[i] ) ) {
1458 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1459 }
1460 }
1461 }
1462
1463 return expand( (*matrix).operand(), n );
1464}
1466//*************************************************************************************************
1467
1468
1469//*************************************************************************************************
1484template< typename MT // Matrix base type of the expression
1485 , size_t... CEAs // Compile time expansion arguments
1486 , typename P // Type of the index producer
1487 , typename... RRAs // Runtime row arguments
1488 , EnableIf_t< IsRowMajorMatrix_v<MT> >* = nullptr >
1489inline decltype(auto) rows( const VecExpandExpr<MT,CEAs...>& matrix, P p, size_t n, RRAs... args )
1490{
1492
1493 if( isChecked( args... ) ) {
1494 for( size_t i=0UL; i<n; ++i ) {
1495 if( (*matrix).rows() <= size_t( p(i) ) ) {
1496 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1497 }
1498 }
1499 }
1500
1501 return expand( (*matrix).operand(), n );
1502}
1504//*************************************************************************************************
1505
1506
1507//*************************************************************************************************
1520template< size_t... CRAs // Compile time row arguments
1521 , typename MT // Matrix base type of the expression
1522 , size_t... CEAs // Compile time expansion arguments
1523 , typename... RRAs // Runtime row arguments
1524 , EnableIf_t< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) &&
1525 !IsRowMajorMatrix_v<MT> >* = nullptr >
1526inline decltype(auto) rows( const VecExpandExpr<MT,CEAs...>& matrix, RRAs... args )
1527{
1529
1530 try {
1531 return expand<CEAs...>( elements<CRAs...>( (*matrix).operand(), args... ), (*matrix).expansion() );
1532 }
1533 catch( ... ) {
1534 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1535 }
1536}
1538//*************************************************************************************************
1539
1540
1541//*************************************************************************************************
1554template< size_t I // First row index
1555 , size_t... Is // Remaining row indices
1556 , typename MT // Matrix base type of the expression
1557 , size_t... CRAs // Compile time repeater arguments
1558 , typename... RRAs > // Optional row arguments
1559inline decltype(auto) rows( const MatRepeatExpr<MT,CRAs...>& matrix, RRAs... args )
1560{
1562
1563 if( isChecked( args... ) ) {
1564 constexpr size_t indices[] = { I, Is... };
1565 for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1566 if( (*matrix).rows() <= indices[i] ) {
1567 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1568 }
1569 }
1570 }
1571
1572 auto lambda = [rows=(*matrix).operand().rows()]( size_t i ) {
1573 constexpr size_t indices[] = { I, Is... };
1574 return indices[i] % rows;
1575 };
1576
1577 return repeat( rows( (*matrix).operand(), std::move(lambda), sizeof...(Is)+1UL, unchecked )
1578 , 1UL, (*matrix).template repetitions<1UL>() );
1579}
1581//*************************************************************************************************
1582
1583
1584//*************************************************************************************************
1599template< typename MT // Matrix base type of the expression
1600 , size_t... CRAs // Compile time repeater arguments
1601 , typename T // Type of the row indices
1602 , typename... RRAs > // Optional row arguments
1603inline decltype(auto) rows( const MatRepeatExpr<MT,CRAs...>& matrix, T* indices, size_t n, RRAs... args )
1604{
1606
1607 if( isChecked( args... ) ) {
1608 for( size_t i=0UL; i<n; ++i ) {
1609 if( (*matrix).rows() <= size_t( indices[i] ) ) {
1610 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1611 }
1612 }
1613 }
1614
1615 SmallArray<size_t,128UL> newIndices( indices, indices+n );
1616
1617 for( size_t& index : newIndices ) {
1618 index = index % (*matrix).operand().rows();
1619 }
1620
1621 return repeat( rows( (*matrix).operand(), newIndices, unchecked )
1622 , 1UL, (*matrix).template repetitions<1UL>() );
1623}
1625//*************************************************************************************************
1626
1627
1628//*************************************************************************************************
1643template< typename MT // Matrix base type of the expression
1644 , size_t... CRAs // Compile time repeater arguments
1645 , typename P // Type of the index producer
1646 , typename... RRAs > // Optional row arguments
1647inline decltype(auto) rows( const MatRepeatExpr<MT,CRAs...>& matrix, P p, size_t n, RRAs... args )
1648{
1650
1651 if( isChecked( args... ) ) {
1652 for( size_t i=0UL; i<n; ++i ) {
1653 if( (*matrix).rows() <= size_t( p(i) ) ) {
1654 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1655 }
1656 }
1657 }
1658
1659 auto lambda = [rows=(*matrix).operand().rows(),p]( size_t i ) {
1660 return p(i) % rows;
1661 };
1662
1663 return repeat( rows( (*matrix).operand(), std::move(lambda), n, unchecked )
1664 , 1UL, (*matrix).template repetitions<1UL>() );
1665}
1667//*************************************************************************************************
1668
1669
1670
1671
1672//=================================================================================================
1673//
1674// GLOBAL RESTRUCTURING FUNCTIONS (ROWS)
1675//
1676//=================================================================================================
1677
1678//*************************************************************************************************
1689template< size_t I // First required row index
1690 , size_t... Is // Remaining required row indices
1691 , typename MT // Type of the matrix
1692 , typename... RRAs // Optional row arguments
1693 , EnableIf_t< IsRows_v< RemoveReference_t<MT> > &&
1694 RemoveReference_t<MT>::compileTimeArgs >* = nullptr >
1695inline decltype(auto) rows( MT&& r, RRAs... args )
1696{
1698
1699 return rows( r.operand(), subsequence<I,Is...>( RemoveReference_t<MT>::idces() ), args... );
1700}
1702//*************************************************************************************************
1703
1704
1705//*************************************************************************************************
1717template< size_t I // First required row index
1718 , size_t... Is // Remaining required row indices
1719 , typename MT // Type of the matrix
1720 , typename... RRAs // Optional row arguments
1721 , EnableIf_t< IsRows_v< RemoveReference_t<MT> > &&
1722 !RemoveReference_t<MT>::compileTimeArgs >* = nullptr >
1723inline decltype(auto) rows( MT&& r, RRAs... args )
1724{
1726
1727 if( isChecked( args... ) ) {
1728 constexpr size_t indices[] = { I, Is... };
1729 for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1730 if( r.rows() <= indices[i] ) {
1731 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1732 }
1733 }
1734 }
1735
1736 return rows( r.operand(), { r.idx(I), r.idx(Is)... }, unchecked );
1737}
1739//*************************************************************************************************
1740
1741
1742//*************************************************************************************************
1756template< typename MT // Type of the matrix
1757 , typename T // Type of the row indices
1758 , typename... RRAs // Optional row arguments
1759 , EnableIf_t< IsRows_v< RemoveReference_t<MT> > >* = nullptr >
1760inline decltype(auto) rows( MT&& r, T* indices, size_t n, RRAs... args )
1761{
1763
1764 if( isChecked( args... ) ) {
1765 for( size_t i=0UL; i<n; ++i ) {
1766 if( r.rows() <= size_t( indices[i] ) ) {
1767 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1768 }
1769 }
1770 }
1771
1772 SmallArray<size_t,128UL> newIndices;
1773 newIndices.reserve( n );
1774
1775 for( size_t i=0UL; i<n; ++i ) {
1776 newIndices.pushBack( r.idx( indices[i] ) );
1777 }
1778
1779 return rows( r.operand(), newIndices.data(), newIndices.size(), unchecked );
1780}
1782//*************************************************************************************************
1783
1784
1785//*************************************************************************************************
1799template< typename MT // Type of the matrix
1800 , typename P // Type of the index producer
1801 , typename... RRAs // Optional row arguments
1802 , EnableIf_t< IsRows_v< RemoveReference_t<MT> > && !IsPointer_v<P> >* = nullptr >
1803inline decltype(auto) rows( MT&& r, P p, size_t n, RRAs... args )
1804{
1806
1807 if( isChecked( args... ) ) {
1808 for( size_t i=0UL; i<n; ++i ) {
1809 if( r.rows() <= size_t( p(i) ) ) {
1810 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1811 }
1812 }
1813 }
1814
1815 SmallArray<size_t,128UL> newIndices;
1816 newIndices.reserve( n );
1817
1818 for( size_t i=0UL; i<n; ++i ) {
1819 newIndices.pushBack( r.idx( p(i) ) );
1820 }
1821
1822 return rows( r.operand(), newIndices.data(), newIndices.size(), unchecked );
1823}
1825//*************************************************************************************************
1826
1827
1828
1829
1830//=================================================================================================
1831//
1832// GLOBAL RESTRUCTURING FUNCTIONS (ELEMENTS)
1833//
1834//=================================================================================================
1835
1836//*************************************************************************************************
1849template< size_t... CEAs // Compile time element arguments
1850 , typename VT // Vector base type of the expression
1851 , typename... REAs > // Runtime element arguments
1852inline decltype(auto) elements( const MatVecMultExpr<VT>& vector, REAs... args )
1853{
1855
1856 try {
1857 return rows<CEAs...>( (*vector).leftOperand(), args... ) * (*vector).rightOperand();
1858 }
1859 catch( ... ) {
1860 BLAZE_THROW_INVALID_ARGUMENT( "Invalid element access index" );
1861 }
1862}
1864//*************************************************************************************************
1865
1866
1867//*************************************************************************************************
1881template< size_t... CEAs // Compile time element arguments
1882 , typename VT // Vector base type of the expression
1883 , typename... REAs > // Runtime element arguments
1884inline decltype(auto) elements( const MatReduceExpr<VT,rowwise>& vector, REAs... args )
1885{
1887
1888 try {
1889 return reduce<rowwise>( rows<CEAs...>( (*vector).operand(), args... ), (*vector).operation() );
1890 }
1891 catch( ... ) {
1892 BLAZE_THROW_INVALID_ARGUMENT( "Invalid element access index" );
1893 }
1894}
1896//*************************************************************************************************
1897
1898
1899
1900
1901//=================================================================================================
1902//
1903// GLOBAL RESTRUCTURING FUNCTIONS (ROW)
1904//
1905//=================================================================================================
1906
1907//*************************************************************************************************
1918template< size_t I // Row index
1919 , typename MT // Type of the matrix
1920 , typename... RRAs // Optional row arguments
1921 , EnableIf_t< IsRows_v< RemoveReference_t<MT> > &&
1922 RemoveReference_t<MT>::compileTimeArgs >* = nullptr >
1923inline decltype(auto) row( MT&& rows, RRAs... args )
1924{
1926
1927 return row< RemoveReference_t<MT>::idx(I) >( rows.operand(), args... );
1928}
1930//*************************************************************************************************
1931
1932
1933//*************************************************************************************************
1945template< size_t... CRAs // Compile time row arguments
1946 , typename MT // Type of the matrix
1947 , typename... RRAs // Runtime row arguments
1948 , EnableIf_t< IsRows_v< RemoveReference_t<MT> > &&
1949 ( sizeof...( CRAs ) == 0UL || !RemoveReference_t<MT>::compileTimeArgs ) >* = nullptr >
1950inline decltype(auto) row( MT&& rows, RRAs... args )
1951{
1953
1954 const RowData<CRAs...> rd( args... );
1955
1956 if( isChecked( args... ) ) {
1957 if( rows.rows() <= rd.row() ) {
1958 BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1959 }
1960 }
1961
1962 return row( rows.operand(), rows.idx( rd.row() ), unchecked );
1963}
1965//*************************************************************************************************
1966
1967
1968
1969
1970//=================================================================================================
1971//
1972// GLOBAL RESTRUCTURING FUNCTIONS (COLUMN)
1973//
1974//=================================================================================================
1975
1976//*************************************************************************************************
1988template< size_t... CCAs // Compile time column arguments
1989 , typename MT // Type of the matrix
1990 , typename... RCAs // Runtime column arguments
1991 , EnableIf_t< IsRows_v< RemoveReference_t<MT> > >* = nullptr >
1992inline decltype(auto) column( MT&& rows, RCAs... args )
1993{
1995
1996 return elements( column<CCAs...>( rows.operand(), args... ), rows.idces() );
1997}
1999//*************************************************************************************************
2000
2001
2002
2003
2004//=================================================================================================
2005//
2006// ROWS OPERATORS
2007//
2008//=================================================================================================
2009
2010//*************************************************************************************************
2036template< RelaxationFlag RF // Relaxation flag
2037 , typename MT // Type of the dense matrix
2038 , bool SO // Storage order
2039 , bool SF // Symmetry flag
2040 , typename... CRAs > // Compile time row arguments
2041inline bool isDefault( const Rows<MT,SO,true,SF,CRAs...>& rows )
2042{
2043 using blaze::isDefault;
2044
2045 if( SO == true ) {
2046 for( size_t i=0UL; i<rows.rows(); ++i )
2047 for( size_t j=0UL; j<rows.columns(); ++j )
2048 if( !isDefault<RF>( rows(i,j) ) )
2049 return false;
2050 }
2051 else {
2052 for( size_t j=0UL; j<rows.columns(); ++j )
2053 for( size_t i=0UL; i<rows.rows(); ++i )
2054 if( !isDefault<RF>( rows(i,j) ) )
2055 return false;
2056 }
2057
2058 return true;
2059}
2061//*************************************************************************************************
2062
2063
2064//*************************************************************************************************
2090template< RelaxationFlag RF // Relaxation flag
2091 , typename MT // Type of the dense matrix
2092 , bool SO // Storage order
2093 , bool SF // Symmetry flag
2094 , typename... CRAs > // Compile time row arguments
2095inline bool isDefault( const Rows<MT,SO,false,SF,CRAs...>& rows )
2096{
2097 using blaze::isDefault;
2098
2099 for( size_t i=0UL; i<rows.rows(); ++i ) {
2100 for( auto element=rows.cbegin(i); element!=rows.cend(i); ++element )
2101 if( !isDefault<RF>( element->value() ) ) return false;
2102 }
2103
2104 return true;
2105}
2107//*************************************************************************************************
2108
2109
2110//*************************************************************************************************
2129template< typename MT // Type of the matrix
2130 , bool SO // Storage order
2131 , bool DF // Density flag
2132 , bool SF // Symmetry flag
2133 , typename... CRAs > // Compile time row arguments
2134inline bool isIntact( const Rows<MT,SO,DF,SF,CRAs...>& rows ) noexcept
2135{
2136 return ( rows.rows() <= rows.operand().rows() &&
2137 rows.columns() == rows.operand().columns() &&
2138 isIntact( rows.operand() ) );
2139}
2141//*************************************************************************************************
2142
2143
2144//*************************************************************************************************
2157template< typename MT // Type of the matrix
2158 , bool SO1 // Storage order of the left-hand side row selection
2159 , bool DF // Density flag
2160 , bool SF // Symmetry flag
2161 , typename... CRAs // Compile time row arguments
2162 , bool SO2 > // Storage order of the right-hand side matrix
2163inline bool isSame( const Rows<MT,SO1,DF,SF,CRAs...>& a, const Matrix<MT,SO2>& b ) noexcept
2164{
2165 if( !isSame( a.operand(), *b ) || ( a.rows() != (*b).rows() ) || ( a.columns() != (*b).columns() ) )
2166 return false;
2167
2168 for( size_t i=0UL; i<a.rows(); ++i ) {
2169 if( a.idx(i) != i )
2170 return false;
2171 }
2172
2173 return true;
2174}
2176//*************************************************************************************************
2177
2178
2179//*************************************************************************************************
2192template< typename MT // Type of the matrix
2193 , bool SO1 // Storage order of the left-hand side matrix
2194 , bool DF // Density flag
2195 , bool SF // Symmetry flag
2196 , typename... CRAs // Compile time row arguments
2197 , bool SO2 > // Storage order of the right-hand side row selection
2198inline bool isSame( const Matrix<MT,SO1>& a, const Rows<MT,SO2,DF,SF,CRAs...>& b ) noexcept
2199{
2200 return isSame( b, a );
2201}
2203//*************************************************************************************************
2204
2205
2206//*************************************************************************************************
2219template< typename MT // Type of the matrix
2220 , bool SO1 // Storage order of the left-hand side row selection
2221 , bool DF // Density flag
2222 , bool SF // Symmetry flag
2223 , typename... CRAs // Compile time row arguments
2224 , AlignmentFlag AF // Alignment flag
2225 , bool SO2 // Storage order of the right-hand side submatrix
2226 , size_t... CSAs > // Compile time submatrix arguments
2227inline bool isSame( const Rows<MT,SO1,DF,SF,CRAs...>& a, const Submatrix<MT,AF,SO2,DF,CSAs...>& b ) noexcept
2228{
2229 if( !isSame( a.operand(), b.operand() ) || ( a.rows() != (*b).rows() ) || ( a.columns() != (*b).columns() ) )
2230 return false;
2231
2232 for( size_t i=0UL; i<a.rows(); ++i ) {
2233 if( a.idx(i) != b.row()+i )
2234 return false;
2235 }
2236
2237 return true;
2238}
2240//*************************************************************************************************
2241
2242
2243//*************************************************************************************************
2256template< typename MT // Type of the matrix
2257 , AlignmentFlag AF // Alignment flag
2258 , bool SO1 // Storage order of the left-hand side submatrix
2259 , bool DF // Density flag
2260 , size_t... CSAs // Compile time submatrix arguments
2261 , bool SO2 // Storage order of the right-hand side row selection
2262 , bool SF // Symmetry flag
2263 , typename... CRAs > // Compile time row arguments
2264inline bool isSame( const Submatrix<MT,AF,SO1,DF,CSAs...>& a, const Rows<MT,SO2,DF,SF,CRAs...>& b ) noexcept
2265{
2266 return isSame( b, a );
2267}
2269//*************************************************************************************************
2270
2271
2272//*************************************************************************************************
2285template< typename MT // Type of the matrix
2286 , bool SO // Storage order
2287 , bool DF // Density flag
2288 , bool SF // Symmetry flag
2289 , typename... CRAs1 // Compile time row arguments of the left-hand side row selection
2290 , typename... CRAs2 > // Compile time row arguments of the right-hand side row selection
2291inline bool isSame( const Rows<MT,SO,DF,SF,CRAs1...>& a,
2292 const Rows<MT,SO,DF,SF,CRAs2...>& b ) noexcept
2293{
2294 if( !isSame( a.operand(), b.operand() ) || a.rows() != b.rows() || a.columns() != b.columns() )
2295 return false;
2296
2297 for( size_t i=0UL; i<a.rows(); ++i ) {
2298 if( a.idx(i) != b.idx(i) )
2299 return false;
2300 }
2301
2302 return true;
2303}
2305//*************************************************************************************************
2306
2307
2308//*************************************************************************************************
2347template< InversionFlag IF // Inversion algorithm
2348 , typename MT // Type of the dense matrix
2349 , bool SO // Storage order
2350 , bool SF // Symmetry flag
2351 , typename... CRAs > // Compile time row arguments
2352inline auto invert( Rows<MT,SO,true,SF,CRAs...>& r )
2353 -> DisableIf_t< HasMutableDataAccess_v<MT> >
2354{
2355 using RT = ResultType_t< Rows<MT,SO,true,SF,CRAs...> >;
2356
2359
2360 RT tmp( r );
2361 invert<IF>( tmp );
2362 r = tmp;
2363}
2365//*************************************************************************************************
2366
2367
2368//*************************************************************************************************
2384template< typename MT // Type of the matrix
2385 , bool SO // Storage order
2386 , bool DF // Density flag
2387 , bool SF // Symmetry flag
2388 , typename... CRAs // Compile time row arguments
2389 , typename ET > // Type of the element
2390inline bool trySet( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
2391{
2392 BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2393 BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2394
2395 return trySet( r.operand(), r.idx(i), j, value );
2396}
2398//*************************************************************************************************
2399
2400
2401//*************************************************************************************************
2419template< typename MT // Type of the matrix
2420 , bool SO // Storage order
2421 , bool DF // Density flag
2422 , bool SF // Symmetry flag
2423 , typename... CRAs // Compile time row arguments
2424 , typename ET > // Type of the element
2426 trySet( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t row, size_t column, size_t m, size_t n, const ET& value )
2427{
2428 BLAZE_INTERNAL_ASSERT( row <= (*r).rows(), "Invalid row access index" );
2429 BLAZE_INTERNAL_ASSERT( column <= (*r).columns(), "Invalid column access index" );
2430 BLAZE_INTERNAL_ASSERT( row + m <= (*r).rows(), "Invalid number of rows" );
2431 BLAZE_INTERNAL_ASSERT( column + n <= (*r).columns(), "Invalid number of columns" );
2432
2433 const size_t iend( row + m );
2434
2435 for( size_t i=row; i<iend; ++i ) {
2436 if( !trySet( r.operand(), r.idx(i), column, 1UL, n, value ) )
2437 return false;
2438 }
2439
2440 return true;
2441}
2443//*************************************************************************************************
2444
2445
2446//*************************************************************************************************
2462template< typename MT // Type of the matrix
2463 , bool SO // Storage order
2464 , bool DF // Density flag
2465 , bool SF // Symmetry flag
2466 , typename... CRAs // Compile time row arguments
2467 , typename ET > // Type of the element
2468inline bool tryAdd( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
2469{
2470 BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2471 BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2472
2473 return tryAdd( r.operand(), r.idx(i), j, value );
2474}
2476//*************************************************************************************************
2477
2478
2479//*************************************************************************************************
2497template< typename MT // Type of the matrix
2498 , bool SO // Storage order
2499 , bool DF // Density flag
2500 , bool SF // Symmetry flag
2501 , typename... CRAs // Compile time row arguments
2502 , typename ET > // Type of the element
2504 tryAdd( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t row, size_t column, size_t m, size_t n, const ET& value )
2505{
2506 BLAZE_INTERNAL_ASSERT( row <= (*r).rows(), "Invalid row access index" );
2507 BLAZE_INTERNAL_ASSERT( column <= (*r).columns(), "Invalid column access index" );
2508 BLAZE_INTERNAL_ASSERT( row + m <= (*r).rows(), "Invalid number of rows" );
2509 BLAZE_INTERNAL_ASSERT( column + n <= (*r).columns(), "Invalid number of columns" );
2510
2511 const size_t iend( row + m );
2512
2513 for( size_t i=row; i<iend; ++i ) {
2514 if( !tryAdd( r.operand(), r.idx(i), column, 1UL, n, value ) )
2515 return false;
2516 }
2517
2518 return true;
2519}
2521//*************************************************************************************************
2522
2523
2524//*************************************************************************************************
2540template< typename MT // Type of the matrix
2541 , bool SO // Storage order
2542 , bool DF // Density flag
2543 , bool SF // Symmetry flag
2544 , typename... CRAs // Compile time row arguments
2545 , typename ET > // Type of the element
2546inline bool trySub( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
2547{
2548 BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2549 BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2550
2551 return trySub( r.operand(), r.idx(i), j, value );
2552}
2554//*************************************************************************************************
2555
2556
2557//*************************************************************************************************
2575template< typename MT // Type of the matrix
2576 , bool SO // Storage order
2577 , bool DF // Density flag
2578 , bool SF // Symmetry flag
2579 , typename... CRAs // Compile time row arguments
2580 , typename ET > // Type of the element
2582 trySub( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t row, size_t column, size_t m, size_t n, const ET& value )
2583{
2584 BLAZE_INTERNAL_ASSERT( row <= (*r).rows(), "Invalid row access index" );
2585 BLAZE_INTERNAL_ASSERT( column <= (*r).columns(), "Invalid column access index" );
2586 BLAZE_INTERNAL_ASSERT( row + m <= (*r).rows(), "Invalid number of rows" );
2587 BLAZE_INTERNAL_ASSERT( column + n <= (*r).columns(), "Invalid number of columns" );
2588
2589 const size_t iend( row + m );
2590
2591 for( size_t i=row; i<iend; ++i ) {
2592 if( !trySub( r.operand(), r.idx(i), column, 1UL, n, value ) )
2593 return false;
2594 }
2595
2596 return true;
2597}
2599//*************************************************************************************************
2600
2601
2602//*************************************************************************************************
2618template< typename MT // Type of the matrix
2619 , bool SO // Storage order
2620 , bool DF // Density flag
2621 , bool SF // Symmetry flag
2622 , typename... CRAs // Compile time row arguments
2623 , typename ET > // Type of the element
2624inline bool tryMult( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
2625{
2626 BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2627 BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2628
2629 return tryMult( r.operand(), r.idx(i), j, value );
2630}
2632//*************************************************************************************************
2633
2634
2635//*************************************************************************************************
2653template< typename MT // Type of the matrix
2654 , bool SO // Storage order
2655 , bool DF // Density flag
2656 , bool SF // Symmetry flag
2657 , typename... CRAs // Compile time row arguments
2658 , typename ET > // Type of the element
2660 tryMult( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t row, size_t column, size_t m, size_t n, const ET& value )
2661{
2662 BLAZE_INTERNAL_ASSERT( row <= (*r).rows(), "Invalid row access index" );
2663 BLAZE_INTERNAL_ASSERT( column <= (*r).columns(), "Invalid column access index" );
2664 BLAZE_INTERNAL_ASSERT( row + m <= (*r).rows(), "Invalid number of rows" );
2665 BLAZE_INTERNAL_ASSERT( column + n <= (*r).columns(), "Invalid number of columns" );
2666
2667 const size_t iend( row + m );
2668
2669 for( size_t i=row; i<iend; ++i ) {
2670 if( !tryMult( r.operand(), r.idx(i), column, 1UL, n, value ) )
2671 return false;
2672 }
2673
2674 return true;
2675}
2677//*************************************************************************************************
2678
2679
2680//*************************************************************************************************
2696template< typename MT // Type of the matrix
2697 , bool SO // Storage order
2698 , bool DF // Density flag
2699 , bool SF // Symmetry flag
2700 , typename... CRAs // Compile time row arguments
2701 , typename ET > // Type of the element
2702inline bool tryDiv( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
2703{
2704 BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2705 BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2706
2707 return tryDiv( r.operand(), r.idx(i), j, value );
2708}
2710//*************************************************************************************************
2711
2712
2713//*************************************************************************************************
2731template< typename MT // Type of the matrix
2732 , bool SO // Storage order
2733 , bool DF // Density flag
2734 , bool SF // Symmetry flag
2735 , typename... CRAs // Compile time row arguments
2736 , typename ET > // Type of the element
2738 tryDiv( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t row, size_t column, size_t m, size_t n, const ET& value )
2739{
2740 BLAZE_INTERNAL_ASSERT( row <= (*r).rows(), "Invalid row access index" );
2741 BLAZE_INTERNAL_ASSERT( column <= (*r).columns(), "Invalid column access index" );
2742 BLAZE_INTERNAL_ASSERT( row + m <= (*r).rows(), "Invalid number of rows" );
2743 BLAZE_INTERNAL_ASSERT( column + n <= (*r).columns(), "Invalid number of columns" );
2744
2745 const size_t iend( row + m );
2746
2747 for( size_t i=row; i<iend; ++i ) {
2748 if( !tryDiv( r.operand(), r.idx(i), column, 1UL, n, value ) )
2749 return false;
2750 }
2751
2752 return true;
2753}
2755//*************************************************************************************************
2756
2757
2758//*************************************************************************************************
2774template< typename MT // Type of the matrix
2775 , bool SO // Storage order
2776 , bool DF // Density flag
2777 , bool SF // Symmetry flag
2778 , typename... CRAs > // Compile time row arguments
2779inline bool tryShift( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, int count )
2780{
2781 BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2782 BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2783
2784 return tryShift( r.operand(), r.idx(i), j, count );
2785}
2787//*************************************************************************************************
2788
2789
2790//*************************************************************************************************
2808template< typename MT // Type of the matrix
2809 , bool SO // Storage order
2810 , bool DF // Density flag
2811 , bool SF // Symmetry flag
2812 , typename... CRAs > // Compile time row arguments
2814 tryShift( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t row, size_t column, size_t m, size_t n, int count )
2815{
2816 BLAZE_INTERNAL_ASSERT( row <= (*r).rows(), "Invalid row access index" );
2817 BLAZE_INTERNAL_ASSERT( column <= (*r).columns(), "Invalid column access index" );
2818 BLAZE_INTERNAL_ASSERT( row + m <= (*r).rows(), "Invalid number of rows" );
2819 BLAZE_INTERNAL_ASSERT( column + n <= (*r).columns(), "Invalid number of columns" );
2820
2821 const size_t iend( row + m );
2822
2823 for( size_t i=row; i<iend; ++i ) {
2824 if( !tryShift( r.operand(), r.idx(i), column, 1UL, n, count ) )
2825 return false;
2826 }
2827
2828 return true;
2829}
2831//*************************************************************************************************
2832
2833
2834//*************************************************************************************************
2850template< typename MT // Type of the matrix
2851 , bool SO // Storage order
2852 , bool DF // Density flag
2853 , bool SF // Symmetry flag
2854 , typename... CRAs // Compile time row arguments
2855 , typename ET > // Type of the element
2856inline bool tryBitand( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
2857{
2858 BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2859 BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2860
2861 return tryBitand( r.operand(), r.idx(i), j, value );
2862}
2864//*************************************************************************************************
2865
2866
2867//*************************************************************************************************
2885template< typename MT // Type of the matrix
2886 , bool SO // Storage order
2887 , bool DF // Density flag
2888 , bool SF // Symmetry flag
2889 , typename... CRAs // Compile time row arguments
2890 , typename ET > // Type of the element
2892 tryBitand( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t row, size_t column, size_t m, size_t n, const ET& value )
2893{
2894 BLAZE_INTERNAL_ASSERT( row <= (*r).rows(), "Invalid row access index" );
2895 BLAZE_INTERNAL_ASSERT( column <= (*r).columns(), "Invalid column access index" );
2896 BLAZE_INTERNAL_ASSERT( row + m <= (*r).rows(), "Invalid number of rows" );
2897 BLAZE_INTERNAL_ASSERT( column + n <= (*r).columns(), "Invalid number of columns" );
2898
2899 const size_t iend( row + m );
2900
2901 for( size_t i=row; i<iend; ++i ) {
2902 if( !tryBitand( r.operand(), r.idx(i), column, 1UL, n, value ) )
2903 return false;
2904 }
2905
2906 return true;
2907}
2909//*************************************************************************************************
2910
2911
2912//*************************************************************************************************
2928template< typename MT // Type of the matrix
2929 , bool SO // Storage order
2930 , bool DF // Density flag
2931 , bool SF // Symmetry flag
2932 , typename... CRAs // Compile time row arguments
2933 , typename ET > // Type of the element
2934inline bool tryBitor( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
2935{
2936 BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2937 BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2938
2939 return tryBitor( r.operand(), r.idx(i), j, value );
2940}
2942//*************************************************************************************************
2943
2944
2945//*************************************************************************************************
2963template< typename MT // Type of the matrix
2964 , bool SO // Storage order
2965 , bool DF // Density flag
2966 , bool SF // Symmetry flag
2967 , typename... CRAs // Compile time row arguments
2968 , typename ET > // Type of the element
2970 tryBitor( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t row, size_t column, size_t m, size_t n, const ET& value )
2971{
2972 BLAZE_INTERNAL_ASSERT( row <= (*r).rows(), "Invalid row access index" );
2973 BLAZE_INTERNAL_ASSERT( column <= (*r).columns(), "Invalid column access index" );
2974 BLAZE_INTERNAL_ASSERT( row + m <= (*r).rows(), "Invalid number of rows" );
2975 BLAZE_INTERNAL_ASSERT( column + n <= (*r).columns(), "Invalid number of columns" );
2976
2977 const size_t iend( row + m );
2978
2979 for( size_t i=row; i<iend; ++i ) {
2980 if( !tryBitor( r.operand(), r.idx(i), column, 1UL, n, value ) )
2981 return false;
2982 }
2983
2984 return true;
2985}
2987//*************************************************************************************************
2988
2989
2990//*************************************************************************************************
3006template< typename MT // Type of the matrix
3007 , bool SO // Storage order
3008 , bool DF // Density flag
3009 , bool SF // Symmetry flag
3010 , typename... CRAs // Compile time row arguments
3011 , typename ET > // Type of the element
3012inline bool tryBitxor( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
3013{
3014 BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
3015 BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
3016
3017 return tryBitxor( r.operand(), r.idx(i), j, value );
3018}
3020//*************************************************************************************************
3021
3022
3023//*************************************************************************************************
3041template< typename MT // Type of the matrix
3042 , bool SO // Storage order
3043 , bool DF // Density flag
3044 , bool SF // Symmetry flag
3045 , typename... CRAs // Compile time row arguments
3046 , typename ET > // Type of the element
3048 tryBitxor( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t row, size_t column, size_t m, size_t n, const ET& value )
3049{
3050 BLAZE_INTERNAL_ASSERT( row <= (*r).rows(), "Invalid row access index" );
3051 BLAZE_INTERNAL_ASSERT( column <= (*r).columns(), "Invalid column access index" );
3052 BLAZE_INTERNAL_ASSERT( row + m <= (*r).rows(), "Invalid number of rows" );
3053 BLAZE_INTERNAL_ASSERT( column + n <= (*r).columns(), "Invalid number of columns" );
3054
3055 const size_t iend( row + m );
3056
3057 for( size_t i=row; i<iend; ++i ) {
3058 if( !tryBitxor( r.operand(), r.idx(i), column, 1UL, n, value ) )
3059 return false;
3060 }
3061
3062 return true;
3063}
3065//*************************************************************************************************
3066
3067
3068//*************************************************************************************************
3084template< typename MT // Type of the matrix
3085 , bool SO // Storage order
3086 , bool DF // Density flag
3087 , bool SF // Symmetry flag
3088 , typename... CRAs // Compile time row arguments
3089 , typename VT > // Type of the right-hand side vector
3090inline bool tryAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3091 const Vector<VT,false>& rhs, size_t row, size_t column )
3092{
3093 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3094 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3095 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3096
3097 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3098 if( !trySet( lhs.operand(), lhs.idx( row+i ), column, (*rhs)[i] ) )
3099 return false;
3100 }
3101
3102 return true;
3103}
3105//*************************************************************************************************
3106
3107
3108//*************************************************************************************************
3124template< 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
3130inline bool tryAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3131 const Vector<VT,true>& 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( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3136
3137 return tryAssign( lhs.operand(), *rhs, lhs.idx( row ), column );
3138}
3140//*************************************************************************************************
3141
3142
3143//*************************************************************************************************
3160template< typename MT // Type of the matrix
3161 , bool SO // Storage order
3162 , bool DF // Density flag
3163 , bool SF // Symmetry flag
3164 , typename... CRAs // Compile time row arguments
3165 , typename VT // Type of the right-hand side vector
3166 , bool TF > // Transpose flag of the right-hand side vector
3167inline bool tryAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3168 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3169{
3170 MAYBE_UNUSED( band );
3171
3172 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3173 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3174 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3175 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3176
3177 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3178 if( !trySet( lhs.operand(), lhs.idx( row+i ), column+i, (*rhs)[i] ) )
3179 return false;
3180 }
3181
3182 return true;
3183}
3185//*************************************************************************************************
3186
3187
3188//*************************************************************************************************
3204template< typename MT1 // Type of the matrix
3205 , bool SO1 // Storage order
3206 , bool DF // Density flag
3207 , bool SF // Symmetry flag
3208 , typename... CRAs // Compile time row arguments
3209 , typename MT2 // Type of the right-hand side matrix
3210 , bool SO2 > // Storage order of the right-hand side matrix
3211inline bool tryAssign( const Rows<MT1,SO1,DF,SF,CRAs...>& lhs,
3212 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3213{
3214 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3215 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3216 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
3217 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3218
3219 for( size_t i=0UL; i<(*rhs).rows(); ++i ) {
3220 if( !tryAssign( lhs.operand(), blaze::row( *rhs, i, unchecked ), lhs.idx( row+i ), column ) )
3221 return false;
3222 }
3223
3224 return true;
3225}
3227//*************************************************************************************************
3228
3229
3230//*************************************************************************************************
3247template< typename MT // Type of the matrix
3248 , bool SO // Storage order
3249 , bool DF // Density flag
3250 , bool SF // Symmetry flag
3251 , typename... CRAs // Compile time row arguments
3252 , typename VT > // Type of the right-hand side vector
3253inline bool tryAddAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3254 const Vector<VT,false>& rhs, size_t row, size_t column )
3255{
3256 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3257 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3258 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3259
3260 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3261 if( !tryAdd( lhs.operand(), lhs.idx( row+i ), column, (*rhs)[i] ) )
3262 return false;
3263 }
3264
3265 return true;
3266}
3268//*************************************************************************************************
3269
3270
3271//*************************************************************************************************
3287template< typename MT // Type of the matrix
3288 , bool SO // Storage order
3289 , bool DF // Density flag
3290 , bool SF // Symmetry flag
3291 , typename... CRAs // Compile time row arguments
3292 , typename VT > // Type of the right-hand side vector
3293inline bool tryAddAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3294 const Vector<VT,true>& rhs, size_t row, size_t column )
3295{
3296 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3297 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3298 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3299
3300 return tryAddAssign( lhs.operand(), *rhs, lhs.idx( row ), column );
3301}
3303//*************************************************************************************************
3304
3305
3306//*************************************************************************************************
3324template< typename MT // Type of the matrix
3325 , bool SO // Storage order
3326 , bool DF // Density flag
3327 , bool SF // Symmetry flag
3328 , typename... CRAs // Compile time row arguments
3329 , typename VT // Type of the right-hand side vector
3330 , bool TF > // Transpose flag of the right-hand side vector
3331inline bool tryAddAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3332 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3333{
3334 MAYBE_UNUSED( band );
3335
3336 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3337 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3338 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3339 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3340
3341 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3342 if( !tryAdd( lhs.operand(), lhs.idx( row+i ), column+i, (*rhs)[i] ) )
3343 return false;
3344 }
3345
3346 return true;
3347}
3349//*************************************************************************************************
3350
3351
3352//*************************************************************************************************
3368template< typename MT1 // Type of the matrix
3369 , bool SO1 // Storage order
3370 , bool DF // Density flag
3371 , bool SF // Symmetry flag
3372 , typename... CRAs // Compile time row arguments
3373 , typename MT2 // Type of the right-hand side matrix
3374 , bool SO2 > // Storage order of the right-hand side matrix
3375inline bool tryAddAssign( const Rows<MT1,SO1,DF,SF,CRAs...>& lhs,
3376 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
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).rows() <= lhs.rows(), "Invalid number of rows" );
3381 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3382
3383 for( size_t i=0UL; i<(*rhs).rows(); ++i ) {
3384 if( !tryAddAssign( lhs.operand(), blaze::row( *rhs, i, unchecked ), lhs.idx( row+i ), column ) )
3385 return false;
3386 }
3387
3388 return true;
3389}
3391//*************************************************************************************************
3392
3393
3394//*************************************************************************************************
3411template< typename MT // Type of the matrix
3412 , bool SO // Storage order
3413 , bool DF // Density flag
3414 , bool SF // Symmetry flag
3415 , typename... CRAs // Compile time row arguments
3416 , typename VT > // Type of the right-hand side vector
3417inline bool trySubAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3418 const Vector<VT,false>& 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).size() <= lhs.rows(), "Invalid number of rows" );
3423
3424 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3425 if( !trySub( lhs.operand(), lhs.idx( row+i ), column, (*rhs)[i] ) )
3426 return false;
3427 }
3428
3429 return true;
3430}
3432//*************************************************************************************************
3433
3434
3435//*************************************************************************************************
3452template< typename MT // Type of the matrix
3453 , bool SO // Storage order
3454 , bool DF // Density flag
3455 , bool SF // Symmetry flag
3456 , typename... CRAs // Compile time row arguments
3457 , typename VT > // Type of the right-hand side vector
3458inline bool trySubAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3459 const Vector<VT,true>& rhs, size_t row, size_t column )
3460{
3461 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3462 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3463 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3464
3465 return trySubAssign( lhs.operand(), *rhs, lhs.idx( row ), column );
3466}
3468//*************************************************************************************************
3469
3470
3471//*************************************************************************************************
3489template< typename MT // Type of the matrix
3490 , bool SO // Storage order
3491 , bool DF // Density flag
3492 , bool SF // Symmetry flag
3493 , typename... CRAs // Compile time row arguments
3494 , typename VT // Type of the right-hand side vector
3495 , bool TF > // Transpose flag of the right-hand side vector
3496inline bool trySubAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3497 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3498{
3499 MAYBE_UNUSED( band );
3500
3501 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3502 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3503 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3504 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3505
3506 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3507 if( !trySub( lhs.operand(), lhs.idx( row+i ), column+i, (*rhs)[i] ) )
3508 return false;
3509 }
3510
3511 return true;
3512}
3514//*************************************************************************************************
3515
3516
3517//*************************************************************************************************
3533template< typename MT1 // Type of the matrix
3534 , bool SO1 // Storage order
3535 , bool DF // Density flag
3536 , bool SF // Symmetry flag
3537 , typename... CRAs // Compile time row arguments
3538 , typename MT2 // Type of the right-hand side matrix
3539 , bool SO2 > // Storage order of the right-hand side matrix
3540inline bool trySubAssign( const Rows<MT1,SO1,DF,SF,CRAs...>& lhs,
3541 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3542{
3543 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3544 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3545 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
3546 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3547
3548 for( size_t i=0UL; i<(*rhs).rows(); ++i ) {
3549 if( !trySubAssign( lhs.operand(), blaze::row( *rhs, i, unchecked ), lhs.idx( row+i ), column ) )
3550 return false;
3551 }
3552
3553 return true;
3554}
3556//*************************************************************************************************
3557
3558
3559//*************************************************************************************************
3576template< typename MT // Type of the matrix
3577 , bool SO // Storage order
3578 , bool DF // Density flag
3579 , bool SF // Symmetry flag
3580 , typename... CRAs // Compile time row arguments
3581 , typename VT > // Type of the right-hand side vector
3582inline bool tryMultAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3583 const Vector<VT,false>& rhs, size_t row, size_t column )
3584{
3585 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3586 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3587 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3588
3589 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3590 if( !tryMult( lhs.operand(), lhs.idx( row+i ), column, (*rhs)[i] ) )
3591 return false;
3592 }
3593
3594 return true;
3595}
3597//*************************************************************************************************
3598
3599
3600//*************************************************************************************************
3617template< typename MT // Type of the matrix
3618 , bool SO // Storage order
3619 , bool DF // Density flag
3620 , bool SF // Symmetry flag
3621 , typename... CRAs // Compile time row arguments
3622 , typename VT > // Type of the right-hand side vector
3623inline bool tryMultAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3624 const Vector<VT,true>& rhs, size_t row, size_t column )
3625{
3626 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3627 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3628 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3629
3630 return tryMultAssign( lhs.operand(), *rhs, lhs.idx( row ), column );
3631}
3633//*************************************************************************************************
3634
3635
3636//*************************************************************************************************
3654template< typename MT // Type of the matrix
3655 , bool SO // Storage order
3656 , bool DF // Density flag
3657 , bool SF // Symmetry flag
3658 , typename... CRAs // Compile time row arguments
3659 , typename VT // Type of the right-hand side vector
3660 , bool TF > // Transpose flag of the right-hand side vector
3661inline bool tryMultAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3662 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3663{
3664 MAYBE_UNUSED( band );
3665
3666 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3667 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3668 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3669 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3670
3671 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3672 if( !tryMult( lhs.operand(), lhs.idx( row+i ), column+i, (*rhs)[i] ) )
3673 return false;
3674 }
3675
3676 return true;
3677}
3679//*************************************************************************************************
3680
3681
3682//*************************************************************************************************
3699template< typename MT1 // Type of the matrix
3700 , bool SO1 // Storage order
3701 , bool DF // Density flag
3702 , bool SF // Symmetry flag
3703 , typename... CRAs // Compile time row arguments
3704 , typename MT2 // Type of the right-hand side matrix
3705 , bool SO2 > // Storage order of the right-hand side matrix
3706inline bool trySchurAssign( const Rows<MT1,SO1,DF,SF,CRAs...>& lhs,
3707 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3708{
3709 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3710 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3711 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
3712 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3713
3714 for( size_t i=0UL; i<(*rhs).rows(); ++i ) {
3715 if( !tryMultAssign( lhs.operand(), blaze::row( *rhs, i, unchecked ), lhs.idx( row+i ), column ) )
3716 return false;
3717 }
3718
3719 return true;
3720}
3722//*************************************************************************************************
3723
3724
3725//*************************************************************************************************
3742template< typename MT // Type of the matrix
3743 , bool SO // Storage order
3744 , bool DF // Density flag
3745 , bool SF // Symmetry flag
3746 , typename... CRAs // Compile time row arguments
3747 , typename VT > // Type of the right-hand side vector
3748inline bool tryDivAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3749 const Vector<VT,false>& rhs, size_t row, size_t column )
3750{
3751 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3752 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3753 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3754
3755 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3756 if( !tryDiv( lhs.operand(), lhs.idx( row+i ), column, (*rhs)[i] ) )
3757 return false;
3758 }
3759
3760 return true;
3761}
3763//*************************************************************************************************
3764
3765
3766//*************************************************************************************************
3782template< typename MT // Type of the matrix
3783 , bool SO // Storage order
3784 , bool DF // Density flag
3785 , bool SF // Symmetry flag
3786 , typename... CRAs // Compile time row arguments
3787 , typename VT > // Type of the right-hand side vector
3788inline bool tryDivAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3789 const Vector<VT,true>& rhs, size_t row, size_t column )
3790{
3791 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3792 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3793 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3794
3795 return tryDivAssign( lhs.operand(), *rhs, lhs.idx( row ), column );
3796}
3798//*************************************************************************************************
3799
3800
3801//*************************************************************************************************
3819template< typename MT // Type of the matrix
3820 , bool SO // Storage order
3821 , bool DF // Density flag
3822 , bool SF // Symmetry flag
3823 , typename... CRAs // Compile time row arguments
3824 , typename VT // Type of the right-hand side vector
3825 , bool TF > // Transpose flag of the right-hand side vector
3826inline bool tryDivAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3827 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3828{
3829 MAYBE_UNUSED( band );
3830
3831 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3832 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3833 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3834 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3835
3836 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3837 if( !tryDiv( lhs.operand(), lhs.idx( row+i ), column+i, (*rhs)[i] ) )
3838 return false;
3839 }
3840
3841 return true;
3842}
3844//*************************************************************************************************
3845
3846
3847//*************************************************************************************************
3864template< typename MT // Type of the matrix
3865 , bool SO // Storage order
3866 , bool DF // Density flag
3867 , bool SF // Symmetry flag
3868 , typename... CRAs // Compile time row arguments
3869 , typename VT > // Type of the right-hand side vector
3870inline bool tryShiftAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3871 const Vector<VT,false>& rhs, size_t row, size_t column )
3872{
3873 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3874 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3875 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3876
3877 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3878 if( !tryShift( lhs.operand(), lhs.idx( row+i ), column, (*rhs)[i] ) )
3879 return false;
3880 }
3881
3882 return true;
3883}
3885//*************************************************************************************************
3886
3887
3888//*************************************************************************************************
3904template< typename MT // Type of the matrix
3905 , bool SO // Storage order
3906 , bool DF // Density flag
3907 , bool SF // Symmetry flag
3908 , typename... CRAs // Compile time row arguments
3909 , typename VT > // Type of the right-hand side vector
3910inline bool tryShiftAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3911 const Vector<VT,true>& rhs, size_t row, size_t column )
3912{
3913 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3914 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3915 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3916
3917 return tryShiftAssign( lhs.operand(), *rhs, lhs.idx( row ), column );
3918}
3920//*************************************************************************************************
3921
3922
3923//*************************************************************************************************
3941template< typename MT // Type of the matrix
3942 , bool SO // Storage order
3943 , bool DF // Density flag
3944 , bool SF // Symmetry flag
3945 , typename... CRAs // Compile time row arguments
3946 , typename VT // Type of the right-hand side vector
3947 , bool TF > // Transpose flag of the right-hand side vector
3948inline bool tryShiftAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3949 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3950{
3951 MAYBE_UNUSED( band );
3952
3953 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3954 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3955 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3956 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3957
3958 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3959 if( !tryShift( lhs.operand(), lhs.idx( row+i ), column+i, (*rhs)[i] ) )
3960 return false;
3961 }
3962
3963 return true;
3964}
3966//*************************************************************************************************
3967
3968
3969//*************************************************************************************************
3985template< typename MT1 // Type of the matrix
3986 , bool SO1 // Storage order
3987 , bool DF // Density flag
3988 , bool SF // Symmetry flag
3989 , typename... CRAs // Compile time row arguments
3990 , typename MT2 // Type of the right-hand side matrix
3991 , bool SO2 > // Storage order of the right-hand side matrix
3992inline bool tryShiftAssign( const Rows<MT1,SO1,DF,SF,CRAs...>& lhs,
3993 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3994{
3995 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3996 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3997 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
3998 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3999
4000 for( size_t i=0UL; i<(*rhs).rows(); ++i ) {
4001 if( !tryShiftAssign( lhs.operand(), blaze::row( *rhs, i, unchecked ), lhs.idx( row+i ), column ) )
4002 return false;
4003 }
4004
4005 return true;
4006}
4008//*************************************************************************************************
4009
4010
4011//*************************************************************************************************
4028template< typename MT // Type of the matrix
4029 , bool SO // Storage order
4030 , bool DF // Density flag
4031 , bool SF // Symmetry flag
4032 , typename... CRAs // Compile time row arguments
4033 , typename VT > // Type of the right-hand side vector
4034inline bool tryBitandAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
4035 const Vector<VT,false>& rhs, size_t row, size_t column )
4036{
4037 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4038 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4039 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4040
4041 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
4042 if( !tryBitand( lhs.operand(), lhs.idx( row+i ), column, (*rhs)[i] ) )
4043 return false;
4044 }
4045
4046 return true;
4047}
4049//*************************************************************************************************
4050
4051
4052//*************************************************************************************************
4069template< typename MT // Type of the matrix
4070 , bool SO // Storage order
4071 , bool DF // Density flag
4072 , bool SF // Symmetry flag
4073 , typename... CRAs // Compile time row arguments
4074 , typename VT > // Type of the right-hand side vector
4075inline bool tryBitandAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
4076 const Vector<VT,true>& rhs, size_t row, size_t column )
4077{
4078 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4079 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4080 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4081
4082 return tryBitandAssign( lhs.operand(), *rhs, lhs.idx( row ), column );
4083}
4085//*************************************************************************************************
4086
4087
4088//*************************************************************************************************
4106template< typename MT // Type of the matrix
4107 , bool SO // Storage order
4108 , bool DF // Density flag
4109 , bool SF // Symmetry flag
4110 , typename... CRAs // Compile time row arguments
4111 , typename VT // Type of the right-hand side vector
4112 , bool TF > // Transpose flag of the right-hand side vector
4113inline bool tryBitandAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
4114 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
4115{
4116 MAYBE_UNUSED( band );
4117
4118 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4119 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4120 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4121 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4122
4123 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
4124 if( !tryBitand( lhs.operand(), lhs.idx( row+i ), column+i, (*rhs)[i] ) )
4125 return false;
4126 }
4127
4128 return true;
4129}
4131//*************************************************************************************************
4132
4133
4134//*************************************************************************************************
4150template< typename MT1 // Type of the matrix
4151 , bool SO1 // Storage order
4152 , bool DF // Density flag
4153 , bool SF // Symmetry flag
4154 , typename... CRAs // Compile time row arguments
4155 , typename MT2 // Type of the right-hand side matrix
4156 , bool SO2 > // Storage order of the right-hand side matrix
4157inline bool tryBitandAssign( const Rows<MT1,SO1,DF,SF,CRAs...>& lhs,
4158 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
4159{
4160 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4161 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4162 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
4163 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
4164
4165 for( size_t i=0UL; i<(*rhs).rows(); ++i ) {
4166 if( !tryBitandAssign( lhs.operand(), blaze::row( *rhs, i, unchecked ), lhs.idx( row+i ), column ) )
4167 return false;
4168 }
4169
4170 return true;
4171}
4173//*************************************************************************************************
4174
4175
4176//*************************************************************************************************
4193template< typename MT // Type of the matrix
4194 , bool SO // Storage order
4195 , bool DF // Density flag
4196 , bool SF // Symmetry flag
4197 , typename... CRAs // Compile time row arguments
4198 , typename VT > // Type of the right-hand side vector
4199inline bool tryBitorAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
4200 const Vector<VT,false>& rhs, size_t row, size_t column )
4201{
4202 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4203 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4204 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4205
4206 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
4207 if( !tryBitor( lhs.operand(), lhs.idx( row+i ), column, (*rhs)[i] ) )
4208 return false;
4209 }
4210
4211 return true;
4212}
4214//*************************************************************************************************
4215
4216
4217//*************************************************************************************************
4234template< typename MT // Type of the matrix
4235 , bool SO // Storage order
4236 , bool DF // Density flag
4237 , bool SF // Symmetry flag
4238 , typename... CRAs // Compile time row arguments
4239 , typename VT > // Type of the right-hand side vector
4240inline bool tryBitorAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
4241 const Vector<VT,true>& rhs, size_t row, size_t column )
4242{
4243 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4244 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4245 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4246
4247 return tryBitorAssign( lhs.operand(), *rhs, lhs.idx( row ), column );
4248}
4250//*************************************************************************************************
4251
4252
4253//*************************************************************************************************
4271template< typename MT // Type of the matrix
4272 , bool SO // Storage order
4273 , bool DF // Density flag
4274 , bool SF // Symmetry flag
4275 , typename... CRAs // Compile time row arguments
4276 , typename VT // Type of the right-hand side vector
4277 , bool TF > // Transpose flag of the right-hand side vector
4278inline bool tryBitorAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
4279 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
4280{
4281 MAYBE_UNUSED( band );
4282
4283 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4284 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4285 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4286 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4287
4288 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
4289 if( !tryBitor( lhs.operand(), lhs.idx( row+i ), column+i, (*rhs)[i] ) )
4290 return false;
4291 }
4292
4293 return true;
4294}
4296//*************************************************************************************************
4297
4298
4299//*************************************************************************************************
4315template< typename MT1 // Type of the matrix
4316 , bool SO1 // Storage order
4317 , bool DF // Density flag
4318 , bool SF // Symmetry flag
4319 , typename... CRAs // Compile time row arguments
4320 , typename MT2 // Type of the right-hand side matrix
4321 , bool SO2 > // Storage order of the right-hand side matrix
4322inline bool tryBitorAssign( const Rows<MT1,SO1,DF,SF,CRAs...>& lhs,
4323 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
4324{
4325 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4326 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4327 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
4328 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
4329
4330 for( size_t i=0UL; i<(*rhs).rows(); ++i ) {
4331 if( !tryBitorAssign( lhs.operand(), blaze::row( *rhs, i, unchecked ), lhs.idx( row+i ), column ) )
4332 return false;
4333 }
4334
4335 return true;
4336}
4338//*************************************************************************************************
4339
4340
4341//*************************************************************************************************
4358template< typename MT // Type of the matrix
4359 , bool SO // Storage order
4360 , bool DF // Density flag
4361 , bool SF // Symmetry flag
4362 , typename... CRAs // Compile time row arguments
4363 , typename VT > // Type of the right-hand side vector
4364inline bool tryBitxorAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
4365 const Vector<VT,false>& rhs, size_t row, size_t column )
4366{
4367 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4368 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4369 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4370
4371 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
4372 if( !tryBitxor( lhs.operand(), lhs.idx( row+i ), column, (*rhs)[i] ) )
4373 return false;
4374 }
4375
4376 return true;
4377}
4379//*************************************************************************************************
4380
4381
4382//*************************************************************************************************
4399template< typename MT // Type of the matrix
4400 , bool SO // Storage order
4401 , bool DF // Density flag
4402 , bool SF // Symmetry flag
4403 , typename... CRAs // Compile time row arguments
4404 , typename VT > // Type of the right-hand side vector
4405inline bool tryBitxorAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
4406 const Vector<VT,true>& rhs, size_t row, size_t column )
4407{
4408 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4409 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4410 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4411
4412 return tryBitxorAssign( lhs.operand(), *rhs, lhs.idx( row ), column );
4413}
4415//*************************************************************************************************
4416
4417
4418//*************************************************************************************************
4436template< typename MT // Type of the matrix
4437 , bool SO // Storage order
4438 , bool DF // Density flag
4439 , bool SF // Symmetry flag
4440 , typename... CRAs // Compile time row arguments
4441 , typename VT // Type of the right-hand side vector
4442 , bool TF > // Transpose flag of the right-hand side vector
4443inline bool tryBitxorAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
4444 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
4445{
4446 MAYBE_UNUSED( band );
4447
4448 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4449 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4450 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4451 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4452
4453 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
4454 if( !tryBitxor( lhs.operand(), lhs.idx( row+i ), column+i, (*rhs)[i] ) )
4455 return false;
4456 }
4457
4458 return true;
4459}
4461//*************************************************************************************************
4462
4463
4464//*************************************************************************************************
4480template< typename MT1 // Type of the matrix
4481 , bool SO1 // Storage order
4482 , bool DF // Density flag
4483 , bool SF // Symmetry flag
4484 , typename... CRAs // Compile time row arguments
4485 , typename MT2 // Type of the right-hand side matrix
4486 , bool SO2 > // Storage order of the right-hand side matrix
4487inline bool tryBitxorAssign( const Rows<MT1,SO1,DF,SF,CRAs...>& lhs,
4488 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
4489{
4490 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4491 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4492 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
4493 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
4494
4495 for( size_t i=0UL; i<(*rhs).rows(); ++i ) {
4496 if( !tryBitxorAssign( lhs.operand(), blaze::row( *rhs, i, unchecked ), lhs.idx( row+i ), column ) )
4497 return false;
4498 }
4499
4500 return true;
4501}
4503//*************************************************************************************************
4504
4505
4506//*************************************************************************************************
4521template< typename MT // Type of the matrix
4522 , bool SO // Storage order
4523 , bool DF // Density flag
4524 , bool SF // Symmetry flag
4525 , typename... CRAs > // Compile time row arguments
4526inline decltype(auto) derestrict( Rows<MT,SO,DF,SF,CRAs...>& r )
4527{
4528 return rows( derestrict( r.operand() ), r.idces(), unchecked );
4529}
4531//*************************************************************************************************
4532
4533
4534//*************************************************************************************************
4549template< typename MT // Type of the matrix
4550 , bool SO // Storage order
4551 , bool DF // Density flag
4552 , bool SF // Symmetry flag
4553 , typename... CRAs > // Compile time row arguments
4554inline decltype(auto) derestrict( Rows<MT,SO,DF,SF,CRAs...>&& r )
4555{
4556 return rows( derestrict( r.operand() ), r.idces(), unchecked );
4557}
4559//*************************************************************************************************
4560
4561
4562//*************************************************************************************************
4575template< typename MT // Type of the matrix
4576 , bool SO // Storage order
4577 , bool DF // Density flag
4578 , bool SF // Symmetry flag
4579 , typename... CRAs > // Compile time row arguments
4580inline decltype(auto) unview( Rows<MT,SO,DF,SF,CRAs...>& r )
4581{
4582 return r.operand();
4583}
4585//*************************************************************************************************
4586
4587
4588//*************************************************************************************************
4602template< typename MT // Type of the matrix
4603 , bool SO // Storage order
4604 , bool DF // Density flag
4605 , bool SF // Symmetry flag
4606 , typename... CRAs > // Compile time row arguments
4607inline decltype(auto) unview( const Rows<MT,SO,DF,SF,CRAs...>& r )
4608{
4609 return r.operand();
4610}
4612//*************************************************************************************************
4613
4614
4615
4616
4617//=================================================================================================
4618//
4619// SIZE SPECIALIZATIONS
4620//
4621//=================================================================================================
4622
4623//*************************************************************************************************
4625template< typename MT, bool SO, bool DF, bool SF, size_t I, size_t... Is, typename... CRAs >
4626struct Size< Rows<MT,SO,DF,SF,index_sequence<I,Is...>,CRAs...>, 0UL >
4627 : public Ptrdiff_t< static_cast<ptrdiff_t>( 1UL+sizeof...(Is) ) >
4628{};
4629
4630template< typename MT, bool SO, bool DF, bool SF, typename... CRAs >
4631struct Size< Rows<MT,SO,DF,SF,CRAs...>, 1UL >
4632 : public Size<MT,1UL>
4633{};
4635//*************************************************************************************************
4636
4637
4638
4639
4640//=================================================================================================
4641//
4642// MAXSIZE SPECIALIZATIONS
4643//
4644//=================================================================================================
4645
4646//*************************************************************************************************
4648template< typename MT, bool SO, bool DF, bool SF, size_t I, size_t... Is, typename... CRAs >
4649struct MaxSize< Rows<MT,SO,DF,SF,index_sequence<I,Is...>,CRAs...>, 0UL >
4650 : public Ptrdiff_t< static_cast<ptrdiff_t>( 1UL+sizeof...(Is) ) >
4651{};
4652
4653template< typename MT, bool SO, bool DF, bool SF, typename... CRAs >
4654struct MaxSize< Rows<MT,SO,DF,SF,CRAs...>, 1UL >
4655 : public MaxSize<MT,1UL>
4656{};
4658//*************************************************************************************************
4659
4660
4661
4662
4663//=================================================================================================
4664//
4665// ISRESTRICTED SPECIALIZATIONS
4666//
4667//=================================================================================================
4668
4669//*************************************************************************************************
4671template< typename MT, bool SO, bool DF, bool SF, typename... CRAs >
4672struct IsRestricted< Rows<MT,SO,DF,SF,CRAs...> >
4673 : public IsRestricted<MT>
4674{};
4676//*************************************************************************************************
4677
4678
4679
4680
4681//=================================================================================================
4682//
4683// HASCONSTDATAACCESS SPECIALIZATIONS
4684//
4685//=================================================================================================
4686
4687//*************************************************************************************************
4689template< typename MT, bool SO, bool SF, typename... CRAs >
4690struct HasConstDataAccess< Rows<MT,SO,true,SF,CRAs...> >
4691 : public HasConstDataAccess<MT>
4692{};
4694//*************************************************************************************************
4695
4696
4697
4698
4699//=================================================================================================
4700//
4701// HASMUTABLEDATAACCESS SPECIALIZATIONS
4702//
4703//=================================================================================================
4704
4705//*************************************************************************************************
4707template< typename MT, bool SO, bool SF, typename... CRAs >
4708struct HasMutableDataAccess< Rows<MT,SO,true,SF,CRAs...> >
4709 : public HasMutableDataAccess<MT>
4710{};
4712//*************************************************************************************************
4713
4714
4715
4716
4717//=================================================================================================
4718//
4719// ISALIGNED SPECIALIZATIONS
4720//
4721//=================================================================================================
4722
4723//*************************************************************************************************
4725template< typename MT, bool SO, bool SF, typename... CRAs >
4726struct IsAligned< Rows<MT,SO,true,SF,CRAs...> >
4727 : public IsAligned<MT>
4728{};
4730//*************************************************************************************************
4731
4732} // namespace blaze
4733
4734#endif
Header file for auxiliary alias declarations.
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition: Aliases.h:450
Header file for the alignment flag enumeration.
Header file for run time assertion macros.
Header file for the blaze::checked and blaze::unchecked instances.
Header file for the EnableIf class template.
Header file for the function trace functionality.
Header file for the HasConstDataAccess type trait.
Header file for the HasMutableDataAccess type trait.
Header file for the integer_sequence and index_sequence aliases.
Header file for the IntegralConstant class template.
Header file for the dense matrix inversion flags.
Header file for the IsAligned type trait.
Header file for the isDefault shim.
Header file for the IsPointer type trait.
Header file for the IsRestricted type trait.
Header file for the IsRowMajorMatrix type trait.
Header file for the IsRows type trait.
Header file for the MaxSize type trait.
Header file for the MAYBE_UNUSED function template.
Constraint on the data type.
Header file for the reduction flags.
Header file for the relaxation flag enumeration.
Header file for the RemoveReference type trait.
Header file for the implementation of the RowData class template.
Header file for the SmallArray implementation.
Base class for matrices.
Definition: Matrix.h:85
Implementation of a dynamic array with small array optimization.
Definition: SmallArray.h:84
Pointer data() noexcept
Low-level data access to the array elements.
Definition: SmallArray.h:531
size_t size() const noexcept
Returns the current size/dimension of the small array.
Definition: SmallArray.h:767
Index sequence type of the Blaze library.
Pointer difference type of the Blaze library.
Size type of the Blaze library.
Constraint on the data type.
Header file for the DeclExpr base class.
Header file for the MatEvalExpr base class.
Header file for the MatMapExpr base class.
Header file for the MatMatAddExpr base class.
Header file for the MatMatKronExpr base class.
Header file for the MatMatMapExpr base class.
Header file for the MatMatMultExpr base class.
Header file for the MatMatSubExpr base class.
Header file for the MatNoAliasExpr base class.
Header file for the MatNoSIMDExpr base class.
Header file for the MatReduceExpr base class.
Header file for the MatRepeatExpr base class.
Header file for the MatScalarDivExpr base class.
Header file for the MatScalarMultExpr base class.
Header file for the MatSerialExpr base class.
Header file for the MatTransExpr base class.
Header file for the MatVecMultExpr base class.
Header file for the Matrix base class.
Header file for the SchurExpr base class.
Header file for the VecExpandExpr base class.
Header file for the VecTVecMapExpr base class.
Header file for the VecTVecMultExpr base class.
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:140
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:137
decltype(auto) noalias(const DenseMatrix< MT, SO > &dm)
Forces the non-aliased evaluation of the given dense matrix expression dm.
Definition: DMatNoAliasExpr.h:679
decltype(auto) eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:790
decltype(auto) repeat(const DenseMatrix< MT, SO > &dm, size_t m, size_t n)
Repeats the given dense matrix.
Definition: DMatRepeatExpr.h:543
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:766
decltype(auto) map(const DenseMatrix< MT1, SO > &lhs, const DenseMatrix< MT2, SO > &rhs, OP op)
Elementwise evaluation of the given binary operation on each single element of the dense matrices lhs...
Definition: DMatDMatMapExpr.h:1144
decltype(auto) nosimd(const DenseMatrix< MT, SO > &dm)
Disables the SIMD evaluation of the given dense matrix expression dm.
Definition: DMatNoSIMDExpr.h:717
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
decltype(auto) expand(const DenseVector< VT, TF > &dv, size_t expansion)
Expansion of the given dense vector.
Definition: DVecExpandExpr.h:746
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:207
bool isDefault(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the given diagonal matrix is in default state.
Definition: DiagonalMatrix.h:169
decltype(auto) elements(Vector< VT, TF > &vector, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition: Elements.h:143
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:693
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition: RequiresEvaluation.h:81
#define BLAZE_CONSTRAINT_MUST_HAVE_MUTABLE_DATA_ACCESS(T)
Constraint on the data type.
Definition: MutableDataAccess.h:61
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition: RelaxationFlag.h:66
InversionFlag
Inversion flag.
Definition: InversionFlag.h:102
AlignmentFlag
Alignment flag for (un-)aligned vectors and matrices.
Definition: AlignmentFlag.h:63
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:660
bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:1424
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:137
decltype(auto) rows(MT &&matrix, const SmallArray< T, N > &indices, RRAs... args)
Creating a view on a selection of rows of the given matrix.
Definition: Rows.h:753
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
IntegralConstant< ptrdiff_t, N > Ptrdiff_t
Compile time integral constant wrapper for ptrdiff_t.
Definition: IntegralConstant.h:237
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition: FunctionTrace.h:94
constexpr bool isChecked(const Ts &... args)
Extracting blaze::Check arguments from a given list of arguments.
Definition: Check.h:225
constexpr Unchecked unchecked
Global Unchecked instance.
Definition: Check.h:146
Header file for the exception macros of the math module.
Header file for the extended initializer_list functionality.
Header file for the matrix storage order types.
Header file for the Size type trait.
Header file for all forward declarations for views.
Header file for the serial shim.
Header file for basic type definitions.
Header file for the implementation of the Rows base template.
Rows specialization for dense matrices.
Rows specialization for sparse matrices.