Rows.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_ROWS_H_
36 #define _BLAZE_MATH_VIEWS_ROWS_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <array>
45 #include <vector>
46 #include <blaze/math/Aliases.h>
50 #include <blaze/math/Exception.h>
83 #include <blaze/math/views/Check.h>
89 #include <blaze/util/Assert.h>
90 #include <blaze/util/EnableIf.h>
92 #include <blaze/util/SmallVector.h>
93 #include <blaze/util/TypeList.h>
94 #include <blaze/util/Types.h>
95 #include <blaze/util/Unused.h>
96 
97 
98 namespace blaze {
99 
100 //=================================================================================================
101 //
102 // GLOBAL FUNCTIONS
103 //
104 //=================================================================================================
105 
106 //*************************************************************************************************
141 template< size_t I // First row index
142  , size_t... Is // Remaining row indices
143  , typename MT // Type of the matrix
144  , bool SO // Storage order
145  , typename... RRAs > // Optional arguments
146 inline decltype(auto) rows( Matrix<MT,SO>& matrix, RRAs... args )
147 {
149 
150  using ReturnType = Rows_<MT,I,Is...>;
151  return ReturnType( ~matrix, args... );
152 }
153 //*************************************************************************************************
154 
155 
156 //*************************************************************************************************
191 template< size_t I // First row index
192  , size_t... Is // Remaining row indices
193  , typename MT // Type of the matrix
194  , bool SO // Storage order
195  , typename... RRAs > // Optional arguments
196 inline decltype(auto) rows( const Matrix<MT,SO>& matrix, RRAs... args )
197 {
199 
200  using ReturnType = const Rows_<const MT,I,Is...>;
201  return ReturnType( ~matrix, args... );
202 }
203 //*************************************************************************************************
204 
205 
206 //*************************************************************************************************
220 template< size_t I // First row index
221  , size_t... Is // Remaining row indices
222  , typename MT // Type of the matrix
223  , bool SO // Storage order
224  , typename... RRAs > // Optional arguments
225 inline decltype(auto) rows( Matrix<MT,SO>&& matrix, RRAs... args )
226 {
228 
229  using ReturnType = Rows_<MT,I,Is...>;
230  return ReturnType( ~matrix, args... );
231 }
232 //*************************************************************************************************
233 
234 
235 //*************************************************************************************************
274 template< typename MT // Type of the matrix
275  , bool SO // Storage order
276  , typename T // Type of the row indices
277  , typename... RRAs > // Optional arguments
278 inline decltype(auto) rows( Matrix<MT,SO>& matrix, const T* indices, size_t n, RRAs... args )
279 {
281 
282  using ReturnType = Rows_<MT>;
283  return ReturnType( ~matrix, indices, n, args... );
284 }
285 //*************************************************************************************************
286 
287 
288 //*************************************************************************************************
328 template< typename MT // Type of the matrix
329  , bool SO // Storage order
330  , typename T // Type of the row indices
331  , typename... RRAs > // Optional arguments
332 inline decltype(auto) rows( const Matrix<MT,SO>& matrix, const T* indices, size_t n, RRAs... args )
333 {
335 
336  using ReturnType = const Rows_<const MT>;
337  return ReturnType( ~matrix, indices, n, args... );
338 }
339 //*************************************************************************************************
340 
341 
342 //*************************************************************************************************
357 template< typename MT // Type of the matrix
358  , bool SO // Storage order
359  , typename T // Type of the row indices
360  , typename... RRAs > // Optional arguments
361 inline decltype(auto) rows( Matrix<MT,SO>&& matrix, const T* indices, size_t n, RRAs... args )
362 {
364 
365  using ReturnType = Rows_<MT>;
366  return ReturnType( ~matrix, indices, n, args... );
367 }
368 //*************************************************************************************************
369 
370 
371 //*************************************************************************************************
387 template< typename MT // Type of the matrix
388  , size_t... Is // Row indices
389  , typename... RRAs > // Optional arguments
390 inline decltype(auto) rows( MT&& matrix, index_sequence<Is...> indices, RRAs... args )
391 {
393 
394  UNUSED_PARAMETER( indices );
395 
396  return rows<Is...>( std::forward<MT>( matrix ), args... );
397 }
399 //*************************************************************************************************
400 
401 
402 //*************************************************************************************************
418 template< typename MT // Type of the matrix
419  , typename T // Type of the row indices
420  , typename... RRAs > // Optional arguments
421 inline decltype(auto) rows( MT&& matrix, initializer_list<T> indices, RRAs... args )
422 {
424 
425  return rows( std::forward<MT>( matrix ), indices.begin(), indices.size(), args... );
426 }
428 //*************************************************************************************************
429 
430 
431 //*************************************************************************************************
447 template< typename MT // Type of the matrix
448  , typename T // Type of the row indices
449  , size_t N // Number of indices
450  , typename... RRAs > // Optional arguments
451 inline decltype(auto) rows( MT&& matrix, const std::array<T,N>& indices, RRAs... args )
452 {
454 
455  return rows( std::forward<MT>( matrix ), indices.data(), N, args... );
456 }
458 //*************************************************************************************************
459 
460 
461 //*************************************************************************************************
477 template< typename MT // Type of the matrix
478  , typename T // Type of the row indices
479  , typename... RRAs > // Optional arguments
480 inline decltype(auto) rows( MT&& matrix, const std::vector<T>& indices, RRAs... args )
481 {
483 
484  return rows( std::forward<MT>( matrix ), indices.data(), indices.size(), args... );
485 }
487 //*************************************************************************************************
488 
489 
490 //*************************************************************************************************
506 template< typename MT // Type of the matrix
507  , typename T // Type of the row indices
508  , size_t N // Number of preallocated elements
509  , typename... RRAs > // Optional arguments
510 inline decltype(auto) rows( MT&& matrix, const SmallVector<T,N>& indices, RRAs... args )
511 {
513 
514  return rows( std::forward<MT>( matrix ), indices.data(), indices.size(), args... );
515 }
517 //*************************************************************************************************
518 
519 
520 
521 
522 //=================================================================================================
523 //
524 // GLOBAL RESTRUCTURING FUNCTIONS
525 //
526 //=================================================================================================
527 
528 //*************************************************************************************************
540 template< size_t... CRAs // Compile time row arguments
541  , typename MT // Matrix base type of the expression
542  , typename... RRAs // Runtime row arguments
543  , typename = EnableIfTrue_< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) > >
544 inline decltype(auto) rows( const MatMatAddExpr<MT>& matrix, RRAs... args )
545 {
547 
548  return rows<CRAs...>( (~matrix).leftOperand(), args... ) +
549  rows<CRAs...>( (~matrix).rightOperand(), args... );
550 }
552 //*************************************************************************************************
553 
554 
555 //*************************************************************************************************
567 template< size_t... CRAs // Compile time row arguments
568  , typename MT // Matrix base type of the expression
569  , typename... RRAs // Runtime row arguments
570  , typename = EnableIfTrue_< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) > >
571 inline decltype(auto) rows( const MatMatSubExpr<MT>& matrix, RRAs... args )
572 {
574 
575  return rows<CRAs...>( (~matrix).leftOperand(), args... ) -
576  rows<CRAs...>( (~matrix).rightOperand(), args... );
577 }
579 //*************************************************************************************************
580 
581 
582 //*************************************************************************************************
594 template< size_t... CRAs // Compile time row arguments
595  , typename MT // Matrix base type of the expression
596  , typename... RRAs // Runtime row arguments
597  , typename = EnableIfTrue_< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) > >
598 inline decltype(auto) rows( const SchurExpr<MT>& matrix, RRAs... args )
599 {
601 
602  return rows<CRAs...>( (~matrix).leftOperand(), args... ) %
603  rows<CRAs...>( (~matrix).rightOperand(), args... );
604 }
606 //*************************************************************************************************
607 
608 
609 //*************************************************************************************************
621 template< size_t... CRAs // Compile time row arguments
622  , typename MT // Matrix base type of the expression
623  , typename... RRAs // Runtime row arguments
624  , typename = EnableIfTrue_< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) > >
625 inline decltype(auto) rows( const MatMatMultExpr<MT>& matrix, RRAs... args )
626 {
628 
629  return rows<CRAs...>( (~matrix).leftOperand(), args... ) * (~matrix).rightOperand();
630 }
632 //*************************************************************************************************
633 
634 
635 //*************************************************************************************************
647 template< size_t... CRAs // Compile time row arguments
648  , typename MT // Matrix base type of the expression
649  , typename... RRAs // Runtime row arguments
650  , typename = EnableIfTrue_< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) > >
651 inline decltype(auto) rows( const VecTVecMultExpr<MT>& matrix, RRAs... args )
652 {
654 
655  return elements<CRAs...>( (~matrix).leftOperand(), args... ) * (~matrix).rightOperand();
656 }
658 //*************************************************************************************************
659 
660 
661 //*************************************************************************************************
673 template< size_t... CRAs // Compile time row arguments
674  , typename MT // Matrix base type of the expression
675  , typename... RRAs // Runtime row arguments
676  , typename = EnableIfTrue_< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) > >
677 inline decltype(auto) rows( const MatScalarMultExpr<MT>& matrix, RRAs... args )
678 {
680 
681  return rows<CRAs...>( (~matrix).leftOperand(), args... ) * (~matrix).rightOperand();
682 }
684 //*************************************************************************************************
685 
686 
687 //*************************************************************************************************
699 template< size_t... CRAs // Compile time row arguments
700  , typename MT // Matrix base type of the expression
701  , typename... RRAs // Runtime row arguments
702  , typename = EnableIfTrue_< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) > >
703 inline decltype(auto) rows( const MatScalarDivExpr<MT>& matrix, RRAs... args )
704 {
706 
707  return rows<CRAs...>( (~matrix).leftOperand(), args... ) / (~matrix).rightOperand();
708 }
710 //*************************************************************************************************
711 
712 
713 //*************************************************************************************************
725 template< size_t... CRAs // Compile time row arguments
726  , typename MT // Matrix base type of the expression
727  , typename... RRAs // Runtime row arguments
728  , typename = EnableIfTrue_< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) > >
729 inline decltype(auto) rows( const MatMapExpr<MT>& matrix, RRAs... args )
730 {
732 
733  return map( rows<CRAs...>( (~matrix).operand(), args... ), (~matrix).operation() );
734 }
736 //*************************************************************************************************
737 
738 
739 //*************************************************************************************************
751 template< size_t... CRAs // Compile time row arguments
752  , typename MT // Matrix base type of the expression
753  , typename... RRAs // Runtime row arguments
754  , typename = EnableIfTrue_< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) > >
755 inline decltype(auto) rows( const MatMatMapExpr<MT>& matrix, RRAs... args )
756 {
758 
759  return map( rows<CRAs...>( (~matrix).leftOperand(), args... ),
760  rows<CRAs...>( (~matrix).rightOperand(), args... ),
761  (~matrix).operation() );
762 }
764 //*************************************************************************************************
765 
766 
767 //*************************************************************************************************
779 template< size_t... CRAs // Compile time row arguments
780  , typename MT // Matrix base type of the expression
781  , typename... RRAs // Runtime row arguments
782  , typename = EnableIfTrue_< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) > >
783 inline decltype(auto) rows( const MatEvalExpr<MT>& matrix, RRAs... args )
784 {
786 
787  return eval( rows<CRAs...>( (~matrix).operand(), args... ) );
788 }
790 //*************************************************************************************************
791 
792 
793 //*************************************************************************************************
805 template< size_t... CRAs // Compile time row arguments
806  , typename MT // Matrix base type of the expression
807  , typename... RRAs // Runtime row arguments
808  , typename = EnableIfTrue_< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) > >
809 inline decltype(auto) rows( const MatSerialExpr<MT>& matrix, RRAs... args )
810 {
812 
813  return serial( rows<CRAs...>( (~matrix).operand(), args... ) );
814 }
816 //*************************************************************************************************
817 
818 
819 //*************************************************************************************************
831 template< size_t... CRAs // Compile time row arguments
832  , typename MT // Matrix base type of the expression
833  , typename... RRAs // Runtime row arguments
834  , typename = EnableIfTrue_< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) > >
835 inline decltype(auto) rows( const DeclExpr<MT>& matrix, RRAs... args )
836 {
838 
839  return rows<CRAs...>( (~matrix).operand(), args... );
840 }
842 //*************************************************************************************************
843 
844 
845 //*************************************************************************************************
857 template< size_t... CRAs // Compile time row arguments
858  , typename MT // Matrix base type of the expression
859  , typename... RRAs // Runtime row arguments
860  , typename = EnableIfTrue_< ( sizeof...( CRAs ) + sizeof...( RRAs ) > 0UL ) > >
861 inline decltype(auto) rows( const MatTransExpr<MT>& matrix, RRAs... args )
862 {
864 
865  return trans( columns<CRAs...>( (~matrix).operand(), args... ) );
866 }
868 //*************************************************************************************************
869 
870 
871 //*************************************************************************************************
882 template< size_t I1 // First required row index
883  , size_t... Is1 // Remaining required row indices
884  , typename MT // Type of the matrix
885  , bool SO // Storage order
886  , bool DF // Density flag
887  , bool SF // Symmetry flag
888  , size_t I2 // First present row index
889  , size_t... Is2 // Remaining present row indices
890  , typename... RRAs > // Optional row arguments
891 inline decltype(auto) rows( Rows<MT,SO,DF,SF,I2,Is2...>& r, RRAs... args )
892 {
894 
895  static constexpr size_t indices[] = { I2, Is2... };
896  return rows< indices[I1], indices[Is1]... >( r.operand(), args... );
897 }
899 //*************************************************************************************************
900 
901 
902 //*************************************************************************************************
914 template< size_t I1 // First required row index
915  , size_t... Is1 // Remaining required row indices
916  , typename MT // Type of the matrix
917  , bool SO // Storage order
918  , bool DF // Density flag
919  , bool SF // Symmetry flag
920  , size_t I2 // First present row index
921  , size_t... Is2 // Remaining present row indices
922  , typename... RRAs > // Optional row arguments
923 inline decltype(auto) rows( const Rows<MT,SO,DF,SF,I2,Is2...>& r, RRAs... args )
924 {
926 
927  static constexpr size_t indices[] = { I2, Is2... };
928  return rows< indices[I1], indices[Is1]... >( r.operand(), args... );
929 }
931 //*************************************************************************************************
932 
933 
934 //*************************************************************************************************
946 template< size_t I1 // First required row index
947  , size_t... Is1 // Remaining required row indices
948  , typename MT // Type of the matrix
949  , bool SO // Storage order
950  , bool DF // Density flag
951  , bool SF // Symmetry flag
952  , size_t I2 // First present row index
953  , size_t... Is2 // Remaining present row indices
954  , typename... RRAs > // Optional row arguments
955 inline decltype(auto) rows( Rows<MT,SO,DF,SF,I2,Is2...>&& r, RRAs... args )
956 {
958 
959  static constexpr size_t indices[] = { I2, Is2... };
960  return rows< indices[I1], indices[Is1]... >( r.operand(), args... );
961 }
963 //*************************************************************************************************
964 
965 
966 //*************************************************************************************************
978 template< size_t I // First required row index
979  , size_t... Is // Remaining required row indices
980  , typename MT // Type of the matrix
981  , bool SO // Storage order
982  , bool DF // Density flag
983  , bool SF // Symmetry flag
984  , size_t... CRAs // Compile time row arguments
985  , typename... RRAs > // Optional row arguments
986 inline decltype(auto) rows( Rows<MT,SO,DF,SF,CRAs...>& r, RRAs... args )
987 {
989 
990  constexpr bool isChecked( !Contains< TypeList<RRAs...>, Unchecked >::value );
991 
992  if( isChecked ) {
993  static constexpr size_t indices[] = { I, Is... };
994  for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
995  if( r.rows() <= indices[i] ) {
996  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
997  }
998  }
999  }
1000 
1001  decltype(auto) indices( r.idces() );
1002  return rows( r.operand(), { indices[I], indices[Is]... }, args... );
1003 }
1005 //*************************************************************************************************
1006 
1007 
1008 //*************************************************************************************************
1021 template< size_t I // First required row index
1022  , size_t... Is // Remaining required row indices
1023  , typename MT // Type of the matrix
1024  , bool SO // Storage order
1025  , bool DF // Density flag
1026  , bool SF // Symmetry flag
1027  , size_t... CRAs // Compile time row arguments
1028  , typename... RRAs > // Optional row arguments
1029 inline decltype(auto) rows( const Rows<MT,SO,DF,SF,CRAs...>& r, RRAs... args )
1030 {
1032 
1033  constexpr bool isChecked( !Contains< TypeList<RRAs...>, Unchecked >::value );
1034 
1035  if( isChecked ) {
1036  static constexpr size_t indices[] = { I, Is... };
1037  for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1038  if( r.rows() <= indices[i] ) {
1039  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1040  }
1041  }
1042  }
1043 
1044  decltype(auto) indices( r.idces() );
1045  return rows( r.operand(), { indices[I], indices[Is]... }, args... );
1046 }
1048 //*************************************************************************************************
1049 
1050 
1051 //*************************************************************************************************
1064 template< size_t I // First required row index
1065  , size_t... Is // Remaining required row indices
1066  , typename MT // Type of the matrix
1067  , bool SO // Storage order
1068  , bool DF // Density flag
1069  , bool SF // Symmetry flag
1070  , size_t... CRAs // Compile time row arguments
1071  , typename... RRAs > // Optional row arguments
1072 inline decltype(auto) rows( Rows<MT,SO,DF,SF,CRAs...>&& r, RRAs... args )
1073 {
1075 
1076  constexpr bool isChecked( !Contains< TypeList<RRAs...>, Unchecked >::value );
1077 
1078  if( isChecked ) {
1079  static constexpr size_t indices[] = { I, Is... };
1080  for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1081  if( r.rows() <= indices[i] ) {
1082  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1083  }
1084  }
1085  }
1086 
1087  decltype(auto) indices( r.idces() );
1088  return rows( r.operand(), { indices[I], indices[Is]... }, args... );
1089 }
1091 //*************************************************************************************************
1092 
1093 
1094 //*************************************************************************************************
1108 template< typename MT // Type of the matrix
1109  , bool SO // Storage order
1110  , bool DF // Density flag
1111  , bool SF // Symmetry flag
1112  , size_t... CRAs // Compile time row arguments
1113  , typename T // Type of the row indices
1114  , typename... RRAs > // Optional row arguments
1115 inline decltype(auto) rows( Rows<MT,SO,DF,SF,CRAs...>& r, const T* indices, size_t n, RRAs... args )
1116 {
1118 
1119  constexpr bool isChecked( !Contains< TypeList<RRAs...>, Unchecked >::value );
1120 
1121  if( isChecked ) {
1122  for( size_t i=0UL; i<n; ++i ) {
1123  if( r.rows() <= indices[i] ) {
1124  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1125  }
1126  }
1127  }
1128 
1129  decltype(auto) oldIndices( r.idces() );
1130  SmallVector<size_t,128UL> newIndices;
1131  newIndices.reserve( n );
1132 
1133  for( size_t i=0UL; i<n; ++i ) {
1134  newIndices.pushBack( oldIndices[indices[i]] );
1135  }
1136 
1137  return rows( r.operand(), newIndices.data(), newIndices.size(), args... );
1138 }
1140 //*************************************************************************************************
1141 
1142 
1143 //*************************************************************************************************
1158 template< typename MT // Type of the matrix
1159  , bool SO // Storage order
1160  , bool DF // Density flag
1161  , bool SF // Symmetry flag
1162  , size_t... CRAs // Compile time row arguments
1163  , typename T // Type of the row indices
1164  , typename... RRAs > // Optional row arguments
1165 inline decltype(auto) rows( const Rows<MT,SO,DF,SF,CRAs...>& r, const T* indices, size_t n, RRAs... args )
1166 {
1168 
1169  constexpr bool isChecked( !Contains< TypeList<RRAs...>, Unchecked >::value );
1170 
1171  if( isChecked ) {
1172  for( size_t i=0UL; i<n; ++i ) {
1173  if( r.rows() <= indices[i] ) {
1174  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1175  }
1176  }
1177  }
1178 
1179  decltype(auto) oldIndices( r.idces() );
1180  SmallVector<size_t,128UL> newIndices;
1181  newIndices.reserve( n );
1182 
1183  for( size_t i=0UL; i<n; ++i ) {
1184  newIndices.pushBack( oldIndices[indices[i]] );
1185  }
1186 
1187  return rows( r.operand(), newIndices.data(), newIndices.size(), args... );
1188 }
1190 //*************************************************************************************************
1191 
1192 
1193 //*************************************************************************************************
1208 template< typename MT // Type of the matrix
1209  , bool SO // Storage order
1210  , bool DF // Density flag
1211  , bool SF // Symmetry flag
1212  , size_t... CRAs // Compile time row arguments
1213  , typename T // Type of the row indices
1214  , typename... RRAs > // Optional row arguments
1215 inline decltype(auto) rows( Rows<MT,SO,DF,SF,CRAs...>&& r, const T* indices, size_t n, RRAs... args )
1216 {
1218 
1219  constexpr bool isChecked( !Contains< TypeList<RRAs...>, Unchecked >::value );
1220 
1221  if( isChecked ) {
1222  for( size_t i=0UL; i<n; ++i ) {
1223  if( r.rows() <= indices[i] ) {
1224  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1225  }
1226  }
1227  }
1228 
1229  decltype(auto) oldIndices( r.idces() );
1230  SmallVector<size_t,128UL> newIndices;
1231  newIndices.reserve( n );
1232 
1233  for( size_t i=0UL; i<n; ++i ) {
1234  newIndices.pushBack( oldIndices[indices[i]] );
1235  }
1236 
1237  return rows( r.operand(), newIndices.data(), newIndices.size(), args... );
1238 }
1240 //*************************************************************************************************
1241 
1242 
1243 
1244 
1245 //=================================================================================================
1246 //
1247 // GLOBAL RESTRUCTURING FUNCTIONS (ELEMENTS)
1248 //
1249 //=================================================================================================
1250 
1251 //*************************************************************************************************
1263 template< size_t... CEAs // Compile time element arguments
1264  , typename VT // Vector base type of the expression
1265  , typename... REAs > // Runtime element arguments
1266 inline decltype(auto) elements( const MatVecMultExpr<VT>& vector, REAs... args )
1267 {
1269 
1270  return rows<CEAs...>( (~vector).leftOperand(), args... ) * (~vector).rightOperand();
1271 }
1273 //*************************************************************************************************
1274 
1275 
1276 
1277 
1278 //=================================================================================================
1279 //
1280 // GLOBAL RESTRUCTURING FUNCTIONS (ROW)
1281 //
1282 //=================================================================================================
1283 
1284 //*************************************************************************************************
1295 template< size_t I1 // Row index
1296  , typename MT // Type of the matrix
1297  , bool SO // Storage order
1298  , bool DF // Density flag
1299  , bool SF // Symmetry flag
1300  , size_t I2 // First row index
1301  , size_t... Is // Remaining row indices
1302  , typename... RRAs > // Optional row arguments
1303 inline decltype(auto) row( Rows<MT,SO,DF,SF,I2,Is...>& rows, RRAs... args )
1304 {
1306 
1307  static constexpr size_t indices[] = { I2, Is... };
1308  return row<indices[I1]>( rows.operand(), args... );
1309 }
1311 //*************************************************************************************************
1312 
1313 
1314 //*************************************************************************************************
1326 template< size_t I1 // Row index
1327  , typename MT // Type of the matrix
1328  , bool SO // Storage order
1329  , bool DF // Density flag
1330  , bool SF // Symmetry flag
1331  , size_t I2 // First row index
1332  , size_t... Is // Remaining row indices
1333  , typename... RRAs > // Optional row arguments
1334 inline decltype(auto) row( const Rows<MT,SO,DF,SF,I2,Is...>& rows, RRAs... args )
1335 {
1337 
1338  static constexpr size_t indices[] = { I2, Is... };
1339  return row<indices[I1]>( rows.operand(), args... );
1340 }
1342 //*************************************************************************************************
1343 
1344 
1345 //*************************************************************************************************
1357 template< size_t I1 // Row index
1358  , typename MT // Type of the matrix
1359  , bool SO // Storage order
1360  , bool DF // Density flag
1361  , bool SF // Symmetry flag
1362  , size_t I2 // First row index
1363  , size_t... Is // Remaining row indices
1364  , typename... RRAs > // Optional row arguments
1365 inline decltype(auto) row( Rows<MT,SO,DF,SF,I2,Is...>&& rows, RRAs... args )
1366 {
1368 
1369  static constexpr size_t indices[] = { I2, Is... };
1370  return row<indices[I1]>( rows.operand(), args... );
1371 }
1373 //*************************************************************************************************
1374 
1375 
1376 //*************************************************************************************************
1388 template< size_t... CRAs1 // Compile time row arguments
1389  , typename MT // Type of the matrix
1390  , bool SO // Storage order
1391  , bool DF // Density flag
1392  , bool SF // Symmetry flag
1393  , size_t... CRAs2 // Compile time row arguments
1394  , typename... RRAs > // Runtime row arguments
1395 inline decltype(auto) row( Rows<MT,SO,DF,SF,CRAs2...>& rows, RRAs... args )
1396 {
1398 
1399  const RowData<CRAs1...> rd( args... );
1400  decltype(auto) indices( rows.idces() );
1401 
1402  constexpr bool isChecked( !Contains< TypeList<RRAs...>, Unchecked >::value );
1403 
1404  if( isChecked ) {
1405  if( indices.size() <= rd.row() ) {
1406  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1407  }
1408  }
1409 
1410  return row( rows.operand(), indices[rd.row()], args... );
1411 }
1413 //*************************************************************************************************
1414 
1415 
1416 //*************************************************************************************************
1429 template< size_t... CRAs1 // Compile time row arguments
1430  , typename MT // Type of the matrix
1431  , bool SO // Storage order
1432  , bool DF // Density flag
1433  , bool SF // Symmetry flag
1434  , size_t... CRAs2 // Compile time row arguments
1435  , typename... RRAs > // Runtime row arguments
1436 inline decltype(auto) row( const Rows<MT,SO,DF,SF,CRAs2...>& rows, RRAs... args )
1437 {
1439 
1440  const RowData<CRAs1...> rd( args... );
1441  decltype(auto) indices( rows.idces() );
1442 
1443  constexpr bool isChecked( !Contains< TypeList<RRAs...>, Unchecked >::value );
1444 
1445  if( isChecked ) {
1446  if( indices.size() <= rd.row() ) {
1447  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1448  }
1449  }
1450 
1451  return row( rows.operand(), indices[rd.row()], args... );
1452 }
1454 //*************************************************************************************************
1455 
1456 
1457 //*************************************************************************************************
1470 template< size_t... CRAs1 // Compile time row arguments
1471  , typename MT // Type of the matrix
1472  , bool SO // Storage order
1473  , bool DF // Density flag
1474  , bool SF // Symmetry flag
1475  , size_t... CRAs2 // Compile time row arguments
1476  , typename... RRAs > // Runtime row arguments
1477 inline decltype(auto) row( Rows<MT,SO,DF,SF,CRAs2...>&& rows, RRAs... args )
1478 {
1480 
1481  const RowData<CRAs1...> rd( args... );
1482  decltype(auto) indices( rows.idces() );
1483 
1484  constexpr bool isChecked( !Contains< TypeList<RRAs...>, Unchecked >::value );
1485 
1486  if( isChecked ) {
1487  if( indices.size() <= rd.row() ) {
1488  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
1489  }
1490  }
1491 
1492  return row( rows.operand(), indices[rd.row()], args... );
1493 }
1495 //*************************************************************************************************
1496 
1497 
1498 
1499 
1500 //=================================================================================================
1501 //
1502 // GLOBAL RESTRUCTURING FUNCTIONS (COLUMN)
1503 //
1504 //=================================================================================================
1505 
1506 //*************************************************************************************************
1517 template< size_t... CCAs // Compile time column arguments
1518  , typename MT // Type of the matrix
1519  , bool SO // Storage order
1520  , bool DF // Density flag
1521  , bool SF // Symmetry flag
1522  , size_t I // First row index
1523  , size_t... Is // Remaining row indices
1524  , typename... RCAs > // Runtime column arguments
1525 inline decltype(auto) column( Rows<MT,SO,DF,SF,I,Is...>& rows, RCAs... args )
1526 {
1528 
1529  return elements<I,Is...>( column<CCAs...>( rows.operand(), args... ) );
1530 }
1532 //*************************************************************************************************
1533 
1534 
1535 //*************************************************************************************************
1547 template< size_t... CCAs // Compile time column arguments
1548  , typename MT // Type of the matrix
1549  , bool SO // Storage order
1550  , bool DF // Density flag
1551  , bool SF // Symmetry flag
1552  , size_t I // First row index
1553  , size_t... Is // Remaining row indices
1554  , typename... RCAs > // Runtime column arguments
1555 inline decltype(auto) column( const Rows<MT,SO,DF,SF,I,Is...>& rows, RCAs... args )
1556 {
1558 
1559  return elements<I,Is...>( column<CCAs...>( rows.operand(), args... ) );
1560 }
1562 //*************************************************************************************************
1563 
1564 
1565 //*************************************************************************************************
1577 template< size_t... CCAs // Compile time column arguments
1578  , typename MT // Type of the matrix
1579  , bool SO // Storage order
1580  , bool DF // Density flag
1581  , bool SF // Symmetry flag
1582  , size_t I // First row index
1583  , size_t... Is // Remaining row indices
1584  , typename... RCAs > // Runtime column arguments
1585 inline decltype(auto) column( Rows<MT,SO,DF,SF,I,Is...>&& rows, RCAs... args )
1586 {
1588 
1589  return elements<I,Is...>( column<CCAs...>( rows.operand(), args... ) );
1590 }
1592 //*************************************************************************************************
1593 
1594 
1595 //*************************************************************************************************
1606 template< size_t... CCAs // Compile time column arguments
1607  , typename MT // Type of the matrix
1608  , bool SO // Storage order
1609  , bool DF // Density flag
1610  , bool SF // Symmetry flag
1611  , typename... RCAs > // Runtime column arguments
1612 inline decltype(auto) column( Rows<MT,SO,DF,SF>& rows, RCAs... args )
1613 {
1615 
1616  return elements( column<CCAs...>( rows.operand(), args... ), rows.idces() );
1617 }
1619 //*************************************************************************************************
1620 
1621 
1622 //*************************************************************************************************
1634 template< size_t... CCAs // Compile time column arguments
1635  , typename MT // Type of the matrix
1636  , bool SO // Storage order
1637  , bool DF // Density flag
1638  , bool SF // Symmetry flag
1639  , typename... RCAs > // Runtime column arguments
1640 inline decltype(auto) column( const Rows<MT,SO,DF,SF>& rows, RCAs... args )
1641 {
1643 
1644  return elements( column<CCAs...>( rows.operand(), args... ), rows.idces() );
1645 }
1647 //*************************************************************************************************
1648 
1649 
1650 //*************************************************************************************************
1662 template< size_t... CCAs // Compile time column arguments
1663  , typename MT // Type of the matrix
1664  , bool SO // Storage order
1665  , bool DF // Density flag
1666  , bool SF // Symmetry flag
1667  , typename... RCAs > // Runtime column arguments
1668 inline decltype(auto) column( Rows<MT,SO,DF,SF>&& rows, RCAs... args )
1669 {
1671 
1672  return elements( column<CCAs...>( rows.operand(), args... ), rows.idces() );
1673 }
1675 //*************************************************************************************************
1676 
1677 
1678 
1679 
1680 //=================================================================================================
1681 //
1682 // ROWS OPERATORS
1683 //
1684 //=================================================================================================
1685 
1686 //*************************************************************************************************
1694 template< typename MT // Type of the matrix
1695  , bool SO // Storage order
1696  , bool DF // Density flag
1697  , bool SF // Symmetry flag
1698  , size_t... CRAs > // Compile time row arguments
1699 inline void reset( Rows<MT,SO,DF,SF,CRAs...>& rows )
1700 {
1701  rows.reset();
1702 }
1704 //*************************************************************************************************
1705 
1706 
1707 //*************************************************************************************************
1715 template< typename MT // Type of the matrix
1716  , bool SO // Storage order
1717  , bool DF // Density flag
1718  , bool SF // Symmetry flag
1719  , size_t... CRAs > // Compile time row arguments
1720 inline void reset( Rows<MT,SO,DF,SF,CRAs...>&& rows )
1721 {
1722  rows.reset();
1723 }
1725 //*************************************************************************************************
1726 
1727 
1728 //*************************************************************************************************
1740 template< typename MT // Type of the matrix
1741  , bool SO // Storage order
1742  , bool DF // Density flag
1743  , bool SF // Symmetry flag
1744  , size_t... CRAs > // Compile time row arguments
1745 inline void reset( Rows<MT,SO,DF,SF,CRAs...>& rows, size_t i )
1746 {
1747  rows.reset( i );
1748 }
1750 //*************************************************************************************************
1751 
1752 
1753 //*************************************************************************************************
1763 template< typename MT // Type of the matrix
1764  , bool SO // Storage order
1765  , bool DF // Density flag
1766  , bool SF // Symmetry flag
1767  , size_t... CRAs > // Compile time row arguments
1768 inline void clear( Rows<MT,SO,DF,SF,CRAs...>& rows )
1769 {
1770  rows.reset();
1771 }
1773 //*************************************************************************************************
1774 
1775 
1776 //*************************************************************************************************
1786 template< typename MT // Type of the matrix
1787  , bool SO // Storage order
1788  , bool DF // Density flag
1789  , bool SF // Symmetry flag
1790  , size_t... CRAs > // Compile time row arguments
1791 inline void clear( Rows<MT,SO,DF,SF,CRAs...>&& rows )
1792 {
1793  rows.reset();
1794 }
1796 //*************************************************************************************************
1797 
1798 
1799 //*************************************************************************************************
1825 template< bool RF // Relaxation flag
1826  , typename MT // Type of the dense matrix
1827  , bool SO // Storage order
1828  , bool SF // Symmetry flag
1829  , size_t... CRAs > // Compile time row arguments
1830 inline bool isDefault( const Rows<MT,SO,true,SF,CRAs...>& rows )
1831 {
1832  using blaze::isDefault;
1833 
1834  if( SO == true ) {
1835  for( size_t i=0UL; i<rows.rows(); ++i )
1836  for( size_t j=0UL; j<rows.columns(); ++j )
1837  if( !isDefault<RF>( rows(i,j) ) )
1838  return false;
1839  }
1840  else {
1841  for( size_t j=0UL; j<rows.columns(); ++j )
1842  for( size_t i=0UL; i<rows.rows(); ++i )
1843  if( !isDefault<RF>( rows(i,j) ) )
1844  return false;
1845  }
1846 
1847  return true;
1848 }
1850 //*************************************************************************************************
1851 
1852 
1853 //*************************************************************************************************
1879 template< bool RF // Relaxation flag
1880  , typename MT // Type of the dense matrix
1881  , bool SO // Storage order
1882  , bool SF // Symmetry flag
1883  , size_t... CRAs > // Compile time row arguments
1884 inline bool isDefault( const Rows<MT,SO,false,SF,CRAs...>& rows )
1885 {
1886  using blaze::isDefault;
1887 
1888  for( size_t i=0UL; i<rows.rows(); ++i ) {
1889  for( auto element=rows.cbegin(i); element!=rows.cend(i); ++element )
1890  if( !isDefault<RF>( element->value() ) ) return false;
1891  }
1892 
1893  return true;
1894 }
1896 //*************************************************************************************************
1897 
1898 
1899 //*************************************************************************************************
1918 template< typename MT // Type of the matrix
1919  , bool SO // Storage order
1920  , bool DF // Density flag
1921  , bool SF // Symmetry flag
1922  , size_t... CRAs > // Compile time row arguments
1923 inline bool isIntact( const Rows<MT,SO,DF,SF,CRAs...>& rows ) noexcept
1924 {
1925  return ( rows.rows() <= rows.operand().rows() &&
1926  rows.columns() == rows.operand().columns() &&
1927  isIntact( rows.operand() ) );
1928 }
1930 //*************************************************************************************************
1931 
1932 
1933 //*************************************************************************************************
1946 template< typename MT // Type of the matrix
1947  , bool SO1 // Storage order of the left-hand side row selection
1948  , bool DF // Density flag
1949  , bool SF // Symmetry flag
1950  , size_t... CRAs // Compile time row arguments
1951  , bool SO2 > // Storage order of the right-hand side matrix
1952 inline bool isSame( const Rows<MT,SO1,DF,SF,CRAs...>& a, const Matrix<MT,SO2>& b ) noexcept
1953 {
1954  if( !isSame( a.operand(), ~b ) || ( a.rows() != (~b).rows() ) || ( a.columns() != (~b).columns() ) )
1955  return false;
1956 
1957  decltype(auto) indices( a.idces() );
1958  for( size_t i=0UL; i<a.rows(); ++i ) {
1959  if( indices[i] != i )
1960  return false;
1961  }
1962 
1963  return true;
1964 }
1966 //*************************************************************************************************
1967 
1968 
1969 //*************************************************************************************************
1982 template< typename MT // Type of the matrix
1983  , bool SO1 // Storage order of the left-hand side matrix
1984  , bool DF // Density flag
1985  , bool SF // Symmetry flag
1986  , size_t... CRAs // Compile time row arguments
1987  , bool SO2 > // Storage order of the right-hand side row selection
1988 inline bool isSame( const Matrix<MT,SO1>& a, const Rows<MT,SO2,DF,SF,CRAs...>& b ) noexcept
1989 {
1990  return isSame( b, a );
1991 }
1993 //*************************************************************************************************
1994 
1995 
1996 //*************************************************************************************************
2009 template< typename MT // Type of the matrix
2010  , bool SO1 // Storage order of the left-hand side row selection
2011  , bool DF // Density flag
2012  , bool SF // Symmetry flag
2013  , size_t... CRAs // Compile time row arguments
2014  , AlignmentFlag AF // Alignment flag
2015  , bool SO2 // Storage order of the right-hand side submatrix
2016  , size_t... CSAs > // Compile time submatrix arguments
2017 inline bool isSame( const Rows<MT,SO1,DF,SF,CRAs...>& a, const Submatrix<MT,AF,SO2,DF,CSAs...>& b ) noexcept
2018 {
2019  if( !isSame( a.operand(), b.operand() ) || ( a.rows() != (~b).rows() ) || ( a.columns() != (~b).columns() ) )
2020  return false;
2021 
2022  decltype(auto) indices( a.idces() );
2023  for( size_t i=0UL; i<a.rows(); ++i ) {
2024  if( indices[i] != b.row()+i )
2025  return false;
2026  }
2027 
2028  return true;
2029 }
2031 //*************************************************************************************************
2032 
2033 
2034 //*************************************************************************************************
2047 template< typename MT // Type of the matrix
2048  , AlignmentFlag AF // Alignment flag
2049  , bool SO1 // Storage order of the left-hand side submatrix
2050  , bool DF // Density flag
2051  , size_t... CSAs // Compile time submatrix arguments
2052  , bool SO2 // Storage order of the right-hand side row selection
2053  , bool SF // Symmetry flag
2054  , size_t... CRAs > // Compile time row arguments
2055 inline bool isSame( const Submatrix<MT,AF,SO1,DF,CSAs...>& a, const Rows<MT,SO2,DF,SF,CRAs...>& b ) noexcept
2056 {
2057  return isSame( b, a );
2058 }
2060 //*************************************************************************************************
2061 
2062 
2063 //*************************************************************************************************
2076 template< typename MT // Type of the matrix
2077  , bool SO // Storage order
2078  , bool DF // Density flag
2079  , bool SF // Symmetry flag
2080  , size_t... CRAs1 // Compile time row arguments of the left-hand side row selection
2081  , size_t... CRAs2 > // Compile time row arguments of the right-hand side row selection
2082 inline bool isSame( const Rows<MT,SO,DF,SF,CRAs1...>& a,
2083  const Rows<MT,SO,DF,SF,CRAs2...>& b ) noexcept
2084 {
2085  if( !isSame( a.operand(), b.operand() ) || a.rows() != b.rows() || a.columns() != b.columns() )
2086  return false;
2087 
2088  decltype(auto) indices1( a.idces() );
2089  decltype(auto) indices2( b.idces() );
2090 
2091  return std::equal( indices1.begin(), indices1.end(), indices2.begin() );
2092 }
2094 //*************************************************************************************************
2095 
2096 
2097 //*************************************************************************************************
2136 template< InversionFlag IF // Inversion algorithm
2137  , typename MT // Type of the dense matrix
2138  , bool SO // Storage order
2139  , bool SF // Symmetry flag
2140  , size_t... CRAs > // Compile time row arguments
2141 inline DisableIf_< HasMutableDataAccess<MT> > invert( Rows<MT,SO,true,SF,CRAs...>& r )
2142 {
2143  using RT = ResultType_< Rows<MT,SO,true,SF,CRAs...> >;
2144 
2147 
2148  RT tmp( r );
2149  invert<IF>( tmp );
2150  r = tmp;
2151 }
2153 //*************************************************************************************************
2154 
2155 
2156 //*************************************************************************************************
2172 template< typename MT // Type of the matrix
2173  , bool SO // Storage order
2174  , bool DF // Density flag
2175  , bool SF // Symmetry flag
2176  , size_t... CRAs // Compile time row arguments
2177  , typename ET > // Type of the element
2178 inline bool trySet( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
2179 {
2180  BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2181  BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2182 
2183  return trySet( r.operand(), r.idx(i), j, value );
2184 }
2186 //*************************************************************************************************
2187 
2188 
2189 //*************************************************************************************************
2205 template< typename MT // Type of the matrix
2206  , bool SO // Storage order
2207  , bool DF // Density flag
2208  , bool SF // Symmetry flag
2209  , size_t... CRAs // Compile time row arguments
2210  , typename ET > // Type of the element
2211 inline bool tryAdd( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
2212 {
2213  BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2214  BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2215 
2216  return tryAdd( r.operand(), r.idx(i), j, value );
2217 }
2219 //*************************************************************************************************
2220 
2221 
2222 //*************************************************************************************************
2238 template< typename MT // Type of the matrix
2239  , bool SO // Storage order
2240  , bool DF // Density flag
2241  , bool SF // Symmetry flag
2242  , size_t... CRAs // Compile time row arguments
2243  , typename ET > // Type of the element
2244 inline bool trySub( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
2245 {
2246  BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2247  BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2248 
2249  return trySub( r.operand(), r.idx(i), j, value );
2250 }
2252 //*************************************************************************************************
2253 
2254 
2255 //*************************************************************************************************
2271 template< typename MT // Type of the matrix
2272  , bool SO // Storage order
2273  , bool DF // Density flag
2274  , bool SF // Symmetry flag
2275  , size_t... CRAs // Compile time row arguments
2276  , typename ET > // Type of the element
2277 inline bool tryMult( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
2278 {
2279  BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2280  BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2281 
2282  return tryMult( r.operand(), r.idx(i), j, value );
2283 }
2285 //*************************************************************************************************
2286 
2287 
2288 //*************************************************************************************************
2306 template< typename MT // Type of the matrix
2307  , bool SO // Storage order
2308  , bool DF // Density flag
2309  , bool SF // Symmetry flag
2310  , size_t... CRAs // Compile time row arguments
2311  , typename ET > // Type of the element
2313  tryMult( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t row, size_t column, size_t m, size_t n, const ET& value )
2314 {
2315  BLAZE_INTERNAL_ASSERT( row <= (~r).rows(), "Invalid row access index" );
2316  BLAZE_INTERNAL_ASSERT( column <= (~r).columns(), "Invalid column access index" );
2317  BLAZE_INTERNAL_ASSERT( row + m <= (~r).rows(), "Invalid number of rows" );
2318  BLAZE_INTERNAL_ASSERT( column + n <= (~r).columns(), "Invalid number of columns" );
2319 
2320  const size_t iend( row + m );
2321 
2322  for( size_t i=row; i<iend; ++i ) {
2323  if( !tryMult( r.operand(), r.idx(i), column, m, n, value ) )
2324  return false;
2325  }
2326 
2327  return true;
2328 }
2330 //*************************************************************************************************
2331 
2332 
2333 //*************************************************************************************************
2349 template< typename MT // Type of the matrix
2350  , bool SO // Storage order
2351  , bool DF // Density flag
2352  , bool SF // Symmetry flag
2353  , size_t... CRAs // Compile time row arguments
2354  , typename ET > // Type of the element
2355 inline bool tryDiv( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t i, size_t j, const ET& value )
2356 {
2357  BLAZE_INTERNAL_ASSERT( i < r.rows(), "Invalid row access index" );
2358  BLAZE_INTERNAL_ASSERT( j < r.columns(), "Invalid column access index" );
2359 
2360  return tryDiv( r.operand(), r.idx(i), j, value );
2361 }
2363 //*************************************************************************************************
2364 
2365 
2366 //*************************************************************************************************
2384 template< typename MT // Type of the matrix
2385  , bool SO // Storage order
2386  , bool DF // Density flag
2387  , bool SF // Symmetry flag
2388  , size_t... CRAs // Compile time row arguments
2389  , typename ET > // Type of the element
2391  tryDiv( const Rows<MT,SO,DF,SF,CRAs...>& r, size_t row, size_t column, size_t m, size_t n, const ET& value )
2392 {
2393  BLAZE_INTERNAL_ASSERT( row <= (~r).rows(), "Invalid row access index" );
2394  BLAZE_INTERNAL_ASSERT( column <= (~r).columns(), "Invalid column access index" );
2395  BLAZE_INTERNAL_ASSERT( row + m <= (~r).rows(), "Invalid number of rows" );
2396  BLAZE_INTERNAL_ASSERT( column + n <= (~r).columns(), "Invalid number of columns" );
2397 
2398  const size_t iend( row + m );
2399 
2400  for( size_t i=row; i<iend; ++i ) {
2401  if( !tryDiv( r.operand(), r.idx(i), column, m, n, value ) )
2402  return false;
2403  }
2404 
2405  return true;
2406 }
2408 //*************************************************************************************************
2409 
2410 
2411 //*************************************************************************************************
2427 template< typename MT // Type of the matrix
2428  , bool SO // Storage order
2429  , bool DF // Density flag
2430  , bool SF // Symmetry flag
2431  , size_t... CRAs // Compile time row arguments
2432  , typename VT > // Type of the right-hand side vector
2433 inline bool tryAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
2434  const Vector<VT,false>& rhs, size_t row, size_t column )
2435 {
2436  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2437  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2438  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
2439 
2440  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2441  if( !trySet( lhs.operand(), lhs.idx( row+i ), column, (~rhs)[i] ) )
2442  return false;
2443  }
2444 
2445  return true;
2446 }
2448 //*************************************************************************************************
2449 
2450 
2451 //*************************************************************************************************
2467 template< typename MT // Type of the matrix
2468  , bool SO // Storage order
2469  , bool DF // Density flag
2470  , bool SF // Symmetry flag
2471  , size_t... CRAs // Compile time row arguments
2472  , typename VT > // Type of the right-hand side vector
2473 inline bool tryAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
2474  const Vector<VT,true>& rhs, size_t row, size_t column )
2475 {
2476  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2477  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2478  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
2479 
2480  return tryAssign( lhs.operand(), ~rhs, lhs.idx( row ), column );
2481 }
2483 //*************************************************************************************************
2484 
2485 
2486 //*************************************************************************************************
2503 template< typename MT // Type of the matrix
2504  , bool SO // Storage order
2505  , bool DF // Density flag
2506  , bool SF // Symmetry flag
2507  , size_t... CRAs // Compile time row arguments
2508  , typename VT // Type of the right-hand side vector
2509  , bool TF > // Transpose flag of the right-hand side vector
2510 inline bool tryAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
2511  const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
2512 {
2513  UNUSED_PARAMETER( band );
2514 
2515  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2516  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2517  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
2518  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
2519 
2520  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2521  if( !trySet( lhs.operand(), lhs.idx( row+i ), column+i, (~rhs)[i] ) )
2522  return false;
2523  }
2524 
2525  return true;
2526 }
2528 //*************************************************************************************************
2529 
2530 
2531 //*************************************************************************************************
2547 template< typename MT1 // Type of the matrix
2548  , bool SO1 // Storage order
2549  , bool DF // Density flag
2550  , bool SF // Symmetry flag
2551  , size_t... CRAs // Compile time row arguments
2552  , typename MT2 // Type of the right-hand side matrix
2553  , bool SO2 > // Storage order of the right-hand side matrix
2554 inline bool tryAssign( const Rows<MT1,SO1,DF,SF,CRAs...>& lhs,
2555  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
2556 {
2557  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2558  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2559  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
2560  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
2561 
2562  for( size_t i=0UL; i<(~rhs).rows(); ++i ) {
2563  if( !tryAssign( lhs.operand(), blaze::row( ~rhs, i, unchecked ), lhs.idx( row+i ), column ) )
2564  return false;
2565  }
2566 
2567  return true;
2568 }
2570 //*************************************************************************************************
2571 
2572 
2573 //*************************************************************************************************
2591 template< typename MT // Type of the matrix
2592  , bool SO // Storage order
2593  , bool DF // Density flag
2594  , bool SF // Symmetry flag
2595  , size_t... CRAs // Compile time row arguments
2596  , typename VT > // Type of the right-hand side vector
2597 inline bool tryAddAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
2598  const Vector<VT,false>& rhs, size_t row, size_t column )
2599 {
2600  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2601  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2602  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
2603 
2604  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2605  if( !tryAdd( lhs.operand(), lhs.idx( row+i ), column, (~rhs)[i] ) )
2606  return false;
2607  }
2608 
2609  return true;
2610 }
2612 //*************************************************************************************************
2613 
2614 
2615 //*************************************************************************************************
2631 template< typename MT // Type of the matrix
2632  , bool SO // Storage order
2633  , bool DF // Density flag
2634  , bool SF // Symmetry flag
2635  , size_t... CRAs // Compile time row arguments
2636  , typename VT > // Type of the right-hand side vector
2637 inline bool tryAddAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
2638  const Vector<VT,true>& rhs, size_t row, size_t column )
2639 {
2640  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2641  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2642  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
2643 
2644  return tryAddAssign( lhs.operand(), ~rhs, lhs.idx( row ), column );
2645 }
2647 //*************************************************************************************************
2648 
2649 
2650 //*************************************************************************************************
2668 template< typename MT // Type of the matrix
2669  , bool SO // Storage order
2670  , bool DF // Density flag
2671  , bool SF // Symmetry flag
2672  , size_t... CRAs // Compile time row arguments
2673  , typename VT // Type of the right-hand side vector
2674  , bool TF > // Transpose flag of the right-hand side vector
2675 inline bool tryAddAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
2676  const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
2677 {
2678  UNUSED_PARAMETER( band );
2679 
2680  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2681  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2682  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
2683  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
2684 
2685  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2686  if( !tryAdd( lhs.operand(), lhs.idx( row+i ), column+i, (~rhs)[i] ) )
2687  return false;
2688  }
2689 
2690  return true;
2691 }
2693 //*************************************************************************************************
2694 
2695 
2696 //*************************************************************************************************
2712 template< typename MT1 // Type of the matrix
2713  , bool SO1 // Storage order
2714  , bool DF // Density flag
2715  , bool SF // Symmetry flag
2716  , size_t... CRAs // Compile time row arguments
2717  , typename MT2 // Type of the right-hand side matrix
2718  , bool SO2 > // Storage order of the right-hand side matrix
2719 inline bool tryAddAssign( const Rows<MT1,SO1,DF,SF,CRAs...>& lhs,
2720  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
2721 {
2722  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2723  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2724  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
2725  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
2726 
2727  for( size_t i=0UL; i<(~rhs).rows(); ++i ) {
2728  if( !tryAddAssign( lhs.operand(), blaze::row( ~rhs, i, unchecked ), lhs.idx( row+i ), column ) )
2729  return false;
2730  }
2731 
2732  return true;
2733 }
2735 //*************************************************************************************************
2736 
2737 
2738 //*************************************************************************************************
2755 template< typename MT // Type of the matrix
2756  , bool SO // Storage order
2757  , bool DF // Density flag
2758  , bool SF // Symmetry flag
2759  , size_t... CRAs // Compile time row arguments
2760  , typename VT > // Type of the right-hand side vector
2761 inline bool trySubAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
2762  const Vector<VT,false>& rhs, size_t row, size_t column )
2763 {
2764  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2765  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2766  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
2767 
2768  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2769  if( !trySub( lhs.operand(), lhs.idx( row+i ), column, (~rhs)[i] ) )
2770  return false;
2771  }
2772 
2773  return true;
2774 }
2776 //*************************************************************************************************
2777 
2778 
2779 //*************************************************************************************************
2796 template< typename MT // Type of the matrix
2797  , bool SO // Storage order
2798  , bool DF // Density flag
2799  , bool SF // Symmetry flag
2800  , size_t... CRAs // Compile time row arguments
2801  , typename VT > // Type of the right-hand side vector
2802 inline bool trySubAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
2803  const Vector<VT,true>& rhs, size_t row, size_t column )
2804 {
2805  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2806  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2807  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
2808 
2809  return trySubAssign( lhs.operand(), ~rhs, lhs.idx( row ), column );
2810 }
2812 //*************************************************************************************************
2813 
2814 
2815 //*************************************************************************************************
2833 template< typename MT // Type of the matrix
2834  , bool SO // Storage order
2835  , bool DF // Density flag
2836  , bool SF // Symmetry flag
2837  , size_t... CRAs // Compile time row arguments
2838  , typename VT // Type of the right-hand side vector
2839  , bool TF > // Transpose flag of the right-hand side vector
2840 inline bool trySubAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
2841  const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
2842 {
2843  UNUSED_PARAMETER( band );
2844 
2845  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2846  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2847  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
2848  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
2849 
2850  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2851  if( !trySub( lhs.operand(), lhs.idx( row+i ), column+i, (~rhs)[i] ) )
2852  return false;
2853  }
2854 
2855  return true;
2856 }
2858 //*************************************************************************************************
2859 
2860 
2861 //*************************************************************************************************
2877 template< typename MT1 // Type of the matrix
2878  , bool SO1 // Storage order
2879  , bool DF // Density flag
2880  , bool SF // Symmetry flag
2881  , size_t... CRAs // Compile time row arguments
2882  , typename MT2 // Type of the right-hand side matrix
2883  , bool SO2 > // Storage order of the right-hand side matrix
2884 inline bool trySubAssign( const Rows<MT1,SO1,DF,SF,CRAs...>& lhs,
2885  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
2886 {
2887  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2888  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2889  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
2890  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
2891 
2892  for( size_t i=0UL; i<(~rhs).rows(); ++i ) {
2893  if( !trySubAssign( lhs.operand(), blaze::row( ~rhs, i, unchecked ), lhs.idx( row+i ), column ) )
2894  return false;
2895  }
2896 
2897  return true;
2898 }
2900 //*************************************************************************************************
2901 
2902 
2903 //*************************************************************************************************
2921 template< typename MT // Type of the matrix
2922  , bool SO // Storage order
2923  , bool DF // Density flag
2924  , bool SF // Symmetry flag
2925  , size_t... CRAs // Compile time row arguments
2926  , typename VT > // Type of the right-hand side vector
2927 inline bool tryMultAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
2928  const Vector<VT,false>& rhs, size_t row, size_t column )
2929 {
2930  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2931  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2932  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
2933 
2934  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2935  if( !tryMult( lhs.operand(), lhs.idx( row+i ), column, (~rhs)[i] ) )
2936  return false;
2937  }
2938 
2939  return true;
2940 }
2942 //*************************************************************************************************
2943 
2944 
2945 //*************************************************************************************************
2962 template< typename MT // Type of the matrix
2963  , bool SO // Storage order
2964  , bool DF // Density flag
2965  , bool SF // Symmetry flag
2966  , size_t... CRAs // Compile time row arguments
2967  , typename VT > // Type of the right-hand side vector
2968 inline bool tryMultAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
2969  const Vector<VT,true>& rhs, size_t row, size_t column )
2970 {
2971  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2972  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2973  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
2974 
2975  return tryMultAssign( lhs.operand(), ~rhs, lhs.idx( row ), column );
2976 }
2978 //*************************************************************************************************
2979 
2980 
2981 //*************************************************************************************************
2999 template< typename MT // Type of the matrix
3000  , bool SO // Storage order
3001  , bool DF // Density flag
3002  , bool SF // Symmetry flag
3003  , size_t... CRAs // Compile time row arguments
3004  , typename VT // Type of the right-hand side vector
3005  , bool TF > // Transpose flag of the right-hand side vector
3006 inline bool tryMultAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3007  const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3008 {
3009  UNUSED_PARAMETER( band );
3010 
3011  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3012  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3013  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3014  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3015 
3016  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3017  if( !tryMult( lhs.operand(), lhs.idx( row+i ), column+i, (~rhs)[i] ) )
3018  return false;
3019  }
3020 
3021  return true;
3022 }
3024 //*************************************************************************************************
3025 
3026 
3027 //*************************************************************************************************
3044 template< typename MT1 // Type of the matrix
3045  , bool SO1 // Storage order
3046  , bool DF // Density flag
3047  , bool SF // Symmetry flag
3048  , size_t... CRAs // Compile time row arguments
3049  , typename MT2 // Type of the right-hand side matrix
3050  , bool SO2 > // Storage order of the right-hand side matrix
3051 inline bool trySchurAssign( const Rows<MT1,SO1,DF,SF,CRAs...>& lhs,
3052  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3053 {
3054  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3055  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3056  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
3057  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
3058 
3059  for( size_t i=0UL; i<(~rhs).rows(); ++i ) {
3060  if( !tryMultAssign( lhs.operand(), blaze::row( ~rhs, i, unchecked ), lhs.idx( row+i ), column ) )
3061  return false;
3062  }
3063 
3064  return true;
3065 }
3067 //*************************************************************************************************
3068 
3069 
3070 //*************************************************************************************************
3088 template< typename MT // Type of the matrix
3089  , bool SO // Storage order
3090  , bool DF // Density flag
3091  , bool SF // Symmetry flag
3092  , size_t... CRAs // Compile time row arguments
3093  , typename VT > // Type of the right-hand side vector
3094 inline bool tryDivAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3095  const Vector<VT,false>& rhs, size_t row, size_t column )
3096 {
3097  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3098  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3099  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3100 
3101  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3102  if( !tryDiv( lhs.operand(), lhs.idx( row+i ), column, (~rhs)[i] ) )
3103  return false;
3104  }
3105 
3106  return true;
3107 }
3109 //*************************************************************************************************
3110 
3111 
3112 //*************************************************************************************************
3128 template< typename MT // Type of the matrix
3129  , bool SO // Storage order
3130  , bool DF // Density flag
3131  , bool SF // Symmetry flag
3132  , size_t... CRAs // Compile time row arguments
3133  , typename VT > // Type of the right-hand side vector
3134 inline bool tryDivAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3135  const Vector<VT,true>& rhs, size_t row, size_t column )
3136 {
3137  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3138  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3139  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3140 
3141  return tryDivAssign( lhs.operand(), ~rhs, lhs.idx( row ), column );
3142 }
3144 //*************************************************************************************************
3145 
3146 
3147 //*************************************************************************************************
3165 template< typename MT // Type of the matrix
3166  , bool SO // Storage order
3167  , bool DF // Density flag
3168  , bool SF // Symmetry flag
3169  , size_t... CRAs // Compile time row arguments
3170  , typename VT // Type of the right-hand side vector
3171  , bool TF > // Transpose flag of the right-hand side vector
3172 inline bool tryDivAssign( const Rows<MT,SO,DF,SF,CRAs...>& lhs,
3173  const Vector<VT,TF>& rhs, ptrdiff_t band, size_t row, size_t column )
3174 {
3175  UNUSED_PARAMETER( band );
3176 
3177  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
3178  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
3179  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
3180  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
3181 
3182  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3183  if( !tryDiv( lhs.operand(), lhs.idx( row+i ), column+i, (~rhs)[i] ) )
3184  return false;
3185  }
3186 
3187  return true;
3188 }
3190 //*************************************************************************************************
3191 
3192 
3193 //*************************************************************************************************
3208 template< typename MT // Type of the matrix
3209  , bool SO // Storage order
3210  , bool DF // Density flag
3211  , bool SF // Symmetry flag
3212  , size_t I // First element index
3213  , size_t... Is > // Remaining element indices
3214 inline decltype(auto) derestrict( Rows<MT,SO,DF,SF,I,Is...>& r )
3215 {
3216  return rows<I,Is...>( derestrict( r.operand() ), unchecked );
3217 }
3219 //*************************************************************************************************
3220 
3221 
3222 //*************************************************************************************************
3237 template< typename MT // Type of the matrix
3238  , bool SO // Storage order
3239  , bool DF // Density flag
3240  , bool SF // Symmetry flag
3241  , size_t I // First element index
3242  , size_t... Is > // Remaining element indices
3243 inline decltype(auto) derestrict( Rows<MT,SO,DF,SF,I,Is...>&& r )
3244 {
3245  return rows<I,Is...>( derestrict( r.operand() ), unchecked );
3246 }
3248 //*************************************************************************************************
3249 
3250 
3251 //*************************************************************************************************
3266 template< typename MT // Type of the matrix
3267  , bool SO // Storage order
3268  , bool DF // Density flag
3269  , bool SF > // Symmetry flag
3270 inline decltype(auto) derestrict( Rows<MT,SO,DF,SF>& r )
3271 {
3272  decltype(auto) indices( r.idces() );
3273  return rows( derestrict( r.operand() ), indices.data(), indices.size(), unchecked );
3274 }
3276 //*************************************************************************************************
3277 
3278 
3279 //*************************************************************************************************
3294 template< typename MT // Type of the matrix
3295  , bool SO // Storage order
3296  , bool DF // Density flag
3297  , bool SF > // Symmetry flag
3298 inline decltype(auto) derestrict( Rows<MT,SO,DF,SF>&& r )
3299 {
3300  decltype(auto) indices( r.idces() );
3301  return rows( derestrict( r.operand() ), indices.data(), indices.size(), unchecked );
3302 }
3304 //*************************************************************************************************
3305 
3306 
3307 
3308 
3309 //=================================================================================================
3310 //
3311 // SIZE SPECIALIZATIONS
3312 //
3313 //=================================================================================================
3314 
3315 //*************************************************************************************************
3317 template< typename MT, bool SO, bool DF, bool SF, size_t I, size_t... Is >
3318 struct Size< Rows<MT,SO,DF,SF,I,Is...>, 0UL >
3319  : public PtrdiffT<1UL+sizeof...(Is)>
3320 {};
3321 
3322 template< typename MT, bool SO, bool DF, bool SF, size_t... CRAs >
3323 struct Size< Rows<MT,SO,DF,SF,CRAs...>, 1UL >
3324  : public Size<MT,1UL>
3325 {};
3327 //*************************************************************************************************
3328 
3329 
3330 
3331 
3332 //=================================================================================================
3333 //
3334 // ISRESTRICTED SPECIALIZATIONS
3335 //
3336 //=================================================================================================
3337 
3338 //*************************************************************************************************
3340 template< typename MT, bool SO, bool DF, bool SF, size_t... CRAs >
3341 struct IsRestricted< Rows<MT,SO,DF,SF,CRAs...> >
3342  : public IsRestricted<MT>
3343 {};
3345 //*************************************************************************************************
3346 
3347 
3348 
3349 
3350 //=================================================================================================
3351 //
3352 // HASCONSTDATAACCESS SPECIALIZATIONS
3353 //
3354 //=================================================================================================
3355 
3356 //*************************************************************************************************
3358 template< typename MT, bool SO, bool SF, size_t... CRAs >
3359 struct HasConstDataAccess< Rows<MT,SO,true,SF,CRAs...> >
3360  : public HasConstDataAccess<MT>
3361 {};
3363 //*************************************************************************************************
3364 
3365 
3366 
3367 
3368 //=================================================================================================
3369 //
3370 // HASMUTABLEDATAACCESS SPECIALIZATIONS
3371 //
3372 //=================================================================================================
3373 
3374 //*************************************************************************************************
3376 template< typename MT, bool SO, bool SF, size_t... CRAs >
3377 struct HasMutableDataAccess< Rows<MT,SO,true,SF,CRAs...> >
3378  : public HasMutableDataAccess<MT>
3379 {};
3381 //*************************************************************************************************
3382 
3383 
3384 
3385 
3386 //=================================================================================================
3387 //
3388 // ISALIGNED SPECIALIZATIONS
3389 //
3390 //=================================================================================================
3391 
3392 //*************************************************************************************************
3394 template< typename MT, bool SO, bool SF, size_t... CRAs >
3395 struct IsAligned< Rows<MT,SO,true,SF,CRAs...> >
3396  : public IsAligned<MT>
3397 {};
3399 //*************************************************************************************************
3400 
3401 
3402 
3403 
3404 //=================================================================================================
3405 //
3406 // SUBMATRIXTRAIT SPECIALIZATIONS
3407 //
3408 //=================================================================================================
3409 
3410 //*************************************************************************************************
3412 template< typename MT, bool SO, bool DF, bool SF, size_t... CRAs, size_t... CSAs >
3413 struct SubmatrixTrait< Rows<MT,SO,DF,SF,CRAs...>, CSAs... >
3414 {
3415  using Type = SubmatrixTrait_< ResultType_< Rows<MT,SO,DF,SF,CRAs...> >, CSAs... >;
3416 };
3418 //*************************************************************************************************
3419 
3420 
3421 
3422 
3423 //=================================================================================================
3424 //
3425 // ROWTRAIT SPECIALIZATIONS
3426 //
3427 //=================================================================================================
3428 
3429 //*************************************************************************************************
3431 template< typename MT, bool SO, bool DF, bool SF, size_t... CRAs1, size_t... CRAs2 >
3432 struct RowTrait< Rows<MT,SO,DF,SF,CRAs1...>, CRAs2... >
3433 {
3434  using Type = RowTrait_< ResultType_< Rows<MT,SO,DF,SF,CRAs1...> >, CRAs2... >;
3435 };
3437 //*************************************************************************************************
3438 
3439 
3440 
3441 
3442 //=================================================================================================
3443 //
3444 // ROWSTRAIT SPECIALIZATIONS
3445 //
3446 //=================================================================================================
3447 
3448 //*************************************************************************************************
3450 template< typename MT, bool SO, bool DF, bool SF, size_t... CRAs1, size_t... CRAs2 >
3451 struct RowsTrait< Rows<MT,SO,DF,SF,CRAs1...>, CRAs2... >
3452 {
3453  using Type = RowsTrait_< ResultType_< Rows<MT,SO,DF,SF,CRAs1...> >, CRAs2... >;
3454 };
3456 //*************************************************************************************************
3457 
3458 
3459 
3460 
3461 //=================================================================================================
3462 //
3463 // COLUMNTRAIT SPECIALIZATIONS
3464 //
3465 //=================================================================================================
3466 
3467 //*************************************************************************************************
3469 template< typename MT, bool SO, bool DF, bool SF, size_t... CRAs, size_t... CCAs >
3470 struct ColumnTrait< Rows<MT,SO,DF,SF,CRAs...>, CCAs... >
3471 {
3472  using Type = ColumnTrait_< ResultType_< Rows<MT,SO,DF,SF,CRAs...> >, CCAs... >;
3473 };
3475 //*************************************************************************************************
3476 
3477 
3478 
3479 
3480 //=================================================================================================
3481 //
3482 // COLUMNSTRAIT SPECIALIZATIONS
3483 //
3484 //=================================================================================================
3485 
3486 //*************************************************************************************************
3488 template< typename MT, bool SO, bool DF, bool SF, size_t... CRAs, size_t... CCAs >
3489 struct ColumnsTrait< Rows<MT,SO,DF,SF,CRAs...>, CCAs... >
3490 {
3491  using Type = ColumnsTrait_< ResultType_< Rows<MT,SO,DF,SF,CRAs...> >, CCAs... >;
3492 };
3494 //*************************************************************************************************
3495 
3496 
3497 
3498 
3499 //=================================================================================================
3500 //
3501 // BANDTRAIT SPECIALIZATIONS
3502 //
3503 //=================================================================================================
3504 
3505 //*************************************************************************************************
3507 template< typename MT, bool SO, bool DF, bool SF, size_t... CRAs, ptrdiff_t... CBAs >
3508 struct BandTrait< Rows<MT,SO,DF,SF,CRAs...>, CBAs... >
3509 {
3510  using Type = BandTrait_< ResultType_< Rows<MT,SO,DF,SF,CRAs...> >, CBAs... >;
3511 };
3513 //*************************************************************************************************
3514 
3515 } // namespace blaze
3516 
3517 #endif
AlignmentFlag
Alignment flag for (un-)aligned vectors and matrices.Via these flags it is possible to specify subvec...
Definition: AlignmentFlag.h:62
Rows specialization for sparse matrices.
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Pointer difference type of the Blaze library.
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:131
Header file for the blaze::checked and blaze::unchecked instances.
Base class for all binary matrix map expression templates.The MatMatMapExpr class serves as a tag for...
Definition: MatMatMapExpr.h:66
Header file for the implementation of the RowData class template.
Compile time check for low-level access to constant data.This type trait tests whether the given data...
Definition: HasConstDataAccess.h:75
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
BLAZE_ALWAYS_INLINE 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:949
Header file for basic type definitions.
Base class for all matrix serial evaluation expression templates.The MatSerialExpr class serves as a ...
Definition: MatSerialExpr.h:67
constexpr bool equal(const T1 &a, const T2 &b)
Generic equality check.
Definition: Equal.h:76
Header file for the row trait.
Base template for the SubmatrixTrait class.
Definition: SubmatrixTrait.h:109
Base class for all matrix/scalar division expression templates.The MatScalarDivExpr class serves as a...
Definition: MatScalarDivExpr.h:66
Base template for the ColumnTrait class.
Definition: ColumnTrait.h:108
Header file for the serial shim.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:265
Header file for the MatTransExpr base class.
Header file for the dense matrix inversion flags.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
Implementation of a dynamic vector with small vector optimization.The SmallVector class template is a...
Definition: SmallVector.h:80
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
Base class for all matrix/scalar multiplication expression templates.The MatScalarMultExpr class serv...
Definition: MatScalarMultExpr.h:67
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.
typename SubmatrixTrait< MT, CSAs... >::Type SubmatrixTrait_
Auxiliary alias declaration for the SubmatrixTrait type trait.The SubmatrixTrait_ alias declaration p...
Definition: SubmatrixTrait.h:145
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:343
typename RowTrait< MT, CRAs... >::Type RowTrait_
Auxiliary alias declaration for the RowTrait type trait.The RowTrait_ alias declaration provides a co...
Definition: RowTrait.h:145
Base template for the RowsTrait class.
Definition: RowsTrait.h:109
Header file for the band trait.
Compile time check for data types with restricted data access.This type trait tests whether the given...
Definition: IsRestricted.h:82
Compile time check for low-level access to mutable data.This type trait tests whether the given data ...
Definition: HasMutableDataAccess.h:75
Compile time check for the alignment of data types.This type trait tests whether the given data type ...
Definition: IsAligned.h:87
Pointer data() noexcept
Low-level data access to the vector elements.
Definition: SmallVector.h:538
Header file for the matrix storage order types.
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:772
Header file for the MatMapExpr base class.
Base template for the RowTrait class.
Definition: RowTrait.h:109
typename ColumnTrait< MT, CCAs... >::Type ColumnTrait_
Auxiliary alias declaration for the ColumnTrait type trait.The ColumnTrait_ alias declaration provide...
Definition: ColumnTrait.h:144
typename ColumnsTrait< MT, CCAs... >::Type ColumnsTrait_
Auxiliary alias declaration for the ColumnsTrait type trait.The ColumnsTrait_ alias declaration provi...
Definition: ColumnsTrait.h:145
Base class for all matrix/matrix subtraction expression templates.The MatMatSubExpr class serves as a...
Definition: MatMatSubExpr.h:67
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
Base class for all matrix/matrix addition expression templates.The MatMatAddExpr class serves as a ta...
Definition: MatMatAddExpr.h:66
Header file for the MatMatSubExpr base class.
Header file for the IsAligned type trait.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:506
Base class for all unary matrix map expression templates.The MatMapExpr class serves as a tag for all...
Definition: MatMapExpr.h:66
Base class for all matrix/vector multiplication expression templates.The MatVecMultExpr class serves ...
Definition: MatVecMultExpr.h:67
Implementation of a type list.The TypeList class template represents a list of data types of arbitrar...
Definition: TypeList.h:119
decltype(auto) eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:794
decltype(auto) elements(Vector< VT, TF > &vector, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition: Elements.h:134
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.
typename BandTrait< MT, CBAs... >::Type BandTrait_
Auxiliary alias declaration for the BandTrait type trait.The BandTrait_ alias declaration provides a ...
Definition: BandTrait.h:145
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:608
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:134
typename RowsTrait< MT, CRAs... >::Type RowsTrait_
Auxiliary alias declaration for the RowsTrait type trait.The RowsTrait_ alias declaration provides a ...
Definition: RowsTrait.h:145
Header file for the HasConstDataAccess type trait.
Header file for the DeclExpr base class.
Base class for all matrix/matrix multiplication expression templates.The MatMatMultExpr class serves ...
Definition: MatMatMultExpr.h:67
Header file for the Matrix base class.
Header file for all forward declarations for views.
typename EnableIfTrue< Condition, T >::Type EnableIfTrue_
Auxiliary type for the EnableIfTrue class template.The EnableIfTrue_ alias declaration provides a con...
Definition: EnableIf.h:138
Header file for the MatScalarMultExpr base class.
Base class for all Schur product expression templates.The SchurExpr class serves as a tag for all exp...
Definition: SchurExpr.h:66
Header file for run time assertion macros.
Header file for the Unique class template.
Header file for the submatrix trait.
Header file for the columns trait.
Header file for the SchurExpr base class.
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:131
Compile time integral constant wrapper for ptrdiff_t.The PtrdiffT class template represents an integr...
Definition: PtrdiffT.h:72
Base class for all matrix evaluation expression templates.The MatEvalExpr class serves as a tag for a...
Definition: MatEvalExpr.h:66
#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
size_t size() const noexcept
Returns the current size/dimension of the small vector.
Definition: SmallVector.h:769
Header file for the column trait.
Header file for the isDefault shim.
void reserve(size_t n)
Setting the minimum capacity of the vector.
Definition: SmallVector.h:895
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:101
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:816
Base class for all matrix transposition expression templates.The MatTransExpr class serves as a tag f...
Definition: MatTransExpr.h:66
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.
Base class for all outer product expression templates.The VecTVecMultExpr class serves as a tag for a...
Definition: VecTVecMultExpr.h:67
Header file for the rows trait.
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:490
Auxiliary class template for the data members of the Row class.The auxiliary RowData class template r...
Definition: RowData.h:64
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:789
Base template for the ColumnsTrait class.
Definition: ColumnsTrait.h:109
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:177
Header file for the MatMatMapExpr base class.
Initializer list type of the Blaze library.
Compile time evaluation of the size of vectors and matrices.The Size type trait evaluates the size of...
Definition: Size.h:80
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:254
Rows specialization for dense matrices.
Header file for the SmallVector implementation.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
Header file for the MatScalarDivExpr base class.
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Searching a type list.The Contains class can be used to search the type list for a particular type Ty...
Definition: Contains.h:78
Header file for the MatVecMultExpr base class.
Header file for the implementation of the Rows base template.
Header file for the IsRestricted type trait.
Header file for the Size type trait.
InversionFlag
Inversion flag.The InversionFlag type enumeration represents the different types of matrix inversion ...
Definition: InversionFlag.h:101
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Base template for the BandTrait class.
Definition: BandTrait.h:109
Header file for the function trace functionality.
Template for the blaze::checked and blaze::unchecked instances.blaze::Check is the template for the b...
Definition: Check.h:56
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:1134