DMatDeclDiagExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATDECLDIAGEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DMATDECLDIAGEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
45 #include <blaze/math/Aliases.h>
50 #include <blaze/math/Exception.h>
71 #include <blaze/util/Assert.h>
72 #include <blaze/util/DisableIf.h>
73 #include <blaze/util/EnableIf.h>
76 #include <blaze/util/InvalidType.h>
77 #include <blaze/util/mpl/If.h>
78 #include <blaze/util/TrueType.h>
79 #include <blaze/util/Types.h>
81 
82 
83 namespace blaze {
84 
85 //=================================================================================================
86 //
87 // CLASS DMATDECLDIAGEXPR
88 //
89 //=================================================================================================
90 
91 //*************************************************************************************************
98 template< typename MT // Type of the dense matrix
99  , bool SO > // Storage order
101  : public DeclDiagExpr< DenseMatrix< DMatDeclDiagExpr<MT,SO>, SO > >
102  , public Declaration<MT>
103 {
104  private:
105  //**Type definitions****************************************************************************
106  using RT = ResultType_<MT>;
107  //**********************************************************************************************
108 
109  //**Serial evaluation strategy******************************************************************
111 
117  enum : bool { useAssign = RequiresEvaluation<MT>::value };
118 
120  template< typename MT2 >
122  struct UseAssign {
123  enum : bool { value = useAssign };
124  };
126  //**********************************************************************************************
127 
128  //**Parallel evaluation strategy****************************************************************
130 
135  template< typename MT2 >
136  struct UseSMPAssign {
137  enum : bool { value = MT2::smpAssignable && useAssign };
138  };
140  //**********************************************************************************************
141 
142  //**********************************************************************************************
144 
148  template< typename MT2 >
149  struct GetConstIterator {
151  struct Success { using Type = typename MT2::ConstIterator; };
152  struct Failure { using Type = INVALID_TYPE; };
153  using Type = typename If_< HasConstIterator<MT2>, Success, Failure >::Type;
154  };
156  //**********************************************************************************************
157 
158  public:
159  //**Type definitions****************************************************************************
166 
169 
171  using ConstIterator = typename GetConstIterator<MT>::Type;
172 
174  using Operand = If_< IsExpression<MT>, const MT, const MT& >;
175  //**********************************************************************************************
176 
177  //**Compilation flags***************************************************************************
179  enum : bool { simdEnabled = MT::simdEnabled };
180 
182  enum : bool { smpAssignable = MT::smpAssignable };
183  //**********************************************************************************************
184 
185  //**SIMD properties*****************************************************************************
187  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
188  //**********************************************************************************************
189 
190  //**Constructor*********************************************************************************
195  explicit inline DMatDeclDiagExpr( const MT& dm ) noexcept
196  : dm_( dm ) // Dense matrix of the decldiag expression
197  {
198  BLAZE_INTERNAL_ASSERT( isSquare( ~dm ), "Non-square matrix detected" );
199  }
200  //**********************************************************************************************
201 
202  //**Access operator*****************************************************************************
209  inline ReturnType operator()( size_t i, size_t j ) const {
210  BLAZE_INTERNAL_ASSERT( i < dm_.rows() , "Invalid row access index" );
211  BLAZE_INTERNAL_ASSERT( j < dm_.columns(), "Invalid column access index" );
212  return dm_(i,j);
213  }
214  //**********************************************************************************************
215 
216  //**At function*********************************************************************************
224  inline ReturnType at( size_t i, size_t j ) const {
225  if( i >= dm_.rows() ) {
226  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
227  }
228  if( j >= dm_.columns() ) {
229  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
230  }
231  return (*this)(i,j);
232  }
233  //**********************************************************************************************
234 
235  //**Load function*******************************************************************************
242  BLAZE_ALWAYS_INLINE auto load( size_t i, size_t j ) const noexcept {
243  BLAZE_INTERNAL_ASSERT( i < dm_.columns(), "Invalid row access index" );
244  BLAZE_INTERNAL_ASSERT( j < dm_.rows() , "Invalid column access index" );
245  BLAZE_INTERNAL_ASSERT( !SO || ( i % SIMDSIZE == 0UL ), "Invalid row access index" );
246  BLAZE_INTERNAL_ASSERT( SO || ( j % SIMDSIZE == 0UL ), "Invalid column access index" );
247  return dm_.load(i,j);
248  }
249  //**********************************************************************************************
250 
251  //**Low-level data access***********************************************************************
256  inline const ElementType* data() const noexcept {
257  return dm_.data();
258  }
259  //**********************************************************************************************
260 
261  //**Begin function******************************************************************************
267  inline ConstIterator begin( size_t i ) const {
268  return ConstIterator( dm_.begin(i) );
269  }
270  //**********************************************************************************************
271 
272  //**End function********************************************************************************
278  inline ConstIterator end( size_t i ) const {
279  return ConstIterator( dm_.end(i) );
280  }
281  //**********************************************************************************************
282 
283  //**Rows function*******************************************************************************
288  inline size_t rows() const noexcept {
289  return dm_.rows();
290  }
291  //**********************************************************************************************
292 
293  //**Columns function****************************************************************************
298  inline size_t columns() const noexcept {
299  return dm_.columns();
300  }
301  //**********************************************************************************************
302 
303  //**Operand access******************************************************************************
308  inline Operand operand() const noexcept {
309  return dm_;
310  }
311  //**********************************************************************************************
312 
313  //**********************************************************************************************
319  template< typename T >
320  inline bool canAlias( const T* alias ) const noexcept {
321  return dm_.canAlias( alias );
322  }
323  //**********************************************************************************************
324 
325  //**********************************************************************************************
331  template< typename T >
332  inline bool isAliased( const T* alias ) const noexcept {
333  return dm_.isAliased( alias );
334  }
335  //**********************************************************************************************
336 
337  //**********************************************************************************************
342  inline bool isAligned() const noexcept {
343  return dm_.isAligned();
344  }
345  //**********************************************************************************************
346 
347  //**********************************************************************************************
352  inline bool canSMPAssign() const noexcept {
353  return dm_.canSMPAssign();
354  }
355  //**********************************************************************************************
356 
357  private:
358  //**Member variables****************************************************************************
360  //**********************************************************************************************
361 
362  //**Assignment to dense matrices****************************************************************
374  template< typename MT2 // Type of the target dense matrix
375  , bool SO2 > // Storage order of the target dense matrix
376  friend inline EnableIf_< UseAssign<MT2> >
377  assign( DenseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
378  {
380 
381  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
382  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
383 
384  assign( ~lhs, rhs.dm_ );
385  }
387  //**********************************************************************************************
388 
389  //**Assignment to sparse matrices***************************************************************
401  template< typename MT2 // Type of the target sparse matrix
402  , bool SO2 > // Storage order of the target dense matrix
403  friend inline EnableIf_< UseAssign<MT2> >
404  assign( SparseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
405  {
407 
408  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
409  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
410 
411  assign( ~lhs, rhs.dm_ );
412  }
414  //**********************************************************************************************
415 
416  //**Addition assignment to dense matrices*******************************************************
428  template< typename MT2 // Type of the target dense matrix
429  , bool SO2 > // Storage order of the target dense matrix
430  friend inline EnableIf_< UseAssign<MT2> >
431  addAssign( DenseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
432  {
434 
435  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
436  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
437 
438  addAssign( ~lhs, rhs.dm_ );
439  }
441  //**********************************************************************************************
442 
443  //**Addition assignment to sparse matrices******************************************************
455  template< typename MT2 // Type of the target sparse matrix
456  , bool SO2 > // Storage order of the target dense matrix
457  friend inline EnableIf_< UseAssign<MT2> >
458  addAssign( SparseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
459  {
461 
462  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
463  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
464 
465  addAssign( ~lhs, rhs.dm_ );
466  }
468  //**********************************************************************************************
469 
470  //**Subtraction assignment to dense matrices****************************************************
482  template< typename MT2 // Type of the target dense matrix
483  , bool SO2 > // Storage order of the target dense matrix
484  friend inline EnableIf_< UseAssign<MT2> >
485  subAssign( DenseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
486  {
488 
489  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
490  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
491 
492  subAssign( ~lhs, rhs.dm_ );
493  }
495  //**********************************************************************************************
496 
497  //**Subtraction assignment to sparse matrices***************************************************
509  template< typename MT2 // Type of the target sparse matrix
510  , bool SO2 > // Storage order of the target dense matrix
511  friend inline EnableIf_< UseAssign<MT2> >
512  subAssign( SparseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
513  {
515 
516  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
517  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
518 
519  subAssign( ~lhs, rhs.dm_ );
520  }
522  //**********************************************************************************************
523 
524  //**Schur product assignment to dense matrices**************************************************
536  template< typename MT2 // Type of the target dense matrix
537  , bool SO2 > // Storage order of the target dense matrix
538  friend inline EnableIf_< UseAssign<MT2> >
539  schurAssign( DenseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
540  {
542 
543  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
544  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
545 
546  schurAssign( ~lhs, rhs.dm_ );
547  }
549  //**********************************************************************************************
550 
551  //**Schur product assignment to sparse matrices*************************************************
563  template< typename MT2 // Type of the target sparse matrix
564  , bool SO2 > // Storage order of the target dense matrix
565  friend inline EnableIf_< UseAssign<MT2> >
566  schurAssign( SparseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
567  {
569 
570  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
571  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
572 
573  schurAssign( ~lhs, rhs.dm_ );
574  }
576  //**********************************************************************************************
577 
578  //**Multiplication assignment to dense matrices*************************************************
590  template< typename MT2 // Type of the target dense matrix
591  , bool SO2 > // Storage order of the target dense matrix
592  friend inline EnableIf_< UseAssign<MT2> >
593  multAssign( DenseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
594  {
596 
597  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
598  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
599 
600  multAssign( ~lhs, rhs.dm_ );
601  }
603  //**********************************************************************************************
604 
605  //**Multiplication assignment to sparse matrices************************************************
617  template< typename MT2 // Type of the target sparse matrix
618  , bool SO2 > // Storage order of the target dense matrix
619  friend inline EnableIf_< UseAssign<MT2> >
620  multAssign( SparseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
621  {
623 
624  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
625  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
626 
627  multAssign( ~lhs, rhs.dm_ );
628  }
630  //**********************************************************************************************
631 
632  //**SMP assignment to dense matrices************************************************************
644  template< typename MT2 // Type of the target dense matrix
645  , bool SO2 > // Storage order of the target dense matrix
646  friend inline EnableIf_< UseSMPAssign<MT2> >
647  smpAssign( DenseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
648  {
650 
651  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
652  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
653 
654  smpAssign( ~lhs, rhs.dm_ );
655  }
657  //**********************************************************************************************
658 
659  //**SMP assignment to sparse matrices***********************************************************
671  template< typename MT2 // Type of the target sparse matrix
672  , bool SO2 > // Storage order of the target dense matrix
673  friend inline EnableIf_< UseSMPAssign<MT2> >
674  smpAssign( SparseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
675  {
677 
678  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
679  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
680 
681  smpAssign( ~lhs, rhs.dm_ );
682  }
684  //**********************************************************************************************
685 
686  //**SMP addition assignment to dense matrices***************************************************
698  template< typename MT2 // Type of the target dense matrix
699  , bool SO2 > // Storage order of the target dense matrix
700  friend inline EnableIf_< UseSMPAssign<MT2> >
701  smpAddAssign( DenseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
702  {
704 
705  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
706  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
707 
708  smpAddAssign( ~lhs, rhs.dm_ );
709  }
711  //**********************************************************************************************
712 
713  //**SMP addition assignment to sparse matrices**************************************************
725  template< typename MT2 // Type of the target sparse matrix
726  , bool SO2 > // Storage order of the target dense matrix
727  friend inline EnableIf_< UseSMPAssign<MT2> >
728  smpAddAssign( SparseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
729  {
731 
732  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
733  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
734 
735  smpAddAssign( ~lhs, rhs.dm_ );
736  }
738  //**********************************************************************************************
739 
740  //**SMP subtraction assignment to dense matrices************************************************
752  template< typename MT2 // Type of the target dense matrix
753  , bool SO2 > // Storage order of the target dense matrix
754  friend inline EnableIf_< UseSMPAssign<MT2> >
755  smpSubAssign( DenseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
756  {
758 
759  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
760  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
761 
762  smpSubAssign( ~lhs, rhs.dm_ );
763  }
765  //**********************************************************************************************
766 
767  //**SMP subtraction assignment to sparse matrices***********************************************
779  template< typename MT2 // Type of the target sparse matrix
780  , bool SO2 > // Storage order of the target dense matrix
781  friend inline EnableIf_< UseSMPAssign<MT2> >
782  smpSubAssign( SparseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
783  {
785 
786  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
787  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
788 
789  smpSubAssign( ~lhs, rhs.dm_ );
790  }
792  //**********************************************************************************************
793 
794  //**SMP Schur product assignment to dense matrices**********************************************
806  template< typename MT2 // Type of the target dense matrix
807  , bool SO2 > // Storage order of the target dense matrix
808  friend inline EnableIf_< UseSMPAssign<MT2> >
809  smpSchurAssign( DenseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
810  {
812 
813  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
814  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
815 
816  smpSchurAssign( ~lhs, rhs.dm_ );
817  }
819  //**********************************************************************************************
820 
821  //**SMP Schur product assignment to sparse matrices*********************************************
833  template< typename MT2 // Type of the target sparse matrix
834  , bool SO2 > // Storage order of the target dense matrix
835  friend inline EnableIf_< UseSMPAssign<MT2> >
836  smpSchurAssign( SparseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
837  {
839 
840  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
841  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
842 
843  smpSchurAssign( ~lhs, rhs.dm_ );
844  }
846  //**********************************************************************************************
847 
848  //**SMP multiplication assignment to dense matrices*********************************************
861  template< typename MT2 // Type of the target dense matrix
862  , bool SO2 > // Storage order of the target dense matrix
863  friend inline EnableIf_< UseSMPAssign<MT2> >
864  smpMultAssign( DenseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
865  {
867 
868  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
869  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
870 
871  smpMultAssign( ~lhs, rhs.dm_ );
872  }
874  //**********************************************************************************************
875 
876  //**SMP multiplication assignment to sparse matrices********************************************
889  template< typename MT2 // Type of the target sparse matrix
890  , bool SO2 > // Storage order of the target dense matrix
891  friend inline EnableIf_< UseSMPAssign<MT2> >
892  smpMultAssign( SparseMatrix<MT2,SO2>& lhs, const DMatDeclDiagExpr& rhs )
893  {
895 
896  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
897  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
898 
899  smpMultAssign( ~lhs, rhs.dm_ );
900  }
902  //**********************************************************************************************
903 
904  //**Compile time checks*************************************************************************
911  //**********************************************************************************************
912 };
913 //*************************************************************************************************
914 
915 
916 
917 
918 //=================================================================================================
919 //
920 // GLOBAL FUNCTIONS
921 //
922 //=================================================================================================
923 
924 //*************************************************************************************************
935 template< typename MT // Type of the dense matrix
936  , bool SO // Storage order
937  , typename = DisableIf_< IsDiagonal<MT> > >
938 inline const DMatDeclDiagExpr<MT,SO> decldiag_backend( const DenseMatrix<MT,SO>& dm )
939 {
941 
942  BLAZE_INTERNAL_ASSERT( isSquare( ~dm ), "Non-square matrix detected" );
943 
944  return DMatDeclDiagExpr<MT,SO>( ~dm );
945 }
947 //*************************************************************************************************
948 
949 
950 //*************************************************************************************************
961 template< typename MT // Type of the dense matrix
962  , bool SO // Storage order
963  , typename = EnableIf_< IsDiagonal<MT> > >
964 inline const MT& decldiag_backend( const DenseMatrix<MT,SO>& dm )
965 {
967 
968  BLAZE_INTERNAL_ASSERT( isSquare( ~dm ), "Non-square matrix detected" );
969 
970  return ~dm;
971 }
973 //*************************************************************************************************
974 
975 
976 //*************************************************************************************************
994 template< typename MT // Type of the dense matrix
995  , bool SO > // Storage order
996 inline decltype(auto) decldiag( const DenseMatrix<MT,SO>& dm )
997 {
999 
1000  if( !isSquare( ~dm ) ) {
1001  BLAZE_THROW_INVALID_ARGUMENT( "Invalid diagonal matrix specification" );
1002  }
1003 
1004  return decldiag_backend( ~dm );
1005 }
1006 //*************************************************************************************************
1007 
1008 
1009 
1010 
1011 //=================================================================================================
1012 //
1013 // GLOBAL RESTRUCTURING FUNCTIONS
1014 //
1015 //=================================================================================================
1016 
1017 //*************************************************************************************************
1031 template< typename MT // Type of the left-hand side dense matrix
1032  , typename ST // Type of the right-hand side scalar value
1033  , bool SO // Storage order
1034  , typename = DisableIf_< IsDiagonal<MT> > >
1035 inline decltype(auto) decldiag( const DMatScalarMultExpr<MT,ST,SO>& dm )
1036 {
1038 
1039  if( !isSquare( dm ) ) {
1040  BLAZE_THROW_INVALID_ARGUMENT( "Invalid diagonal matrix specification" );
1041  }
1042 
1043  return decldiag( dm.leftOperand() ) * dm.rightOperand();
1044 }
1046 //*************************************************************************************************
1047 
1048 
1049 
1050 
1051 //=================================================================================================
1052 //
1053 // ROWS SPECIALIZATIONS
1054 //
1055 //=================================================================================================
1056 
1057 //*************************************************************************************************
1059 template< typename MT, bool SO >
1060 struct Rows< DMatDeclDiagExpr<MT,SO> >
1061  : public Rows<MT>
1062 {};
1064 //*************************************************************************************************
1065 
1066 
1067 
1068 
1069 //=================================================================================================
1070 //
1071 // COLUMNS SPECIALIZATIONS
1072 //
1073 //=================================================================================================
1074 
1075 //*************************************************************************************************
1077 template< typename MT, bool SO >
1078 struct Columns< DMatDeclDiagExpr<MT,SO> >
1079  : public Columns<MT>
1080 {};
1082 //*************************************************************************************************
1083 
1084 
1085 
1086 
1087 //=================================================================================================
1088 //
1089 // ISALIGNED SPECIALIZATIONS
1090 //
1091 //=================================================================================================
1092 
1093 //*************************************************************************************************
1095 template< typename MT, bool SO >
1096 struct IsAligned< DMatDeclDiagExpr<MT,SO> >
1097  : public BoolConstant< IsAligned<MT>::value >
1098 {};
1100 //*************************************************************************************************
1101 
1102 
1103 
1104 
1105 //=================================================================================================
1106 //
1107 // ISSYMMETRIC SPECIALIZATIONS
1108 //
1109 //=================================================================================================
1110 
1111 //*************************************************************************************************
1113 template< typename MT, bool SO >
1114 struct IsSymmetric< DMatDeclDiagExpr<MT,SO> >
1115  : public TrueType
1116 {};
1118 //*************************************************************************************************
1119 
1120 
1121 
1122 
1123 //=================================================================================================
1124 //
1125 // ISHERMITIAN SPECIALIZATIONS
1126 //
1127 //=================================================================================================
1128 
1129 //*************************************************************************************************
1131 template< typename MT, bool SO >
1132 struct IsHermitian< DMatDeclDiagExpr<MT,SO> >
1133  : public BoolConstant< IsHermitian<MT>::value >
1134 {};
1136 //*************************************************************************************************
1137 
1138 
1139 
1140 
1141 //=================================================================================================
1142 //
1143 // ISLOWER SPECIALIZATIONS
1144 //
1145 //=================================================================================================
1146 
1147 //*************************************************************************************************
1149 template< typename MT, bool SO >
1150 struct IsLower< DMatDeclDiagExpr<MT,SO> >
1151  : public TrueType
1152 {};
1154 //*************************************************************************************************
1155 
1156 
1157 
1158 
1159 //=================================================================================================
1160 //
1161 // ISUNILOWER SPECIALIZATIONS
1162 //
1163 //=================================================================================================
1164 
1165 //*************************************************************************************************
1167 template< typename MT, bool SO >
1168 struct IsUniLower< DMatDeclDiagExpr<MT,SO> >
1169  : public BoolConstant< IsUniLower<MT>::value >
1170 {};
1172 //*************************************************************************************************
1173 
1174 
1175 
1176 
1177 //=================================================================================================
1178 //
1179 // ISSTRICTLYLOWER SPECIALIZATIONS
1180 //
1181 //=================================================================================================
1182 
1183 //*************************************************************************************************
1185 template< typename MT, bool SO >
1186 struct IsStrictlyLower< DMatDeclDiagExpr<MT,SO> >
1187  : public BoolConstant< IsStrictlyLower<MT>::value >
1188 {};
1190 //*************************************************************************************************
1191 
1192 
1193 
1194 
1195 //=================================================================================================
1196 //
1197 // ISUPPER SPECIALIZATIONS
1198 //
1199 //=================================================================================================
1200 
1201 //*************************************************************************************************
1203 template< typename MT, bool SO >
1204 struct IsUpper< DMatDeclDiagExpr<MT,SO> >
1205  : public TrueType
1206 {};
1208 //*************************************************************************************************
1209 
1210 
1211 
1212 
1213 //=================================================================================================
1214 //
1215 // ISUNIUPPER SPECIALIZATIONS
1216 //
1217 //=================================================================================================
1218 
1219 //*************************************************************************************************
1221 template< typename MT, bool SO >
1222 struct IsUniUpper< DMatDeclDiagExpr<MT,SO> >
1223  : public BoolConstant< IsUniUpper<MT>::value >
1224 {};
1226 //*************************************************************************************************
1227 
1228 
1229 
1230 
1231 //=================================================================================================
1232 //
1233 // ISSTRICTLYUPPER SPECIALIZATIONS
1234 //
1235 //=================================================================================================
1236 
1237 //*************************************************************************************************
1239 template< typename MT, bool SO >
1240 struct IsStrictlyUpper< DMatDeclDiagExpr<MT,SO> >
1241  : public BoolConstant< IsStrictlyUpper<MT>::value >
1242 {};
1244 //*************************************************************************************************
1245 
1246 } // namespace blaze
1247 
1248 #endif
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
Header file for the decldiag trait.
decltype(auto) decldiag(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as diagonal.
Definition: DMatDeclDiagExpr.h:996
Header file for the Rows type trait.
Header file for the IsUniUpper type trait.
EnableIf_< IsDenseMatrix< MT1 > > smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:196
Header file for basic type definitions.
EnableIf_< IsDenseMatrix< MT1 > > smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:164
BLAZE_ALWAYS_INLINE auto load(size_t i, size_t j) const noexcept
Access to the SIMD elements of the matrix.
Definition: DMatDeclDiagExpr.h:242
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.In case the given data type T is not a dense or sparse matrix type and in...
Definition: StorageOrder.h:63
DeclDiagTrait_< RT > ResultType
Result type for expression template evaluations.
Definition: DMatDeclDiagExpr.h:161
Generic wrapper for a compile time constant integral value.The IntegralConstant class template repres...
Definition: IntegralConstant.h:71
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type...
Definition: DenseMatrix.h:61
Base class for all declaration expression templates.The Declaration class serves as a tag for all dec...
Definition: Declaration.h:70
EnableIf_< IsDenseVector< VT1 > > smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP multiplication assignment of a vector to a dense vector...
Definition: DenseVector.h:193
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatDeclDiagExpr.h:298
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:88
#define BLAZE_CREATE_HAS_TYPE_MEMBER_TYPE_TRAIT(TYPE_TRAIT_NAME, MEMBER_NAME)
Macro for the creation of a type trait for compile time checks for member types.This macro creates th...
Definition: HasMember.h:182
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:88
Header file for the RequiresEvaluation type trait.
Expression object for the explicit diagonal declaration of dense matrices.The DMatDeclDiagExpr class ...
Definition: DMatDeclDiagExpr.h:100
Header file for the SIMD trait.
Header file for the IsUniLower type trait.
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:343
EnableIf_< IsDenseMatrix< MT1 > > smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:133
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:78
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:129
Header file for all forward declarations for sparse vectors and matrices.
Base class for all decldiag expression templates.The DeclDiagExpr class serves as a tag for all expre...
Definition: DeclDiagExpr.h:66
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:363
Compile time check for the alignment of data types.This type trait tests whether the given data type ...
Definition: IsAligned.h:87
Constraint on the data type.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:72
Compile time check for upper unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniUpper.h:86
Header file for the DisableIf class template.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatDeclDiagExpr.h:209
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
Header file for the If class template.
Header file for the DeclDiagExpr base class.
If_< IsExpression< MT >, const MT, const MT &> Operand
Composite data type of the dense matrix expression.
Definition: DMatDeclDiagExpr.h:174
EnableIf_< IsDenseMatrix< MT1 > > smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:102
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatDeclDiagExpr.h:352
Expression object for dense matrix-scalar multiplications.The DMatScalarMultExpr class represents the...
Definition: DMatScalarMultExpr.h:110
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the DenseMatrix base class.
Header file for the Columns type trait.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3087
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
#define BLAZE_CONSTRAINT_MUST_NOT_BE_DIAGONAL_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a diagonal matrix type, a compilation error is created.
Definition: Diagonal.h:79
Header file for the IsLower type trait.
Header file for the IsAligned type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_MATMATMULTEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a matrix/matrix multiplication expressio...
Definition: MatMatMultExpr.h:88
RightOperand rightOperand() const noexcept
Returns the right-hand side scalar operand.
Definition: DMatScalarMultExpr.h:567
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatDeclDiagExpr.h:342
Constraints on the storage order of matrix types.
Operand operand() const noexcept
Returns the dense matrix operand.
Definition: DMatDeclDiagExpr.h:308
const ElementType * data() const noexcept
Low-level data access to the matrix elements.
Definition: DMatDeclDiagExpr.h:256
Compile time check for symmetric matrices.This type trait tests whether or not the given template par...
Definition: IsSymmetric.h:85
DMatDeclDiagExpr(const MT &dm) noexcept
Constructor for the DMatDeclDiagExpr class.
Definition: DMatDeclDiagExpr.h:195
ElementType_< MT > ElementType
Resulting element type.
Definition: DMatDeclDiagExpr.h:164
Header file for the exception macros of the math module.
Compile time check for strictly upper triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyUpper.h:86
Header file for all forward declarations for expression class templates.
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatDeclDiagExpr.h:163
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatDeclDiagExpr.h:288
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Compile time check for lower unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniLower.h:86
Header file for the Declaration base class.
Header file for run time assertion macros.
ReturnType_< MT > ReturnType
Return type for expression template evaluations.
Definition: DMatDeclDiagExpr.h:165
Utility type for generic codes.
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:154
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:296
#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
Compile time check for Hermitian matrices.This type trait tests whether or not the given template par...
Definition: IsHermitian.h:85
Constraint on the data type.
Header file for the HasMember type traits.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
typename T::OppositeType OppositeType_
Alias declaration for nested OppositeType type definitions.The OppositeType_ alias declaration provid...
Definition: Aliases.h:263
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: DMatDeclDiagExpr.h:267
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatDeclDiagExpr.h:162
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatDeclDiagExpr.h:332
Header file for the implementation of the base template of the DiagonalMatrix.
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatDeclDiagExpr.h:224
Operand dm_
Dense matrix of the decldiag expression.
Definition: DMatDeclDiagExpr.h:359
Header file for the IntegralConstant class template.
Compile time evaluation of the number of columns of a matrix.The Columns type trait evaluates the num...
Definition: Columns.h:75
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: DMatDeclDiagExpr.h:278
Compile time evaluation of the number of rows of a matrix.The Rows type trait evaluates the number of...
Definition: Rows.h:75
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:423
Header file for the IsUpper type trait.
If_< RequiresEvaluation< MT >, const ResultType, const DMatDeclDiagExpr &> CompositeType
Data type for composite expression templates.
Definition: DMatDeclDiagExpr.h:168
typename DeclDiagTrait< MT >::Type DeclDiagTrait_
Auxiliary alias declaration for the DeclDiagTrait type trait.The DeclDiagTrait_ alias declaration pro...
Definition: DeclDiagTrait.h:176
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatDeclDiagExpr.h:320
Constraint on the data type.
Header file for the IsHermitian type trait.
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:742
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatScalarMultExpr.h:557
typename GetConstIterator< MT >::Type ConstIterator
Iterator over the elements of the dense matrix.
Definition: DMatDeclDiagExpr.h:171
#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
ResultType_< MT > RT
Result type of the dense matrix expression.
Definition: DMatDeclDiagExpr.h:106
Header file for the TrueType type/value trait base class.
Header file for the IsExpression type trait class.
Header file for the function trace functionality.