Band.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_BAND_H_
36 #define _BLAZE_MATH_VIEWS_BAND_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
72 #include <blaze/math/views/Check.h>
76 #include <blaze/util/Assert.h>
77 #include <blaze/util/DisableIf.h>
78 #include <blaze/util/EnableIf.h>
80 #include <blaze/util/mpl/If.h>
81 #include <blaze/util/mpl/Minimum.h>
83 #include <blaze/util/TrueType.h>
84 #include <blaze/util/Types.h>
86 
87 
88 namespace blaze {
89 
90 //=================================================================================================
91 //
92 // GLOBAL FUNCTIONS
93 //
94 //=================================================================================================
95 
96 //*************************************************************************************************
131 template< ptrdiff_t I // Band index
132  , typename MT // Type of the matrix
133  , bool SO // Storage order
134  , typename... RBAs > // Optional band arguments
135 inline decltype(auto) band( Matrix<MT,SO>& matrix, RBAs... args )
136 {
138 
139  using ReturnType = Band_<MT,I>;
140  return ReturnType( ~matrix, args... );
141 }
142 //*************************************************************************************************
143 
144 
145 //*************************************************************************************************
180 template< ptrdiff_t I // Band index
181  , typename MT // Type of the matrix
182  , bool SO // Storage order
183  , typename... RBAs > // Optional band arguments
184 inline decltype(auto) band( const Matrix<MT,SO>& matrix, RBAs... args )
185 {
187 
188  using ReturnType = const Band_<const MT,I>;
189  return ReturnType( ~matrix, args... );
190 }
191 //*************************************************************************************************
192 
193 
194 //*************************************************************************************************
208 template< ptrdiff_t I // Band index
209  , typename MT // Type of the matrix
210  , bool SO // Storage order
211  , typename... RBAs > // Optional band arguments
212 inline decltype(auto) band( Matrix<MT,SO>&& matrix, RBAs... args )
213 {
215 
216  using ReturnType = Band_<MT,I>;
217  return ReturnType( ~matrix, args... );
218 }
219 //*************************************************************************************************
220 
221 
222 //*************************************************************************************************
258 template< typename MT // Type of the matrix
259  , bool SO // Storage order
260  , typename... RBAs > // Optional band arguments
261 inline decltype(auto) band( Matrix<MT,SO>& matrix, ptrdiff_t index, RBAs... args )
262 {
264 
265  using ReturnType = Band_<MT>;
266  return ReturnType( ~matrix, index, args... );
267 }
268 //*************************************************************************************************
269 
270 
271 //*************************************************************************************************
307 template< typename MT // Type of the matrix
308  , bool SO // Storage order
309  , typename... RBAs > // Optional band arguments
310 inline decltype(auto) band( const Matrix<MT,SO>& matrix, ptrdiff_t index, RBAs... args )
311 {
313 
314  using ReturnType = const Band_<const MT>;
315  return ReturnType( ~matrix, index, args... );
316 }
317 //*************************************************************************************************
318 
319 
320 //*************************************************************************************************
335 template< typename MT // Type of the matrix
336  , bool SO // Storage order
337  , typename... RBAs > // Optional band arguments
338 inline decltype(auto) band( Matrix<MT,SO>&& matrix, ptrdiff_t index, RBAs... args )
339 {
341 
342  using ReturnType = Band_<MT>;
343  return ReturnType( ~matrix, index, args... );
344 }
345 //*************************************************************************************************
346 
347 
348 //*************************************************************************************************
372 template< typename MT // Type of the matrix
373  , bool SO // Storage order
374  , typename... RDAs > // Optional diagonal arguments
375 inline decltype(auto) diagonal( Matrix<MT,SO>& matrix, RDAs... args )
376 {
378 
379  return band<0L>( ~matrix, unchecked, args... );
380 }
381 //*************************************************************************************************
382 
383 
384 //*************************************************************************************************
407 template< typename MT // Type of the matrix
408  , bool SO // Storage order
409  , typename... RDAs > // Optional diagonal arguments
410 inline decltype(auto) diagonal( const Matrix<MT,SO>& matrix, RDAs... args )
411 {
413 
414  return band<0L>( ~matrix, unchecked, args... );
415 }
416 //*************************************************************************************************
417 
418 
419 //*************************************************************************************************
431 template< typename MT // Type of the matrix
432  , bool SO // Storage order
433  , typename... RDAs > // Optional diagonal arguments
434 inline decltype(auto) diagonal( Matrix<MT,SO>&& matrix, RDAs... args )
435 {
437 
438  return band<0L>( ~matrix, unchecked, args... );
439 }
440 //*************************************************************************************************
441 
442 
443 
444 
445 //=================================================================================================
446 //
447 // GLOBAL RESTRUCTURING FUNCTIONS
448 //
449 //=================================================================================================
450 
451 //*************************************************************************************************
463 template< ptrdiff_t... CBAs // Compile time band arguments
464  , typename MT // Type of the matrix
465  , typename... RBAs > // Runtime band arguments
466 inline decltype(auto) band( const MatMatAddExpr<MT>& matrix, RBAs... args )
467 {
469 
470  return band<CBAs...>( (~matrix).leftOperand(), args... ) +
471  band<CBAs...>( (~matrix).rightOperand(), args... );
472 }
474 //*************************************************************************************************
475 
476 
477 //*************************************************************************************************
489 template< ptrdiff_t... CBAs // Compile time band arguments
490  , typename MT // Type of the matrix
491  , typename... RBAs > // Runtime band arguments
492 inline decltype(auto) band( const MatMatSubExpr<MT>& matrix, RBAs... args )
493 {
495 
496  return band<CBAs...>( (~matrix).leftOperand(), args... ) -
497  band<CBAs...>( (~matrix).rightOperand(), args... );
498 }
500 //*************************************************************************************************
501 
502 
503 //*************************************************************************************************
514 template< ptrdiff_t... CBAs // Compile time band arguments
515  , typename MT // Type of the matrix
516  , typename... RBAs > // Runtime band arguments
517 inline decltype(auto) band( const SchurExpr<MT>& matrix, RBAs... args )
518 {
520 
521  return band<CBAs...>( (~matrix).leftOperand(), args... ) *
522  band<CBAs...>( (~matrix).rightOperand(), args... );
523 }
525 //*************************************************************************************************
526 
527 
528 //*************************************************************************************************
538 template< ptrdiff_t I // Band index
539  , typename MT > // Type of the matrix
540 inline decltype(auto) band( const VecTVecMultExpr<MT>& matrix )
541 {
543 
544  decltype(auto) leftOperand ( (~matrix).leftOperand() );
545  decltype(auto) rightOperand( (~matrix).rightOperand() );
546 
547  const size_t row ( I < 0L ? -I : 0UL );
548  const size_t column( I >= 0L ? I : 0UL );
549  const size_t size ( min( leftOperand.size() - row, rightOperand.size() - column ) );
550 
551  return transTo<defaultTransposeFlag>( subvector( leftOperand , row , size ) ) *
552  transTo<defaultTransposeFlag>( subvector( rightOperand, column, size ) );
553 }
555 //*************************************************************************************************
556 
557 
558 //*************************************************************************************************
569 template< typename MT > // Type of the matrix
570 inline decltype(auto) band( const VecTVecMultExpr<MT>& matrix, ptrdiff_t index )
571 {
573 
574  decltype(auto) leftOperand ( (~matrix).leftOperand() );
575  decltype(auto) rightOperand( (~matrix).rightOperand() );
576 
577  const size_t row ( index < 0L ? -index : 0UL );
578  const size_t column( index >= 0L ? index : 0UL );
579  const size_t size ( min( leftOperand.size() - row, rightOperand.size() - column ) );
580 
581  return transTo<defaultTransposeFlag>( subvector( leftOperand , row , size ) ) *
582  transTo<defaultTransposeFlag>( subvector( rightOperand, column, size ) );
583 }
585 //*************************************************************************************************
586 
587 
588 //*************************************************************************************************
600 template< ptrdiff_t... CBAs // Compile time band arguments
601  , typename MT // Type of the matrix
602  , typename... RBAs > // Runtime band arguments
603 inline decltype(auto) band( const MatScalarMultExpr<MT>& matrix, RBAs... args )
604 {
606 
607  return band<CBAs...>( (~matrix).leftOperand(), args... ) * (~matrix).rightOperand();
608 }
610 //*************************************************************************************************
611 
612 
613 //*************************************************************************************************
625 template< ptrdiff_t... CBAs // Compile time band arguments
626  , typename MT // Type of the matrix
627  , typename... RBAs > // Runtime band arguments
628 inline decltype(auto) band( const MatScalarDivExpr<MT>& matrix, RBAs... args )
629 {
631 
632  return band<CBAs...>( (~matrix).leftOperand(), args... ) / (~matrix).rightOperand();
633 }
635 //*************************************************************************************************
636 
637 
638 //*************************************************************************************************
650 template< ptrdiff_t... CBAs // Compile time band arguments
651  , typename MT // Type of the matrix
652  , typename... RBAs > // Runtime band arguments
653 inline decltype(auto) band( const MatMapExpr<MT>& matrix, RBAs... args )
654 {
656 
657  return map( band<CBAs...>( (~matrix).operand(), args... ), (~matrix).operation() );
658 }
660 //*************************************************************************************************
661 
662 
663 //*************************************************************************************************
675 template< ptrdiff_t... CBAs // Compile time band arguments
676  , typename MT // Type of the matrix
677  , typename... RBAs > // Runtime band arguments
678 inline decltype(auto) band( const MatMatMapExpr<MT>& matrix, RBAs... args )
679 {
681 
682  return map( band<CBAs...>( (~matrix).leftOperand(), args... ),
683  band<CBAs...>( (~matrix).rightOperand(), args... ),
684  (~matrix).operation() );
685 }
687 //*************************************************************************************************
688 
689 
690 //*************************************************************************************************
702 template< ptrdiff_t... CBAs // Compile time band arguments
703  , typename MT // Type of the matrix
704  , typename... RBAs > // Runtime band arguments
705 inline decltype(auto) band( const MatEvalExpr<MT>& matrix, RBAs... args )
706 {
708 
709  return eval( band<CBAs...>( (~matrix).operand(), args... ) );
710 }
712 //*************************************************************************************************
713 
714 
715 //*************************************************************************************************
727 template< ptrdiff_t... CBAs // Compile time band arguments
728  , typename MT // Type of the matrix
729  , typename... RBAs > // Runtime band arguments
730 inline decltype(auto) band( const MatSerialExpr<MT>& matrix, RBAs... args )
731 {
733 
734  return serial( band<CBAs...>( (~matrix).operand(), args... ) );
735 }
737 //*************************************************************************************************
738 
739 
740 //*************************************************************************************************
752 template< ptrdiff_t... CBAs // Compile time band arguments
753  , typename MT // Type of the matrix
754  , typename... RBAs > // Runtime band arguments
755 inline decltype(auto) band( const DeclExpr<MT>& matrix, RBAs... args )
756 {
758 
759  return band<CBAs...>( (~matrix).operand(), args... );
760 }
762 //*************************************************************************************************
763 
764 
765 //*************************************************************************************************
777 template< ptrdiff_t... CBAs // Compile time band arguments
778  , typename MT // Type of the matrix
779  , typename... RBAs > // Runtime band arguments
780 inline decltype(auto) band( const MatTransExpr<MT>& matrix, RBAs... args )
781 {
783 
784  return band<-CBAs...>( (~matrix).operand(), -args... );
785 }
787 //*************************************************************************************************
788 
789 
790 //*************************************************************************************************
802 template< ptrdiff_t... CBAs // Compile time band arguments
803  , typename MT // Type of the matrix
804  , size_t... CEAs // Compile time expansion arguments
805  , typename... RBAs > // Runtime band arguments
806 inline decltype(auto) band( const VecExpandExpr<MT,CEAs...>& matrix, RBAs... args )
807 {
809 
810  using VT = VectorType_t< RemoveReference_t< decltype( (~matrix).operand() ) > >;
811 
812  constexpr bool TF( TransposeFlag_v<VT> );
813 
814  const BandData<CBAs...> bd( args... );
815 
816  const size_t index( TF ? bd.column() : bd.row() );
817  const size_t size ( min( (~matrix).rows() - bd.row(), (~matrix).columns() - bd.column() ) );
818 
819  return subvector( transTo<defaultTransposeFlag>( (~matrix).operand() ), index, size, args... );
820 }
822 //*************************************************************************************************
823 
824 
825 
826 
827 //=================================================================================================
828 //
829 // GLOBAL RESTRUCTURING FUNCTIONS (SUBVECTOR)
830 //
831 //=================================================================================================
832 
833 //*************************************************************************************************
844 template< AlignmentFlag AF // Alignment flag
845  , size_t I1 // Index of the first subvector element
846  , size_t N // Size of the subvector
847  , typename MT // Type of the matrix
848  , bool TF // Transpose flag
849  , bool DF // Density flag
850  , bool MF // Multiplication flag
851  , ptrdiff_t I2 // Band index
852  , typename... RSAs > // Optional subvector arguments
853 inline decltype(auto) subvector( Band<MT,TF,DF,MF,I2>& b, RSAs... args )
854 {
856 
857  constexpr size_t row ( ( I2 >= 0L ? 0UL : -I2 ) + I1 );
858  constexpr size_t column( ( I2 >= 0L ? I2 : 0UL ) + I1 );
859 
860  return diagonal( submatrix<AF,row,column,N,N>( b.operand(), args... ), unchecked );
861 }
863 //*************************************************************************************************
864 
865 
866 //*************************************************************************************************
878 template< AlignmentFlag AF // Alignment flag
879  , size_t I1 // Index of the first subvector element
880  , size_t N // Size of the subvector
881  , typename MT // Type of the matrix
882  , bool TF // Transpose flag
883  , bool DF // Density flag
884  , bool MF // Multiplication flag
885  , ptrdiff_t I2 // Band index
886  , typename... RSAs > // Optional subvector arguments
887 inline decltype(auto) subvector( const Band<MT,TF,DF,MF,I2>& b, RSAs... args )
888 {
890 
891  constexpr size_t row ( ( I2 >= 0L ? 0UL : -I2 ) + I1 );
892  constexpr size_t column( ( I2 >= 0L ? I2 : 0UL ) + I1 );
893 
894  return diagonal( submatrix<AF,row,column,N,N>( b.operand(), args... ), unchecked );
895 }
897 //*************************************************************************************************
898 
899 
900 //*************************************************************************************************
912 template< AlignmentFlag AF // Alignment flag
913  , size_t I1 // Index of the first subvector element
914  , size_t N // Size of the subvector
915  , typename MT // Type of the matrix
916  , bool TF // Transpose flag
917  , bool DF // Density flag
918  , bool MF // Multiplication flag
919  , ptrdiff_t I2 // Band index
920  , typename... RSAs > // Optional subvector arguments
921 inline decltype(auto) subvector( Band<MT,TF,DF,MF,I2>&& b, RSAs... args )
922 {
924 
925  constexpr size_t row ( ( I2 >= 0L ? 0UL : -I2 ) + I1 );
926  constexpr size_t column( ( I2 >= 0L ? I2 : 0UL ) + I1 );
927 
928  return diagonal( submatrix<AF,row,column,N,N>( b.operand(), args... ), unchecked );
929 }
931 //*************************************************************************************************
932 
933 
934 //*************************************************************************************************
945 template< AlignmentFlag AF // Alignment flag
946  , size_t... CSAs // Compile time subvector arguments
947  , typename MT // Type of the matrix
948  , bool TF // Transpose flag
949  , bool DF // Density flag
950  , bool MF // Multiplication flag
951  , ptrdiff_t... CBAs // Compile time band arguments
952  , typename... RSAs > // Optional subvector arguments
953 inline decltype(auto) subvector( Band<MT,TF,DF,MF,CBAs...>& b, RSAs... args )
954 {
956 
957  const SubvectorData<CSAs...> sd( args... );
958 
959  const size_t row ( b.row() + sd.offset() );
960  const size_t column( b.column() + sd.offset() );
961 
962  return diagonal( submatrix<AF>( b.operand(), row, column, sd.size(), sd.size(), args... ), unchecked );
963 }
965 //*************************************************************************************************
966 
967 
968 //*************************************************************************************************
980 template< AlignmentFlag AF // Alignment flag
981  , size_t... CSAs // Compile time subvector arguments
982  , typename MT // Type of the matrix
983  , bool TF // Transpose flag
984  , bool DF // Density flag
985  , bool MF // Multiplication flag
986  , ptrdiff_t... CBAs // Compile time band arguments
987  , typename... RSAs > // Optional subvector arguments
988 inline decltype(auto) subvector( const Band<MT,TF,DF,MF,CBAs...>& b, RSAs... args )
989 {
991 
992  const SubvectorData<CSAs...> sd( args... );
993 
994  const size_t row ( b.row() + sd.offset() );
995  const size_t column( b.column() + sd.offset() );
996 
997  return diagonal( submatrix<AF>( b.operand(), row, column, sd.size(), sd.size(), args... ), unchecked );
998 }
1000 //*************************************************************************************************
1001 
1002 
1003 //*************************************************************************************************
1015 template< AlignmentFlag AF // Alignment flag
1016  , size_t... CSAs // Compile time subvector arguments
1017  , typename MT // Type of the matrix
1018  , bool TF // Transpose flag
1019  , bool DF // Density flag
1020  , bool MF // Multiplication flag
1021  , ptrdiff_t... CBAs // Compile time band arguments
1022  , typename... RSAs > // Optional subvector arguments
1023 inline decltype(auto) subvector( Band<MT,TF,DF,MF,CBAs...>&& b, RSAs... args )
1024 {
1026 
1027  const SubvectorData<CSAs...> sd( args... );
1028 
1029  const size_t row ( b.row() + sd.offset() );
1030  const size_t column( b.column() + sd.offset() );
1031 
1032  return diagonal( submatrix<AF>( b.operand(), row, column, sd.size(), sd.size(), args... ), unchecked );
1033 }
1035 //*************************************************************************************************
1036 
1037 
1038 
1039 
1040 //=================================================================================================
1041 //
1042 // BAND OPERATORS
1043 //
1044 //=================================================================================================
1045 
1046 //*************************************************************************************************
1054 template< typename MT // Type of the matrix
1055  , bool TF // Transpose flag
1056  , bool DF // Density flag
1057  , bool MF // Multiplication flag
1058  , ptrdiff_t... CBAs > // Compile time band arguments
1059 inline void reset( Band<MT,TF,DF,MF,CBAs...>& band )
1060 {
1061  band.reset();
1062 }
1064 //*************************************************************************************************
1065 
1066 
1067 //*************************************************************************************************
1075 template< typename MT // Type of the matrix
1076  , bool TF // Transpose flag
1077  , bool DF // Density flag
1078  , bool MF // Multiplication flag
1079  , ptrdiff_t... CBAs > // Compile time band arguments
1080 inline void reset( Band<MT,TF,DF,MF,CBAs...>&& band )
1081 {
1082  band.reset();
1083 }
1085 //*************************************************************************************************
1086 
1087 
1088 //*************************************************************************************************
1098 template< typename MT // Type of the matrix
1099  , bool TF // Transpose flag
1100  , bool DF // Density flag
1101  , bool MF // Multiplication flag
1102  , ptrdiff_t... CBAs > // Compile time band arguments
1103 inline void clear( Band<MT,TF,DF,MF,CBAs...>& band )
1104 {
1105  band.reset();
1106 }
1108 //*************************************************************************************************
1109 
1110 
1111 //*************************************************************************************************
1121 template< typename MT // Type of the matrix
1122  , bool TF // Transpose flag
1123  , bool DF // Density flag
1124  , bool MF // Multiplication flag
1125  , ptrdiff_t... CBAs > // Compile time band arguments
1126 inline void clear( Band<MT,TF,DF,MF,CBAs...>&& band )
1127 {
1128  band.reset();
1129 }
1131 //*************************************************************************************************
1132 
1133 
1134 //*************************************************************************************************
1160 template< bool RF // Relaxation flag
1161  , typename MT // Type of the dense matrix
1162  , bool TF // Transpose flag
1163  , bool MF // Multiplication flag
1164  , ptrdiff_t... CBAs > // Compile time band arguments
1165 inline bool isDefault( const Band<MT,TF,true,MF,CBAs...>& band )
1166 {
1167  using blaze::isDefault;
1168 
1169  for( size_t i=0UL; i<band.size(); ++i )
1170  if( !isDefault<RF>( band[i] ) ) return false;
1171  return true;
1172 }
1174 //*************************************************************************************************
1175 
1176 
1177 //*************************************************************************************************
1203 template< bool RF // Relaxation flag
1204  , typename MT // Type of the sparse matrix
1205  , bool TF // Transpose flag
1206  , bool MF // Multiplication flag
1207  , ptrdiff_t... CBAs > // Compile time band arguments
1208 inline bool isDefault( const Band<MT,TF,false,MF,CBAs...>& band )
1209 {
1210  using blaze::isDefault;
1211 
1212  for( const auto& element : band )
1213  if( !isDefault<RF>( element.value() ) ) return false;
1214  return true;
1215 }
1217 //*************************************************************************************************
1218 
1219 
1220 //*************************************************************************************************
1238 template< typename MT // Type of the matrix
1239  , bool TF // Transpose flag
1240  , bool DF // Density flag
1241  , bool MF // Multiplication flag
1242  , ptrdiff_t... CBAs > // Compile time band arguments
1243 inline bool isIntact( const Band<MT,TF,DF,MF,CBAs...>& band ) noexcept
1244 {
1245  const ptrdiff_t index( band.band() );
1246 
1247  return ( ( index >= 0L || size_t( -index ) < band.operand().rows() ) &&
1248  ( index <= 0L || size_t( index ) < band.operand().columns() ) &&
1249  isIntact( band.operand() ) );
1250 }
1252 //*************************************************************************************************
1253 
1254 
1255 //*************************************************************************************************
1268 template< typename MT1 // Type of the matrix of the left-hand side band
1269  , bool TF // Transpose flag
1270  , bool DF // Density flag
1271  , bool MF // Multiplication flag
1272  , ptrdiff_t... CBAs1 // Compile time band arguments of the left-hand side band
1273  , typename MT2 // Type of the matrix of the right-hand side band
1274  , ptrdiff_t... CBAs2 > // Compile time band arguments of the right-hand side band
1275 inline auto isSame_backend( const Band<MT1,TF,DF,MF,CBAs1...>& a,
1276  const Band<MT2,TF,DF,MF,CBAs2...>& b ) noexcept
1277  -> DisableIf_t< IsSubmatrix_v<MT1> || IsSubmatrix_v<MT2>, bool >
1278 {
1279  return ( isSame( a.operand(), b.operand() ) && ( a.band() == b.band() ) );
1280 }
1282 //*************************************************************************************************
1283 
1284 
1285 //*************************************************************************************************
1298 template< typename MT1 // Type of the submatrix of the left-hand side band
1299  , bool TF // Transpose flag
1300  , bool DF // Density flag
1301  , bool MF // Multiplication flag
1302  , ptrdiff_t... CBAs1 // Compile time band arguments of the left-hand side band
1303  , typename MT2 // Type of the matrix of the right-hand side band
1304  , ptrdiff_t... CBAs2 > // Compile time band arguments of the right-hand side band
1305 inline auto isSame_backend( const Band<MT1,TF,DF,MF,CBAs1...>& a,
1306  const Band<MT2,TF,DF,MF,CBAs2...>& b ) noexcept
1307  -> EnableIf_t< IsSubmatrix_v<MT1> && !IsSubmatrix_v<MT2>, bool >
1308 {
1309  return ( isSame( a.operand().operand(), b.operand() ) &&
1310  ( a.size() == b.size() ) &&
1311  ( a.row() + a.operand().row() == b.row() ) &&
1312  ( a.column() + a.operand().column() == b.column() ) );
1313 }
1315 //*************************************************************************************************
1316 
1317 
1318 //*************************************************************************************************
1331 template< typename MT1 // Type of the matrix of the left-hand side band
1332  , bool TF // Transpose flag
1333  , bool DF // Density flag
1334  , bool MF // Multiplication flag
1335  , ptrdiff_t... CBAs1 // Compile time band arguments of the left-hand side band
1336  , typename MT2 // Type of the submatrix of the right-hand side band
1337  , ptrdiff_t... CBAs2 > // Compile time band arguments of the right-hand side band
1338 inline auto isSame_backend( const Band<MT1,TF,DF,MF,CBAs1...>& a,
1339  const Band<MT2,TF,DF,MF,CBAs2...>& b ) noexcept
1340  -> EnableIf_t< !IsSubmatrix_v<MT1> && IsSubmatrix_v<MT2>, bool >
1341 {
1342  return ( isSame( a.operand(), b.operand().operand() ) &&
1343  ( a.size() == b.size() ) &&
1344  ( a.row() == b.row() + b.operand().row() ) &&
1345  ( a.column() == b.column() + b.operand().column() ) );
1346 }
1348 //*************************************************************************************************
1349 
1350 
1351 //*************************************************************************************************
1364 template< typename MT1 // Type of the submatrix of the left-hand side band
1365  , bool TF // Transpose flag
1366  , bool DF // Density flag
1367  , bool MF // Multiplication flag
1368  , ptrdiff_t... CBAs1 // Compile time band arguments of the left-hand side band
1369  , typename MT2 // Type of the submatrix of the right-hand side band
1370  , ptrdiff_t... CBAs2 > // Compile time band arguments of the right-hand side band
1371 inline auto isSame_backend( const Band<MT1,TF,DF,MF,CBAs1...>& a,
1372  const Band<MT2,TF,DF,MF,CBAs2...>& b ) noexcept
1373  -> EnableIf_t< IsSubmatrix_v<MT1> && IsSubmatrix_v<MT2>, bool >
1374 {
1375  return ( isSame( a.operand().operand(), b.operand().operand() ) &&
1376  ( a.size() == b.size() ) &&
1377  ( a.row() + a.operand().row() == b.row() + b.operand().row() ) &&
1378  ( a.column() + a.operand().column() == b.column() + b.operand().column() ) );
1379 }
1381 //*************************************************************************************************
1382 
1383 
1384 //*************************************************************************************************
1397 template< typename MT1 // Type of the matrix of the left-hand side band
1398  , bool TF // Transpose flag
1399  , bool DF // Density flag
1400  , bool MF // Multiplication flag
1401  , ptrdiff_t... CBAs1 // Compile time band arguments of the left-hand side band
1402  , typename MT2 // Type of the matrix of the right-hand side band
1403  , ptrdiff_t... CBAs2 > // Compile time band arguments of the right-hand side band
1404 inline bool isSame( const Band<MT1,TF,DF,MF,CBAs1...>& a,
1405  const Band<MT2,TF,DF,MF,CBAs2...>& b ) noexcept
1406 {
1407  return isSame_backend( a, b );
1408 }
1410 //*************************************************************************************************
1411 
1412 
1413 //*************************************************************************************************
1428 template< typename MT // Type of the matrix
1429  , bool TF // Transpose flag
1430  , bool DF // Density flag
1431  , bool MF // Multiplication flag
1432  , ptrdiff_t... CBAs // Compile time band arguments
1433  , typename ET > // Type of the element
1434 inline bool trySet( const Band<MT,TF,DF,MF,CBAs...>& band, size_t index, const ET& value )
1435 {
1436  BLAZE_INTERNAL_ASSERT( index < band.size(), "Invalid vector access index" );
1437 
1438  return trySet( band.operand(), band.row()+index, band.column()+index, value );
1439 }
1441 //*************************************************************************************************
1442 
1443 
1444 //*************************************************************************************************
1459 template< typename MT // Type of the matrix
1460  , bool TF // Transpose flag
1461  , bool DF // Density flag
1462  , bool MF // Multiplication flag
1463  , ptrdiff_t... CBAs // Compile time band arguments
1464  , typename ET > // Type of the element
1465 inline bool tryAdd( const Band<MT,TF,DF,MF,CBAs...>& band, size_t index, const ET& value )
1466 {
1467  BLAZE_INTERNAL_ASSERT( index < band.size(), "Invalid vector access index" );
1468 
1469  return tryAdd( band.operand(), band.row()+index, band.column()+index, value );
1470 }
1472 //*************************************************************************************************
1473 
1474 
1475 //*************************************************************************************************
1490 template< typename MT // Type of the matrix
1491  , bool TF // Transpose flag
1492  , bool DF // Density flag
1493  , bool MF // Multiplication flag
1494  , ptrdiff_t... CBAs // Compile time band arguments
1495  , typename ET > // Type of the element
1496 inline bool trySub( const Band<MT,TF,DF,MF,CBAs...>& band, size_t index, const ET& value )
1497 {
1498  BLAZE_INTERNAL_ASSERT( index < band.size(), "Invalid vector access index" );
1499 
1500  return trySub( band.operand(), band.row()+index, band.column()+index, value );
1501 }
1503 //*************************************************************************************************
1504 
1505 
1506 //*************************************************************************************************
1521 template< typename MT // Type of the matrix
1522  , bool TF // Transpose flag
1523  , bool DF // Density flag
1524  , bool MF // Multiplication flag
1525  , ptrdiff_t... CBAs // Compile time band arguments
1526  , typename ET > // Type of the element
1527 inline bool tryMult( const Band<MT,TF,DF,MF,CBAs...>& band, size_t index, const ET& value )
1528 {
1529  BLAZE_INTERNAL_ASSERT( index < band.size(), "Invalid vector access index" );
1530 
1531  return tryMult( band.operand(), band.row()+index, band.column()+index, value );
1532 }
1534 //*************************************************************************************************
1535 
1536 
1537 //*************************************************************************************************
1553 template< typename MT // Type of the matrix
1554  , bool TF // Transpose flag
1555  , bool DF // Density flag
1556  , bool MF // Multiplication flag
1557  , ptrdiff_t... CBAs // Compile time band arguments
1558  , typename ET > // Type of the element
1560  tryMult( const Band<MT,TF,DF,MF,CBAs...>& band, size_t index, size_t size, const ET& value )
1561 {
1562  BLAZE_INTERNAL_ASSERT( index <= (~band).size(), "Invalid vector access index" );
1563  BLAZE_INTERNAL_ASSERT( index + size <= (~band).size(), "Invalid range size" );
1564 
1565  const size_t iend( index + size );
1566 
1567  for( size_t i=index; i<iend; ++i ) {
1568  if( !tryMult( band.operand(), band.row()+i, band.column()+i, value ) )
1569  return false;
1570  }
1571 
1572  return true;
1573 }
1575 //*************************************************************************************************
1576 
1577 
1578 //*************************************************************************************************
1593 template< typename MT // Type of the matrix
1594  , bool TF // Transpose flag
1595  , bool DF // Density flag
1596  , bool MF // Multiplication flag
1597  , ptrdiff_t... CBAs // Compile time band arguments
1598  , typename ET > // Type of the element
1599 inline bool tryDiv( const Band<MT,TF,DF,MF,CBAs...>& band, size_t index, const ET& value )
1600 {
1601  BLAZE_INTERNAL_ASSERT( index < band.size(), "Invalid vector access index" );
1602 
1603  return tryDiv( band.operand(), band.row()+index, band.column()+index, value );
1604 }
1606 //*************************************************************************************************
1607 
1608 
1609 //*************************************************************************************************
1625 template< typename MT // Type of the matrix
1626  , bool TF // Transpose flag
1627  , bool DF // Density flag
1628  , bool MF // Multiplication flag
1629  , ptrdiff_t... CBAs // Compile time band arguments
1630  , typename ET > // Type of the element
1632  tryDiv( const Band<MT,TF,DF,MF,CBAs...>& band, size_t index, size_t size, const ET& value )
1633 {
1634  BLAZE_INTERNAL_ASSERT( index <= (~band).size(), "Invalid vector access index" );
1635  BLAZE_INTERNAL_ASSERT( index + size <= (~band).size(), "Invalid range size" );
1636 
1637  const size_t iend( index + size );
1638 
1639  for( size_t i=index; i<iend; ++i ) {
1640  if( !tryDiv( band.operand(), band.row()+i, band.column()+i, value ) )
1641  return false;
1642  }
1643 
1644  return true;
1645 }
1647 //*************************************************************************************************
1648 
1649 
1650 //*************************************************************************************************
1665 template< typename MT // Type of the matrix
1666  , bool TF // Transpose flag
1667  , bool DF // Density flag
1668  , bool MF // Multiplication flag
1669  , ptrdiff_t... CBAs // Compile time band arguments
1670  , typename VT > // Type of the right-hand side vector
1671 inline bool tryAssign( const Band<MT,TF,DF,MF,CBAs...>& lhs,
1672  const Vector<VT,TF>& rhs, size_t index )
1673 {
1674  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
1675  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
1676 
1677  return tryAssign( lhs.operand(), ~rhs, lhs.band(), lhs.row()+index, lhs.column()+index );
1678 }
1680 //*************************************************************************************************
1681 
1682 
1683 //*************************************************************************************************
1698 template< typename MT // Type of the matrix
1699  , bool TF // Transpose flag
1700  , bool DF // Density flag
1701  , bool MF // Multiplication flag
1702  , ptrdiff_t... CBAs // Compile time band arguments
1703  , typename VT > // Type of the right-hand side vector
1704 inline bool tryAddAssign( const Band<MT,TF,DF,MF,CBAs...>& lhs,
1705  const Vector<VT,TF>& rhs, size_t index )
1706 {
1707  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
1708  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
1709 
1710  return tryAddAssign( lhs.operand(), ~rhs, lhs.band(), lhs.row()+index, lhs.column()+index );
1711 }
1713 //*************************************************************************************************
1714 
1715 
1716 //*************************************************************************************************
1731 template< typename MT // Type of the matrix
1732  , bool TF // Transpose flag
1733  , bool DF // Density flag
1734  , bool MF // Multiplication flag
1735  , ptrdiff_t... CBAs // Compile time band arguments
1736  , typename VT > // Type of the right-hand side vector
1737 inline bool trySubAssign( const Band<MT,TF,DF,MF,CBAs...>& lhs,
1738  const Vector<VT,TF>& rhs, size_t index )
1739 {
1740  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
1741  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
1742 
1743  return trySubAssign( lhs.operand(), ~rhs, lhs.band(), lhs.row()+index, lhs.column()+index );
1744 }
1746 //*************************************************************************************************
1747 
1748 
1749 //*************************************************************************************************
1764 template< typename MT // Type of the matrix
1765  , bool TF // Transpose flag
1766  , bool DF // Density flag
1767  , bool MF // Multiplication flag
1768  , ptrdiff_t... CBAs // Compile time band arguments
1769  , typename VT > // Type of the right-hand side vector
1770 inline bool tryMultAssign( const Band<MT,TF,DF,MF,CBAs...>& lhs,
1771  const Vector<VT,TF>& rhs, size_t index )
1772 {
1773  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
1774  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
1775 
1776  return tryMultAssign( lhs.operand(), ~rhs, lhs.band(), lhs.row()+index, lhs.column()+index );
1777 }
1779 //*************************************************************************************************
1780 
1781 
1782 //*************************************************************************************************
1797 template< typename MT // Type of the matrix
1798  , bool TF // Transpose flag
1799  , bool DF // Density flag
1800  , bool MF // Multiplication flag
1801  , ptrdiff_t... CBAs // Compile time band arguments
1802  , typename VT > // Type of the right-hand side vector
1803 inline bool tryDivAssign( const Band<MT,TF,DF,MF,CBAs...>& lhs,
1804  const Vector<VT,TF>& rhs, size_t index )
1805 {
1806  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
1807  BLAZE_INTERNAL_ASSERT( index + (~rhs).size() <= lhs.size(), "Invalid vector size" );
1808 
1809  return tryDivAssign( lhs.operand(), ~rhs, lhs.band(), lhs.row()+index, lhs.column()+index );
1810 }
1812 //*************************************************************************************************
1813 
1814 
1815 //*************************************************************************************************
1830 template< typename MT // Type of the matrix
1831  , bool TF // Transpose flag
1832  , bool DF // Density flag
1833  , bool MF // Multiplication flag
1834  , ptrdiff_t I > // Band index
1835 inline decltype(auto) derestrict( Band<MT,TF,DF,MF,I>& b )
1836 {
1837  return band<I>( derestrict( b.operand() ), unchecked );
1838 }
1840 //*************************************************************************************************
1841 
1842 
1843 //*************************************************************************************************
1858 template< typename MT // Type of the matrix
1859  , bool TF // Transpose flag
1860  , bool DF // Density flag
1861  , bool MF // Multiplication flag
1862  , ptrdiff_t I > // Band index
1863 inline decltype(auto) derestrict( Band<MT,TF,DF,MF,I>&& b )
1864 {
1865  return band<I>( derestrict( b.operand() ), unchecked );
1866 }
1868 //*************************************************************************************************
1869 
1870 
1871 //*************************************************************************************************
1886 template< typename MT // Type of the matrix
1887  , bool TF // Transpose flag
1888  , bool DF // Density flag
1889  , bool MF > // Multiplication flag
1890 inline decltype(auto) derestrict( Band<MT,TF,DF,MF>& b )
1891 {
1892  return band( derestrict( b.operand() ), b.band(), unchecked );
1893 }
1895 //*************************************************************************************************
1896 
1897 
1898 //*************************************************************************************************
1913 template< typename MT // Type of the matrix
1914  , bool TF // Transpose flag
1915  , bool DF // Density flag
1916  , bool MF > // Multiplication flag
1917 inline decltype(auto) derestrict( Band<MT,TF,DF,MF>&& b )
1918 {
1919  return band( derestrict( b.operand() ), b.band(), unchecked );
1920 }
1922 //*************************************************************************************************
1923 
1924 
1925 
1926 
1927 //=================================================================================================
1928 //
1929 // SIZE SPECIALIZATIONS
1930 //
1931 //=================================================================================================
1932 
1933 //*************************************************************************************************
1935 template< typename MT, bool TF, bool DF, bool MF, ptrdiff_t I >
1936 struct Size< Band<MT,TF,DF,MF,I>, 0UL >
1937  : public If_t< ( Size_v<MT,0UL> >= 0L && Size_v<MT,1UL> >= 0L )
1938  , Minimum< PtrdiffT< Size_v<MT,0UL> - ( I >= 0L ? 0L : -I ) >
1939  , PtrdiffT< Size_v<MT,1UL> - ( I >= 0L ? I : 0L ) > >
1940  , PtrdiffT<-1L> >
1941 {};
1943 //*************************************************************************************************
1944 
1945 
1946 
1947 
1948 //=================================================================================================
1949 //
1950 // MAXSIZE SPECIALIZATIONS
1951 //
1952 //=================================================================================================
1953 
1954 //*************************************************************************************************
1956 template< typename MT, bool TF, bool DF, bool MF, ptrdiff_t I >
1957 struct MaxSize< Band<MT,TF,DF,MF,I>, 0UL >
1958  : public If_t< ( MaxSize_v<MT,0UL> >= 0L && MaxSize_v<MT,1UL> >= 0L )
1959  , Minimum< PtrdiffT< MaxSize_v<MT,0UL> - ( I >= 0L ? 0L : -I ) >
1960  , PtrdiffT< MaxSize_v<MT,1UL> - ( I >= 0L ? I : 0L ) > >
1961  , PtrdiffT<-1L> >
1962 {};
1964 //*************************************************************************************************
1965 
1966 
1967 
1968 
1969 //=================================================================================================
1970 //
1971 // ISRESTRICTED SPECIALIZATIONS
1972 //
1973 //=================================================================================================
1974 
1975 //*************************************************************************************************
1977 template< typename MT, bool TF, bool DF, bool MF, ptrdiff_t... CBAs >
1978 struct IsRestricted< Band<MT,TF,DF,MF,CBAs...> >
1979  : public IsRestricted<MT>
1980 {};
1982 //*************************************************************************************************
1983 
1984 
1985 
1986 
1987 //=================================================================================================
1988 //
1989 // HASCONSTDATAACCESS SPECIALIZATIONS
1990 //
1991 //=================================================================================================
1992 
1993 //*************************************************************************************************
1995 template< typename MT, bool TF, bool MF, ptrdiff_t... CBAs >
1996 struct HasConstDataAccess< Band<MT,TF,true,MF,CBAs...> >
1997  : public HasConstDataAccess<MT>
1998 {};
2000 //*************************************************************************************************
2001 
2002 
2003 
2004 
2005 //=================================================================================================
2006 //
2007 // HASMUTABLEDATAACCESS SPECIALIZATIONS
2008 //
2009 //=================================================================================================
2010 
2011 //*************************************************************************************************
2013 template< typename MT, bool TF, bool MF, ptrdiff_t... CBAs >
2014 struct HasMutableDataAccess< Band<MT,TF,true,MF,CBAs...> >
2015  : public HasMutableDataAccess<MT>
2016 {};
2018 //*************************************************************************************************
2019 
2020 
2021 
2022 
2023 //=================================================================================================
2024 //
2025 // ISOPPOSEDVIEW SPECIALIZATIONS
2026 //
2027 //=================================================================================================
2028 
2029 //*************************************************************************************************
2031 template< typename MT, bool TF, bool DF, bool MF, ptrdiff_t... CBAs >
2032 struct IsOpposedView< Band<MT,TF,DF,MF,CBAs...> >
2033  : public TrueType
2034 {};
2036 //*************************************************************************************************
2037 
2038 } // namespace blaze
2039 
2040 #endif
decltype(auto) subvector(Vector< VT, TF > &, RSAs...)
Creating a view on a specific subvector of the given vector.
Definition: Subvector.h:329
AlignmentFlag
Alignment flag for (un-)aligned vectors and matrices.Via these flags it is possible to specify subvec...
Definition: AlignmentFlag.h:62
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:133
Header file for the blaze::checked and blaze::unchecked instances.
bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:992
Header file for basic type definitions.
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias declaration for the If class template.The If_t alias declaration provides a convenien...
Definition: If.h:109
Header file for the MatTransExpr base class.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
Header file for the MatEvalExpr base class.
typename RemoveReference< T >::Type RemoveReference_t
Auxiliary alias declaration for the RemoveReference type trait.The RemoveReference_t alias declaratio...
Definition: RemoveReference.h:95
Header file for the implementation of the Band base template.
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
Header file for the MaxSize type trait.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
Header file for the MatMapExpr base class.
Band specialization for sparse matrices.
Header file for the DisableIf class template.
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
Header file for the If class template.
Header file for the IsSubmatrix type trait.
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1147
Header file for the implementation of the SubvectorData class template.
Header file for the MatMatSubExpr base class.
decltype(auto) transTo(const DenseVector< VT, TF > &dv)
Conditional calculation of the transpose of the given dense vector.
Definition: DVecTransExpr.h:783
Header file for the IsOpposedView type trait.
Header file for the TransposeFlag type trait.
decltype(auto) eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:786
decltype(auto) diagonal(Matrix< MT, SO > &matrix, RDAs... args)
Creating a view on the diagonal of the given matrix.
Definition: Band.h:375
Header file for all forward declarations for expression class templates.
Header file for the MatSerialExpr base class.
Header file for the VecTVecMultExpr base class.
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:135
Header file for the HasConstDataAccess type trait.
IntegralConstant< ptrdiff_t, N > PtrdiffT
Compile time integral constant wrapper for ptrdiff_t.The PtrdiffT class template represents an integr...
Definition: PtrdiffT.h:72
Header file for the DeclExpr base class.
Header file for the Matrix base class.
Header file for the PtrdiffT class template.
Header file for all forward declarations for views.
Header file for the MatScalarMultExpr base class.
Header file for run time assertion macros.
Header file for the SchurExpr base class.
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
Header file for the isDefault shim.
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:109
typename T::VectorType VectorType_t
Alias declaration for nested VectorType type definitions.The VectorType_t alias declaration provides ...
Definition: Aliases.h:510
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
Header file for the HasMutableDataAccess type trait.
Header file for the MatMatAddExpr base class.
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
Header file for the RemoveReference type trait.
If_t< Less< T1, T2 >::value, T1, T2 > Minimum
Compile time value evaluation.The Minimum alias declaration selects the smaller of the two given temp...
Definition: Minimum.h:73
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
Header file for the VecExpandExpr base class.
Band specialization for dense matrices.
Header file for the MatMatMapExpr base class.
Header file for the default transpose flag for all vectors of the Blaze library.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
Header file for the Minimum class template.
Header file for the MatScalarDivExpr base class.
Header file for the IsRestricted type trait.
Header file for the Size type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the TrueType type/value trait base class.
Header file for the implementation of the BandData class template.
Header file for the function trace functionality.
decltype(auto) map(const DenseMatrix< MT1, SO > &lhs, const DenseMatrix< MT2, SO > &rhs, OP op)
Evaluates the given binary operation on each single element of the dense matrices lhs and rhs...
Definition: DMatDMatMapExpr.h:1110