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>
50 #include <blaze/math/Exception.h>
82 #include <blaze/math/views/Check.h>
88 #include <blaze/util/Assert.h>
89 #include <blaze/util/EnableIf.h>
90 #include <blaze/util/DisableIf.h>
93 #include <blaze/util/SmallArray.h>
94 #include <blaze/util/TypeList.h>
95 #include <blaze/util/Types.h>
97 #include <blaze/util/Unused.h>
98 
99 
100 namespace blaze {
101 
102 //=================================================================================================
103 //
104 // GLOBAL FUNCTIONS
105 //
106 //=================================================================================================
107 
108 //*************************************************************************************************
143 template< size_t I // First column index
144  , size_t... Is // Remaining column indices
145  , typename MT // Type of the matrix
146  , bool SO // Storage order
147  , typename... RCAs > // Optional arguments
148 inline decltype(auto) columns( Matrix<MT,SO>& matrix, RCAs... args )
149 {
151 
152  using ReturnType = Columns_< MT, index_sequence<I,Is...> >;
153  return ReturnType( ~matrix, args... );
154 }
155 //*************************************************************************************************
156 
157 
158 //*************************************************************************************************
193 template< size_t I // First column index
194  , size_t... Is // Remaining column indices
195  , typename MT // Type of the matrix
196  , bool SO // Storage order
197  , typename... RCAs > // Optional arguments
198 inline decltype(auto) columns( const Matrix<MT,SO>& matrix, RCAs... args )
199 {
201 
202  using ReturnType = const Columns_< const MT, index_sequence<I,Is...> >;
203  return ReturnType( ~matrix, args... );
204 }
205 //*************************************************************************************************
206 
207 
208 //*************************************************************************************************
222 template< size_t I // First column index
223  , size_t... Is // Remaining column indices
224  , typename MT // Type of the matrix
225  , bool SO // Storage order
226  , typename... RCAs > // Optional arguments
227 inline decltype(auto) columns( Matrix<MT,SO>&& matrix, RCAs... args )
228 {
230 
231  using ReturnType = Columns_< MT, index_sequence<I,Is...> >;
232  return ReturnType( ~matrix, args... );
233 }
234 //*************************************************************************************************
235 
236 
237 //*************************************************************************************************
276 template< typename MT // Type of the matrix
277  , bool SO // Storage order
278  , typename T // Type of the column indices
279  , typename... RCAs > // Optional arguments
280 inline decltype(auto) columns( Matrix<MT,SO>& matrix, const T* indices, size_t n, RCAs... args )
281 {
283 
284  using ReturnType = Columns_<MT>;
285  return ReturnType( ~matrix, indices, n, args... );
286 }
287 //*************************************************************************************************
288 
289 
290 //*************************************************************************************************
330 template< typename MT // Type of the matrix
331  , bool SO // Storage order
332  , typename T // Type of the column indices
333  , typename... RCAs > // Optional arguments
334 inline decltype(auto) columns( const Matrix<MT,SO>& matrix, const T* indices, size_t n, RCAs... args )
335 {
337 
338  using ReturnType = const Columns_<const MT>;
339  return ReturnType( ~matrix, indices, n, args... );
340 }
341 //*************************************************************************************************
342 
343 
344 //*************************************************************************************************
359 template< typename MT // Type of the matrix
360  , bool SO // Storage order
361  , typename T // Type of the column indices
362  , typename... RCAs > // Optional arguments
363 inline decltype(auto) columns( Matrix<MT,SO>&& matrix, const T* indices, size_t n, RCAs... args )
364 {
366 
367  using ReturnType = Columns_<MT>;
368  return ReturnType( ~matrix, indices, n, args... );
369 }
370 //*************************************************************************************************
371 
372 
373 //*************************************************************************************************
410 template< typename MT // Type of the matrix
411  , bool SO // Storage order
412  , typename P // Type of the index producer
413  , typename... RCAs // Optional arguments
414  , EnableIf_t< !IsPointer_v<P> >* = nullptr >
415 inline decltype(auto) columns( Matrix<MT,SO>& matrix, P p, size_t n, RCAs... args )
416 {
418 
419  using ReturnType = Columns_<MT,P>;
420  return ReturnType( ~matrix, p, n, args... );
421 }
422 //*************************************************************************************************
423 
424 
425 //*************************************************************************************************
464 template< typename MT // Type of the matrix
465  , bool SO // Storage order
466  , typename P // Type of the index producer
467  , typename... RCAs // Optional arguments
468  , EnableIf_t< !IsPointer_v<P> >* = nullptr >
469 inline decltype(auto) columns( const Matrix<MT,SO>& matrix, P p, size_t n, RCAs... args )
470 {
472 
473  using ReturnType = const Columns_<const MT,P>;
474  return ReturnType( ~matrix, p, n, args... );
475 }
476 //*************************************************************************************************
477 
478 
479 //*************************************************************************************************
494 template< typename MT // Type of the matrix
495  , bool SO // Storage order
496  , typename P // Type of the index producer
497  , typename... RCAs // Optional arguments
498  , EnableIf_t< !IsPointer_v<P> >* = nullptr >
499 inline decltype(auto) columns( Matrix<MT,SO>&& matrix, P p, size_t n, RCAs... args )
500 {
502 
503  using ReturnType = Columns_<MT,P>;
504  return ReturnType( ~matrix, p, n, args... );
505 }
506 //*************************************************************************************************
507 
508 
509 //*************************************************************************************************
546 template< typename MT // Type of the matrix
547  , size_t... Is // Column indices
548  , typename... RCAs > // Optional arguments
549 inline decltype(auto) columns( MT&& matrix, index_sequence<Is...> indices, RCAs... args )
550 {
552 
553  UNUSED_PARAMETER( indices );
554 
555  return columns<Is...>( std::forward<MT>( matrix ), args... );
556 }
557 //*************************************************************************************************
558 
559 
560 //*************************************************************************************************
596 template< typename MT // Type of the matrix
597  , typename T // Type of the column indices
598  , typename... RCAs > // Optional arguments
599 inline decltype(auto) columns( MT&& matrix, initializer_list<T> indices, RCAs... args )
600 {
602 
603  return columns( std::forward<MT>( matrix ), indices.begin(), indices.size(), args... );
604 }
605 //*************************************************************************************************
606 
607 
608 //*************************************************************************************************
646 template< typename MT // Type of the matrix
647  , typename T // Type of the column indices
648  , size_t N // Number of indices
649  , typename... RCAs > // Optional arguments
650 inline decltype(auto) columns( MT&& matrix, const std::array<T,N>& indices, RCAs... args )
651 {
653 
654  return columns( std::forward<MT>( matrix ), indices.data(), N, args... );
655 }
656 //*************************************************************************************************
657 
658 
659 //*************************************************************************************************
697 template< typename MT // Type of the matrix
698  , typename T // Type of the column indices
699  , typename... RCAs > // Optional arguments
700 inline decltype(auto) columns( MT&& matrix, const std::vector<T>& indices, RCAs... args )
701 {
703 
704  return columns( std::forward<MT>( matrix ), indices.data(), indices.size(), args... );
705 }
706 //*************************************************************************************************
707 
708 
709 //*************************************************************************************************
748 template< typename MT // Type of the matrix
749  , typename T // Type of the column indices
750  , size_t N // Number of preallocated elements
751  , typename... RCAs > // Optional arguments
752 inline decltype(auto) columns( MT&& matrix, const SmallArray<T,N>& indices, RCAs... args )
753 {
755 
756  return columns( std::forward<MT>( matrix ), indices.data(), indices.size(), args... );
757 }
759 //*************************************************************************************************
760 
761 
762 
763 
764 //=================================================================================================
765 //
766 // GLOBAL RESTRUCTURING FUNCTIONS
767 //
768 //=================================================================================================
769 
770 //*************************************************************************************************
782 template< typename... CCAs // Compile time column arguments
783  , typename MT // Matrix base type of the expression
784  , typename... RCAs // Runtime column arguments
785  , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
786 inline decltype(auto) columns( const MatMatAddExpr<MT>& matrix, RCAs... args )
787 {
789 
790  return columns<CCAs...>( (~matrix).leftOperand(), args... ) +
791  columns<CCAs...>( (~matrix).rightOperand(), args... );
792 }
794 //*************************************************************************************************
795 
796 
797 //*************************************************************************************************
809 template< typename... CCAs // Compile time column arguments
810  , typename MT // Matrix base type of the expression
811  , typename... RCAs // Runtime column arguments
812  , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
813 inline decltype(auto) columns( const MatMatSubExpr<MT>& matrix, RCAs... args )
814 {
816 
817  return columns<CCAs...>( (~matrix).leftOperand(), args... ) -
818  columns<CCAs...>( (~matrix).rightOperand(), args... );
819 }
821 //*************************************************************************************************
822 
823 
824 //*************************************************************************************************
836 template< typename... CCAs // Compile time column arguments
837  , typename MT // Matrix base type of the expression
838  , typename... RCAs // Runtime column arguments
839  , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
840 inline decltype(auto) columns( const SchurExpr<MT>& matrix, RCAs... args )
841 {
843 
844  return columns<CCAs...>( (~matrix).leftOperand(), args... ) %
845  columns<CCAs...>( (~matrix).rightOperand(), args... );
846 }
848 //*************************************************************************************************
849 
850 
851 //*************************************************************************************************
863 template< typename... CCAs // Compile time column arguments
864  , typename MT // Matrix base type of the expression
865  , typename... RCAs // Runtime column arguments
866  , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
867 inline decltype(auto) columns( const MatMatMultExpr<MT>& matrix, RCAs... args )
868 {
870 
871  return (~matrix).leftOperand() * columns<CCAs...>( (~matrix).rightOperand(), args... );
872 }
874 //*************************************************************************************************
875 
876 
877 //*************************************************************************************************
889 template< typename... CCAs // Compile time column arguments
890  , typename MT // Matrix base type of the expression
891  , typename... RCAs // Runtime column arguments
892  , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
893 inline decltype(auto) columns( const VecTVecMultExpr<MT>& matrix, RCAs... args )
894 {
896 
897  return (~matrix).leftOperand() * elements<CCAs...>( (~matrix).rightOperand(), args... );
898 }
900 //*************************************************************************************************
901 
902 
903 //*************************************************************************************************
915 template< typename... CCAs // Compile time column arguments
916  , typename MT // Matrix base type of the expression
917  , typename... RCAs // Runtime column arguments
918  , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
919 inline decltype(auto) columns( const MatScalarMultExpr<MT>& matrix, RCAs... args )
920 {
922 
923  return columns<CCAs...>( (~matrix).leftOperand(), args... ) * (~matrix).rightOperand();
924 }
926 //*************************************************************************************************
927 
928 
929 //*************************************************************************************************
941 template< typename... CCAs // Compile time column arguments
942  , typename MT // Matrix base type of the expression
943  , typename... RCAs // Runtime column arguments
944  , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
945 inline decltype(auto) columns( const MatScalarDivExpr<MT>& matrix, RCAs... args )
946 {
948 
949  return columns<CCAs...>( (~matrix).leftOperand(), args... ) / (~matrix).rightOperand();
950 }
952 //*************************************************************************************************
953 
954 
955 //*************************************************************************************************
967 template< typename... CCAs // Compile time column arguments
968  , typename MT // Matrix base type of the expression
969  , typename... RCAs // Runtime column arguments
970  , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
971 inline decltype(auto) columns( const MatMapExpr<MT>& matrix, RCAs... args )
972 {
974 
975  return map( columns<CCAs...>( (~matrix).operand(), args... ), (~matrix).operation() );
976 }
978 //*************************************************************************************************
979 
980 
981 //*************************************************************************************************
993 template< typename... CCAs // Compile time column arguments
994  , typename MT // Matrix base type of the expression
995  , typename... RCAs // Runtime column arguments
996  , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
997 inline decltype(auto) columns( const MatMatMapExpr<MT>& matrix, RCAs... args )
998 {
1000 
1001  return map( columns<CCAs...>( (~matrix).leftOperand(), args... ),
1002  columns<CCAs...>( (~matrix).rightOperand(), args... ),
1003  (~matrix).operation() );
1004 }
1006 //*************************************************************************************************
1007 
1008 
1009 //*************************************************************************************************
1021 template< typename... CCAs // Compile time column arguments
1022  , typename MT // Matrix base type of the expression
1023  , typename... RCAs // Runtime column arguments
1024  , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
1025 inline decltype(auto) columns( const MatEvalExpr<MT>& matrix, RCAs... args )
1026 {
1028 
1029  return eval( columns<CCAs...>( (~matrix).operand(), args... ) );
1030 }
1032 //*************************************************************************************************
1033 
1034 
1035 //*************************************************************************************************
1047 template< typename... CCAs // Compile time column arguments
1048  , typename MT // Matrix base type of the expression
1049  , typename... RCAs // Runtime column arguments
1050  , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
1051 inline decltype(auto) columns( const MatSerialExpr<MT>& matrix, RCAs... args )
1052 {
1054 
1055  return serial( columns<CCAs...>( (~matrix).operand(), args... ) );
1056 }
1058 //*************************************************************************************************
1059 
1060 
1061 //*************************************************************************************************
1073 template< typename... CCAs // Compile time column arguments
1074  , typename MT // Matrix base type of the expression
1075  , typename... RCAs // Runtime column arguments
1076  , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) >* = nullptr >
1077 inline decltype(auto) columns( const DeclExpr<MT>& matrix, RCAs... args )
1078 {
1080 
1081  return columns<CCAs...>( (~matrix).operand(), args... );
1082 }
1084 //*************************************************************************************************
1085 
1086 
1087 //*************************************************************************************************
1099 template< typename... 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 >
1103 inline decltype(auto) columns( const MatTransExpr<MT>& matrix, RCAs... args )
1104 {
1106 
1107  return trans( rows<CCAs...>( (~matrix).operand(), args... ) );
1108 }
1110 //*************************************************************************************************
1111 
1112 
1113 //*************************************************************************************************
1126 template< typename... CCAs // Compile time column arguments
1127  , typename MT // Matrix base type of the expression
1128  , size_t... CEAs // Compile time expansion arguments
1129  , typename... RCAs // Runtime column arguments
1130  , EnableIf_t< ( sizeof...( CCAs ) > 0UL ) &&
1131  IsColumnMajorMatrix_v<MT> >* = nullptr >
1132 inline decltype(auto) columns( const VecExpandExpr<MT,CEAs...>& matrix, RCAs... args )
1133 {
1135 
1136  UNUSED_PARAMETER( args... );
1137 
1138  return expand< sizeof...( CCAs ) >( (~matrix).operand() );
1139 }
1141 //*************************************************************************************************
1142 
1143 
1144 //*************************************************************************************************
1157 template< typename... CCAs // Compile time column arguments
1158  , typename MT // Matrix base type of the expression
1159  , size_t... CEAs // Compile time expansion arguments
1160  , typename... RCAs // Runtime column arguments
1161  , EnableIf_t< ( sizeof...( CCAs ) == 0UL ) &&
1162  IsColumnMajorMatrix_v<MT> >* = nullptr >
1163 inline decltype(auto) columns( const VecExpandExpr<MT,CEAs...>& matrix, RCAs... args )
1164 {
1166 
1167  const ColumnsData<CCAs...> cd( args... );
1168 
1169  return expand( (~matrix).operand(), cd.columns() );
1170 }
1172 //*************************************************************************************************
1173 
1174 
1175 //*************************************************************************************************
1187 template< typename... CCAs // Compile time column arguments
1188  , typename MT // Matrix base type of the expression
1189  , size_t... CEAs // Compile time expansion arguments
1190  , typename... RCAs // Runtime column arguments
1191  , EnableIf_t< ( sizeof...( CCAs ) + sizeof...( RCAs ) > 0UL ) &&
1192  !IsColumnMajorMatrix_v<MT> >* = nullptr >
1193 inline decltype(auto) columns( const VecExpandExpr<MT,CEAs...>& matrix, RCAs... args )
1194 {
1196 
1197  return expand<CEAs...>( elements<CCAs...>( (~matrix).operand(), args... ), (~matrix).expansion() );
1198 }
1200 //*************************************************************************************************
1201 
1202 
1203 //*************************************************************************************************
1215 template< size_t I1 // First required column index
1216  , size_t... Is1 // Remaining required column indices
1217  , typename MT // Type of the matrix
1218  , bool SO // Storage order
1219  , bool DF // Density flag
1220  , bool SF // Symmetry flag
1221  , size_t I2 // First present column index
1222  , size_t... Is2 // Remaining present column indices
1223  , typename... CCAs // Compile time column arguments
1224  , typename... RCAs > // Optional column arguments
1225 inline decltype(auto) columns( Columns<MT,SO,DF,SF,index_sequence<I2,Is2...>,CCAs...>& c, RCAs... args )
1226 {
1228 
1229  static constexpr size_t indices[] = { I2, Is2... };
1230  return columns< indices[I1], indices[Is1]... >( c.operand(), args... );
1231 }
1233 //*************************************************************************************************
1234 
1235 
1236 //*************************************************************************************************
1248 template< size_t I1 // First required column index
1249  , size_t... Is1 // Remaining required column indices
1250  , typename MT // Type of the matrix
1251  , bool SO // Storage order
1252  , bool DF // Density flag
1253  , bool SF // Symmetry flag
1254  , size_t I2 // First present column index
1255  , size_t... Is2 // Remaining present column indices
1256  , typename... CCAs // Compile time column arguments
1257  , typename... RCAs > // Optional column arguments
1258 inline decltype(auto) columns( const Columns<MT,SO,DF,SF,index_sequence<I2,Is2...>,CCAs...>& c, RCAs... args )
1259 {
1261 
1262  static constexpr size_t indices[] = { I2, Is2... };
1263  return columns< indices[I1], indices[Is1]... >( c.operand(), args... );
1264 }
1266 //*************************************************************************************************
1267 
1268 
1269 //*************************************************************************************************
1281 template< size_t I1 // First required column index
1282  , size_t... Is1 // Remaining required column indices
1283  , typename MT // Type of the matrix
1284  , bool SO // Storage order
1285  , bool DF // Density flag
1286  , bool SF // Symmetry flag
1287  , size_t I2 // First present column index
1288  , size_t... Is2 // Remaining present column indices
1289  , typename... CCAs // Compile time column arguments
1290  , typename... RCAs > // Optional column arguments
1291 inline decltype(auto) columns( Columns<MT,SO,DF,SF,index_sequence<I2,Is2...>,CCAs...>&& c, RCAs... args )
1292 {
1294 
1295  static constexpr size_t indices[] = { I2, Is2... };
1296  return columns< indices[I1], indices[Is1]... >( c.operand(), args... );
1297 }
1299 //*************************************************************************************************
1300 
1301 
1302 //*************************************************************************************************
1315 template< size_t I // First required column index
1316  , size_t... Is // Remaining required column indices
1317  , typename MT // Type of the matrix
1318  , bool SO // Storage order
1319  , bool DF // Density flag
1320  , bool SF // Symmetry flag
1321  , typename... CCAs // Compile time column arguments
1322  , typename... RCAs > // Optional column arguments
1323 inline decltype(auto) columns( Columns<MT,SO,DF,SF,CCAs...>& c, RCAs... args )
1324 {
1326 
1327  constexpr bool isChecked( !Contains_v< TypeList<RCAs...>, Unchecked > );
1328 
1329  if( isChecked ) {
1330  static constexpr size_t indices[] = { I, Is... };
1331  for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1332  if( c.columns() <= indices[i] ) {
1333  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1334  }
1335  }
1336  }
1337 
1338  return columns( c.operand(), { c.idx(I), c.idx(Is)... }, args... );
1339 }
1341 //*************************************************************************************************
1342 
1343 
1344 //*************************************************************************************************
1357 template< size_t I // First required column index
1358  , size_t... Is // Remaining required column indices
1359  , typename MT // Type of the matrix
1360  , bool SO // Storage order
1361  , bool DF // Density flag
1362  , bool SF // Symmetry flag
1363  , typename... CCAs // Compile time column arguments
1364  , typename... RCAs > // Optional column arguments
1365 inline decltype(auto) columns( const Columns<MT,SO,DF,SF,CCAs...>& c, RCAs... args )
1366 {
1368 
1369  constexpr bool isChecked( !Contains_v< TypeList<RCAs...>, Unchecked > );
1370 
1371  if( isChecked ) {
1372  static constexpr size_t indices[] = { I, Is... };
1373  for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1374  if( c.columns() <= indices[i] ) {
1375  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1376  }
1377  }
1378  }
1379 
1380  return columns( c.operand(), { c.idx(I), c.idx(Is)... }, args... );
1381 }
1383 //*************************************************************************************************
1384 
1385 
1386 //*************************************************************************************************
1399 template< size_t I // First required column index
1400  , size_t... Is // Remaining required column indices
1401  , typename MT // Type of the matrix
1402  , bool SO // Storage order
1403  , bool DF // Density flag
1404  , bool SF // Symmetry flag
1405  , typename... CCAs // Compile time column arguments
1406  , typename... RCAs > // Optional column arguments
1407 inline decltype(auto) columns( Columns<MT,SO,DF,SF,CCAs...>&& c, RCAs... args )
1408 {
1410 
1411  constexpr bool isChecked( !Contains_v< TypeList<RCAs...>, Unchecked > );
1412 
1413  if( isChecked ) {
1414  static constexpr size_t indices[] = { I, Is... };
1415  for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1416  if( c.columns() <= indices[i] ) {
1417  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1418  }
1419  }
1420  }
1421 
1422  return columns( c.operand(), { c.idx(I), c.idx(Is)... }, args... );
1423 }
1425 //*************************************************************************************************
1426 
1427 
1428 //*************************************************************************************************
1443 template< typename MT // Type of the matrix
1444  , bool SO // Storage order
1445  , bool DF // Density flag
1446  , bool SF // Symmetry flag
1447  , typename... CCAs // Compile time column arguments
1448  , typename T // Type of the column indices
1449  , typename... RCAs > // Optional column arguments
1450 inline decltype(auto) columns( Columns<MT,SO,DF,SF,CCAs...>& c, const T* indices, size_t n, RCAs... args )
1451 {
1453 
1454  constexpr bool isChecked( !Contains_v< TypeList<RCAs...>, Unchecked > );
1455 
1456  if( isChecked ) {
1457  for( size_t i=0UL; i<n; ++i ) {
1458  if( c.columns() <= size_t( indices[i] ) ) {
1459  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1460  }
1461  }
1462  }
1463 
1464  SmallArray<size_t,128UL> newIndices;
1465  newIndices.reserve( n );
1466 
1467  for( size_t i=0UL; i<n; ++i ) {
1468  newIndices.pushBack( c.idx( indices[i] ) );
1469  }
1470 
1471  return columns( c.operand(), newIndices.data(), newIndices.size(), args... );
1472 }
1474 //*************************************************************************************************
1475 
1476 
1477 //*************************************************************************************************
1492 template< typename MT // Type of the matrix
1493  , bool SO // Storage order
1494  , bool DF // Density flag
1495  , bool SF // Symmetry flag
1496  , typename... CCAs // Compile time column arguments
1497  , typename T // Type of the column indices
1498  , typename... RCAs > // Optional column arguments
1499 inline decltype(auto) columns( const Columns<MT,SO,DF,SF,CCAs...>& c, const T* indices, size_t n, RCAs... args )
1500 {
1502 
1503  constexpr bool isChecked( !Contains_v< TypeList<RCAs...>, Unchecked > );
1504 
1505  if( isChecked ) {
1506  for( size_t i=0UL; i<n; ++i ) {
1507  if( c.columns() <= size_t( indices[i] ) ) {
1508  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1509  }
1510  }
1511  }
1512 
1513  SmallArray<size_t,128UL> newIndices;
1514  newIndices.reserve( n );
1515 
1516  for( size_t i=0UL; i<n; ++i ) {
1517  newIndices.pushBack( c.idx( indices[i] ) );
1518  }
1519 
1520  return columns( c.operand(), newIndices.data(), newIndices.size(), args... );
1521 }
1523 //*************************************************************************************************
1524 
1525 
1526 //*************************************************************************************************
1541 template< typename MT // Type of the matrix
1542  , bool SO // Storage order
1543  , bool DF // Density flag
1544  , bool SF // Symmetry flag
1545  , typename... CCAs // Compile time column arguments
1546  , typename T // Type of the column indices
1547  , typename... RCAs > // Optional column arguments
1548 inline decltype(auto) columns( Columns<MT,SO,DF,SF,CCAs...>&& c, const T* indices, size_t n, RCAs... args )
1549 {
1551 
1552  constexpr bool isChecked( !Contains_v< TypeList<RCAs...>, Unchecked > );
1553 
1554  if( isChecked ) {
1555  for( size_t i=0UL; i<n; ++i ) {
1556  if( c.columns() <= size_t( indices[i] ) ) {
1557  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1558  }
1559  }
1560  }
1561 
1562  SmallArray<size_t,128UL> newIndices;
1563  newIndices.reserve( n );
1564 
1565  for( size_t i=0UL; i<n; ++i ) {
1566  newIndices.pushBack( c.idx( indices[i] ) );
1567  }
1568 
1569  return columns( c.operand(), newIndices.data(), newIndices.size(), args... );
1570 }
1572 //*************************************************************************************************
1573 
1574 
1575 //*************************************************************************************************
1590 template< typename MT // Type of the matrix
1591  , bool SO // Storage order
1592  , bool DF // Density flag
1593  , bool SF // Symmetry flag
1594  , typename... CCAs // Compile time column arguments
1595  , typename P // Type of the index producer
1596  , typename... RCAs > // Optional column arguments
1597 inline decltype(auto) columns( Columns<MT,SO,DF,SF,CCAs...>& c, P p, size_t n, RCAs... args )
1598 {
1600 
1601  constexpr bool isChecked( !Contains_v< TypeList<RCAs...>, Unchecked > );
1602 
1603  if( isChecked ) {
1604  for( size_t i=0UL; i<n; ++i ) {
1605  if( c.columns() <= size_t( p(i) ) ) {
1606  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1607  }
1608  }
1609  }
1610 
1611  SmallArray<size_t,128UL> newIndices;
1612  newIndices.reserve( n );
1613 
1614  for( size_t i=0UL; i<n; ++i ) {
1615  newIndices.pushBack( c.idx( p(i) ) );
1616  }
1617 
1618  return columns( c.operand(), newIndices.data(), newIndices.size(), args... );
1619 }
1621 //*************************************************************************************************
1622 
1623 
1624 //*************************************************************************************************
1639 template< typename MT // Type of the matrix
1640  , bool SO // Storage order
1641  , bool DF // Density flag
1642  , bool SF // Symmetry flag
1643  , typename... CCAs // Compile time column arguments
1644  , typename P // Type of the index producer
1645  , typename... RCAs > // Optional column arguments
1646 inline decltype(auto) columns( const Columns<MT,SO,DF,SF,CCAs...>& c, P p, size_t n, RCAs... args )
1647 {
1649 
1650  constexpr bool isChecked( !Contains_v< TypeList<RCAs...>, Unchecked > );
1651 
1652  if( isChecked ) {
1653  for( size_t i=0UL; i<n; ++i ) {
1654  if( c.columns() <= size_t( p(i) ) ) {
1655  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1656  }
1657  }
1658  }
1659 
1660  SmallArray<size_t,128UL> newIndices;
1661  newIndices.reserve( n );
1662 
1663  for( size_t i=0UL; i<n; ++i ) {
1664  newIndices.pushBack( c.idx( p(i) ) );
1665  }
1666 
1667  return columns( c.operand(), newIndices.data(), newIndices.size(), args... );
1668 }
1670 //*************************************************************************************************
1671 
1672 
1673 //*************************************************************************************************
1688 template< typename MT // Type of the matrix
1689  , bool SO // Storage order
1690  , bool DF // Density flag
1691  , bool SF // Symmetry flag
1692  , typename... CCAs // Compile time column arguments
1693  , typename P // Type of the index producer
1694  , typename... RCAs > // Optional column arguments
1695 inline decltype(auto) columns( Columns<MT,SO,DF,SF,CCAs...>&& c, P p, size_t n, RCAs... args )
1696 {
1698 
1699  constexpr bool isChecked( !Contains_v< TypeList<RCAs...>, Unchecked > );
1700 
1701  if( isChecked ) {
1702  for( size_t i=0UL; i<n; ++i ) {
1703  if( c.columns() <= size_t( p(i) ) ) {
1704  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
1705  }
1706  }
1707  }
1708 
1709  SmallArray<size_t,128UL> newIndices;
1710  newIndices.reserve( n );
1711 
1712  for( size_t i=0UL; i<n; ++i ) {
1713  newIndices.pushBack( c.idx( p(i) ) );
1714  }
1715 
1716  return columns( c.operand(), newIndices.data(), newIndices.size(), args... );
1717 }
1719 //*************************************************************************************************
1720 
1721 
1722 
1723 
1724 //=================================================================================================
1725 //
1726 // GLOBAL RESTRUCTURING FUNCTIONS (ELEMENTS)
1727 //
1728 //=================================================================================================
1729 
1730 //*************************************************************************************************
1742 template< size_t... CEAs // Compile time element arguments
1743  , typename VT // Vector base type of the expression
1744  , typename... REAs > // Runtime element arguments
1745 inline decltype(auto) elements( const TVecMatMultExpr<VT>& vector, REAs... args )
1746 {
1748 
1749  return (~vector).leftOperand() * columns<CEAs...>( (~vector).rightOperand(), args... );
1750 }
1752 //*************************************************************************************************
1753 
1754 
1755 //*************************************************************************************************
1768 template< size_t... CEAs // Compile time element arguments
1769  , typename VT // Vector base type of the expression
1770  , typename... REAs > // Runtime element arguments
1771 inline decltype(auto) elements( const MatReduceExpr<VT,columnwise>& vector, REAs... args )
1772 {
1774 
1775  return reduce<columnwise>( columns<CEAs...>( (~vector).operand(), args... ), (~vector).operation() );
1776 }
1778 //*************************************************************************************************
1779 
1780 
1781 
1782 
1783 //=================================================================================================
1784 //
1785 // GLOBAL RESTRUCTURING FUNCTIONS (ROW)
1786 //
1787 //=================================================================================================
1788 
1789 //*************************************************************************************************
1800 template< size_t... CRAs // Compile time row arguments
1801  , typename MT // Type of the matrix
1802  , bool SO // Storage order
1803  , bool DF // Density flag
1804  , bool SF // Symmetry flag
1805  , size_t I // First column index
1806  , size_t... Is // Remaining column indices
1807  , typename... CCAs // Compile time column arguments
1808  , typename... RRAs > // Runtime row arguments
1809 inline decltype(auto) row( Columns<MT,SO,DF,SF,index_sequence<I,Is...>,CCAs...>& columns, RRAs... args )
1810 {
1812 
1813  return elements<I,Is...>( row<CRAs...>( columns.operand(), args... ) );
1814 }
1816 //*************************************************************************************************
1817 
1818 
1819 //*************************************************************************************************
1831 template< size_t... CRAs // Compile time row arguments
1832  , typename MT // Type of the matrix
1833  , bool SO // Storage order
1834  , bool DF // Density flag
1835  , bool SF // Symmetry flag
1836  , size_t I // First column index
1837  , size_t... Is // Remaining column indices
1838  , typename... CCAs // Compile time column arguments
1839  , typename... RRAs > // Runtime row arguments
1840 inline decltype(auto) row( const Columns<MT,SO,DF,SF,index_sequence<I,Is...>,CCAs...>& columns, RRAs... args )
1841 {
1843 
1844  return elements<I,Is...>( row<CRAs...>( columns.operand(), args... ) );
1845 }
1847 //*************************************************************************************************
1848 
1849 
1850 //*************************************************************************************************
1862 template< size_t... CRAs // Compile time row arguments
1863  , typename MT // Type of the matrix
1864  , bool SO // Storage order
1865  , bool DF // Density flag
1866  , bool SF // Symmetry flag
1867  , size_t I // First column index
1868  , size_t... Is // Remaining column indices
1869  , typename... CCAs // Compile time column arguments
1870  , typename... RRAs > // Runtime row arguments
1871 inline decltype(auto) row( Columns<MT,SO,DF,SF,index_sequence<I,Is...>,CCAs...>&& columns, RRAs... args )
1872 {
1874 
1875  return elements<I,Is...>( row<CRAs...>( columns.operand(), args... ) );
1876 }
1878 //*************************************************************************************************
1879 
1880 
1881 //*************************************************************************************************
1892 template< size_t... CRAs // Compile time row arguments
1893  , typename MT // Type of the matrix
1894  , bool SO // Storage order
1895  , bool DF // Density flag
1896  , bool SF // Symmetry flag
1897  , typename... CCAs // Compile time column arguments
1898  , typename... RRAs > // Runtime row arguments
1899 inline decltype(auto) row( Columns<MT,SO,DF,SF,CCAs...>& columns, RRAs... args )
1900 {
1902 
1903  return elements( row<CRAs...>( columns.operand(), args... ), columns.idces() );
1904 }
1906 //*************************************************************************************************
1907 
1908 
1909 //*************************************************************************************************
1921 template< size_t... CRAs // Compile time row arguments
1922  , typename MT // Type of the matrix
1923  , bool SO // Storage order
1924  , bool DF // Density flag
1925  , bool SF // Symmetry flag
1926  , typename... CCAs // Compile time column arguments
1927  , typename... RRAs > // Runtime row arguments
1928 inline decltype(auto) row( const Columns<MT,SO,DF,SF,CCAs...>& columns, RRAs... args )
1929 {
1931 
1932  return elements( row<CRAs...>( columns.operand(), args... ), columns.idces() );
1933 }
1935 //*************************************************************************************************
1936 
1937 
1938 //*************************************************************************************************
1950 template< size_t... CRAs // Compile time row arguments
1951  , typename MT // Type of the matrix
1952  , bool SO // Storage order
1953  , bool DF // Density flag
1954  , bool SF // Symmetry flag
1955  , typename... CCAs // Compile time column arguments
1956  , typename... RRAs > // Runtime row arguments
1957 inline decltype(auto) row( Columns<MT,SO,DF,SF,CCAs...>&& columns, RRAs... args )
1958 {
1960 
1961  return elements( row<CRAs...>( columns.operand(), args... ), columns.idces() );
1962 }
1964 //*************************************************************************************************
1965 
1966 
1967 
1968 
1969 //=================================================================================================
1970 //
1971 // GLOBAL RESTRUCTURING FUNCTIONS (COLUMN)
1972 //
1973 //=================================================================================================
1974 
1975 //*************************************************************************************************
1987 template< size_t I1 // Column index
1988  , typename MT // Type of the matrix
1989  , bool SO // Storage order
1990  , bool DF // Density flag
1991  , bool SF // Symmetry flag
1992  , size_t I2 // First column index
1993  , size_t... Is // Remaining column indices
1994  , typename... CCAs // Compile time column arguments
1995  , typename... RCAs > // Optional column arguments
1996 inline decltype(auto) column( Columns<MT,SO,DF,SF,index_sequence<I2,Is...>,CCAs...>& columns, RCAs... args )
1997 {
1999 
2000  static constexpr size_t indices[] = { I2, Is... };
2001  return column<indices[I1]>( columns.operand(), args... );
2002 }
2004 //*************************************************************************************************
2005 
2006 
2007 //*************************************************************************************************
2019 template< size_t I1 // Column index
2020  , typename MT // Type of the matrix
2021  , bool SO // Storage order
2022  , bool DF // Density flag
2023  , bool SF // Symmetry flag
2024  , size_t I2 // First column index
2025  , size_t... Is // Remaining column indices
2026  , typename... CCAs // Compile time column arguments
2027  , typename... RCAs > // Optional column arguments
2028 inline decltype(auto) column( const Columns<MT,SO,DF,SF,index_sequence<I2,Is...>,CCAs...>& columns, RCAs... args )
2029 {
2031 
2032  static constexpr size_t indices[] = { I2, Is... };
2033  return column<indices[I1]>( columns.operand(), args... );
2034 }
2036 //*************************************************************************************************
2037 
2038 
2039 //*************************************************************************************************
2051 template< size_t I1 // Column index
2052  , typename MT // Type of the matrix
2053  , bool SO // Storage order
2054  , bool DF // Density flag
2055  , bool SF // Symmetry flag
2056  , size_t I2 // First column index
2057  , size_t... Is // Remaining column indices
2058  , typename... CCAs // Compile time column arguments
2059  , typename... RCAs > // Optional column arguments
2060 inline decltype(auto) column( Columns<MT,SO,DF,SF,index_sequence<I2,Is...>,CCAs...>&& columns, RCAs... args )
2061 {
2063 
2064  static constexpr size_t indices[] = { I2, Is... };
2065  return column<indices[I1]>( columns.operand(), args... );
2066 }
2068 //*************************************************************************************************
2069 
2070 
2071 //*************************************************************************************************
2084 template< size_t... CCAs1 // Compile time column arguments
2085  , typename MT // Type of the matrix
2086  , bool SO // Storage order
2087  , bool DF // Density flag
2088  , bool SF // Symmetry flag
2089  , typename... CCAs2 // Compile time column arguments
2090  , typename... RCAs > // Runtime column arguments
2091 inline decltype(auto) column( Columns<MT,SO,DF,SF,CCAs2...>& columns, RCAs... args )
2092 {
2094 
2095  const ColumnData<CCAs1...> cd( args... );
2096 
2097  constexpr bool isChecked( !Contains_v< TypeList<RCAs...>, Unchecked > );
2098 
2099  if( isChecked ) {
2100  if( columns.columns() <= cd.column() ) {
2101  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
2102  }
2103  }
2104 
2105  return column( columns.operand(), columns.idx( cd.column() ), args... );
2106 }
2108 //*************************************************************************************************
2109 
2110 
2111 //*************************************************************************************************
2124 template< size_t... CCAs1 // Compile time column arguments
2125  , typename MT // Type of the matrix
2126  , bool SO // Storage order
2127  , bool DF // Density flag
2128  , bool SF // Symmetry flag
2129  , typename... CCAs2 // Compile time column arguments
2130  , typename... RCAs > // Runtime column arguments
2131 inline decltype(auto) column( const Columns<MT,SO,DF,SF,CCAs2...>& columns, RCAs... args )
2132 {
2134 
2135  const ColumnData<CCAs1...> cd( args... );
2136 
2137  constexpr bool isChecked( !Contains_v< TypeList<RCAs...>, Unchecked > );
2138 
2139  if( isChecked ) {
2140  if( columns.columns() <= cd.column() ) {
2141  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
2142  }
2143  }
2144 
2145  return column( columns.operand(), columns.idx( cd.column() ), args... );
2146 }
2148 //*************************************************************************************************
2149 
2150 
2151 //*************************************************************************************************
2164 template< size_t... CCAs1 // Compile time column arguments
2165  , typename MT // Type of the matrix
2166  , bool SO // Storage order
2167  , bool DF // Density flag
2168  , bool SF // Symmetry flag
2169  , typename... CCAs2 // Compile time column arguments
2170  , typename... RCAs > // Runtime column arguments
2171 inline decltype(auto) column( Columns<MT,SO,DF,SF,CCAs2...>&& columns, RCAs... args )
2172 {
2174 
2175  const ColumnData<CCAs1...> cd( args... );
2176 
2177  constexpr bool isChecked( !Contains_v< TypeList<RCAs...>, Unchecked > );
2178 
2179  if( isChecked ) {
2180  if( columns.columns() <= cd.column() ) {
2181  BLAZE_THROW_INVALID_ARGUMENT( "Invalid column access index" );
2182  }
2183  }
2184 
2185  return column( columns.operand(), columns.idx( cd.column() ), args... );
2186 }
2188 //*************************************************************************************************
2189 
2190 
2191 
2192 
2193 //=================================================================================================
2194 //
2195 // COLUMNS OPERATORS
2196 //
2197 //=================================================================================================
2198 
2199 //*************************************************************************************************
2207 template< typename MT // Type of the matrix
2208  , bool SO // Storage order
2209  , bool DF // Density flag
2210  , bool SF // Symmetry flag
2211  , typename... CCAs > // Compile time column arguments
2212 inline void reset( Columns<MT,SO,DF,SF,CCAs...>& columns )
2213 {
2214  columns.reset();
2215 }
2217 //*************************************************************************************************
2218 
2219 
2220 //*************************************************************************************************
2228 template< typename MT // Type of the matrix
2229  , bool SO // Storage order
2230  , bool DF // Density flag
2231  , bool SF // Symmetry flag
2232  , typename... CCAs > // Compile time column arguments
2233 inline void reset( Columns<MT,SO,DF,SF,CCAs...>&& columns )
2234 {
2235  columns.reset();
2236 }
2238 //*************************************************************************************************
2239 
2240 
2241 //*************************************************************************************************
2253 template< typename MT // Type of the matrix
2254  , bool SO // Storage order
2255  , bool DF // Density flag
2256  , bool SF // Symmetry flag
2257  , typename... CCAs > // Compile time column arguments
2258 inline void reset( Columns<MT,SO,DF,SF,CCAs...>& columns, size_t i )
2259 {
2260  columns.reset( i );
2261 }
2263 //*************************************************************************************************
2264 
2265 
2266 //*************************************************************************************************
2276 template< typename MT // Type of the matrix
2277  , bool SO // Storage order
2278  , bool DF // Density flag
2279  , bool SF // Symmetry flag
2280  , typename... CCAs > // Compile time column arguments
2281 inline void clear( Columns<MT,SO,DF,SF,CCAs...>& columns )
2282 {
2283  columns.reset();
2284 }
2286 //*************************************************************************************************
2287 
2288 
2289 //*************************************************************************************************
2299 template< typename MT // Type of the matrix
2300  , bool SO // Storage order
2301  , bool DF // Density flag
2302  , bool SF // Symmetry flag
2303  , typename... CCAs > // Compile time column arguments
2304 inline void clear( Columns<MT,SO,DF,SF,CCAs...>&& columns )
2305 {
2306  columns.reset();
2307 }
2309 //*************************************************************************************************
2310 
2311 
2312 //*************************************************************************************************
2338 template< bool RF // Relaxation flag
2339  , typename MT // Type of the dense matrix
2340  , bool SO // Storage order
2341  , bool SF // Symmetry flag
2342  , typename... CCAs > // Compile time column arguments
2343 inline bool isDefault( const Columns<MT,SO,true,SF,CCAs...>& columns )
2344 {
2345  using blaze::isDefault;
2346 
2347  if( SO == false ) {
2348  for( size_t i=0UL; i<columns.rows(); ++i )
2349  for( size_t j=0UL; j<columns.columns(); ++j )
2350  if( !isDefault<RF>( columns(i,j) ) )
2351  return false;
2352  }
2353  else {
2354  for( size_t j=0UL; j<columns.columns(); ++j )
2355  for( size_t i=0UL; i<columns.rows(); ++i )
2356  if( !isDefault<RF>( columns(i,j) ) )
2357  return false;
2358  }
2359 
2360  return true;
2361 }
2363 //*************************************************************************************************
2364 
2365 
2366 //*************************************************************************************************
2392 template< bool RF // Relaxation flag
2393  , typename MT // Type of the dense matrix
2394  , bool SO // Storage order
2395  , bool SF // Symmetry flag
2396  , typename... CCAs > // Compile time column arguments
2397 inline bool isDefault( const Columns<MT,SO,false,SF,CCAs...>& columns )
2398 {
2399  using blaze::isDefault;
2400 
2401  for( size_t j=0UL; j<columns.columns(); ++j ) {
2402  for( auto element=columns.cbegin(j); element!=columns.cend(j); ++element )
2403  if( !isDefault<RF>( element->value() ) ) return false;
2404  }
2405 
2406  return true;
2407 }
2409 //*************************************************************************************************
2410 
2411 
2412 //*************************************************************************************************
2430 template< typename MT // Type of the matrix
2431  , bool SO // Storage order
2432  , bool DF // Density flag
2433  , bool SF // Symmetry flag
2434  , typename... CCAs > // Compile time column arguments
2435 inline bool isIntact( const Columns<MT,SO,DF,SF,CCAs...>& columns ) noexcept
2436 {
2437  return ( columns.rows() == columns.operand().rows() &&
2438  columns.columns() <= columns.operand().columns() &&
2439  isIntact( columns.operand() ) );
2440 }
2442 //*************************************************************************************************
2443 
2444 
2445 //*************************************************************************************************
2458 template< typename MT // Type of the matrix
2459  , bool SO1 // Storage order of the left-hand side column selection
2460  , bool DF // Density flag
2461  , bool SF // Symmetry flag
2462  , typename... CCAs // Compile time column arguments
2463  , bool SO2 > // Storage order of the right-hand side matrix
2464 inline bool isSame( const Columns<MT,SO1,DF,SF,CCAs...>& a, const Matrix<MT,SO2>& b ) noexcept
2465 {
2466  if( !isSame( a.operand(), ~b ) || ( a.rows() != (~b).rows() ) || ( a.columns() != (~b).columns() ) )
2467  return false;
2468 
2469  for( size_t j=0UL; j<a.columns(); ++j ) {
2470  if( a.idx(j) != j )
2471  return false;
2472  }
2473 
2474  return true;
2475 }
2477 //*************************************************************************************************
2478 
2479 
2480 //*************************************************************************************************
2493 template< typename MT // Type of the matrix
2494  , bool SO1 // Storage order of the left-hand side matrix
2495  , bool DF // Density flag
2496  , bool SF // Symmetry flag
2497  , typename... CCAs // Compile time column arguments
2498  , bool SO2 > // Storage order of the right-hand side column selection
2499 inline bool isSame( const Matrix<MT,SO1>& a, const Columns<MT,SO2,DF,SF,CCAs...>& b ) noexcept
2500 {
2501  return isSame( b, a );
2502 }
2504 //*************************************************************************************************
2505 
2506 
2507 //*************************************************************************************************
2520 template< typename MT // Type of the matrix
2521  , bool SO1 // Storage order of the left-hand side column selection
2522  , bool DF // Density flag
2523  , bool SF // Symmetry flag
2524  , typename... CCAs // Compile time column arguments
2525  , AlignmentFlag AF // Alignment flag
2526  , bool SO2 // Storage order of the right-hand side submatrix
2527  , size_t... CSAs > // Compile time submatrix arguments
2528 inline bool isSame( const Columns<MT,SO1,DF,SF,CCAs...>& a, const Submatrix<MT,AF,SO2,DF,CSAs...>& b ) noexcept
2529 {
2530  if( !isSame( a.operand(), b.operand() ) || ( a.rows() != (~b).rows() ) || ( a.columns() != (~b).columns() ) )
2531  return false;
2532 
2533  for( size_t j=0UL; j<a.columns(); ++j ) {
2534  if( a.idx(j) != b.column()+j )
2535  return false;
2536  }
2537 
2538  return true;
2539 }
2541 //*************************************************************************************************
2542 
2543 
2544 //*************************************************************************************************
2557 template< typename MT // Type of the matrix
2558  , AlignmentFlag AF // Alignment flag
2559  , bool SO1 // Storage order of the left-hand side submatrix
2560  , bool DF // Density flag
2561  , size_t... CSAs // Compile time submatrix arguments
2562  , bool SO2 // Storage order of the right-hand side column selection
2563  , bool SF // Symmetry flag
2564  , typename... CCAs > // Compile time column arguments
2565 inline bool isSame( const Submatrix<MT,AF,SO1,DF,CSAs...>& a, const Columns<MT,SO2,DF,SF,CCAs...>& b ) noexcept
2566 {
2567  return isSame( b, a );
2568 }
2570 //*************************************************************************************************
2571 
2572 
2573 //*************************************************************************************************
2586 template< typename MT // Type of the matrix
2587  , bool SO // Storage order
2588  , bool DF // Density flag
2589  , bool SF // Symmetry flag
2590  , typename... CCAs1 // Compile time column arguments of the left-hand side column selection
2591  , typename... CCAs2 > // Compile time column arguments of the right-hand side column selection
2592 inline bool isSame( const Columns<MT,SO,DF,SF,CCAs1...>& a,
2593  const Columns<MT,SO,DF,SF,CCAs2...>& b ) noexcept
2594 {
2595  if( !isSame( a.operand(), b.operand() ) || a.rows() != b.rows() || a.columns() != b.columns() )
2596  return false;
2597 
2598  for( size_t i=0UL; i<a.columns(); ++i ) {
2599  if( a.idx(i) != b.idx(i) )
2600  return false;
2601  }
2602 
2603  return true;
2604 }
2606 //*************************************************************************************************
2607 
2608 
2609 //*************************************************************************************************
2648 template< InversionFlag IF // Inversion algorithm
2649  , typename MT // Type of the dense matrix
2650  , bool SO // Storage order
2651  , bool SF // Symmetry flag
2652  , typename... CCAs > // Compile time column arguments
2653 inline auto invert( Columns<MT,SO,true,SF,CCAs...>& c )
2654  -> DisableIf_t< HasMutableDataAccess_v<MT> >
2655 {
2656  using RT = ResultType_t< Columns<MT,SO,true,SF,CCAs...> >;
2657 
2660 
2661  RT tmp( c );
2662  invert<IF>( tmp );
2663  c = tmp;
2664 }
2666 //*************************************************************************************************
2667 
2668 
2669 //*************************************************************************************************
2685 template< typename MT // Type of the matrix
2686  , bool SO // Storage order
2687  , bool DF // Density flag
2688  , bool SF // Symmetry flag
2689  , typename... CCAs // Compile time column arguments
2690  , typename ET > // Type of the element
2691 inline bool trySet( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t i, size_t j, const ET& value )
2692 {
2693  BLAZE_INTERNAL_ASSERT( i < c.rows(), "Invalid row access index" );
2694  BLAZE_INTERNAL_ASSERT( j < c.columns(), "Invalid column access index" );
2695 
2696  return trySet( c.operand(), c.idx(i), j, value );
2697 }
2699 //*************************************************************************************************
2700 
2701 
2702 //*************************************************************************************************
2718 template< typename MT // Type of the matrix
2719  , bool SO // Storage order
2720  , bool DF // Density flag
2721  , bool SF // Symmetry flag
2722  , typename... CCAs // Compile time column arguments
2723  , typename ET > // Type of the element
2724 inline bool tryAdd( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t i, size_t j, const ET& value )
2725 {
2726  BLAZE_INTERNAL_ASSERT( i < c.rows(), "Invalid row access index" );
2727  BLAZE_INTERNAL_ASSERT( j < c.columns(), "Invalid column access index" );
2728 
2729  return tryAdd( c.operand(), c.idx(i), j, value );
2730 }
2732 //*************************************************************************************************
2733 
2734 
2735 //*************************************************************************************************
2751 template< typename MT // Type of the matrix
2752  , bool SO // Storage order
2753  , bool DF // Density flag
2754  , bool SF // Symmetry flag
2755  , typename... CCAs // Compile time column arguments
2756  , typename ET > // Type of the element
2757 inline bool trySub( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t i, size_t j, const ET& value )
2758 {
2759  BLAZE_INTERNAL_ASSERT( i < c.rows(), "Invalid row access index" );
2760  BLAZE_INTERNAL_ASSERT( j < c.columns(), "Invalid column access index" );
2761 
2762  return trySub( c.operand(), c.idx(i), j, value );
2763 }
2765 //*************************************************************************************************
2766 
2767 
2768 //*************************************************************************************************
2784 template< typename MT // Type of the matrix
2785  , bool SO // Storage order
2786  , bool DF // Density flag
2787  , bool SF // Symmetry flag
2788  , typename... CCAs // Compile time column arguments
2789  , typename ET > // Type of the element
2790 inline bool tryMult( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t i, size_t j, const ET& value )
2791 {
2792  BLAZE_INTERNAL_ASSERT( i < c.rows(), "Invalid row access index" );
2793  BLAZE_INTERNAL_ASSERT( j < c.columns(), "Invalid column access index" );
2794 
2795  return tryMult( c.operand(), c.idx(i), j, value );
2796 }
2798 //*************************************************************************************************
2799 
2800 
2801 //*************************************************************************************************
2819 template< typename MT // Type of the matrix
2820  , bool SO // Storage order
2821  , bool DF // Density flag
2822  , bool SF // Symmetry flag
2823  , typename... CCAs // Compile time column arguments
2824  , typename ET > // Type of the element
2826  tryMult( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t row, size_t column, size_t m, size_t n, const ET& value )
2827 {
2828  BLAZE_INTERNAL_ASSERT( row <= (~c).rows(), "Invalid row access index" );
2829  BLAZE_INTERNAL_ASSERT( column <= (~c).columns(), "Invalid column access index" );
2830  BLAZE_INTERNAL_ASSERT( row + m <= (~c).rows(), "Invalid number of rows" );
2831  BLAZE_INTERNAL_ASSERT( column + n <= (~c).columns(), "Invalid number of columns" );
2832 
2833  const size_t jend( column + n );
2834 
2835  for( size_t j=column; j<jend; ++j ) {
2836  if( !tryMult( c.operand(), row, c.idx(j), m, n, value ) )
2837  return false;
2838  }
2839 
2840  return true;
2841 }
2843 //*************************************************************************************************
2844 
2845 
2846 //*************************************************************************************************
2862 template< typename MT // Type of the matrix
2863  , bool SO // Storage order
2864  , bool DF // Density flag
2865  , bool SF // Symmetry flag
2866  , typename... CCAs // Compile time column arguments
2867  , typename ET > // Type of the element
2868 inline bool tryDiv( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t i, size_t j, const ET& value )
2869 {
2870  BLAZE_INTERNAL_ASSERT( i < c.rows(), "Invalid row access index" );
2871  BLAZE_INTERNAL_ASSERT( j < c.columns(), "Invalid column access index" );
2872 
2873  return tryDiv( c.operand(), c.idx(i), j, value );
2874 }
2876 //*************************************************************************************************
2877 
2878 
2879 //*************************************************************************************************
2897 template< typename MT // Type of the matrix
2898  , bool SO // Storage order
2899  , bool DF // Density flag
2900  , bool SF // Symmetry flag
2901  , typename... CCAs // Compile time column arguments
2902  , typename ET > // Type of the element
2904  tryDiv( const Columns<MT,SO,DF,SF,CCAs...>& c, size_t row, size_t column, size_t m, size_t n, const ET& value )
2905 {
2906  BLAZE_INTERNAL_ASSERT( row <= (~c).rows(), "Invalid row access index" );
2907  BLAZE_INTERNAL_ASSERT( column <= (~c).columns(), "Invalid column access index" );
2908  BLAZE_INTERNAL_ASSERT( row + m <= (~c).rows(), "Invalid number of rows" );
2909  BLAZE_INTERNAL_ASSERT( column + n <= (~c).columns(), "Invalid number of columns" );
2910 
2911  const size_t jend( column + n );
2912 
2913  for( size_t j=column; j<jend; ++j ) {
2914  if( !tryDiv( c.operand(), row, c.idx(j), m, n, value ) )
2915  return false;
2916  }
2917 
2918  return true;
2919 }
2921 //*************************************************************************************************
2922 
2923 
2924 //*************************************************************************************************
2940 template< typename MT // Type of the matrix
2941  , bool SO // Storage order
2942  , bool DF // Density flag
2943  , bool SF // Symmetry flag
2944  , typename... CCAs // Compile time column arguments
2945  , typename VT > // Type of the right-hand side vector
2946 inline bool tryAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
2947  const Vector<VT,false>& rhs, size_t row, size_t column )
2948 {
2949  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2950  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2951  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
2952 
2953  return tryAssign( lhs.operand(), ~rhs, row, lhs.idx( column ) );
2954 }
2956 //*************************************************************************************************
2957 
2958 
2959 //*************************************************************************************************
2975 template< typename MT // Type of the matrix
2976  , bool SO // Storage order
2977  , bool DF // Density flag
2978  , bool SF // Symmetry flag
2979  , typename... CCAs // Compile time column arguments
2980  , typename VT > // Type of the right-hand side vector
2981 inline bool tryAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
2982  const Vector<VT,true>& rhs, size_t row, size_t column )
2983 {
2984  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2985  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2986  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
2987 
2988  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2989  if( !trySet( lhs.operand(), row, lhs.idx( column+i ), (~rhs)[i] ) )
2990  return false;
2991  }
2992 
2993  return true;
2994 }
2996 //*************************************************************************************************
2997 
2998 
2999 //*************************************************************************************************
3017 template< typename MT // Type of the matrix
3018  , bool SO // Storage order
3019  , bool DF // Density flag
3020  , bool SF // Symmetry flag
3021  , typename... CCAs // Compile time column arguments
3022  , typename VT // Type of the right-hand side vector
3023  , bool TF > // Transpose flag of the right-hand side vector
3024 inline bool tryAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3025  const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3026 {
3028 
3029  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3030  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3031  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3032  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3033 
3034  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3035  if( !trySet( lhs.operand(), row+i, lhs.idx( column+i ), (~rhs)[i] ) )
3036  return false;
3037  }
3038 
3039  return true;
3040 }
3042 //*************************************************************************************************
3043 
3044 
3045 //*************************************************************************************************
3061 template< typename MT1 // Type of the matrix
3062  , bool SO1 // Storage order
3063  , bool DF // Density flag
3064  , bool SF // Symmetry flag
3065  , typename... CCAs // Compile time column arguments
3066  , typename MT2 // Type of the right-hand side matrix
3067  , bool SO2 > // Storage order of the right-hand side matrix
3068 inline bool tryAssign( const Columns<MT1,SO1,DF,SF,CCAs...>& lhs,
3069  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3070 {
3071  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3072  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3073  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
3074  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3075 
3076  for( size_t j=0UL; j<(~rhs).columns(); ++j ) {
3077  if( !tryAssign( lhs.operand(), blaze::column( ~rhs, j, unchecked ), row, lhs.idx( column+j ) ) )
3078  return false;
3079  }
3080 
3081  return true;
3082 }
3084 //*************************************************************************************************
3085 
3086 
3087 //*************************************************************************************************
3104 template< typename MT // Type of the matrix
3105  , bool SO // Storage order
3106  , bool DF // Density flag
3107  , bool SF // Symmetry flag
3108  , typename... CCAs // Compile time column arguments
3109  , typename VT > // Type of the right-hand side vector
3110 inline bool tryAddAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3111  const Vector<VT,false>& rhs, size_t row, size_t column )
3112 {
3113  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3114  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3115  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3116 
3117  return tryAddAssign( lhs.operand(), ~rhs, row, lhs.idx( column ) );
3118 }
3120 //*************************************************************************************************
3121 
3122 
3123 //*************************************************************************************************
3140 template< typename MT // Type of the matrix
3141  , bool SO // Storage order
3142  , bool DF // Density flag
3143  , bool SF // Symmetry flag
3144  , typename... CCAs // Compile time column arguments
3145  , typename VT > // Type of the right-hand side vector
3146 inline bool tryAddAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3147  const Vector<VT,true>& rhs, size_t row, size_t column )
3148 {
3149  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3150  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3151  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3152 
3153  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3154  if( !tryAdd( lhs.operand(), row, lhs.idx( column+i ), (~rhs)[i] ) )
3155  return false;
3156  }
3157 
3158  return true;
3159 }
3161 //*************************************************************************************************
3162 
3163 
3164 //*************************************************************************************************
3182 template< typename MT // Type of the matrix
3183  , bool SO // Storage order
3184  , bool DF // Density flag
3185  , bool SF // Symmetry flag
3186  , typename... CCAs // Compile time column arguments
3187  , typename VT // Type of the right-hand side vector
3188  , bool TF > // Transpose flag of the right-hand side vector
3189 inline bool tryAddAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3190  const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3191 {
3193 
3194  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3195  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3196  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3197  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3198 
3199  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3200  if( !tryAdd( lhs.operand(), row+i, lhs.idx( column+i ), (~rhs)[i] ) )
3201  return false;
3202  }
3203 
3204  return true;
3205 }
3207 //*************************************************************************************************
3208 
3209 
3210 //*************************************************************************************************
3226 template< typename MT1 // Type of the matrix
3227  , bool SO1 // Storage order
3228  , bool DF // Density flag
3229  , bool SF // Symmetry flag
3230  , typename... CCAs // Compile time column arguments
3231  , typename MT2 // Type of the right-hand side matrix
3232  , bool SO2 > // Storage order of the right-hand side matrix
3233 inline bool tryAddAssign( const Columns<MT1,SO1,DF,SF,CCAs...>& lhs,
3234  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3235 {
3236  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3237  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3238  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
3239  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3240 
3241  for( size_t j=0UL; j<(~rhs).columns(); ++j ) {
3242  if( !tryAddAssign( lhs.operand(), blaze::column( ~rhs, j, unchecked ), row, lhs.idx( column+j ) ) )
3243  return false;
3244  }
3245 
3246  return true;
3247 }
3249 //*************************************************************************************************
3250 
3251 
3252 //*************************************************************************************************
3269 template< typename MT // Type of the matrix
3270  , bool SO // Storage order
3271  , bool DF // Density flag
3272  , bool SF // Symmetry flag
3273  , typename... CCAs // Compile time column arguments
3274  , typename VT > // Type of the right-hand side vector
3275 inline bool trySubAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3276  const Vector<VT,false>& rhs, size_t row, size_t column )
3277 {
3278  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3279  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3280  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3281 
3282  return trySubAssign( lhs.operand(), ~rhs, row, lhs.idx( column ) );
3283 }
3285 //*************************************************************************************************
3286 
3287 
3288 //*************************************************************************************************
3305 template< typename MT // Type of the matrix
3306  , bool SO // Storage order
3307  , bool DF // Density flag
3308  , bool SF // Symmetry flag
3309  , typename... CCAs // Compile time column arguments
3310  , typename VT > // Type of the right-hand side vector
3311 inline bool trySubAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3312  const Vector<VT,true>& rhs, size_t row, size_t column )
3313 {
3314  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3315  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3316  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3317 
3318  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3319  if( !trySub( lhs.operand(), row, lhs.idx( column+i ), (~rhs)[i] ) )
3320  return false;
3321  }
3322 
3323  return true;
3324 }
3326 //*************************************************************************************************
3327 
3328 
3329 //*************************************************************************************************
3347 template< typename MT // Type of the matrix
3348  , bool SO // Storage order
3349  , bool DF // Density flag
3350  , bool SF // Symmetry flag
3351  , typename... CCAs // Compile time column arguments
3352  , typename VT // Type of the right-hand side vector
3353  , bool TF > // Transpose flag of the right-hand side vector
3354 inline bool trySubAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3355  const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3356 {
3358 
3359  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3360  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3361  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3362  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3363 
3364  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3365  if( !trySub( lhs.operand(), row+i, lhs.idx( column+i ), (~rhs)[i] ) )
3366  return false;
3367  }
3368 
3369  return true;
3370 }
3372 //*************************************************************************************************
3373 
3374 
3375 //*************************************************************************************************
3392 template< typename MT1 // Type of the matrix
3393  , bool SO1 // Storage order
3394  , bool DF // Density flag
3395  , bool SF // Symmetry flag
3396  , typename... CCAs // Compile time column arguments
3397  , typename MT2 // Type of the right-hand side matrix
3398  , bool SO2 > // Storage order of the right-hand side matrix
3399 inline bool trySubAssign( const Columns<MT1,SO1,DF,SF,CCAs...>& lhs,
3400  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3401 {
3402  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3403  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3404  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
3405  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3406 
3407  for( size_t j=0UL; j<(~rhs).columns(); ++j ) {
3408  if( !trySubAssign( lhs.operand(), blaze::column( ~rhs, j, unchecked ), row, lhs.idx( column+j ) ) )
3409  return false;
3410  }
3411 
3412  return true;
3413 }
3415 //*************************************************************************************************
3416 
3417 
3418 //*************************************************************************************************
3435 template< typename MT // Type of the matrix
3436  , bool SO // Storage order
3437  , bool DF // Density flag
3438  , bool SF // Symmetry flag
3439  , typename... CCAs // Compile time column arguments
3440  , typename VT > // Type of the right-hand side vector
3441 inline bool tryMultAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3442  const Vector<VT,false>& rhs, size_t row, size_t column )
3443 {
3444  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3445  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3446  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3447 
3448  return tryMultAssign( lhs.operand(), ~rhs, row, lhs.idx( column ) );
3449 }
3451 //*************************************************************************************************
3452 
3453 
3454 //*************************************************************************************************
3471 template< typename MT // Type of the matrix
3472  , bool SO // Storage order
3473  , bool DF // Density flag
3474  , bool SF // Symmetry flag
3475  , typename... CCAs // Compile time column arguments
3476  , typename VT > // Type of the right-hand side vector
3477 inline bool tryMultAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3478  const Vector<VT,true>& rhs, size_t row, size_t column )
3479 {
3480  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3481  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3482  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3483 
3484  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3485  if( !tryMult( lhs.operand(), row, lhs.idx( column+i ), (~rhs)[i] ) )
3486  return false;
3487  }
3488 
3489  return true;
3490 }
3492 //*************************************************************************************************
3493 
3494 
3495 //*************************************************************************************************
3513 template< typename MT // Type of the matrix
3514  , bool SO // Storage order
3515  , bool DF // Density flag
3516  , bool SF // Symmetry flag
3517  , typename... CCAs // Compile time column arguments
3518  , typename VT // Type of the right-hand side vector
3519  , bool TF > // Transpose flag of the right-hand side vector
3520 inline bool tryMultAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3521  const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3522 {
3524 
3525  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3526  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3527  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3528  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3529 
3530  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3531  if( !tryMult( lhs.operand(), row+i, lhs.idx( column+i ), (~rhs)[i] ) )
3532  return false;
3533  }
3534 
3535  return true;
3536 }
3538 //*************************************************************************************************
3539 
3540 
3541 //*************************************************************************************************
3558 template< typename MT1 // Type of the matrix
3559  , bool SO1 // Storage order
3560  , bool DF // Density flag
3561  , bool SF // Symmetry flag
3562  , typename... CCAs // Compile time column arguments
3563  , typename MT2 // Type of the right-hand side matrix
3564  , bool SO2 > // Storage order of the right-hand side matrix
3565 inline bool trySchurAssign( const Columns<MT1,SO1,DF,SF,CCAs...>& lhs,
3566  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3567 {
3568  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3569  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3570  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
3571  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3572 
3573  for( size_t j=0UL; j<(~rhs).columns(); ++j ) {
3574  if( !tryMultAssign( lhs.operand(), blaze::column( ~rhs, j, unchecked ), row, lhs.idx( column+j ) ) )
3575  return false;
3576  }
3577 
3578  return true;
3579 }
3581 //*************************************************************************************************
3582 
3583 
3584 //*************************************************************************************************
3601 template< typename MT // Type of the matrix
3602  , bool SO // Storage order
3603  , bool DF // Density flag
3604  , bool SF // Symmetry flag
3605  , typename... CCAs // Compile time column arguments
3606  , typename VT > // Type of the right-hand side vector
3607 inline bool tryDivAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3608  const Vector<VT,false>& rhs, size_t row, size_t column )
3609 {
3610  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3611  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3612  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3613 
3614  return tryDivAssign( lhs.operand(), ~rhs, row, lhs.idx( column ) );
3615 }
3617 //*************************************************************************************************
3618 
3619 
3620 //*************************************************************************************************
3637 template< typename MT // Type of the matrix
3638  , bool SO // Storage order
3639  , bool DF // Density flag
3640  , bool SF // Symmetry flag
3641  , typename... CCAs // Compile time column arguments
3642  , typename VT > // Type of the right-hand side vector
3643 inline bool tryDivAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3644  const Vector<VT,true>& rhs, size_t row, size_t column )
3645 {
3646  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3647  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3648  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3649 
3650  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3651  if( !tryDiv( lhs.operand(), row, lhs.idx( column+i ), (~rhs)[i] ) )
3652  return false;
3653  }
3654 
3655  return true;
3656 }
3658 //*************************************************************************************************
3659 
3660 
3661 //*************************************************************************************************
3679 template< typename MT // Type of the matrix
3680  , bool SO // Storage order
3681  , bool DF // Density flag
3682  , bool SF // Symmetry flag
3683  , typename... CCAs // Compile time column arguments
3684  , typename VT // Type of the right-hand side vector
3685  , bool TF > // Transpose flag of the right-hand side vector
3686 inline bool tryDivAssign( const Columns<MT,SO,DF,SF,CCAs...>& lhs,
3687  const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3688 {
3690 
3691  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3692  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3693  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3694  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3695 
3696  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3697  if( !tryDiv( lhs.operand(), row+i, lhs.idx( column+i ), (~rhs)[i] ) )
3698  return false;
3699  }
3700 
3701  return true;
3702 }
3704 //*************************************************************************************************
3705 
3706 
3707 //*************************************************************************************************
3722 template< typename MT // Type of the matrix
3723  , bool SO // Storage order
3724  , bool DF // Density flag
3725  , bool SF // Symmetry flag
3726  , typename... CCAs > // Compile time column arguments
3727 inline decltype(auto) derestrict( Columns<MT,SO,DF,SF,CCAs...>& c )
3728 {
3729  return columns( derestrict( c.operand() ), c.idces(), unchecked );
3730 }
3732 //*************************************************************************************************
3733 
3734 
3735 //*************************************************************************************************
3750 template< typename MT // Type of the matrix
3751  , bool SO // Storage order
3752  , bool DF // Density flag
3753  , bool SF // Symmetry flag
3754  , typename... CCAs > // Compile time column arguments
3755 inline decltype(auto) derestrict( Columns<MT,SO,DF,SF,CCAs...>&& c )
3756 {
3757  return columns( derestrict( c.operand() ), c.idces(), unchecked );
3758 }
3760 //*************************************************************************************************
3761 
3762 
3763 
3764 
3765 //=================================================================================================
3766 //
3767 // SIZE SPECIALIZATIONS
3768 //
3769 //=================================================================================================
3770 
3771 //*************************************************************************************************
3773 template< typename MT, bool SO, bool DF, bool SF, typename... CCAs >
3774 struct Size< Columns<MT,SO,DF,SF,CCAs...>, 0UL >
3775  : public Size<MT,0UL>
3776 {};
3777 
3778 template< typename MT, bool SO, bool DF, bool SF, size_t I, size_t... Is, typename... CCAs >
3779 struct Size< Columns<MT,SO,DF,SF,index_sequence<I,Is...>,CCAs...>, 1UL >
3780  : public PtrdiffT<1UL+sizeof...(Is)>
3781 {};
3783 //*************************************************************************************************
3784 
3785 
3786 
3787 
3788 //=================================================================================================
3789 //
3790 // MAXSIZE SPECIALIZATIONS
3791 //
3792 //=================================================================================================
3793 
3794 //*************************************************************************************************
3796 template< typename MT, bool SO, bool DF, bool SF, typename... CCAs >
3797 struct MaxSize< Columns<MT,SO,DF,SF,CCAs...>, 0UL >
3798  : public MaxSize<MT,0UL>
3799 {};
3800 
3801 template< typename MT, bool SO, bool DF, bool SF, size_t I, size_t... Is, typename... CCAs >
3802 struct MaxSize< Columns<MT,SO,DF,SF,index_sequence<I,Is...>,CCAs...>, 1UL >
3803  : public PtrdiffT<1UL+sizeof...(Is)>
3804 {};
3806 //*************************************************************************************************
3807 
3808 
3809 
3810 
3811 //=================================================================================================
3812 //
3813 // ISRESTRICTED SPECIALIZATIONS
3814 //
3815 //=================================================================================================
3816 
3817 //*************************************************************************************************
3819 template< typename MT, bool SO, bool DF, bool SF, typename... CCAs >
3820 struct IsRestricted< Columns<MT,SO,DF,SF,CCAs...> >
3821  : public IsRestricted<MT>
3822 {};
3824 //*************************************************************************************************
3825 
3826 
3827 
3828 
3829 //=================================================================================================
3830 //
3831 // HASCONSTDATAACCESS SPECIALIZATIONS
3832 //
3833 //=================================================================================================
3834 
3835 //*************************************************************************************************
3837 template< typename MT, bool SO, bool SF, typename... CCAs >
3838 struct HasConstDataAccess< Columns<MT,SO,true,SF,CCAs...> >
3839  : public HasConstDataAccess<MT>
3840 {};
3842 //*************************************************************************************************
3843 
3844 
3845 
3846 
3847 //=================================================================================================
3848 //
3849 // HASMUTABLEDATAACCESS SPECIALIZATIONS
3850 //
3851 //=================================================================================================
3852 
3853 //*************************************************************************************************
3855 template< typename MT, bool SO, bool SF, typename... CCAs >
3856 struct HasMutableDataAccess< Columns<MT,SO,true,SF,CCAs...> >
3857  : public HasMutableDataAccess<MT>
3858 {};
3860 //*************************************************************************************************
3861 
3862 
3863 
3864 
3865 //=================================================================================================
3866 //
3867 // ISALIGNED SPECIALIZATIONS
3868 //
3869 //=================================================================================================
3870 
3871 //*************************************************************************************************
3873 template< typename MT, bool SO, bool SF, typename... CCAs >
3874 struct IsAligned< Columns<MT,SO,true,SF,CCAs...> >
3875  : public IsAligned<MT>
3876 {};
3878 //*************************************************************************************************
3879 
3880 } // namespace blaze
3881 
3882 #endif
AlignmentFlag
Alignment flag for (un-)aligned vectors and matrices.Via these flags it is possible to specify subvec...
Definition: AlignmentFlag.h:62
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Header file for the blaze::checked and blaze::unchecked instances.
Header file for the implementation of the Columns base template.
Header file for the alignment flag values.
Header file for the UNUSED_PARAMETER function template.
#define BLAZE_CONSTRAINT_MUST_HAVE_MUTABLE_DATA_ACCESS(T)
Constraint on the data type.In case the given data type T does not provide low-level data access to m...
Definition: MutableDataAccess.h:61
bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:992
Header file for basic type definitions.
Header file for the MatReduceExpr base class.
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
Header file for the serial shim.
Header file for the MatTransExpr base class.
Columns specialization for sparse matrices.
Header file for the dense matrix inversion flags.
Header file for the IsColumnMajorMatrix type trait.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
Header file for the MatEvalExpr base class.
Header file for the MatMatMultExpr base class.
Header file for the extended initializer_list functionality.
Index sequence type of the Blaze library.
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
STL namespace.
Header file for the MaxSize type trait.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
Header file for the matrix storage order types.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:775
Header file for the MatMapExpr base class.
Header file for the DisableIf class template.
Header file for the SmallArray implementation.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Columns specialization for dense matrices.
Header file for the MatMatSubExpr base class.
constexpr bool Contains_v
Auxiliary variable template for the Contains type trait.The Contains_v variable template provides a c...
Definition: Contains.h:139
Header file for the IsAligned type trait.
decltype(auto) eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:786
decltype(auto) elements(Vector< VT, TF > &vector, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition: Elements.h:135
Header file for the exception macros of the math module.
Constraint on the data type.
Constraint on the data type.
Header file for the MatSerialExpr base class.
Header file for the VecTVecMultExpr base class.
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:135
Header file for the HasConstDataAccess type trait.
IntegralConstant< ptrdiff_t, N > PtrdiffT
Compile time integral constant wrapper for ptrdiff_t.The PtrdiffT class template represents an integr...
Definition: PtrdiffT.h:72
Header file for the DeclExpr base class.
Header file for the Matrix base class.
Header file for the PtrdiffT class template.
constexpr size_t columnwise
Reduction flag for column-wise reduction operations.
Definition: ReductionFlag.h:90
Header file for all forward declarations for views.
Header file for the MatScalarMultExpr base class.
Header file for run time assertion macros.
Header file for the Unique class template.
Check< false > Unchecked
Type of the blaze::unchecked instance.blaze::Unchecked is the type of the blaze::unchecked instance...
Definition: Check.h:96
Header file for the SchurExpr base class.
decltype(auto) expand(const DenseVector< VT, TF > &dv, size_t expansion)
Expansion of the given dense vector.
Definition: DVecExpandExpr.h:739
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
Header file for the IsPointer type trait.
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
Header file for the isDefault shim.
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:109
Header file for the TVecMatMultExpr base class.
Header file for the integer_sequence and index_sequence aliases.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
Header file for the HasMutableDataAccess type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
Header file for the MatMatAddExpr base class.
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
Header file for the VecExpandExpr base class.
Header file for the MatMatMapExpr base class.
Initializer list type of the Blaze library.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
Header file for the implementation of the ColumnData class template.
Header file for the MatScalarDivExpr base class.
Header file for the IsRestricted type trait.
Header file for the Size type trait.
InversionFlag
Inversion flag.The InversionFlag type enumeration represents the different types of matrix inversion ...
Definition: InversionFlag.h:101
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the reduction flags.
Header file for the function trace functionality.
decltype(auto) map(const DenseMatrix< MT1, SO > &lhs, const DenseMatrix< MT2, SO > &rhs, OP op)
Evaluates the given binary operation on each single element of the dense matrices lhs and rhs...
Definition: DMatDMatMapExpr.h:1110