Blaze 3.9
Columns.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_VIEWS_COLUMNS_H_
36#define _BLAZE_MATH_VIEWS_COLUMNS_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 column index
150 , size_t... Is // Remaining column indices
151 , typename MT // Type of the matrix
152 , bool SO // Storage order
153 , typename... RCAs > // Optional arguments
154inline decltype(auto) columns( Matrix<MT,SO>& matrix, RCAs... args )
155{
157
158 using ReturnType = Columns_< MT, index_sequence<I,Is...> >;
159 return ReturnType( *matrix, args... );
160}
161//*************************************************************************************************
162
163
164//*************************************************************************************************
199template< size_t I // First column index
200 , size_t... Is // Remaining column indices
201 , typename MT // Type of the matrix
202 , bool SO // Storage order
203 , typename... RCAs > // Optional arguments
204inline decltype(auto) columns( const Matrix<MT,SO>& matrix, RCAs... args )
205{
207
208 using ReturnType = const Columns_< const MT, index_sequence<I,Is...> >;
209 return ReturnType( *matrix, args... );
210}
211//*************************************************************************************************
212
213
214//*************************************************************************************************
228template< size_t I // First column index
229 , size_t... Is // Remaining column indices
230 , typename MT // Type of the matrix
231 , bool SO // Storage order
232 , typename... RCAs > // Optional arguments
233inline decltype(auto) columns( Matrix<MT,SO>&& matrix, RCAs... args )
234{
236
237 using ReturnType = Columns_< 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 column indices
285 , typename... RCAs > // Optional arguments
286inline decltype(auto) columns( Matrix<MT,SO>& matrix, T* indices, size_t n, RCAs... args )
287{
289
290 using ReturnType = Columns_<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 column indices
339 , typename... RCAs > // Optional arguments
340inline decltype(auto) columns( const Matrix<MT,SO>& matrix, T* indices, size_t n, RCAs... args )
341{
343
344 using ReturnType = const Columns_<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 column indices
368 , typename... RCAs > // Optional arguments
369inline decltype(auto) columns( Matrix<MT,SO>&& matrix, T* indices, size_t n, RCAs... args )
370{
372
373 using ReturnType = Columns_<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... RCAs > // Optional arguments
420inline decltype(auto) columns( Matrix<MT,SO>& matrix, P p, size_t n, RCAs... args )
421{
423
424 using ReturnType = Columns_<MT,P>;
425 return ReturnType( *matrix, p, n, args... );
426}
427//*************************************************************************************************
428
429
430//*************************************************************************************************
469template< typename MT // Type of the matrix
470 , bool SO // Storage order
471 , typename P // Type of the index producer
472 , typename... RCAs > // Optional arguments
473inline decltype(auto) columns( const Matrix<MT,SO>& matrix, P p, size_t n, RCAs... args )
474{
476
477 using ReturnType = const Columns_<const MT,P>;
478 return ReturnType( *matrix, p, n, args... );
479}
480//*************************************************************************************************
481
482
483//*************************************************************************************************
498template< typename MT // Type of the matrix
499 , bool SO // Storage order
500 , typename P // Type of the index producer
501 , typename... RCAs > // Optional arguments
502inline decltype(auto) columns( Matrix<MT,SO>&& matrix, P p, size_t n, RCAs... args )
503{
505
506 using ReturnType = Columns_<MT,P>;
507 return ReturnType( *matrix, p, n, args... );
508}
509//*************************************************************************************************
510
511
512//*************************************************************************************************
549template< typename MT // Type of the matrix
550 , size_t... Is // Column indices
551 , typename... RCAs > // Optional arguments
552inline decltype(auto) columns( MT&& matrix, index_sequence<Is...> indices, RCAs... args )
553{
555
556 MAYBE_UNUSED( indices );
557
558 return columns<Is...>( std::forward<MT>( matrix ), args... );
559}
560//*************************************************************************************************
561
562
563//*************************************************************************************************
599template< typename MT // Type of the matrix
600 , typename T // Type of the column indices
601 , typename... RCAs > // Optional arguments
602inline decltype(auto) columns( MT&& matrix, initializer_list<T> indices, RCAs... args )
603{
605
606 return columns( std::forward<MT>( matrix ), indices.begin(), indices.size(), args... );
607}
608//*************************************************************************************************
609
610
611//*************************************************************************************************
649template< typename MT // Type of the matrix
650 , typename T // Type of the column indices
651 , size_t N // Number of indices
652 , typename... RCAs > // Optional arguments
653inline decltype(auto) columns( MT&& matrix, const std::array<T,N>& indices, RCAs... args )
654{
656
657 return columns( std::forward<MT>( matrix ), indices.data(), N, args... );
658}
659//*************************************************************************************************
660
661
662//*************************************************************************************************
700template< typename MT // Type of the matrix
701 , typename T // Type of the column indices
702 , typename... RCAs > // Optional arguments
703inline decltype(auto) columns( MT&& matrix, const std::vector<T>& indices, RCAs... args )
704{
706
707 return columns( std::forward<MT>( matrix ), indices.data(), indices.size(), args... );
708}
709//*************************************************************************************************
710
711
712//*************************************************************************************************
751template< typename MT // Type of the matrix
752 , typename T // Type of the column indices
753 , size_t N // Number of preallocated elements
754 , typename... RCAs > // Optional arguments
755inline decltype(auto) columns( MT&& matrix, const SmallArray<T,N>& indices, RCAs... args )
756{
758
759 return columns( std::forward<MT>( matrix ), indices.data(), indices.size(), args... );
760}
762//*************************************************************************************************
763
764
765//*************************************************************************************************
781template< typename MT // Type of the matrix
782 , typename T1 // First type of the pair of arguments
783 , typename T2 // Second type of the pair of arguments
784 , typename... RRAs > // Optional arguments
785inline decltype(auto) columns( MT&& matrix, const std::pair<T1,T2>& pair, RRAs... args )
786{
788
789 return columns( std::forward<MT>( matrix ), pair.first, pair.second, args... );
790}
792//*************************************************************************************************
793
794
795
796
797//=================================================================================================
798//
799// GLOBAL RESTRUCTURING FUNCTIONS
800//
801//=================================================================================================
802
803//*************************************************************************************************
816template< size_t... CCAs // Compile time column arguments
817 , typename MT // Matrix base type of the expression
818 , typename... RCAs // Runtime column arguments
819 , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
820inline decltype(auto) columns( const MatMatAddExpr<MT>& matrix, RCAs... args )
821{
823
824 return columns<CCAs...>( (*matrix).leftOperand(), args... ) +
825 columns<CCAs...>( (*matrix).rightOperand(), args... );
826}
828//*************************************************************************************************
829
830
831//*************************************************************************************************
844template< size_t... CCAs // Compile time column arguments
845 , typename MT // Matrix base type of the expression
846 , typename... RCAs // Runtime column arguments
847 , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
848inline decltype(auto) columns( const MatMatSubExpr<MT>& matrix, RCAs... args )
849{
851
852 return columns<CCAs...>( (*matrix).leftOperand(), args... ) -
853 columns<CCAs...>( (*matrix).rightOperand(), args... );
854}
856//*************************************************************************************************
857
858
859//*************************************************************************************************
872template< size_t... CCAs // Compile time column arguments
873 , typename MT // Matrix base type of the expression
874 , typename... RCAs // Runtime column arguments
875 , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
876inline decltype(auto) columns( const SchurExpr<MT>& matrix, RCAs... args )
877{
879
880 return columns<CCAs...>( (*matrix).leftOperand(), args... ) %
881 columns<CCAs...>( (*matrix).rightOperand(), args... );
882}
884//*************************************************************************************************
885
886
887//*************************************************************************************************
900template< size_t... CCAs // Compile time column arguments
901 , typename MT // Matrix base type of the expression
902 , typename... RCAs // Runtime column arguments
903 , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
904inline decltype(auto) columns( const MatMatMultExpr<MT>& matrix, RCAs... args )
905{
907
908 return (*matrix).leftOperand() * columns<CCAs...>( (*matrix).rightOperand(), args... );
909}
911//*************************************************************************************************
912
913
914//*************************************************************************************************
927template< size_t I // First column index
928 , size_t... Is // Remaining column indices
929 , typename MT // Matrix base type of the expression
930 , typename... RCAs > // Optional arguments
931inline decltype(auto) columns( const MatMatKronExpr<MT>& matrix, RCAs... args )
932{
934
935 decltype(auto) lhs( (*matrix).leftOperand() );
936 decltype(auto) rhs( (*matrix).rightOperand() );
937
938 const size_t M( rhs.rows() );
939 const size_t N( rhs.columns() );
940
941 const auto lhsRows( [M]( size_t i ){ return i / M; } );
942 const auto rhsRows( [M]( size_t i ){ return i % M; } );
943
944 const auto lhsColumns( [N]( size_t i ) {
945 constexpr size_t indices[] = { I, Is... };
946 return indices[i] / N;
947 } );
948
949 const auto rhsColumns( [N]( size_t i ) {
950 constexpr size_t indices[] = { I, Is... };
951 return indices[i] % N;
952 } );
953
954 return columns( rows( lhs, lhsRows, (*matrix).rows(), args... ), lhsColumns, sizeof...(Is)+1UL, args... ) %
955 columns( rows( rhs, rhsRows, (*matrix).rows(), args... ), rhsColumns, sizeof...(Is)+1UL, args... );
956}
958//*************************************************************************************************
959
960
961//*************************************************************************************************
976template< typename MT // Matrix base type of the expression
977 , typename T // Type of the column indices
978 , typename... RCAs > // Optional arguments
979inline decltype(auto) columns( const MatMatKronExpr<MT>& matrix, T* indices, size_t n, RCAs... args )
980{
982
983 decltype(auto) lhs( (*matrix).leftOperand() );
984 decltype(auto) rhs( (*matrix).rightOperand() );
985
986 const size_t M( rhs.rows() );
987 const size_t N( rhs.columns() );
988
989 const auto lhsRows( [M]( size_t i ){ return i / M; } );
990 const auto rhsRows( [M]( size_t i ){ return i % M; } );
991
992 SmallArray<size_t,128UL> lhsColumns;
993 lhsColumns.reserve( n );
994
995 for( size_t i=0UL; i<n; ++i ) {
996 lhsColumns.pushBack( indices[i] / N );
997 }
998
999 SmallArray<size_t,128UL> rhsColumns;
1000 rhsColumns.reserve( n );
1001
1002 for( size_t i=0UL; i<n; ++i ) {
1003 rhsColumns.pushBack( indices[i] % N );
1004 }
1005
1006 return columns( rows( lhs, lhsRows, (*matrix).rows(), args... ), lhsColumns, n, args... ) %
1007 columns( rows( rhs, rhsRows, (*matrix).rows(), args... ), rhsColumns, n, args... );
1008}
1010//*************************************************************************************************
1011
1012
1013//*************************************************************************************************
1028template< typename MT // Matrix base type of the expression
1029 , typename P // Type of the index producer
1030 , typename... RCAs > // Optional arguments
1031inline decltype(auto) columns( const MatMatKronExpr<MT>& matrix, P p, size_t n, RCAs... args )
1032{
1034
1035 decltype(auto) lhs( (*matrix).leftOperand() );
1036 decltype(auto) rhs( (*matrix).rightOperand() );
1037
1038 const size_t M( rhs.rows() );
1039 const size_t N( rhs.columns() );
1040
1041 const auto lhsRows( [M]( size_t i ){ return i / M; } );
1042 const auto rhsRows( [M]( size_t i ){ return i % M; } );
1043
1044 const auto lhsColumns( [p,N]( size_t i ) { return p(i) / N; } );
1045 const auto rhsColumns( [p,N]( size_t i ) { return p(i) % N; } );
1046
1047 return columns( rows( lhs, lhsRows, (*matrix).rows(), args... ), lhsColumns, n, args... ) %
1048 columns( rows( rhs, rhsRows, (*matrix).rows(), args... ), rhsColumns, n, args... );
1049}
1051//*************************************************************************************************
1052
1053
1054//*************************************************************************************************
1067template< size_t... CCAs // Compile time column arguments
1068 , typename MT // Matrix base type of the expression
1069 , typename... RCAs // Runtime column arguments
1070 , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
1071inline decltype(auto) columns( const VecTVecMultExpr<MT>& matrix, RCAs... args )
1072{
1074
1075 try {
1076 return (*matrix).leftOperand() * elements<CCAs...>( (*matrix).rightOperand(), args... );
1077 }
1078 catch( ... ) {
1079 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1080 }
1081}
1083//*************************************************************************************************
1084
1085
1086//*************************************************************************************************
1099template< size_t... CCAs // Compile time column arguments
1100 , typename MT // Matrix base type of the expression
1101 , typename... RCAs // Runtime column arguments
1102 , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
1103inline decltype(auto) columns( const MatScalarMultExpr<MT>& matrix, RCAs... args )
1104{
1106
1107 return columns<CCAs...>( (*matrix).leftOperand(), args... ) * (*matrix).rightOperand();
1108}
1110//*************************************************************************************************
1111
1112
1113//*************************************************************************************************
1126template< size_t... CCAs // Compile time column arguments
1127 , typename MT // Matrix base type of the expression
1128 , typename... RCAs // Runtime column arguments
1129 , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
1130inline decltype(auto) columns( const MatScalarDivExpr<MT>& matrix, RCAs... args )
1131{
1133
1134 return columns<CCAs...>( (*matrix).leftOperand(), args... ) / (*matrix).rightOperand();
1135}
1137//*************************************************************************************************
1138
1139
1140//*************************************************************************************************
1153template< size_t... CCAs // Compile time column arguments
1154 , typename MT // Matrix base type of the expression
1155 , typename... RCAs // Runtime column arguments
1156 , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
1157inline decltype(auto) columns( const MatMapExpr<MT>& matrix, RCAs... args )
1158{
1160
1161 return map( columns<CCAs...>( (*matrix).operand(), args... ), (*matrix).operation() );
1162}
1164//*************************************************************************************************
1165
1166
1167//*************************************************************************************************
1180template< size_t... CCAs // Compile time column arguments
1181 , typename MT // Matrix base type of the expression
1182 , typename... RCAs // Runtime column arguments
1183 , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
1184inline decltype(auto) columns( const MatMatMapExpr<MT>& matrix, RCAs... args )
1185{
1187
1188 return map( columns<CCAs...>( (*matrix).leftOperand(), args... ),
1189 columns<CCAs...>( (*matrix).rightOperand(), args... ),
1190 (*matrix).operation() );
1191}
1193//*************************************************************************************************
1194
1195
1196//*************************************************************************************************
1209template< size_t... CCAs // Compile time column arguments
1210 , typename MT // Matrix base type of the expression
1211 , typename... RCAs // Runtime column arguments
1212 , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
1213inline decltype(auto) columns( const VecTVecMapExpr<MT>& matrix, RCAs... args )
1214{
1216
1217 try {
1218 return map( (*matrix).leftOperand(),
1219 elements<CCAs...>( (*matrix).rightOperand(), args... ), (*matrix).operation() );
1220 }
1221 catch( ... ) {
1222 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1223 }
1224}
1226//*************************************************************************************************
1227
1228
1229//*************************************************************************************************
1242template< size_t... CCAs // Compile time column arguments
1243 , typename MT // Matrix base type of the expression
1244 , typename... RCAs // Runtime column arguments
1245 , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
1246inline decltype(auto) columns( const MatEvalExpr<MT>& matrix, RCAs... args )
1247{
1249
1250 return eval( columns<CCAs...>( (*matrix).operand(), args... ) );
1251}
1253//*************************************************************************************************
1254
1255
1256//*************************************************************************************************
1269template< size_t... CCAs // Compile time column arguments
1270 , typename MT // Matrix base type of the expression
1271 , typename... RCAs // Runtime column arguments
1272 , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
1273inline decltype(auto) columns( const MatSerialExpr<MT>& matrix, RCAs... args )
1274{
1276
1277 return serial( columns<CCAs...>( (*matrix).operand(), args... ) );
1278}
1280//*************************************************************************************************
1281
1282
1283//*************************************************************************************************
1296template< size_t... CCAs // Compile time column arguments
1297 , typename MT // Matrix base type of the expression
1298 , typename... RCAs // Runtime column arguments
1299 , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
1300inline decltype(auto) columns( const MatNoAliasExpr<MT>& matrix, RCAs... args )
1301{
1303
1304 return noalias( columns<CCAs...>( (*matrix).operand(), args... ) );
1305}
1307//*************************************************************************************************
1308
1309
1310//*************************************************************************************************
1323template< size_t... CCAs // Compile time column arguments
1324 , typename MT // Matrix base type of the expression
1325 , typename... RCAs // Runtime column arguments
1326 , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
1327inline decltype(auto) columns( const MatNoSIMDExpr<MT>& matrix, RCAs... args )
1328{
1330
1331 return nosimd( columns<CCAs...>( (*matrix).operand(), args... ) );
1332}
1334//*************************************************************************************************
1335
1336
1337//*************************************************************************************************
1350template< size_t... CCAs // Compile time column arguments
1351 , typename MT // Matrix base type of the expression
1352 , typename... RCAs // Runtime column arguments
1353 , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
1354inline decltype(auto) columns( const DeclExpr<MT>& matrix, RCAs... args )
1355{
1357
1358 return columns<CCAs...>( (*matrix).operand(), args... );
1359}
1361//*************************************************************************************************
1362
1363
1364//*************************************************************************************************
1377template< size_t... CCAs // Compile time column arguments
1378 , typename MT // Matrix base type of the expression
1379 , typename... RCAs // Runtime column arguments
1380 , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
1381inline decltype(auto) columns( const MatTransExpr<MT>& matrix, RCAs... args )
1382{
1384
1385 return trans( rows<CCAs...>( (*matrix).operand(), args... ) );
1386}
1388//*************************************************************************************************
1389
1390
1391//*************************************************************************************************
1405template< size_t... CCAs // Compile time column arguments
1406 , typename MT // Matrix base type of the expression
1407 , size_t... CEAs // Compile time expansion arguments
1408 , typename... RCAs // Runtime column arguments
1409 , EnableIf_t< ( sizeof...( CCAs ) > 0UL ) &&
1410 IsColumnMajorMatrix_v<MT> >* = nullptr >
1411inline decltype(auto) columns( const VecExpandExpr<MT,CEAs...>& matrix, RCAs... args )
1412{
1414
1415 if( isChecked( args... ) ) {
1416 constexpr size_t indices[] = { CCAs... };
1417 for( size_t i=0UL; i<sizeof...(CCAs); ++i ) {
1418 if( (*matrix).columns() <= indices[i] ) {
1419 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1420 }
1421 }
1422 }
1423
1424 return expand< sizeof...( CCAs ) >( (*matrix).operand() );
1425}
1427//*************************************************************************************************
1428
1429
1430//*************************************************************************************************
1446template< typename MT // Matrix base type of the expression
1447 , size_t... CEAs // Compile time expansion arguments
1448 , typename T // Type of the column indices or index producer
1449 , typename... RCAs // Runtime column arguments
1450 , EnableIf_t< IsColumnMajorMatrix_v<MT> >* = nullptr >
1451inline decltype(auto) columns( const VecExpandExpr<MT,CEAs...>& matrix, T* indices, size_t n, RCAs... args )
1452{
1454
1455 if( isChecked( args... ) ) {
1456 for( size_t i=0UL; i<n; ++i ) {
1457 if( (*matrix).columns() <= size_t( indices[i] ) ) {
1458 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1459 }
1460 }
1461 }
1462
1463 return expand( (*matrix).operand(), n );
1464}
1466//*************************************************************************************************
1467
1468
1469//*************************************************************************************************
1485template< typename MT // Matrix base type of the expression
1486 , size_t... CEAs // Compile time expansion arguments
1487 , typename P // Type of the index producer
1488 , typename... RCAs // Runtime column arguments
1489 , EnableIf_t< IsColumnMajorMatrix_v<MT> >* = nullptr >
1490inline decltype(auto) columns( const VecExpandExpr<MT,CEAs...>& matrix, P p, size_t n, RCAs... args )
1491{
1493
1494 if( isChecked( args... ) ) {
1495 for( size_t i=0UL; i<n; ++i ) {
1496 if( (*matrix).columns() <= size_t( p(i) ) ) {
1497 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1498 }
1499 }
1500 }
1501
1502 return expand( (*matrix).operand(), n );
1503}
1505//*************************************************************************************************
1506
1507
1508//*************************************************************************************************
1521template< size_t... CCAs // Compile time column arguments
1522 , typename MT // Matrix base type of the expression
1523 , size_t... CEAs // Compile time expansion arguments
1524 , typename... RCAs // Runtime column arguments
1525 , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) &&
1526 !IsColumnMajorMatrix_v<MT> >* = nullptr >
1527inline decltype(auto) columns( const VecExpandExpr<MT,CEAs...>& matrix, RCAs... args )
1528{
1530
1531 try {
1532 return expand<CEAs...>( elements<CCAs...>( (*matrix).operand(), args... ), (*matrix).expansion() );
1533 }
1534 catch( ... ) {
1535 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1536 }
1537}
1539//*************************************************************************************************
1540
1541
1542//*************************************************************************************************
1555template< size_t I // First column index
1556 , size_t... Is // Remaining column indices
1557 , typename MT // Matrix base type of the expression
1558 , size_t... CRAs // Compile time repeater arguments
1559 , typename... RCAs > // Optional column arguments
1560inline decltype(auto) columns( const MatRepeatExpr<MT,CRAs...>& matrix, RCAs... args )
1561{
1563
1564 if( isChecked( args... ) ) {
1565 constexpr size_t indices[] = { I, Is... };
1566 for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1567 if( (*matrix).columns() <= indices[i] ) {
1568 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1569 }
1570 }
1571 }
1572
1573 auto lambda = [columns=(*matrix).operand().columns()]( size_t i ) {
1574 constexpr size_t indices[] = { I, Is... };
1575 return indices[i] % columns;
1576 };
1577
1578 return repeat( columns( (*matrix).operand(), std::move(lambda), sizeof...(Is)+1UL, unchecked )
1579 , (*matrix).template repetitions<0UL>(), 1UL );
1580}
1582//*************************************************************************************************
1583
1584
1585//*************************************************************************************************
1600template< typename MT // Matrix base type of the expression
1601 , size_t... CRAs // Compile time repeater arguments
1602 , typename T // Type of the column indices
1603 , typename... RCAs > // Optional column arguments
1604inline decltype(auto) columns( const MatRepeatExpr<MT,CRAs...>& matrix, T* indices, size_t n, RCAs... args )
1605{
1607
1608 if( isChecked( args... ) ) {
1609 for( size_t i=0UL; i<n; ++i ) {
1610 if( (*matrix).columns() <= size_t( indices[i] ) ) {
1611 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1612 }
1613 }
1614 }
1615
1616 SmallArray<size_t,128UL> newIndices( indices, indices+n );
1617
1618 for( size_t& index : newIndices ) {
1619 index = index % (*matrix).operand().columns();
1620 }
1621
1622 return repeat( columns( (*matrix).operand(), newIndices, unchecked )
1623 , (*matrix).template repetitions<0UL>(), 1UL );
1624}
1626//*************************************************************************************************
1627
1628
1629//*************************************************************************************************
1644template< typename MT // Matrix base type of the expression
1645 , size_t... CRAs // Compile time repeater arguments
1646 , typename P // Type of the index producer
1647 , typename... RCAs > // Optional column arguments
1648inline decltype(auto) columns( const MatRepeatExpr<MT,CRAs...>& matrix, P p, size_t n, RCAs... args )
1649{
1651
1652 if( isChecked( args... ) ) {
1653 for( size_t i=0UL; i<n; ++i ) {
1654 if( (*matrix).columns() <= size_t( p(i) ) ) {
1655 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1656 }
1657 }
1658 }
1659
1660 auto lambda = [columns=(*matrix).operand().columns(),p]( size_t i ) {
1661 return p(i) % columns;
1662 };
1663
1664 return repeat( columns( (*matrix).operand(), std::move(lambda), n, unchecked )
1665 , (*matrix).template repetitions<0UL>(), 1UL );
1666}
1668//*************************************************************************************************
1669
1670
1671
1672
1673//=================================================================================================
1674//
1675// GLOBAL RESTRUCTURING FUNCTIONS (COLUMNS)
1676//
1677//=================================================================================================
1678
1679//*************************************************************************************************
1691template< size_t I // First required column index
1692 , size_t... Is // Remaining required column indices
1693 , typename MT // Type of the matrix
1694 , typename... RCAs // Optional column arguments
1695 , EnableIf_t< IsColumns_v< RemoveReference_t<MT> > &&
1696 RemoveReference_t<MT>::compileTimeArgs >* = nullptr >
1697inline decltype(auto) columns( MT&& c, RCAs... args )
1698{
1700
1701 return columns( c.operand(), subsequence<I,Is...>( RemoveReference_t<MT>::idces() ), args... );
1702}
1704//*************************************************************************************************
1705
1706
1707//*************************************************************************************************
1720template< size_t I // First required column index
1721 , size_t... Is // Remaining required column indices
1722 , typename MT // Type of the matrix
1723 , typename... RCAs // Optional column arguments
1724 , EnableIf_t< IsColumns_v< RemoveReference_t<MT> > &&
1725 !RemoveReference_t<MT>::compileTimeArgs >* = nullptr >
1726inline decltype(auto) columns( MT&& c, RCAs... args )
1727{
1729
1730 if( isChecked( args... ) ) {
1731 constexpr size_t indices[] = { I, Is... };
1732 for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1733 if( c.columns() <= indices[i] ) {
1734 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1735 }
1736 }
1737 }
1738
1739 return columns( c.operand(), { c.idx(I), c.idx(Is)... }, unchecked );
1740}
1742//*************************************************************************************************
1743
1744
1745//*************************************************************************************************
1760template< typename MT // Type of the matrix
1761 , typename T // Type of the column indices
1762 , typename... RCAs // Optional column arguments
1763 , EnableIf_t< IsColumns_v< RemoveReference_t<MT> > >* = nullptr >
1764inline decltype(auto) columns( MT&& c, T* indices, size_t n, RCAs... args )
1765{
1767
1768 if( isChecked( args... ) ) {
1769 for( size_t i=0UL; i<n; ++i ) {
1770 if( c.columns() <= size_t( indices[i] ) ) {
1771 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1772 }
1773 }
1774 }
1775
1776 SmallArray<size_t,128UL> newIndices;
1777 newIndices.reserve( n );
1778
1779 for( size_t i=0UL; i<n; ++i ) {
1780 newIndices.pushBack( c.idx( indices[i] ) );
1781 }
1782
1783 return columns( c.operand(), newIndices.data(), newIndices.size(), unchecked );
1784}
1786//*************************************************************************************************
1787
1788
1789//*************************************************************************************************
1804template< typename MT // Type of the matrix
1805 , typename P // Type of the index producer
1806 , typename... RCAs // Optional column arguments
1807 , EnableIf_t< IsColumns_v< RemoveReference_t<MT> > && !IsPointer_v<P> >* = nullptr >
1808inline decltype(auto) columns( MT&& c, P p, size_t n, RCAs... args )
1809{
1811
1812 if( isChecked( args... ) ) {
1813 for( size_t i=0UL; i<n; ++i ) {
1814 if( c.columns() <= size_t( p(i) ) ) {
1815 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1816 }
1817 }
1818 }
1819
1820 SmallArray<size_t,128UL> newIndices;
1821 newIndices.reserve( n );
1822
1823 for( size_t i=0UL; i<n; ++i ) {
1824 newIndices.pushBack( c.idx( p(i) ) );
1825 }
1826
1827 return columns( c.operand(), newIndices.data(), newIndices.size(), unchecked );
1828}
1830//*************************************************************************************************
1831
1832
1833
1834
1835//=================================================================================================
1836//
1837// GLOBAL RESTRUCTURING FUNCTIONS (ELEMENTS)
1838//
1839//=================================================================================================
1840
1841//*************************************************************************************************
1854template< size_t... CEAs // Compile time element arguments
1855 , typename VT // Vector base type of the expression
1856 , typename... REAs > // Runtime element arguments
1857inline decltype(auto) elements( const TVecMatMultExpr<VT>& vector, REAs... args )
1858{
1860
1861 try {
1862 return (*vector).leftOperand() * columns<CEAs...>( (*vector).rightOperand(), args... );
1863 }
1864 catch( ... ) {
1865 BLAZE_THROW_INVALID_ARGUMENT( "Invalid element access index" );
1866 }
1867}
1869//*************************************************************************************************
1870
1871
1872//*************************************************************************************************
1886template< size_t... CEAs // Compile time element arguments
1887 , typename VT // Vector base type of the expression
1888 , typename... REAs > // Runtime element arguments
1889inline decltype(auto) elements( const MatReduceExpr<VT,columnwise>& vector, REAs... args )
1890{
1892
1893 try {
1894 return reduce<columnwise>( columns<CEAs...>( (*vector).operand(), args... ), (*vector).operation() );
1895 }
1896 catch( ... ) {
1897 BLAZE_THROW_INVALID_ARGUMENT( "Invalid element access index" );
1898 }
1899}
1901//*************************************************************************************************
1902
1903
1904
1905
1906//=================================================================================================
1907//
1908// GLOBAL RESTRUCTURING FUNCTIONS (ROW)
1909//
1910//=================================================================================================
1911
1912//*************************************************************************************************
1924template< size_t... CRAs // Compile time row arguments
1925 , typename MT // Type of the matrix
1926 , typename... RRAs // Runtime row arguments
1927 , EnableIf_t< IsColumns_v< RemoveReference_t<MT> > >* = nullptr >
1928inline decltype(auto) row( MT&& columns, RRAs... args )
1929{
1931
1932 return elements( row<CRAs...>( columns.operand(), args... ), columns.idces() );
1933}
1935//*************************************************************************************************
1936
1937
1938
1939
1940//=================================================================================================
1941//
1942// GLOBAL RESTRUCTURING FUNCTIONS (COLUMN)
1943//
1944//=================================================================================================
1945
1946//*************************************************************************************************
1958template< size_t I // Column index
1959 , typename MT // Type of the matrix
1960 , typename... RCAs // Optional column arguments
1961 , EnableIf_t< IsColumns_v< RemoveReference_t<MT> > &&
1962 RemoveReference_t<MT>::compileTimeArgs >* = nullptr >
1963inline decltype(auto) column( MT&& columns, RCAs... args )
1964{
1966
1967 return column< RemoveReference_t<MT>::idx(I) >( columns.operand(), args... );
1968}
1970//*************************************************************************************************
1971
1972
1973//*************************************************************************************************
1986template< size_t... CCAs // Compile time column arguments
1987 , typename MT // Type of the matrix
1988 , typename... RCAs // Runtime column arguments
1989 , EnableIf_t< IsColumns_v< RemoveReference_t<MT> > &&
1990 ( sizeof...( CCAs ) == 0UL || !RemoveReference_t<MT>::compileTimeArgs ) >* = nullptr >
1991inline decltype(auto) column( MT&& columns, RCAs... args )
1992{
1994
1995 const ColumnData<CCAs...> cd( args... );
1996
1997 if( isChecked( args... ) ) {
1998 if( columns.columns() <= cd.column() ) {
1999 BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
2000 }
2001 }
2002
2003 return column( columns.operand(), columns.idx( cd.column() ), args... );
2004}
2006//*************************************************************************************************
2007
2008
2009
2010
2011//=================================================================================================
2012//
2013// COLUMNS OPERATORS
2014//
2015//=================================================================================================
2016
2017//*************************************************************************************************
2043template< RelaxationFlag RF // Relaxation flag
2044 , typename MT // Type of the dense matrix
2045 , bool SO // Storage order
2046 , bool SF // Symmetry flag
2047 , typename... CCAs > // Compile time column arguments
2048inline bool isDefault( const Columns<MT,SO,true,SF,CCAs...>& columns )
2049{
2050 using blaze::isDefault;
2051
2052 if( SO == false ) {
2053 for( size_t i=0UL; i<columns.rows(); ++i )
2054 for( size_t j=0UL; j<columns.columns(); ++j )
2055 if( !isDefault<RF>( columns(i,j) ) )
2056 return false;
2057 }
2058 else {
2059 for( size_t j=0UL; j<columns.columns(); ++j )
2060 for( size_t i=0UL; i<columns.rows(); ++i )
2061 if( !isDefault<RF>( columns(i,j) ) )
2062 return false;
2063 }
2064
2065 return true;
2066}
2068//*************************************************************************************************
2069
2070
2071//*************************************************************************************************
2097template< RelaxationFlag RF // Relaxation flag
2098 , typename MT // Type of the dense matrix
2099 , bool SO // Storage order
2100 , bool SF // Symmetry flag
2101 , typename... CCAs > // Compile time column arguments
2102inline bool isDefault( const Columns<MT,SO,false,SF,CCAs...>& columns )
2103{
2104 using blaze::isDefault;
2105
2106 for( size_t j=0UL; j<columns.columns(); ++j ) {
2107 for( auto element=columns.cbegin(j); element!=columns.cend(j); ++element )
2108 if( !isDefault<RF>( element->value() ) ) return false;
2109 }
2110
2111 return true;
2112}
2114//*************************************************************************************************
2115
2116
2117//*************************************************************************************************
2135template< typename MT // Type of the matrix
2136 , bool SO // Storage order
2137 , bool DF // Density flag
2138 , bool SF // Symmetry flag
2139 , typename... CCAs > // Compile time column arguments
2140inline bool isIntact( const Columns<MT,SO,DF,SF,CCAs...>& columns ) noexcept
2141{
2142 return ( columns.rows() == columns.operand().rows() &&
2143 columns.columns() <= columns.operand().columns() &&
2144 isIntact( columns.operand() ) );
2145}
2147//*************************************************************************************************
2148
2149
2150//*************************************************************************************************
2163template< typename MT // Type of the matrix
2164 , bool SO1 // Storage order of the left-hand side column selection
2165 , bool DF // Density flag
2166 , bool SF // Symmetry flag
2167 , typename... CCAs // Compile time column arguments
2168 , bool SO2 > // Storage order of the right-hand side matrix
2169inline bool isSame( const Columns<MT,SO1,DF,SF,CCAs...>& a, const Matrix<MT,SO2>& b ) noexcept
2170{
2171 if( !isSame( a.operand(), *b ) || ( a.rows() != (*b).rows() ) || ( a.columns() != (*b).columns() ) )
2172 return false;
2173
2174 for( size_t j=0UL; j<a.columns(); ++j ) {
2175 if( a.idx(j) != j )
2176 return false;
2177 }
2178
2179 return true;
2180}
2182//*************************************************************************************************
2183
2184
2185//*************************************************************************************************
2198template< typename MT // Type of the matrix
2199 , bool SO1 // Storage order of the left-hand side matrix
2200 , bool DF // Density flag
2201 , bool SF // Symmetry flag
2202 , typename... CCAs // Compile time column arguments
2203 , bool SO2 > // Storage order of the right-hand side column selection
2204inline bool isSame( const Matrix<MT,SO1>& a, const Columns<MT,SO2,DF,SF,CCAs...>& b ) noexcept
2205{
2206 return isSame( b, a );
2207}
2209//*************************************************************************************************
2210
2211
2212//*************************************************************************************************
2225template< typename MT // Type of the matrix
2226 , bool SO1 // Storage order of the left-hand side column selection
2227 , bool DF // Density flag
2228 , bool SF // Symmetry flag
2229 , typename... CCAs // Compile time column arguments
2230 , AlignmentFlag AF // Alignment flag
2231 , bool SO2 // Storage order of the right-hand side submatrix
2232 , size_t... CSAs > // Compile time submatrix arguments
2233inline bool isSame( const Columns<MT,SO1,DF,SF,CCAs...>& a, const Submatrix<MT,AF,SO2,DF,CSAs...>& b ) noexcept
2234{
2235 if( !isSame( a.operand(), b.operand() ) || ( a.rows() != (*b).rows() ) || ( a.columns() != (*b).columns() ) )
2236 return false;
2237
2238 for( size_t j=0UL; j<a.columns(); ++j ) {
2239 if( a.idx(j) != b.column()+j )
2240 return false;
2241 }
2242
2243 return true;
2244}
2246//*************************************************************************************************
2247
2248
2249//*************************************************************************************************
2262template< typename MT // Type of the matrix
2263 , AlignmentFlag AF // Alignment flag
2264 , bool SO1 // Storage order of the left-hand side submatrix
2265 , bool DF // Density flag
2266 , size_t... CSAs // Compile time submatrix arguments
2267 , bool SO2 // Storage order of the right-hand side column selection
2268 , bool SF // Symmetry flag
2269 , typename... CCAs > // Compile time column arguments
2270inline bool isSame( const Submatrix<MT,AF,SO1,DF,CSAs...>& a, const Columns<MT,SO2,DF,SF,CCAs...>& b ) noexcept
2271{
2272 return isSame( b, a );
2273}
2275//*************************************************************************************************
2276
2277
2278//*************************************************************************************************
2291template< typename MT // Type of the matrix
2292 , bool SO // Storage order
2293 , bool DF // Density flag
2294 , bool SF // Symmetry flag
2295 , typename... CCAs1 // Compile time column arguments of the left-hand side column selection
2296 , typename... CCAs2 > // Compile time column arguments of the right-hand side column selection
2297inline bool isSame( const Columns<MT,SO,DF,SF,CCAs1...>& a,
2298 const Columns<MT,SO,DF,SF,CCAs2...>& b ) noexcept
2299{
2300 if( !isSame( a.operand(), b.operand() ) || a.rows() != b.rows() || a.columns() != b.columns() )
2301 return false;
2302
2303 for( size_t i=0UL; i<a.columns(); ++i ) {
2304 if( a.idx(i) != b.idx(i) )
2305 return false;
2306 }
2307
2308 return true;
2309}
2311//*************************************************************************************************
2312
2313
2314//*************************************************************************************************
2353template< InversionFlag IF // Inversion algorithm
2354 , typename MT // Type of the dense matrix
2355 , bool SO // Storage order
2356 , bool SF // Symmetry flag
2357 , typename... CCAs > // Compile time column arguments
2358inline auto invert( Columns<MT,SO,true,SF,CCAs...>& c )
2359 -> DisableIf_t< HasMutableDataAccess_v<MT> >
2360{
2361 using RT = ResultType_t< Columns<MT,SO,true,SF,CCAs...> >;
2362
2365
2366 RT tmp( c );
2367 invert<IF>( tmp );
2368 c = tmp;
2369}
2371//*************************************************************************************************
2372
2373
2374//*************************************************************************************************
2390template< typename MT // Type of the matrix
2391 , bool SO // Storage order
2392 , bool DF // Density flag
2393 , bool SF // Symmetry flag
2394 , typename... CCAs // Compile time column arguments
2395 , typename ET > // Type of the element
2396inline bool trySet( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t i, size_t j, const ET& value )
2397{
2398 BLAZE_INTERNAL_ASSERT( i < c.rows(), "Invalid row access index" );
2399 BLAZE_INTERNAL_ASSERT( j < c.columns(), "Invalid column access index" );
2400
2401 return trySet( c.operand(), c.idx(i), j, value );
2402}
2404//*************************************************************************************************
2405
2406
2407//*************************************************************************************************
2425template< typename MT // Type of the matrix
2426 , bool SO // Storage order
2427 , bool DF // Density flag
2428 , bool SF // Symmetry flag
2429 , typename... CCAs // Compile time column arguments
2430 , typename ET > // Type of the element
2432 trySet( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t row, size_t column, size_t m, size_t n, const ET& value )
2433{
2434 BLAZE_INTERNAL_ASSERT( row <= (*c).rows(), "Invalid row access index" );
2435 BLAZE_INTERNAL_ASSERT( column <= (*c).columns(), "Invalid column access index" );
2436 BLAZE_INTERNAL_ASSERT( row + m <= (*c).rows(), "Invalid number of rows" );
2437 BLAZE_INTERNAL_ASSERT( column + n <= (*c).columns(), "Invalid number of columns" );
2438
2439 const size_t jend( column + n );
2440
2441 for( size_t j=column; j<jend; ++j ) {
2442 if( !trySet( c.operand(), row, c.idx(j), m, 1UL, value ) )
2443 return false;
2444 }
2445
2446 return true;
2447}
2449//*************************************************************************************************
2450
2451
2452//*************************************************************************************************
2468template< typename MT // Type of the matrix
2469 , bool SO // Storage order
2470 , bool DF // Density flag
2471 , bool SF // Symmetry flag
2472 , typename... CCAs // Compile time column arguments
2473 , typename ET > // Type of the element
2474inline bool tryAdd( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t i, size_t j, const ET& value )
2475{
2476 BLAZE_INTERNAL_ASSERT( i < c.rows(), "Invalid row access index" );
2477 BLAZE_INTERNAL_ASSERT( j < c.columns(), "Invalid column access index" );
2478
2479 return tryAdd( c.operand(), c.idx(i), j, value );
2480}
2482//*************************************************************************************************
2483
2484
2485//*************************************************************************************************
2503template< typename MT // Type of the matrix
2504 , bool SO // Storage order
2505 , bool DF // Density flag
2506 , bool SF // Symmetry flag
2507 , typename... CCAs // Compile time column arguments
2508 , typename ET > // Type of the element
2510 tryAdd( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t row, size_t column, size_t m, size_t n, const ET& value )
2511{
2512 BLAZE_INTERNAL_ASSERT( row <= (*c).rows(), "Invalid row access index" );
2513 BLAZE_INTERNAL_ASSERT( column <= (*c).columns(), "Invalid column access index" );
2514 BLAZE_INTERNAL_ASSERT( row + m <= (*c).rows(), "Invalid number of rows" );
2515 BLAZE_INTERNAL_ASSERT( column + n <= (*c).columns(), "Invalid number of columns" );
2516
2517 const size_t jend( column + n );
2518
2519 for( size_t j=column; j<jend; ++j ) {
2520 if( !tryAdd( c.operand(), row, c.idx(j), m, 1UL, value ) )
2521 return false;
2522 }
2523
2524 return true;
2525}
2527//*************************************************************************************************
2528
2529
2530//*************************************************************************************************
2546template< typename MT // Type of the matrix
2547 , bool SO // Storage order
2548 , bool DF // Density flag
2549 , bool SF // Symmetry flag
2550 , typename... CCAs // Compile time column arguments
2551 , typename ET > // Type of the element
2552inline bool trySub( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t i, size_t j, const ET& value )
2553{
2554 BLAZE_INTERNAL_ASSERT( i < c.rows(), "Invalid row access index" );
2555 BLAZE_INTERNAL_ASSERT( j < c.columns(), "Invalid column access index" );
2556
2557 return trySub( c.operand(), c.idx(i), j, value );
2558}
2560//*************************************************************************************************
2561
2562
2563//*************************************************************************************************
2581template< typename MT // Type of the matrix
2582 , bool SO // Storage order
2583 , bool DF // Density flag
2584 , bool SF // Symmetry flag
2585 , typename... CCAs // Compile time column arguments
2586 , typename ET > // Type of the element
2588 trySub( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t row, size_t column, size_t m, size_t n, const ET& value )
2589{
2590 BLAZE_INTERNAL_ASSERT( row <= (*c).rows(), "Invalid row access index" );
2591 BLAZE_INTERNAL_ASSERT( column <= (*c).columns(), "Invalid column access index" );
2592 BLAZE_INTERNAL_ASSERT( row + m <= (*c).rows(), "Invalid number of rows" );
2593 BLAZE_INTERNAL_ASSERT( column + n <= (*c).columns(), "Invalid number of columns" );
2594
2595 const size_t jend( column + n );
2596
2597 for( size_t j=column; j<jend; ++j ) {
2598 if( !trySub( c.operand(), row, c.idx(j), m, 1UL, value ) )
2599 return false;
2600 }
2601
2602 return true;
2603}
2605//*************************************************************************************************
2606
2607
2608//*************************************************************************************************
2624template< typename MT // Type of the matrix
2625 , bool SO // Storage order
2626 , bool DF // Density flag
2627 , bool SF // Symmetry flag
2628 , typename... CCAs // Compile time column arguments
2629 , typename ET > // Type of the element
2630inline bool tryMult( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t i, size_t j, const ET& value )
2631{
2632 BLAZE_INTERNAL_ASSERT( i < c.rows(), "Invalid row access index" );
2633 BLAZE_INTERNAL_ASSERT( j < c.columns(), "Invalid column access index" );
2634
2635 return tryMult( c.operand(), c.idx(i), j, value );
2636}
2638//*************************************************************************************************
2639
2640
2641//*************************************************************************************************
2659template< typename MT // Type of the matrix
2660 , bool SO // Storage order
2661 , bool DF // Density flag
2662 , bool SF // Symmetry flag
2663 , typename... CCAs // Compile time column arguments
2664 , typename ET > // Type of the element
2666 tryMult( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t row, size_t column, size_t m, size_t n, const ET& value )
2667{
2668 BLAZE_INTERNAL_ASSERT( row <= (*c).rows(), "Invalid row access index" );
2669 BLAZE_INTERNAL_ASSERT( column <= (*c).columns(), "Invalid column access index" );
2670 BLAZE_INTERNAL_ASSERT( row + m <= (*c).rows(), "Invalid number of rows" );
2671 BLAZE_INTERNAL_ASSERT( column + n <= (*c).columns(), "Invalid number of columns" );
2672
2673 const size_t jend( column + n );
2674
2675 for( size_t j=column; j<jend; ++j ) {
2676 if( !tryMult( c.operand(), row, c.idx(j), m, 1UL, value ) )
2677 return false;
2678 }
2679
2680 return true;
2681}
2683//*************************************************************************************************
2684
2685
2686//*************************************************************************************************
2702template< typename MT // Type of the matrix
2703 , bool SO // Storage order
2704 , bool DF // Density flag
2705 , bool SF // Symmetry flag
2706 , typename... CCAs // Compile time column arguments
2707 , typename ET > // Type of the element
2708inline bool tryDiv( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t i, size_t j, const ET& value )
2709{
2710 BLAZE_INTERNAL_ASSERT( i < c.rows(), "Invalid row access index" );
2711 BLAZE_INTERNAL_ASSERT( j < c.columns(), "Invalid column access index" );
2712
2713 return tryDiv( c.operand(), c.idx(i), j, value );
2714}
2716//*************************************************************************************************
2717
2718
2719//*************************************************************************************************
2737template< typename MT // Type of the matrix
2738 , bool SO // Storage order
2739 , bool DF // Density flag
2740 , bool SF // Symmetry flag
2741 , typename... CCAs // Compile time column arguments
2742 , typename ET > // Type of the element
2744 tryDiv( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t row, size_t column, size_t m, size_t n, const ET& value )
2745{
2746 BLAZE_INTERNAL_ASSERT( row <= (*c).rows(), "Invalid row access index" );
2747 BLAZE_INTERNAL_ASSERT( column <= (*c).columns(), "Invalid column access index" );
2748 BLAZE_INTERNAL_ASSERT( row + m <= (*c).rows(), "Invalid number of rows" );
2749 BLAZE_INTERNAL_ASSERT( column + n <= (*c).columns(), "Invalid number of columns" );
2750
2751 const size_t jend( column + n );
2752
2753 for( size_t j=column; j<jend; ++j ) {
2754 if( !tryDiv( c.operand(), row, c.idx(j), m, 1UL, value ) )
2755 return false;
2756 }
2757
2758 return true;
2759}
2761//*************************************************************************************************
2762
2763
2764//*************************************************************************************************
2780template< typename MT // Type of the matrix
2781 , bool SO // Storage order
2782 , bool DF // Density flag
2783 , bool SF // Symmetry flag
2784 , typename... CCAs > // Compile time column arguments
2785inline bool tryShift( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t i, size_t j, int count )
2786{
2787 BLAZE_INTERNAL_ASSERT( i < c.rows(), "Invalid row access index" );
2788 BLAZE_INTERNAL_ASSERT( j < c.columns(), "Invalid column access index" );
2789
2790 return tryShift( c.operand(), c.idx(i), j, count );
2791}
2793//*************************************************************************************************
2794
2795
2796//*************************************************************************************************
2814template< typename MT // Type of the matrix
2815 , bool SO // Storage order
2816 , bool DF // Density flag
2817 , bool SF // Symmetry flag
2818 , typename... CCAs > // Compile time column arguments
2820 tryShift( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t row, size_t column, size_t m, size_t n, int count )
2821{
2822 BLAZE_INTERNAL_ASSERT( row <= (*c).rows(), "Invalid row access index" );
2823 BLAZE_INTERNAL_ASSERT( column <= (*c).columns(), "Invalid column access index" );
2824 BLAZE_INTERNAL_ASSERT( row + m <= (*c).rows(), "Invalid number of rows" );
2825 BLAZE_INTERNAL_ASSERT( column + n <= (*c).columns(), "Invalid number of columns" );
2826
2827 const size_t jend( column + n );
2828
2829 for( size_t j=column; j<jend; ++j ) {
2830 if( !tryShift( c.operand(), row, c.idx(j), m, 1UL, count ) )
2831 return false;
2832 }
2833
2834 return true;
2835}
2837//*************************************************************************************************
2838
2839
2840//*************************************************************************************************
2856template< typename MT // Type of the matrix
2857 , bool SO // Storage order
2858 , bool DF // Density flag
2859 , bool SF // Symmetry flag
2860 , typename... CCAs // Compile time column arguments
2861 , typename ET > // Type of the element
2862inline bool tryBitand( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t i, size_t j, const ET& value )
2863{
2864 BLAZE_INTERNAL_ASSERT( i < c.rows(), "Invalid row access index" );
2865 BLAZE_INTERNAL_ASSERT( j < c.columns(), "Invalid column access index" );
2866
2867 return tryBitand( c.operand(), c.idx(i), j, value );
2868}
2870//*************************************************************************************************
2871
2872
2873//*************************************************************************************************
2891template< typename MT // Type of the matrix
2892 , bool SO // Storage order
2893 , bool DF // Density flag
2894 , bool SF // Symmetry flag
2895 , typename... CCAs // Compile time column arguments
2896 , typename ET > // Type of the element
2898 tryBitand( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t row, size_t column, size_t m, size_t n, const ET& value )
2899{
2900 BLAZE_INTERNAL_ASSERT( row <= (*c).rows(), "Invalid row access index" );
2901 BLAZE_INTERNAL_ASSERT( column <= (*c).columns(), "Invalid column access index" );
2902 BLAZE_INTERNAL_ASSERT( row + m <= (*c).rows(), "Invalid number of rows" );
2903 BLAZE_INTERNAL_ASSERT( column + n <= (*c).columns(), "Invalid number of columns" );
2904
2905 const size_t jend( column + n );
2906
2907 for( size_t j=column; j<jend; ++j ) {
2908 if( !tryBitand( c.operand(), row, c.idx(j), m, 1UL, value ) )
2909 return false;
2910 }
2911
2912 return true;
2913}
2915//*************************************************************************************************
2916
2917
2918//*************************************************************************************************
2934template< typename MT // Type of the matrix
2935 , bool SO // Storage order
2936 , bool DF // Density flag
2937 , bool SF // Symmetry flag
2938 , typename... CCAs // Compile time column arguments
2939 , typename ET > // Type of the element
2940inline bool tryBitor( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t i, size_t j, const ET& value )
2941{
2942 BLAZE_INTERNAL_ASSERT( i < c.rows(), "Invalid row access index" );
2943 BLAZE_INTERNAL_ASSERT( j < c.columns(), "Invalid column access index" );
2944
2945 return tryBitor( c.operand(), c.idx(i), j, value );
2946}
2948//*************************************************************************************************
2949
2950
2951//*************************************************************************************************
2969template< typename MT // Type of the matrix
2970 , bool SO // Storage order
2971 , bool DF // Density flag
2972 , bool SF // Symmetry flag
2973 , typename... CCAs // Compile time column arguments
2974 , typename ET > // Type of the element
2976 tryBitor( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t row, size_t column, size_t m, size_t n, const ET& value )
2977{
2978 BLAZE_INTERNAL_ASSERT( row <= (*c).rows(), "Invalid row access index" );
2979 BLAZE_INTERNAL_ASSERT( column <= (*c).columns(), "Invalid column access index" );
2980 BLAZE_INTERNAL_ASSERT( row + m <= (*c).rows(), "Invalid number of rows" );
2981 BLAZE_INTERNAL_ASSERT( column + n <= (*c).columns(), "Invalid number of columns" );
2982
2983 const size_t jend( column + n );
2984
2985 for( size_t j=column; j<jend; ++j ) {
2986 if( !tryBitor( c.operand(), row, c.idx(j), m, 1UL, value ) )
2987 return false;
2988 }
2989
2990 return true;
2991}
2993//*************************************************************************************************
2994
2995
2996//*************************************************************************************************
3012template< typename MT // Type of the matrix
3013 , bool SO // Storage order
3014 , bool DF // Density flag
3015 , bool SF // Symmetry flag
3016 , typename... CCAs // Compile time column arguments
3017 , typename ET > // Type of the element
3018inline bool tryBitxor( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t i, size_t j, const ET& value )
3019{
3020 BLAZE_INTERNAL_ASSERT( i < c.rows(), "Invalid row access index" );
3021 BLAZE_INTERNAL_ASSERT( j < c.columns(), "Invalid column access index" );
3022
3023 return tryBitxor( c.operand(), c.idx(i), j, value );
3024}
3026//*************************************************************************************************
3027
3028
3029//*************************************************************************************************
3047template< typename MT // Type of the matrix
3048 , bool SO // Storage order
3049 , bool DF // Density flag
3050 , bool SF // Symmetry flag
3051 , typename... CCAs // Compile time column arguments
3052 , typename ET > // Type of the element
3054 tryBitxor( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t row, size_t column, size_t m, size_t n, const ET& value )
3055{
3056 BLAZE_INTERNAL_ASSERT( row <= (*c).rows(), "Invalid row access index" );
3057 BLAZE_INTERNAL_ASSERT( column <= (*c).columns(), "Invalid column access index" );
3058 BLAZE_INTERNAL_ASSERT( row + m <= (*c).rows(), "Invalid number of rows" );
3059 BLAZE_INTERNAL_ASSERT( column + n <= (*c).columns(), "Invalid number of columns" );
3060
3061 const size_t jend( column + n );
3062
3063 for( size_t j=column; j<jend; ++j ) {
3064 if( !tryBitxor( c.operand(), row, c.idx(j), m, 1UL, value ) )
3065 return false;
3066 }
3067
3068 return true;
3069}
3071//*************************************************************************************************
3072
3073
3074//*************************************************************************************************
3090template< typename MT // Type of the matrix
3091 , bool SO // Storage order
3092 , bool DF // Density flag
3093 , bool SF // Symmetry flag
3094 , typename... CCAs // Compile time column arguments
3095 , typename VT > // Type of the right-hand side vector
3096inline bool tryAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3097 const Vector<VT,false>& rhs, size_t row, size_t column )
3098{
3099 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3100 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3101 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3102
3103 return tryAssign( lhs.operand(), *rhs, row, lhs.idx( column ) );
3104}
3106//*************************************************************************************************
3107
3108
3109//*************************************************************************************************
3125template< typename MT // Type of the matrix
3126 , bool SO // Storage order
3127 , bool DF // Density flag
3128 , bool SF // Symmetry flag
3129 , typename... CCAs // Compile time column arguments
3130 , typename VT > // Type of the right-hand side vector
3131inline bool tryAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3132 const Vector<VT,true>& rhs, size_t row, size_t column )
3133{
3134 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3135 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3136 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3137
3138 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3139 if( !trySet( lhs.operand(), row, lhs.idx( column+i ), (*rhs)[i] ) )
3140 return false;
3141 }
3142
3143 return true;
3144}
3146//*************************************************************************************************
3147
3148
3149//*************************************************************************************************
3167template< typename MT // Type of the matrix
3168 , bool SO // Storage order
3169 , bool DF // Density flag
3170 , bool SF // Symmetry flag
3171 , typename... CCAs // Compile time column arguments
3172 , typename VT // Type of the right-hand side vector
3173 , bool TF > // Transpose flag of the right-hand side vector
3174inline bool tryAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3175 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3176{
3177 MAYBE_UNUSED( band );
3178
3179 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3180 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3181 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3182 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3183
3184 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3185 if( !trySet( lhs.operand(), row+i, lhs.idx( column+i ), (*rhs)[i] ) )
3186 return false;
3187 }
3188
3189 return true;
3190}
3192//*************************************************************************************************
3193
3194
3195//*************************************************************************************************
3211template< typename MT1 // Type of the matrix
3212 , bool SO1 // Storage order
3213 , bool DF // Density flag
3214 , bool SF // Symmetry flag
3215 , typename... CCAs // Compile time column arguments
3216 , typename MT2 // Type of the right-hand side matrix
3217 , bool SO2 > // Storage order of the right-hand side matrix
3218inline bool tryAssign( const Columns<MT1,SO1,DF,SF,CCAs...>& lhs,
3219 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3220{
3221 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3222 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3223 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
3224 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3225
3226 for( size_t j=0UL; j<(*rhs).columns(); ++j ) {
3227 if( !tryAssign( lhs.operand(), blaze::column( *rhs, j, unchecked ), row, lhs.idx( column+j ) ) )
3228 return false;
3229 }
3230
3231 return true;
3232}
3234//*************************************************************************************************
3235
3236
3237//*************************************************************************************************
3254template< typename MT // Type of the matrix
3255 , bool SO // Storage order
3256 , bool DF // Density flag
3257 , bool SF // Symmetry flag
3258 , typename... CCAs // Compile time column arguments
3259 , typename VT > // Type of the right-hand side vector
3260inline bool tryAddAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3261 const Vector<VT,false>& rhs, size_t row, size_t column )
3262{
3263 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3264 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3265 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3266
3267 return tryAddAssign( lhs.operand(), *rhs, row, lhs.idx( column ) );
3268}
3270//*************************************************************************************************
3271
3272
3273//*************************************************************************************************
3290template< typename MT // Type of the matrix
3291 , bool SO // Storage order
3292 , bool DF // Density flag
3293 , bool SF // Symmetry flag
3294 , typename... CCAs // Compile time column arguments
3295 , typename VT > // Type of the right-hand side vector
3296inline bool tryAddAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3297 const Vector<VT,true>& rhs, size_t row, size_t column )
3298{
3299 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3300 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3301 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3302
3303 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3304 if( !tryAdd( lhs.operand(), row, lhs.idx( column+i ), (*rhs)[i] ) )
3305 return false;
3306 }
3307
3308 return true;
3309}
3311//*************************************************************************************************
3312
3313
3314//*************************************************************************************************
3332template< typename MT // Type of the matrix
3333 , bool SO // Storage order
3334 , bool DF // Density flag
3335 , bool SF // Symmetry flag
3336 , typename... CCAs // Compile time column arguments
3337 , typename VT // Type of the right-hand side vector
3338 , bool TF > // Transpose flag of the right-hand side vector
3339inline bool tryAddAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3340 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3341{
3342 MAYBE_UNUSED( band );
3343
3344 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3345 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3346 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3347 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3348
3349 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3350 if( !tryAdd( lhs.operand(), row+i, lhs.idx( column+i ), (*rhs)[i] ) )
3351 return false;
3352 }
3353
3354 return true;
3355}
3357//*************************************************************************************************
3358
3359
3360//*************************************************************************************************
3376template< typename MT1 // Type of the matrix
3377 , bool SO1 // Storage order
3378 , bool DF // Density flag
3379 , bool SF // Symmetry flag
3380 , typename... CCAs // Compile time column arguments
3381 , typename MT2 // Type of the right-hand side matrix
3382 , bool SO2 > // Storage order of the right-hand side matrix
3383inline bool tryAddAssign( const Columns<MT1,SO1,DF,SF,CCAs...>& lhs,
3384 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3385{
3386 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3387 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3388 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
3389 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3390
3391 for( size_t j=0UL; j<(*rhs).columns(); ++j ) {
3392 if( !tryAddAssign( lhs.operand(), blaze::column( *rhs, j, unchecked ), row, lhs.idx( column+j ) ) )
3393 return false;
3394 }
3395
3396 return true;
3397}
3399//*************************************************************************************************
3400
3401
3402//*************************************************************************************************
3419template< typename MT // Type of the matrix
3420 , bool SO // Storage order
3421 , bool DF // Density flag
3422 , bool SF // Symmetry flag
3423 , typename... CCAs // Compile time column arguments
3424 , typename VT > // Type of the right-hand side vector
3425inline bool trySubAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3426 const Vector<VT,false>& rhs, size_t row, size_t column )
3427{
3428 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3429 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3430 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3431
3432 return trySubAssign( lhs.operand(), *rhs, row, lhs.idx( column ) );
3433}
3435//*************************************************************************************************
3436
3437
3438//*************************************************************************************************
3455template< typename MT // Type of the matrix
3456 , bool SO // Storage order
3457 , bool DF // Density flag
3458 , bool SF // Symmetry flag
3459 , typename... CCAs // Compile time column arguments
3460 , typename VT > // Type of the right-hand side vector
3461inline bool trySubAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3462 const Vector<VT,true>& rhs, size_t row, size_t column )
3463{
3464 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3465 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3466 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3467
3468 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3469 if( !trySub( lhs.operand(), row, lhs.idx( column+i ), (*rhs)[i] ) )
3470 return false;
3471 }
3472
3473 return true;
3474}
3476//*************************************************************************************************
3477
3478
3479//*************************************************************************************************
3497template< typename MT // Type of the matrix
3498 , bool SO // Storage order
3499 , bool DF // Density flag
3500 , bool SF // Symmetry flag
3501 , typename... CCAs // Compile time column arguments
3502 , typename VT // Type of the right-hand side vector
3503 , bool TF > // Transpose flag of the right-hand side vector
3504inline bool trySubAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3505 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3506{
3507 MAYBE_UNUSED( band );
3508
3509 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3510 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3511 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3512 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3513
3514 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3515 if( !trySub( lhs.operand(), row+i, lhs.idx( column+i ), (*rhs)[i] ) )
3516 return false;
3517 }
3518
3519 return true;
3520}
3522//*************************************************************************************************
3523
3524
3525//*************************************************************************************************
3542template< typename MT1 // Type of the matrix
3543 , bool SO1 // Storage order
3544 , bool DF // Density flag
3545 , bool SF // Symmetry flag
3546 , typename... CCAs // Compile time column arguments
3547 , typename MT2 // Type of the right-hand side matrix
3548 , bool SO2 > // Storage order of the right-hand side matrix
3549inline bool trySubAssign( const Columns<MT1,SO1,DF,SF,CCAs...>& lhs,
3550 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3551{
3552 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3553 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3554 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
3555 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3556
3557 for( size_t j=0UL; j<(*rhs).columns(); ++j ) {
3558 if( !trySubAssign( lhs.operand(), blaze::column( *rhs, j, unchecked ), row, lhs.idx( column+j ) ) )
3559 return false;
3560 }
3561
3562 return true;
3563}
3565//*************************************************************************************************
3566
3567
3568//*************************************************************************************************
3585template< typename MT // Type of the matrix
3586 , bool SO // Storage order
3587 , bool DF // Density flag
3588 , bool SF // Symmetry flag
3589 , typename... CCAs // Compile time column arguments
3590 , typename VT > // Type of the right-hand side vector
3591inline bool tryMultAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3592 const Vector<VT,false>& rhs, size_t row, size_t column )
3593{
3594 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3595 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3596 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3597
3598 return tryMultAssign( lhs.operand(), *rhs, row, lhs.idx( column ) );
3599}
3601//*************************************************************************************************
3602
3603
3604//*************************************************************************************************
3621template< typename MT // Type of the matrix
3622 , bool SO // Storage order
3623 , bool DF // Density flag
3624 , bool SF // Symmetry flag
3625 , typename... CCAs // Compile time column arguments
3626 , typename VT > // Type of the right-hand side vector
3627inline bool tryMultAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3628 const Vector<VT,true>& rhs, size_t row, size_t column )
3629{
3630 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3631 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3632 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3633
3634 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3635 if( !tryMult( lhs.operand(), row, lhs.idx( column+i ), (*rhs)[i] ) )
3636 return false;
3637 }
3638
3639 return true;
3640}
3642//*************************************************************************************************
3643
3644
3645//*************************************************************************************************
3663template< typename MT // Type of the matrix
3664 , bool SO // Storage order
3665 , bool DF // Density flag
3666 , bool SF // Symmetry flag
3667 , typename... CCAs // Compile time column arguments
3668 , typename VT // Type of the right-hand side vector
3669 , bool TF > // Transpose flag of the right-hand side vector
3670inline bool tryMultAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3671 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3672{
3673 MAYBE_UNUSED( band );
3674
3675 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3676 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3677 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3678 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3679
3680 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3681 if( !tryMult( lhs.operand(), row+i, lhs.idx( column+i ), (*rhs)[i] ) )
3682 return false;
3683 }
3684
3685 return true;
3686}
3688//*************************************************************************************************
3689
3690
3691//*************************************************************************************************
3708template< typename MT1 // Type of the matrix
3709 , bool SO1 // Storage order
3710 , bool DF // Density flag
3711 , bool SF // Symmetry flag
3712 , typename... CCAs // Compile time column arguments
3713 , typename MT2 // Type of the right-hand side matrix
3714 , bool SO2 > // Storage order of the right-hand side matrix
3715inline bool trySchurAssign( const Columns<MT1,SO1,DF,SF,CCAs...>& lhs,
3716 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3717{
3718 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3719 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3720 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
3721 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3722
3723 for( size_t j=0UL; j<(*rhs).columns(); ++j ) {
3724 if( !tryMultAssign( lhs.operand(), blaze::column( *rhs, j, unchecked ), row, lhs.idx( column+j ) ) )
3725 return false;
3726 }
3727
3728 return true;
3729}
3731//*************************************************************************************************
3732
3733
3734//*************************************************************************************************
3751template< typename MT // Type of the matrix
3752 , bool SO // Storage order
3753 , bool DF // Density flag
3754 , bool SF // Symmetry flag
3755 , typename... CCAs // Compile time column arguments
3756 , typename VT > // Type of the right-hand side vector
3757inline bool tryDivAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3758 const Vector<VT,false>& rhs, size_t row, size_t column )
3759{
3760 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3761 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3762 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3763
3764 return tryDivAssign( lhs.operand(), *rhs, row, lhs.idx( column ) );
3765}
3767//*************************************************************************************************
3768
3769
3770//*************************************************************************************************
3787template< typename MT // Type of the matrix
3788 , bool SO // Storage order
3789 , bool DF // Density flag
3790 , bool SF // Symmetry flag
3791 , typename... CCAs // Compile time column arguments
3792 , typename VT > // Type of the right-hand side vector
3793inline bool tryDivAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3794 const Vector<VT,true>& rhs, size_t row, size_t column )
3795{
3796 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3797 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3798 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3799
3800 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3801 if( !tryDiv( lhs.operand(), row, lhs.idx( column+i ), (*rhs)[i] ) )
3802 return false;
3803 }
3804
3805 return true;
3806}
3808//*************************************************************************************************
3809
3810
3811//*************************************************************************************************
3829template< typename MT // Type of the matrix
3830 , bool SO // Storage order
3831 , bool DF // Density flag
3832 , bool SF // Symmetry flag
3833 , typename... CCAs // Compile time column arguments
3834 , typename VT // Type of the right-hand side vector
3835 , bool TF > // Transpose flag of the right-hand side vector
3836inline bool tryDivAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3837 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3838{
3839 MAYBE_UNUSED( band );
3840
3841 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3842 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3843 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3844 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3845
3846 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3847 if( !tryDiv( lhs.operand(), row+i, lhs.idx( column+i ), (*rhs)[i] ) )
3848 return false;
3849 }
3850
3851 return true;
3852}
3854//*************************************************************************************************
3855
3856
3857//*************************************************************************************************
3874template< typename MT // Type of the matrix
3875 , bool SO // Storage order
3876 , bool DF // Density flag
3877 , bool SF // Symmetry flag
3878 , typename... CCAs // Compile time column arguments
3879 , typename VT > // Type of the right-hand side vector
3880inline bool tryShiftAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3881 const Vector<VT,false>& rhs, size_t row, size_t column )
3882{
3883 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3884 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3885 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3886
3887 return tryShiftAssign( lhs.operand(), *rhs, row, lhs.idx( column ) );
3888}
3890//*************************************************************************************************
3891
3892
3893//*************************************************************************************************
3910template< typename MT // Type of the matrix
3911 , bool SO // Storage order
3912 , bool DF // Density flag
3913 , bool SF // Symmetry flag
3914 , typename... CCAs // Compile time column arguments
3915 , typename VT > // Type of the right-hand side vector
3916inline bool tryShiftAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3917 const Vector<VT,true>& rhs, size_t row, size_t column )
3918{
3919 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3920 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3921 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3922
3923 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3924 if( !tryShift( lhs.operand(), row, lhs.idx( column+i ), (*rhs)[i] ) )
3925 return false;
3926 }
3927
3928 return true;
3929}
3931//*************************************************************************************************
3932
3933
3934//*************************************************************************************************
3952template< typename MT // Type of the matrix
3953 , bool SO // Storage order
3954 , bool DF // Density flag
3955 , bool SF // Symmetry flag
3956 , typename... CCAs // Compile time column arguments
3957 , typename VT // Type of the right-hand side vector
3958 , bool TF > // Transpose flag of the right-hand side vector
3959inline bool tryShiftAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3960 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3961{
3962 MAYBE_UNUSED( band );
3963
3964 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3965 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3966 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
3967 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
3968
3969 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
3970 if( !tryShift( lhs.operand(), row+i, lhs.idx( column+i ), (*rhs)[i] ) )
3971 return false;
3972 }
3973
3974 return true;
3975}
3977//*************************************************************************************************
3978
3979
3980//*************************************************************************************************
3996template< typename MT1 // Type of the matrix
3997 , bool SO1 // Storage order
3998 , bool DF // Density flag
3999 , bool SF // Symmetry flag
4000 , typename... CCAs // Compile time column arguments
4001 , typename MT2 // Type of the right-hand side matrix
4002 , bool SO2 > // Storage order of the right-hand side matrix
4003inline bool tryShiftAssign( const Columns<MT1,SO1,DF,SF,CCAs...>& lhs,
4004 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
4005{
4006 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4007 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4008 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
4009 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
4010
4011 for( size_t j=0UL; j<(*rhs).columns(); ++j ) {
4012 if( !tryShiftAssign( lhs.operand(), blaze::column( *rhs, j, unchecked ), row, lhs.idx( column+j ) ) )
4013 return false;
4014 }
4015
4016 return true;
4017}
4019//*************************************************************************************************
4020
4021
4022//*************************************************************************************************
4039template< typename MT // Type of the matrix
4040 , bool SO // Storage order
4041 , bool DF // Density flag
4042 , bool SF // Symmetry flag
4043 , typename... CCAs // Compile time column arguments
4044 , typename VT > // Type of the right-hand side vector
4045inline bool tryBitandAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
4046 const Vector<VT,false>& rhs, size_t row, size_t column )
4047{
4048 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4049 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4050 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4051
4052 return tryBitandAssign( lhs.operand(), *rhs, row, lhs.idx( column ) );
4053}
4055//*************************************************************************************************
4056
4057
4058//*************************************************************************************************
4075template< typename MT // Type of the matrix
4076 , bool SO // Storage order
4077 , bool DF // Density flag
4078 , bool SF // Symmetry flag
4079 , typename... CCAs // Compile time column arguments
4080 , typename VT > // Type of the right-hand side vector
4081inline bool tryBitandAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
4082 const Vector<VT,true>& rhs, size_t row, size_t column )
4083{
4084 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4085 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4086 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4087
4088 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
4089 if( !tryBitand( lhs.operand(), row, lhs.idx( column+i ), (*rhs)[i] ) )
4090 return false;
4091 }
4092
4093 return true;
4094}
4096//*************************************************************************************************
4097
4098
4099//*************************************************************************************************
4117template< typename MT // Type of the matrix
4118 , bool SO // Storage order
4119 , bool DF // Density flag
4120 , bool SF // Symmetry flag
4121 , typename... CCAs // Compile time column arguments
4122 , typename VT // Type of the right-hand side vector
4123 , bool TF > // Transpose flag of the right-hand side vector
4124inline bool tryBitandAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
4125 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
4126{
4127 MAYBE_UNUSED( band );
4128
4129 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4130 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4131 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4132 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4133
4134 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
4135 if( !tryBitand( lhs.operand(), row+i, lhs.idx( column+i ), (*rhs)[i] ) )
4136 return false;
4137 }
4138
4139 return true;
4140}
4142//*************************************************************************************************
4143
4144
4145//*************************************************************************************************
4162template< typename MT1 // Type of the matrix
4163 , bool SO1 // Storage order
4164 , bool DF // Density flag
4165 , bool SF // Symmetry flag
4166 , typename... CCAs // Compile time column arguments
4167 , typename MT2 // Type of the right-hand side matrix
4168 , bool SO2 > // Storage order of the right-hand side matrix
4169inline bool tryBitandAssign( const Columns<MT1,SO1,DF,SF,CCAs...>& lhs,
4170 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
4171{
4172 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4173 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4174 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
4175 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
4176
4177 for( size_t j=0UL; j<(*rhs).columns(); ++j ) {
4178 if( !tryBitandAssign( lhs.operand(), blaze::column( *rhs, j, unchecked ), row, lhs.idx( column+j ) ) )
4179 return false;
4180 }
4181
4182 return true;
4183}
4185//*************************************************************************************************
4186
4187
4188//*************************************************************************************************
4205template< typename MT // Type of the matrix
4206 , bool SO // Storage order
4207 , bool DF // Density flag
4208 , bool SF // Symmetry flag
4209 , typename... CCAs // Compile time column arguments
4210 , typename VT > // Type of the right-hand side vector
4211inline bool tryBitorAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
4212 const Vector<VT,false>& rhs, size_t row, size_t column )
4213{
4214 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4215 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4216 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4217
4218 return tryBitorAssign( lhs.operand(), *rhs, row, lhs.idx( column ) );
4219}
4221//*************************************************************************************************
4222
4223
4224//*************************************************************************************************
4241template< typename MT // Type of the matrix
4242 , bool SO // Storage order
4243 , bool DF // Density flag
4244 , bool SF // Symmetry flag
4245 , typename... CCAs // Compile time column arguments
4246 , typename VT > // Type of the right-hand side vector
4247inline bool tryBitorAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
4248 const Vector<VT,true>& rhs, size_t row, size_t column )
4249{
4250 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4251 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4252 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4253
4254 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
4255 if( !tryBitor( lhs.operand(), row, lhs.idx( column+i ), (*rhs)[i] ) )
4256 return false;
4257 }
4258
4259 return true;
4260}
4262//*************************************************************************************************
4263
4264
4265//*************************************************************************************************
4283template< typename MT // Type of the matrix
4284 , bool SO // Storage order
4285 , bool DF // Density flag
4286 , bool SF // Symmetry flag
4287 , typename... CCAs // Compile time column arguments
4288 , typename VT // Type of the right-hand side vector
4289 , bool TF > // Transpose flag of the right-hand side vector
4290inline bool tryBitorAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
4291 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
4292{
4293 MAYBE_UNUSED( band );
4294
4295 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4296 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4297 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4298 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4299
4300 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
4301 if( !tryBitor( lhs.operand(), row+i, lhs.idx( column+i ), (*rhs)[i] ) )
4302 return false;
4303 }
4304
4305 return true;
4306}
4308//*************************************************************************************************
4309
4310
4311//*************************************************************************************************
4328template< typename MT1 // Type of the matrix
4329 , bool SO1 // Storage order
4330 , bool DF // Density flag
4331 , bool SF // Symmetry flag
4332 , typename... CCAs // Compile time column arguments
4333 , typename MT2 // Type of the right-hand side matrix
4334 , bool SO2 > // Storage order of the right-hand side matrix
4335inline bool tryBitorAssign( const Columns<MT1,SO1,DF,SF,CCAs...>& lhs,
4336 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
4337{
4338 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4339 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4340 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
4341 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
4342
4343 for( size_t j=0UL; j<(*rhs).columns(); ++j ) {
4344 if( !tryBitorAssign( lhs.operand(), blaze::column( *rhs, j, unchecked ), row, lhs.idx( column+j ) ) )
4345 return false;
4346 }
4347
4348 return true;
4349}
4351//*************************************************************************************************
4352
4353
4354//*************************************************************************************************
4371template< typename MT // Type of the matrix
4372 , bool SO // Storage order
4373 , bool DF // Density flag
4374 , bool SF // Symmetry flag
4375 , typename... CCAs // Compile time column arguments
4376 , typename VT > // Type of the right-hand side vector
4377inline bool tryBitxorAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
4378 const Vector<VT,false>& rhs, size_t row, size_t column )
4379{
4380 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4381 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4382 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4383
4384 return tryBitxorAssign( lhs.operand(), *rhs, row, lhs.idx( column ) );
4385}
4387//*************************************************************************************************
4388
4389
4390//*************************************************************************************************
4407template< typename MT // Type of the matrix
4408 , bool SO // Storage order
4409 , bool DF // Density flag
4410 , bool SF // Symmetry flag
4411 , typename... CCAs // Compile time column arguments
4412 , typename VT > // Type of the right-hand side vector
4413inline bool tryBitxorAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
4414 const Vector<VT,true>& rhs, size_t row, size_t column )
4415{
4416 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4417 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4418 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4419
4420 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
4421 if( !tryBitxor( lhs.operand(), row, lhs.idx( column+i ), (*rhs)[i] ) )
4422 return false;
4423 }
4424
4425 return true;
4426}
4428//*************************************************************************************************
4429
4430
4431//*************************************************************************************************
4449template< typename MT // Type of the matrix
4450 , bool SO // Storage order
4451 , bool DF // Density flag
4452 , bool SF // Symmetry flag
4453 , typename... CCAs // Compile time column arguments
4454 , typename VT // Type of the right-hand side vector
4455 , bool TF > // Transpose flag of the right-hand side vector
4456inline bool tryBitxorAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
4457 const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
4458{
4459 MAYBE_UNUSED( band );
4460
4461 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4462 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4463 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
4464 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
4465
4466 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
4467 if( !tryBitxor( lhs.operand(), row+i, lhs.idx( column+i ), (*rhs)[i] ) )
4468 return false;
4469 }
4470
4471 return true;
4472}
4474//*************************************************************************************************
4475
4476
4477//*************************************************************************************************
4494template< typename MT1 // Type of the matrix
4495 , bool SO1 // Storage order
4496 , bool DF // Density flag
4497 , bool SF // Symmetry flag
4498 , typename... CCAs // Compile time column arguments
4499 , typename MT2 // Type of the right-hand side matrix
4500 , bool SO2 > // Storage order of the right-hand side matrix
4501inline bool tryBitxorAssign( const Columns<MT1,SO1,DF,SF,CCAs...>& lhs,
4502 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
4503{
4504 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
4505 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
4506 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
4507 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
4508
4509 for( size_t j=0UL; j<(*rhs).columns(); ++j ) {
4510 if( !tryBitxorAssign( lhs.operand(), blaze::column( *rhs, j, unchecked ), row, lhs.idx( column+j ) ) )
4511 return false;
4512 }
4513
4514 return true;
4515}
4517//*************************************************************************************************
4518
4519
4520//*************************************************************************************************
4535template< typename MT // Type of the matrix
4536 , bool SO // Storage order
4537 , bool DF // Density flag
4538 , bool SF // Symmetry flag
4539 , typename... CCAs > // Compile time column arguments
4540inline decltype(auto) derestrict( Columns<MT,SO,DF,SF,CCAs...>& c )
4541{
4542 return columns( derestrict( c.operand() ), c.idces(), unchecked );
4543}
4545//*************************************************************************************************
4546
4547
4548//*************************************************************************************************
4563template< typename MT // Type of the matrix
4564 , bool SO // Storage order
4565 , bool DF // Density flag
4566 , bool SF // Symmetry flag
4567 , typename... CCAs > // Compile time column arguments
4568inline decltype(auto) derestrict( Columns<MT,SO,DF,SF,CCAs...>&& c )
4569{
4570 return columns( derestrict( c.operand() ), c.idces(), unchecked );
4571}
4573//*************************************************************************************************
4574
4575
4576//*************************************************************************************************
4589template< typename MT // Type of the matrix
4590 , bool SO // Storage order
4591 , bool DF // Density flag
4592 , bool SF // Symmetry flag
4593 , typename... CCAs > // Compile time column arguments
4594inline decltype(auto) unview( Columns<MT,SO,DF,SF,CCAs...>& c )
4595{
4596 return c.operand();
4597}
4599//*************************************************************************************************
4600
4601
4602//*************************************************************************************************
4616template< typename MT // Type of the matrix
4617 , bool SO // Storage order
4618 , bool DF // Density flag
4619 , bool SF // Symmetry flag
4620 , typename... CCAs > // Compile time column arguments
4621inline decltype(auto) unview( const Columns<MT,SO,DF,SF,CCAs...>& c )
4622{
4623 return c.operand();
4624}
4626//*************************************************************************************************
4627
4628
4629
4630
4631//=================================================================================================
4632//
4633// SIZE SPECIALIZATIONS
4634//
4635//=================================================================================================
4636
4637//*************************************************************************************************
4639template< typename MT, bool SO, bool DF, bool SF, typename... CCAs >
4640struct Size< Columns<MT,SO,DF,SF,CCAs...>, 0UL >
4641 : public Size<MT,0UL>
4642{};
4643
4644template< typename MT, bool SO, bool DF, bool SF, size_t I, size_t... Is, typename... CCAs >
4645struct Size< Columns<MT,SO,DF,SF,index_sequence<I,Is...>,CCAs...>, 1UL >
4646 : public Ptrdiff_t< static_cast<ptrdiff_t>( 1UL+sizeof...(Is) ) >
4647{};
4649//*************************************************************************************************
4650
4651
4652
4653
4654//=================================================================================================
4655//
4656// MAXSIZE SPECIALIZATIONS
4657//
4658//=================================================================================================
4659
4660//*************************************************************************************************
4662template< typename MT, bool SO, bool DF, bool SF, typename... CCAs >
4663struct MaxSize< Columns<MT,SO,DF,SF,CCAs...>, 0UL >
4664 : public MaxSize<MT,0UL>
4665{};
4666
4667template< typename MT, bool SO, bool DF, bool SF, size_t I, size_t... Is, typename... CCAs >
4668struct MaxSize< Columns<MT,SO,DF,SF,index_sequence<I,Is...>,CCAs...>, 1UL >
4669 : public Ptrdiff_t< static_cast<ptrdiff_t>( 1UL+sizeof...(Is) ) >
4670{};
4672//*************************************************************************************************
4673
4674
4675
4676
4677//=================================================================================================
4678//
4679// ISRESTRICTED SPECIALIZATIONS
4680//
4681//=================================================================================================
4682
4683//*************************************************************************************************
4685template< typename MT, bool SO, bool DF, bool SF, typename... CCAs >
4686struct IsRestricted< Columns<MT,SO,DF,SF,CCAs...> >
4687 : public IsRestricted<MT>
4688{};
4690//*************************************************************************************************
4691
4692
4693
4694
4695//=================================================================================================
4696//
4697// HASCONSTDATAACCESS SPECIALIZATIONS
4698//
4699//=================================================================================================
4700
4701//*************************************************************************************************
4703template< typename MT, bool SO, bool SF, typename... CCAs >
4704struct HasConstDataAccess< Columns<MT,SO,true,SF,CCAs...> >
4705 : public HasConstDataAccess<MT>
4706{};
4708//*************************************************************************************************
4709
4710
4711
4712
4713//=================================================================================================
4714//
4715// HASMUTABLEDATAACCESS SPECIALIZATIONS
4716//
4717//=================================================================================================
4718
4719//*************************************************************************************************
4721template< typename MT, bool SO, bool SF, typename... CCAs >
4722struct HasMutableDataAccess< Columns<MT,SO,true,SF,CCAs...> >
4723 : public HasMutableDataAccess<MT>
4724{};
4726//*************************************************************************************************
4727
4728
4729
4730
4731//=================================================================================================
4732//
4733// ISALIGNED SPECIALIZATIONS
4734//
4735//=================================================================================================
4736
4737//*************************************************************************************************
4739template< typename MT, bool SO, bool SF, typename... CCAs >
4740struct IsAligned< Columns<MT,SO,true,SF,CCAs...> >
4741 : public IsAligned<MT>
4742{};
4744//*************************************************************************************************
4745
4746} // namespace blaze
4747
4748#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 implementation of the ColumnData class template.
Header file for the EnableIf class template.
Header file for the function trace functionality.
Header file for the HasConstDataAccess type trait.
Header file for the HasMutableDataAccess type trait.
Header file for the integer_sequence and index_sequence aliases.
Header file for the IntegralConstant class template.
Header file for the dense matrix inversion flags.
Header file for the IsAligned type trait.
Header file for the IsColumnMajorMatrix type trait.
Header file for the IsColumns 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 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 SmallArray implementation.
Base class for matrices.
Definition: Matrix.h:85
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 Matrix base class.
Header file for the SchurExpr base class.
Header file for the TVecMatMultExpr base class.
Header file for the VecExpandExpr base class.
Header file for the VecTVecMapExpr base class.
Header file for the VecTVecMultExpr base class.
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:140
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:137
decltype(auto) columns(MT &&matrix, const std::vector< T > &indices, RCAs... args)
Creating a view on a selection of columns of the given matrix.
Definition: Columns.h:703
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 rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:644
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
#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 Columns base template.
Columns specialization for dense matrices.
Columns specialization for sparse matrices.