Matrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_MATRIX_H_
36 #define _BLAZE_MATH_EXPRESSIONS_MATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
48 #include <blaze/system/Inline.h>
49 #include <blaze/util/Assert.h>
50 #include <blaze/util/DisableIf.h>
51 #include <blaze/util/EnableIf.h>
52 #include <blaze/util/Exception.h>
54 #include <blaze/util/mpl/And.h>
55 #include <blaze/util/mpl/Not.h>
56 #include <blaze/util/Types.h>
58 #include <blaze/util/Unused.h>
59 
60 
61 namespace blaze {
62 
63 //=================================================================================================
64 //
65 // CLASS DEFINITION
66 //
67 //=================================================================================================
68 
69 //*************************************************************************************************
80 template< typename MT // Type of the matrix
81  , bool SO > // Storage order
82 struct Matrix
83 {
84  //**Type definitions****************************************************************************
85  typedef MT MatrixType;
86  //**********************************************************************************************
87 
88  //**Non-const conversion operator***************************************************************
94  return *static_cast<MatrixType*>( this );
95  }
96  //**********************************************************************************************
97 
98  //**Const conversion operator*******************************************************************
103  BLAZE_ALWAYS_INLINE const MatrixType& operator~() const {
104  return *static_cast<const MatrixType*>( this );
105  }
106  //**********************************************************************************************
107 };
108 //*************************************************************************************************
109 
110 
111 
112 
113 //=================================================================================================
114 //
115 // GLOBAL FUNCTIONS
116 //
117 //=================================================================================================
118 
119 //*************************************************************************************************
122 template< typename MT, bool SO >
123 BLAZE_ALWAYS_INLINE typename MT::Iterator begin( Matrix<MT,SO>& matrix, size_t i );
124 
125 template< typename MT, bool SO >
126 BLAZE_ALWAYS_INLINE typename MT::ConstIterator begin( const Matrix<MT,SO>& matrix, size_t i );
127 
128 template< typename MT, bool SO >
129 BLAZE_ALWAYS_INLINE typename MT::ConstIterator cbegin( const Matrix<MT,SO>& matrix, size_t i );
130 
131 template< typename MT, bool SO >
132 BLAZE_ALWAYS_INLINE typename MT::Iterator end( Matrix<MT,SO>& matrix, size_t i );
133 
134 template< typename MT, bool SO >
135 BLAZE_ALWAYS_INLINE typename MT::ConstIterator end( const Matrix<MT,SO>& matrix, size_t i );
136 
137 template< typename MT, bool SO >
138 BLAZE_ALWAYS_INLINE typename MT::ConstIterator cend( const Matrix<MT,SO>& matrix, size_t i );
139 
140 template< typename MT, bool SO >
141 BLAZE_ALWAYS_INLINE size_t rows( const Matrix<MT,SO>& matrix );
142 
143 template< typename MT, bool SO >
144 BLAZE_ALWAYS_INLINE size_t columns( const Matrix<MT,SO>& matrix );
145 
146 template< typename MT, bool SO >
147 BLAZE_ALWAYS_INLINE size_t capacity( const Matrix<MT,SO>& matrix );
148 
149 template< typename MT, bool SO >
150 BLAZE_ALWAYS_INLINE size_t capacity( const Matrix<MT,SO>& matrix, size_t i );
151 
152 template< typename MT, bool SO >
153 BLAZE_ALWAYS_INLINE size_t nonZeros( const Matrix<MT,SO>& matrix );
154 
155 template< typename MT, bool SO >
156 BLAZE_ALWAYS_INLINE size_t nonZeros( const Matrix<MT,SO>& matrix, size_t i );
157 
158 template< typename MT, bool SO >
159 BLAZE_ALWAYS_INLINE void resize( Matrix<MT,SO>& matrix, size_t rows, size_t columns, bool preserve=true );
160 
161 template< typename MT, bool SO >
162 BLAZE_ALWAYS_INLINE void transpose( Matrix<MT,SO>& matrix );
163 
164 template< typename MT, bool SO >
165 BLAZE_ALWAYS_INLINE bool isSquare( const Matrix<MT,SO>& matrix );
166 
167 template< typename MT1, bool SO1, typename MT2, bool SO2 >
168 BLAZE_ALWAYS_INLINE bool isSame( const Matrix<MT1,SO1>& a, const Matrix<MT2,SO2>& b );
170 //*************************************************************************************************
171 
172 
173 //*************************************************************************************************
185 template< typename MT // Type of the matrix
186  , bool SO > // Storage order of the matrix
188 {
189  return (~matrix).begin(i);
190 }
191 //*************************************************************************************************
192 
193 
194 //*************************************************************************************************
206 template< typename MT // Type of the matrix
207  , bool SO > // Storage order of the matrix
208 BLAZE_ALWAYS_INLINE typename MT::ConstIterator begin( const Matrix<MT,SO>& matrix, size_t i )
209 {
210  return (~matrix).begin(i);
211 }
212 //*************************************************************************************************
213 
214 
215 //*************************************************************************************************
227 template< typename MT // Type of the matrix
228  , bool SO > // Storage order of the matrix
229 BLAZE_ALWAYS_INLINE typename MT::ConstIterator cbegin( const Matrix<MT,SO>& matrix, size_t i )
230 {
231  return (~matrix).cbegin(i);
232 }
233 //*************************************************************************************************
234 
235 
236 //*************************************************************************************************
248 template< typename MT // Type of the matrix
249  , bool SO > // Storage order of the matrix
250 BLAZE_ALWAYS_INLINE typename MT::Iterator end( Matrix<MT,SO>& matrix, size_t i )
251 {
252  return (~matrix).end(i);
253 }
254 //*************************************************************************************************
255 
256 
257 //*************************************************************************************************
269 template< typename MT // Type of the matrix
270  , bool SO > // Storage order of the matrix
271 BLAZE_ALWAYS_INLINE typename MT::ConstIterator end( const Matrix<MT,SO>& matrix, size_t i )
272 {
273  return (~matrix).end(i);
274 }
275 //*************************************************************************************************
276 
277 
278 //*************************************************************************************************
290 template< typename MT // Type of the matrix
291  , bool SO > // Storage order of the matrix
292 BLAZE_ALWAYS_INLINE typename MT::ConstIterator cend( const Matrix<MT,SO>& matrix, size_t i )
293 {
294  return (~matrix).cend(i);
295 }
296 //*************************************************************************************************
297 
298 
299 //*************************************************************************************************
306 template< typename MT // Type of the matrix
307  , bool SO > // Storage order of the matrix
308 BLAZE_ALWAYS_INLINE size_t rows( const Matrix<MT,SO>& matrix )
309 {
310  return (~matrix).rows();
311 }
312 //*************************************************************************************************
313 
314 
315 //*************************************************************************************************
322 template< typename MT // Type of the matrix
323  , bool SO > // Storage order of the matrix
325 {
326  return (~matrix).columns();
327 }
328 //*************************************************************************************************
329 
330 
331 //*************************************************************************************************
338 template< typename MT // Type of the matrix
339  , bool SO > // Storage order of the matrix
341 {
342  return (~matrix).capacity();
343 }
344 //*************************************************************************************************
345 
346 
347 //*************************************************************************************************
360 template< typename MT // Type of the matrix
361  , bool SO > // Storage order of the matrix
362 BLAZE_ALWAYS_INLINE size_t capacity( const Matrix<MT,SO>& matrix, size_t i )
363 {
364  return (~matrix).capacity( i );
365 }
366 //*************************************************************************************************
367 
368 
369 //*************************************************************************************************
376 template< typename MT // Type of the matrix
377  , bool SO > // Storage order of the matrix
379 {
380  return (~matrix).nonZeros();
381 }
382 //*************************************************************************************************
383 
384 
385 //*************************************************************************************************
398 template< typename MT // Type of the matrix
399  , bool SO > // Storage order of the matrix
400 BLAZE_ALWAYS_INLINE size_t nonZeros( const Matrix<MT,SO>& matrix, size_t i )
401 {
402  return (~matrix).nonZeros( i );
403 }
404 //*************************************************************************************************
405 
406 
407 //*************************************************************************************************
424 template< typename MT // Type of the matrix
425  , bool SO > // Storage order of the matrix
426 BLAZE_ALWAYS_INLINE typename DisableIf< IsResizable<MT> >::Type
427  resize_backend( Matrix<MT,SO>& matrix, size_t m, size_t n, bool preserve )
428 {
429  UNUSED_PARAMETER( preserve );
430 
431  if( (~matrix).rows() != m || (~matrix).columns() != n ) {
432  BLAZE_THROW_INVALID_ARGUMENT( "Matrix cannot be resized" );
433  }
434 }
436 //*************************************************************************************************
437 
438 
439 //*************************************************************************************************
452 template< typename MT // Type of the matrix
453  , bool SO > // Storage order of the matrix
454 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsResizable<MT>, Not< IsSquare<MT> > > >::Type
455  resize_backend( Matrix<MT,SO>& matrix, size_t m, size_t n, bool preserve )
456 {
457  (~matrix).resize( m, n, preserve );
458 }
460 //*************************************************************************************************
461 
462 
463 //*************************************************************************************************
477 template< typename MT // Type of the matrix
478  , bool SO > // Storage order of the matrix
479 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsResizable<MT>, IsSquare<MT> > >::Type
480  resize_backend( Matrix<MT,SO>& matrix, size_t m, size_t n, bool preserve )
481 {
482  if( m != n ) {
483  BLAZE_THROW_INVALID_ARGUMENT( "Invalid resize arguments for square matrix" );
484  }
485 
486  (~matrix).resize( m, preserve );
487 }
489 //*************************************************************************************************
490 
491 
492 //*************************************************************************************************
530 template< typename MT // Type of the matrix
531  , bool SO > // Storage order of the matrix
532 BLAZE_ALWAYS_INLINE void resize( Matrix<MT,SO>& matrix, size_t m, size_t n, bool preserve )
533 {
534  resize_backend( matrix, m, n, preserve );
535 }
536 //*************************************************************************************************
537 
538 
539 //*************************************************************************************************
556 template< typename MT // Type of the matrix
557  , bool SO > // Storage order of the matrix
559 {
560  (~matrix).transpose();
561 }
562 //*************************************************************************************************
563 
564 
565 //*************************************************************************************************
582 template< typename MT // Type of the matrix
583  , bool SO > // Storage order of the matrix
585 {
586  (~matrix).ctranspose();
587 }
588 //*************************************************************************************************
589 
590 
591 //*************************************************************************************************
601 template< typename MT // Type of the matrix
602  , bool SO > // Storage order
604 {
605  return ( IsSquare<MT>::value || (~matrix).rows() == (~matrix).columns() );
606 }
607 //*************************************************************************************************
608 
609 
610 //*************************************************************************************************
643 template< typename MT1 // Type of the left-hand side matrix
644  , bool SO1 // Storage order of the left-hand side matrix
645  , typename MT2 // Type of the right-hand side matrix
646  , bool SO2 > // Storage order of the right-hand side matrix
648 {
649  return ( IsSame<MT1,MT2>::value &&
650  reinterpret_cast<const void*>( &a ) == reinterpret_cast<const void*>( &b ) );
651 }
652 //*************************************************************************************************
653 
654 
655 //*************************************************************************************************
664 template< typename MT1 // Type of the left-hand side matrix
665  , typename MT2 // Type of the right-hand side matrix
666  , bool SO > // Storage order of both matrices
667 BLAZE_ALWAYS_INLINE void assign_backend( Matrix<MT1,SO>& lhs, const Matrix<MT2,SO>& rhs )
668 {
670 
671  (~lhs).assign( ~rhs );
672 }
674 //*************************************************************************************************
675 
676 
677 //*************************************************************************************************
686 template< typename MT1 // Type of the left-hand side matrix
687  , bool SO // Storage order of the left-hand side matrix
688  , typename MT2 > // Type of the right-hand side matrix
689 BLAZE_ALWAYS_INLINE typename DisableIf< IsSymmetric<MT2> >::Type
690  assign_backend( Matrix<MT1,SO>& lhs, const Matrix<MT2,!SO>& rhs )
691 {
693 
695 
696  (~lhs).assign( ~rhs );
697 }
699 //*************************************************************************************************
700 
701 
702 //*************************************************************************************************
712 template< typename MT1 // Type of the left-hand side matrix
713  , bool SO // Storage order of the left-hand side matrix
714  , typename MT2 > // Type of the right-hand side matrix
715 BLAZE_ALWAYS_INLINE typename EnableIf< IsSymmetric<MT2> >::Type
716  assign_backend( Matrix<MT1,SO>& lhs, const Matrix<MT2,!SO>& rhs )
717 {
719 
721 
722  BLAZE_INTERNAL_ASSERT( isSquare( ~rhs ), "Non-square symmetric matrix detected" );
723 
724  (~lhs).assign( trans( ~rhs ) );
725 }
727 //*************************************************************************************************
728 
729 
730 //*************************************************************************************************
745 template< typename MT1 // Type of the left-hand side matrix
746  , bool SO1 // Storage order of the left-hand side matrix
747  , typename MT2 // Type of the right-hand side matrix
748  , bool SO2 > // Storage order of the right-hand side matrix
749 BLAZE_ALWAYS_INLINE void assign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
750 {
752 
753  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
754  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
755 
756  assign_backend( ~lhs, ~rhs );
757 }
759 //*************************************************************************************************
760 
761 
762 //*************************************************************************************************
772 template< typename MT1 // Type of the left-hand side matrix
773  , typename MT2 // Type of the right-hand side matrix
774  , bool SO > // Storage order of both matrices
775 BLAZE_ALWAYS_INLINE void addAssign_backend( Matrix<MT1,SO>& lhs, const Matrix<MT2,SO>& rhs )
776 {
778 
779  (~lhs).addAssign( ~rhs );
780 }
782 //*************************************************************************************************
783 
784 
785 //*************************************************************************************************
795 template< typename MT1 // Type of the left-hand side matrix
796  , bool SO // Storage order of the left-hand side matrix
797  , typename MT2 > // Type of the right-hand side matrix
798 BLAZE_ALWAYS_INLINE typename DisableIf< IsSymmetric<MT2> >::Type
799  addAssign_backend( Matrix<MT1,SO>& lhs, const Matrix<MT2,!SO>& rhs )
800 {
802 
804 
805  (~lhs).addAssign( ~rhs );
806 }
808 //*************************************************************************************************
809 
810 
811 //*************************************************************************************************
821 template< typename MT1 // Type of the left-hand side matrix
822  , bool SO // Storage order of the left-hand side matrix
823  , typename MT2 > // Type of the right-hand side matrix
824 BLAZE_ALWAYS_INLINE typename EnableIf< IsSymmetric<MT2> >::Type
825  addAssign_backend( Matrix<MT1,SO>& lhs, const Matrix<MT2,!SO>& rhs )
826 {
828 
830 
831  BLAZE_INTERNAL_ASSERT( isSquare( ~rhs ), "Non-square symmetric matrix detected" );
832 
833  (~lhs).addAssign( trans( ~rhs ) );
834 }
836 //*************************************************************************************************
837 
838 
839 //*************************************************************************************************
854 template< typename MT1 // Type of the left-hand side matrix
855  , bool SO1 // Storage order of the left-hand side matrix
856  , typename MT2 // Type of the right-hand side matrix
857  , bool SO2 > // Storage order of the right-hand side matrix
858 BLAZE_ALWAYS_INLINE void addAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
859 {
861 
862  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
863  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
864 
865  addAssign_backend( ~lhs, ~rhs );
866 }
868 //*************************************************************************************************
869 
870 
871 //*************************************************************************************************
881 template< typename MT1 // Type of the left-hand side matrix
882  , typename MT2 // Type of the right-hand side matrix
883  , bool SO > // Storage order of both matrices
884 BLAZE_ALWAYS_INLINE void subAssign_backend( Matrix<MT1,SO>& lhs, const Matrix<MT2,SO>& rhs )
885 {
887 
888  (~lhs).subAssign( ~rhs );
889 }
891 //*************************************************************************************************
892 
893 
894 //*************************************************************************************************
904 template< typename MT1 // Type of the left-hand side matrix
905  , bool SO // Storage order of the left-hand side matrix
906  , typename MT2 > // Type of the right-hand side matrix
907 BLAZE_ALWAYS_INLINE typename DisableIf< IsSymmetric<MT2> >::Type
908  subAssign_backend( Matrix<MT1,SO>& lhs, const Matrix<MT2,!SO>& rhs )
909 {
911 
913 
914  (~lhs).subAssign( ~rhs );
915 }
917 //*************************************************************************************************
918 
919 
920 //*************************************************************************************************
930 template< typename MT1 // Type of the left-hand side matrix
931  , bool SO // Storage order of the left-hand side matrix
932  , typename MT2 > // Type of the right-hand side matrix
933 BLAZE_ALWAYS_INLINE typename EnableIf< IsSymmetric<MT2> >::Type
934  subAssign_backend( Matrix<MT1,SO>& lhs, const Matrix<MT2,!SO>& rhs )
935 {
937 
939 
940  BLAZE_INTERNAL_ASSERT( isSquare( ~rhs ), "Non-square symmetric matrix detected" );
941 
942  (~lhs).subAssign( trans( ~rhs ) );
943 }
945 //*************************************************************************************************
946 
947 
948 //*************************************************************************************************
963 template< typename MT1 // Type of the left-hand side matrix
964  , bool SO1 // Storage order of the left-hand side matrix
965  , typename MT2 // Type of the right-hand side matrix
966  , bool SO2 > // Storage order of the right-hand side matrix
967 BLAZE_ALWAYS_INLINE void subAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
968 {
970 
971  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
972  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
973 
974  subAssign_backend( ~lhs, ~rhs );
975 }
977 //*************************************************************************************************
978 
979 
980 //*************************************************************************************************
995 template< typename MT1 // Type of the left-hand side matrix
996  , bool SO1 // Storage order of the left-hand side matrix
997  , typename MT2 // Type of the right-hand side matrix
998  , bool SO2 > // Storage order of the right-hand side matrix
999 BLAZE_ALWAYS_INLINE void multAssign( Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs )
1000 {
1002 
1003  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).rows(), "Invalid matrix sizes" );
1004 
1005  (~lhs).multAssign( ~rhs );
1006 }
1008 //*************************************************************************************************
1009 
1010 
1011 //*************************************************************************************************
1027 template< typename MT // Type of the left-hand side matrix
1028  , bool SO // Storage order of the left-hand side matrix
1029  , typename VT // Type of the right-hand side vector
1030  , bool TF > // Transpose flag of the right-hand side vector
1031 BLAZE_ALWAYS_INLINE bool tryAssign( const Matrix<MT,SO>& lhs, const Vector<VT,TF>& rhs,
1032  size_t row, size_t column )
1033 {
1034  BLAZE_INTERNAL_ASSERT( row <= (~lhs).rows(), "Invalid row access index" );
1035  BLAZE_INTERNAL_ASSERT( column <= (~lhs).columns(), "Invalid column access index" );
1036  BLAZE_INTERNAL_ASSERT( TF || ( (~rhs).size() <= (~lhs).rows() - row ), "Invalid number of rows" );
1037  BLAZE_INTERNAL_ASSERT( !TF || ( (~rhs).size() <= (~lhs).columns() - column ), "Invalid number of columns" );
1038 
1039  UNUSED_PARAMETER( lhs, rhs, row, column );
1040 
1041  return true;
1042 }
1044 //*************************************************************************************************
1045 
1046 
1047 //*************************************************************************************************
1063 template< typename MT1 // Type of the left-hand side matrix
1064  , bool SO1 // Storage order of the left-hand side matrix
1065  , typename MT2 // Type of the right-hand side matrix
1066  , bool SO2 > // Storage order of the right-hand side matrix
1067 BLAZE_ALWAYS_INLINE bool tryAssign( const Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs,
1068  size_t row, size_t column )
1069 {
1070  BLAZE_INTERNAL_ASSERT( row <= (~lhs).rows(), "Invalid row access index" );
1071  BLAZE_INTERNAL_ASSERT( column <= (~lhs).columns(), "Invalid column access index" );
1072  BLAZE_INTERNAL_ASSERT( (~rhs).rows() <= (~lhs).rows() - row, "Invalid number of rows" );
1073  BLAZE_INTERNAL_ASSERT( (~rhs).columns() <= (~lhs).columns() - column, "Invalid number of columns" );
1074 
1075  UNUSED_PARAMETER( lhs, rhs, row, column );
1076 
1077  return true;
1078 }
1080 //*************************************************************************************************
1081 
1082 
1083 //*************************************************************************************************
1099 template< typename MT // Type of the left-hand side matrix
1100  , bool SO // Storage order of the left-hand side matrix
1101  , typename VT // Type of the right-hand side vector
1102  , bool TF > // Transpose flag of the right-hand side vector
1103 BLAZE_ALWAYS_INLINE bool tryAddAssign( const Matrix<MT,SO>& lhs, const Vector<VT,TF>& rhs,
1104  size_t row, size_t column )
1105 {
1106  BLAZE_INTERNAL_ASSERT( row <= (~lhs).rows(), "Invalid row access index" );
1107  BLAZE_INTERNAL_ASSERT( column <= (~lhs).columns(), "Invalid column access index" );
1108  BLAZE_INTERNAL_ASSERT( TF || ( (~rhs).size() <= (~lhs).rows() - row ), "Invalid number of rows" );
1109  BLAZE_INTERNAL_ASSERT( !TF || ( (~rhs).size() <= (~lhs).columns() - column ), "Invalid number of columns" );
1110 
1111  UNUSED_PARAMETER( lhs, rhs, row, column );
1112 
1113  return true;
1114 }
1116 //*************************************************************************************************
1117 
1118 
1119 //*************************************************************************************************
1135 template< typename MT1 // Type of the left-hand side matrix
1136  , bool SO1 // Storage order of the left-hand side matrix
1137  , typename MT2 // Type of the right-hand side matrix
1138  , bool SO2 > // Storage order of the right-hand side matrix
1139 BLAZE_ALWAYS_INLINE bool tryAddAssign( const Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs,
1140  size_t row, size_t column )
1141 {
1142  BLAZE_INTERNAL_ASSERT( row <= (~lhs).rows(), "Invalid row access index" );
1143  BLAZE_INTERNAL_ASSERT( column <= (~lhs).columns(), "Invalid column access index" );
1144  BLAZE_INTERNAL_ASSERT( (~rhs).rows() <= (~lhs).rows() - row, "Invalid number of rows" );
1145  BLAZE_INTERNAL_ASSERT( (~rhs).columns() <= (~lhs).columns() - column, "Invalid number of columns" );
1146 
1147  UNUSED_PARAMETER( lhs, rhs, row, column );
1148 
1149  return true;
1150 }
1152 //*************************************************************************************************
1153 
1154 
1155 //*************************************************************************************************
1171 template< typename MT // Type of the left-hand side matrix
1172  , bool SO // Storage order of the left-hand side matrix
1173  , typename VT // Type of the right-hand side vector
1174  , bool TF > // Transpose flag of the right-hand side vector
1175 BLAZE_ALWAYS_INLINE bool trySubAssign( const Matrix<MT,SO>& lhs, const Vector<VT,TF>& rhs,
1176  size_t row, size_t column )
1177 {
1178  BLAZE_INTERNAL_ASSERT( row <= (~lhs).rows(), "Invalid row access index" );
1179  BLAZE_INTERNAL_ASSERT( column <= (~lhs).columns(), "Invalid column access index" );
1180  BLAZE_INTERNAL_ASSERT( TF || ( (~rhs).size() <= (~lhs).rows() - row ), "Invalid number of rows" );
1181  BLAZE_INTERNAL_ASSERT( !TF || ( (~rhs).size() <= (~lhs).columns() - column ), "Invalid number of columns" );
1182 
1183  UNUSED_PARAMETER( lhs, rhs, row, column );
1184 
1185  return true;
1186 }
1188 //*************************************************************************************************
1189 
1190 
1191 //*************************************************************************************************
1207 template< typename MT1 // Type of the left-hand side matrix
1208  , bool SO1 // Storage order of the left-hand side matrix
1209  , typename MT2 // Type of the right-hand side matrix
1210  , bool SO2 > // Storage order of the right-hand side matrix
1211 BLAZE_ALWAYS_INLINE bool trySubAssign( const Matrix<MT1,SO1>& lhs, const Matrix<MT2,SO2>& rhs,
1212  size_t row, size_t column )
1213 {
1214  BLAZE_INTERNAL_ASSERT( row <= (~lhs).rows(), "Invalid row access index" );
1215  BLAZE_INTERNAL_ASSERT( column <= (~lhs).columns(), "Invalid column access index" );
1216  BLAZE_INTERNAL_ASSERT( (~rhs).rows() <= (~lhs).rows() - row, "Invalid number of rows" );
1217  BLAZE_INTERNAL_ASSERT( (~rhs).columns() <= (~lhs).columns() - column, "Invalid number of columns" );
1218 
1219  UNUSED_PARAMETER( lhs, rhs, row, column );
1220 
1221  return true;
1222 }
1224 //*************************************************************************************************
1225 
1226 
1227 //*************************************************************************************************
1243 template< typename MT // Type of the left-hand side matrix
1244  , bool SO // Storage order of the left-hand side matrix
1245  , typename VT // Type of the right-hand side vector
1246  , bool TF > // Transpose flag of the right-hand side vector
1247 BLAZE_ALWAYS_INLINE bool tryMultAssign( const Matrix<MT,SO>& lhs, const Vector<VT,TF>& rhs,
1248  size_t row, size_t column )
1249 {
1250  BLAZE_INTERNAL_ASSERT( row <= (~lhs).rows(), "Invalid row access index" );
1251  BLAZE_INTERNAL_ASSERT( column <= (~lhs).columns(), "Invalid column access index" );
1252  BLAZE_INTERNAL_ASSERT( TF || ( (~rhs).size() <= (~lhs).rows() - row ), "Invalid number of rows" );
1253  BLAZE_INTERNAL_ASSERT( !TF || ( (~rhs).size() <= (~lhs).columns() - column ), "Invalid number of columns" );
1254 
1255  UNUSED_PARAMETER( lhs, rhs, row, column );
1256 
1257  return true;
1258 }
1260 //*************************************************************************************************
1261 
1262 
1263 //*************************************************************************************************
1278 template< typename MT // Type of the matrix
1279  , bool SO > // Storage order
1280 BLAZE_ALWAYS_INLINE MT& derestrict( Matrix<MT,SO>& matrix )
1281 {
1282  return ~matrix;
1283 }
1285 //*************************************************************************************************
1286 
1287 } // namespace blaze
1288 
1289 #endif
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
Header file for the UNUSED_PARAMETER function template.
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE const MatrixType & operator~() const
Conversion operator for constant matrices.
Definition: Matrix.h:103
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix)
Checks if the given matrix is a square matrix.
Definition: Matrix.h:603
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:229
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:252
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:292
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:250
MT MatrixType
Type of the matrix.
Definition: Matrix.h:85
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b)
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:647
Header file for the IsSame and IsStrictlySame type traits.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:340
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:308
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename ColumnExprTrait< MT >::Type >::Type column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:107
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the And class template.
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:584
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:378
Type relationship analysis.This class tests if the two data types A and B are equal. For this type comparison, the cv-qualifiers of both data types are ignored. If A and B are the same data type (ignoring the cv-qualifiers), then the value member enumeration is set to 1, the nested type definition Type is TrueType, and the class derives from TrueType. Otherwise value is set to 0, Type is FalseType, and the class derives from FalseType.
Definition: IsSame.h:158
Header file for the IsSquare type trait.
Header file for the DisableIf class template.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
Header file for the Not class template.
BLAZE_ALWAYS_INLINE MatrixType & operator~()
Conversion operator for non-constant matrices.
Definition: Matrix.h:93
Compile time check for square matrices.This type trait tests whether or not the given template parame...
Definition: IsSquare.h:87
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:187
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:532
Header file for all forward declarations for expression class templates.
Header file for the EnableIf class template.
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< MT >::Type >::Type row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:107
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:116
Header file for run time assertion macros.
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2591
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:94
Constraint on the data type.
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:944
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:324
Header file for exception macros.
Header file for the IsResizable type trait.
System settings for the inline keywords.
#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 FunctionTrace class.
BLAZE_ALWAYS_INLINE void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:558