SMatDeclDiagExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATDECLDIAGEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATDECLDIAGEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
45 #include <blaze/math/Aliases.h>
49 #include <blaze/math/Exception.h>
62 #include <blaze/util/Assert.h>
63 #include <blaze/util/DisableIf.h>
64 #include <blaze/util/EnableIf.h>
66 #include <blaze/util/InvalidType.h>
67 #include <blaze/util/mpl/If.h>
68 #include <blaze/util/TrueType.h>
69 #include <blaze/util/Types.h>
71 
72 
73 namespace blaze {
74 
75 //=================================================================================================
76 //
77 // CLASS SMATDECLHERMEXPR
78 //
79 //=================================================================================================
80 
81 //*************************************************************************************************
88 template< typename MT // Type of the sparse matrix
89  , bool SO > // Storage order
90 class SMatDeclDiagExpr
91  : public DeclDiagExpr< SparseMatrix< SMatDeclDiagExpr<MT,SO>, SO > >
92  , public Declaration<MT>
93 {
94  private:
95  //**Type definitions****************************************************************************
96  using RT = ResultType_t<MT>;
97 
99  BLAZE_CREATE_GET_TYPE_MEMBER_TYPE_TRAIT( GetConstIterator, ConstIterator, INVALID_TYPE );
100  //**********************************************************************************************
101 
102  //**Serial evaluation strategy******************************************************************
104 
110  static constexpr bool useAssign = RequiresEvaluation_v<MT>;
111 
113  template< typename MT2 >
115  static constexpr bool UseAssign_v = useAssign;
117  //**********************************************************************************************
118 
119  //**Parallel evaluation strategy****************************************************************
121 
127  template< typename MT2 >
128  static constexpr bool UseSMPAssign_v = ( MT2::smpAssignable && useAssign );
130  //**********************************************************************************************
131 
132  public:
133  //**Type definitions****************************************************************************
141 
144 
146  using ConstIterator = GetConstIterator_t<MT>;
147 
149  using Operand = If_t< IsExpression_v<MT>, const MT, const MT& >;
150  //**********************************************************************************************
151 
152  //**Compilation flags***************************************************************************
154  static constexpr bool smpAssignable = MT::smpAssignable;
155  //**********************************************************************************************
156 
157  //**Constructor*********************************************************************************
162  explicit inline SMatDeclDiagExpr( const MT& sm ) noexcept
163  : sm_( sm ) // Sparse matrix of the decldiag expression
164  {
165  BLAZE_INTERNAL_ASSERT( isSquare( ~sm ), "Non-square matrix detected" );
166  }
167  //**********************************************************************************************
168 
169  //**Access operator*****************************************************************************
176  inline ReturnType operator()( size_t i, size_t j ) const {
177  BLAZE_INTERNAL_ASSERT( i < sm_.rows() , "Invalid row access index" );
178  BLAZE_INTERNAL_ASSERT( j < sm_.columns(), "Invalid column access index" );
179  return sm_(i,j);
180  }
181  //**********************************************************************************************
182 
183  //**At function*********************************************************************************
191  inline ReturnType at( size_t i, size_t j ) const {
192  if( i >= sm_.rows() ) {
193  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
194  }
195  if( j >= sm_.columns() ) {
196  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
197  }
198  return (*this)(i,j);
199  }
200  //**********************************************************************************************
201 
202  //**Begin function******************************************************************************
208  inline ConstIterator begin( size_t i ) const {
209  return ConstIterator( sm_.begin(i) );
210  }
211  //**********************************************************************************************
212 
213  //**End function********************************************************************************
219  inline ConstIterator end( size_t i ) const {
220  return ConstIterator( sm_.end(i) );
221  }
222  //**********************************************************************************************
223 
224  //**Rows function*******************************************************************************
229  inline size_t rows() const noexcept {
230  return sm_.rows();
231  }
232  //**********************************************************************************************
233 
234  //**Columns function****************************************************************************
239  inline size_t columns() const noexcept {
240  return sm_.columns();
241  }
242  //**********************************************************************************************
243 
244  //**NonZeros function***************************************************************************
249  inline size_t nonZeros() const {
250  return sm_.nonZeros();
251  }
252  //**********************************************************************************************
253 
254  //**NonZeros function***************************************************************************
260  inline size_t nonZeros( size_t i ) const {
261  return sm_.nonZeros(i);
262  }
263  //**********************************************************************************************
264 
265  //**Operand access******************************************************************************
270  inline Operand operand() const noexcept {
271  return sm_;
272  }
273  //**********************************************************************************************
274 
275  //**********************************************************************************************
281  template< typename T >
282  inline bool canAlias( const T* alias ) const noexcept {
283  return sm_.canAlias( alias );
284  }
285  //**********************************************************************************************
286 
287  //**********************************************************************************************
293  template< typename T >
294  inline bool isAliased( const T* alias ) const noexcept {
295  return sm_.isAliased( alias );
296  }
297  //**********************************************************************************************
298 
299  //**********************************************************************************************
304  inline bool canSMPAssign() const noexcept {
305  return sm_.canSMPAssign();
306  }
307  //**********************************************************************************************
308 
309  private:
310  //**Member variables****************************************************************************
312  //**********************************************************************************************
313 
314  //**Assignment to dense matrices****************************************************************
326  template< typename MT2 // Type of the target dense matrix
327  , bool SO2 > // Storage order of the target dense matrix
328  friend inline auto assign( DenseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
330  {
332 
333  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
334  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
335 
336  assign( ~lhs, rhs.sm_ );
337  }
339  //**********************************************************************************************
340 
341  //**Assignment to sparse matrices***************************************************************
353  template< typename MT2 // Type of the target sparse matrix
354  , bool SO2 > // Storage order of the target sparse matrix
355  friend inline auto assign( SparseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
357  {
359 
360  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
361  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
362 
363  assign( ~lhs, rhs.sm_ );
364  }
366  //**********************************************************************************************
367 
368  //**Addition assignment to dense matrices*******************************************************
380  template< typename MT2 // Type of the target dense matrix
381  , bool SO2 > // Storage order of the target dense matrix
382  friend inline auto addAssign( DenseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
383  -> EnableIf_t< UseAssign_v<MT2> >
384  {
386 
387  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
388  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
389 
390  addAssign( ~lhs, rhs.sm_ );
391  }
393  //**********************************************************************************************
394 
395  //**Addition assignment to sparse matrices******************************************************
407  template< typename MT2 // Type of the target sparse matrix
408  , bool SO2 > // Storage order of the target sparse matrix
409  friend inline auto addAssign( SparseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
410  -> EnableIf_t< UseAssign_v<MT2> >
411  {
413 
414  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
415  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
416 
417  addAssign( ~lhs, rhs.sm_ );
418  }
420  //**********************************************************************************************
421 
422  //**Subtraction assignment to dense matrices****************************************************
434  template< typename MT2 // Type of the target dense matrix
435  , bool SO2 > // Storage order of the target dense matrix
436  friend inline auto subAssign( DenseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
437  -> EnableIf_t< UseAssign_v<MT2> >
438  {
440 
441  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
442  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
443 
444  subAssign( ~lhs, rhs.sm_ );
445  }
447  //**********************************************************************************************
448 
449  //**Subtraction assignment to sparse matrices***************************************************
461  template< typename MT2 // Type of the target sparse matrix
462  , bool SO2 > // Storage order of the target sparse matrix
463  friend inline auto subAssign( SparseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
464  -> EnableIf_t< UseAssign_v<MT2> >
465  {
467 
468  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
469  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
470 
471  subAssign( ~lhs, rhs.sm_ );
472  }
474  //**********************************************************************************************
475 
476  //**Schur product assignment to dense matrices**************************************************
488  template< typename MT2 // Type of the target dense matrix
489  , bool SO2 > // Storage order of the target dense matrix
490  friend inline auto schurAssign( DenseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
491  -> EnableIf_t< UseAssign_v<MT2> >
492  {
494 
495  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
496  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
497 
498  schurAssign( ~lhs, rhs.sm_ );
499  }
501  //**********************************************************************************************
502 
503  //**Schur product assignment to sparse matrices*************************************************
515  template< typename MT2 // Type of the target sparse matrix
516  , bool SO2 > // Storage order of the target sparse matrix
517  friend inline auto schurAssign( SparseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
518  -> EnableIf_t< UseAssign_v<MT2> >
519  {
521 
522  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
523  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
524 
525  schurAssign( ~lhs, rhs.sm_ );
526  }
528  //**********************************************************************************************
529 
530  //**Multiplication assignment to dense matrices*************************************************
542  template< typename MT2 // Type of the target dense matrix
543  , bool SO2 > // Storage order of the target dense matrix
544  friend inline auto multAssign( DenseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
545  -> EnableIf_t< UseAssign_v<MT2> >
546  {
548 
549  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
550  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
551 
552  multAssign( ~lhs, rhs.sm_ );
553  }
555  //**********************************************************************************************
556 
557  //**Multiplication assignment to sparse matrices************************************************
569  template< typename MT2 // Type of the target sparse matrix
570  , bool SO2 > // Storage order of the target sparse matrix
571  friend inline auto multAssign( SparseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
572  -> EnableIf_t< UseAssign_v<MT2> >
573  {
575 
576  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
577  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
578 
579  multAssign( ~lhs, rhs.sm_ );
580  }
582  //**********************************************************************************************
583 
584  //**SMP assignment to dense matrices************************************************************
596  template< typename MT2 // Type of the target dense matrix
597  , bool SO2 > // Storage order of the target dense matrix
598  friend inline auto smpAssign( DenseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
599  -> EnableIf_t< UseSMPAssign_v<MT2> >
600  {
602 
603  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
604  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
605 
606  smpAssign( ~lhs, rhs.sm_ );
607  }
609  //**********************************************************************************************
610 
611  //**SMP assignment to sparse matrices***********************************************************
623  template< typename MT2 // Type of the target sparse matrix
624  , bool SO2 > // Storage order of the target sparse matrix
625  friend inline auto smpAssign( SparseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
626  -> EnableIf_t< UseSMPAssign_v<MT2> >
627  {
629 
630  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
631  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
632 
633  smpAssign( ~lhs, rhs.sm_ );
634  }
636  //**********************************************************************************************
637 
638  //**SMP addition assignment to dense matrices***************************************************
650  template< typename MT2 // Type of the target dense matrix
651  , bool SO2 > // Storage order of the target dense matrix
652  friend inline auto smpAddAssign( DenseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
653  -> EnableIf_t< UseSMPAssign_v<MT2> >
654  {
656 
657  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
658  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
659 
660  smpAddAssign( ~lhs, rhs.sm_ );
661  }
663  //**********************************************************************************************
664 
665  //**SMP addition assignment to sparse matrices**************************************************
677  template< typename MT2 // Type of the target sparse matrix
678  , bool SO2 > // Storage order of the target sparse matrix
679  friend inline auto smpAddAssign( SparseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
680  -> EnableIf_t< UseSMPAssign_v<MT2> >
681  {
683 
684  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
685  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
686 
687  smpAddAssign( ~lhs, rhs.sm_ );
688  }
690  //**********************************************************************************************
691 
692  //**SMP subtraction assignment to dense matrices************************************************
704  template< typename MT2 // Type of the target dense matrix
705  , bool SO2 > // Storage order of the target dense matrix
706  friend inline auto smpSubAssign( DenseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
707  -> EnableIf_t< UseSMPAssign_v<MT2> >
708  {
710 
711  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
712  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
713 
714  smpSubAssign( ~lhs, rhs.sm_ );
715  }
717  //**********************************************************************************************
718 
719  //**SMP subtraction assignment to sparse matrices***********************************************
731  template< typename MT2 // Type of the target sparse matrix
732  , bool SO2 > // Storage order of the target sparse matrix
733  friend inline auto smpSubAssign( SparseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
734  -> EnableIf_t< UseSMPAssign_v<MT2> >
735  {
737 
738  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
739  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
740 
741  smpSubAssign( ~lhs, rhs.sm_ );
742  }
744  //**********************************************************************************************
745 
746  //**SMP Schur product assignment to dense matrices**********************************************
758  template< typename MT2 // Type of the target dense matrix
759  , bool SO2 > // Storage order of the target dense matrix
760  friend inline auto smpSchurAssign( DenseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
761  -> EnableIf_t< UseSMPAssign_v<MT2> >
762  {
764 
765  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
766  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
767 
768  smpSchurAssign( ~lhs, rhs.sm_ );
769  }
771  //**********************************************************************************************
772 
773  //**SMP Schur product assignment to sparse matrices*********************************************
785  template< typename MT2 // Type of the target sparse matrix
786  , bool SO2 > // Storage order of the target sparse matrix
787  friend inline auto smpSchurAssign( SparseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
788  -> EnableIf_t< UseSMPAssign_v<MT2> >
789  {
791 
792  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
793  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
794 
795  smpSchurAssign( ~lhs, rhs.sm_ );
796  }
798  //**********************************************************************************************
799 
800  //**SMP multiplication assignment to dense matrices*********************************************
813  template< typename MT2 // Type of the target dense matrix
814  , bool SO2 > // Storage order of the target dense matrix
815  friend inline auto smpMultAssign( DenseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
816  -> EnableIf_t< UseSMPAssign_v<MT2> >
817  {
819 
820  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
821  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
822 
823  smpMultAssign( ~lhs, rhs.sm_ );
824  }
826  //**********************************************************************************************
827 
828  //**SMP multiplication assignment to sparse matrices********************************************
841  template< typename MT2 // Type of the target sparse matrix
842  , bool SO2 > // Storage order of the target sparse matrix
843  friend inline auto smpMultAssign( SparseMatrix<MT2,SO2>& lhs, const SMatDeclDiagExpr& rhs )
844  -> EnableIf_t< UseSMPAssign_v<MT2> >
845  {
847 
848  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
849  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
850 
851  smpMultAssign( ~lhs, rhs.sm_ );
852  }
854  //**********************************************************************************************
855 
856  //**Compile time checks*************************************************************************
862  //**********************************************************************************************
863 };
864 //*************************************************************************************************
865 
866 
867 
868 
869 //=================================================================================================
870 //
871 // GLOBAL FUNCTIONS
872 //
873 //=================================================================================================
874 
875 //*************************************************************************************************
886 template< typename MT // Type of the sparse matrix
887  , bool SO // Storage order
888  , DisableIf_t< IsDiagonal_v<MT> >* = nullptr >
889 inline const SMatDeclDiagExpr<MT,SO> decldiag_backend( const SparseMatrix<MT,SO>& sm )
890 {
892 
893  BLAZE_INTERNAL_ASSERT( isSquare( ~sm ), "Non-square matrix detected" );
894 
895  return SMatDeclDiagExpr<MT,SO>( ~sm );
896 }
898 //*************************************************************************************************
899 
900 
901 //*************************************************************************************************
912 template< typename MT // Type of the sparse matrix
913  , bool SO // Storage order
914  , EnableIf_t< IsDiagonal_v<MT> >* = nullptr >
915 inline const MT& decldiag_backend( const SparseMatrix<MT,SO>& sm )
916 {
918 
919  BLAZE_INTERNAL_ASSERT( isSquare( ~sm ), "Non-square matrix detected" );
920 
921  return ~sm;
922 }
924 //*************************************************************************************************
925 
926 
927 //*************************************************************************************************
945 template< typename MT // Type of the sparse matrix
946  , bool SO > // Storage order
947 inline decltype(auto) decldiag( const SparseMatrix<MT,SO>& sm )
948 {
950 
951  if( !isSquare( ~sm ) ) {
952  BLAZE_THROW_INVALID_ARGUMENT( "Invalid diagonal matrix specification" );
953  }
954 
955  return decldiag_backend( ~sm );
956 }
957 //*************************************************************************************************
958 
959 
960 
961 
962 //=================================================================================================
963 //
964 // GLOBAL RESTRUCTURING FUNCTIONS
965 //
966 //=================================================================================================
967 
968 //*************************************************************************************************
982 template< typename MT // Type of the left-hand side sparse matrix
983  , typename ST // Type of the right-hand side scalar value
984  , bool SO // Storage order
985  , DisableIf_t< IsDiagonal_v<MT> >* = nullptr >
986 inline decltype(auto) decldiag( const SMatScalarMultExpr<MT,ST,SO>& sm )
987 {
989 
990  if( !isSquare( ~sm ) ) {
991  BLAZE_THROW_INVALID_ARGUMENT( "Invalid diagonal matrix specification" );
992  }
993 
994  return decldiag( sm.leftOperand() ) * sm.rightOperand();
995 }
997 //*************************************************************************************************
998 
999 
1000 
1001 
1002 //=================================================================================================
1003 //
1004 // ISSYMMETRIC SPECIALIZATIONS
1005 //
1006 //=================================================================================================
1007 
1008 //*************************************************************************************************
1010 template< typename MT, bool SO >
1011 struct IsSymmetric< SMatDeclDiagExpr<MT,SO> >
1012  : public TrueType
1013 {};
1015 //*************************************************************************************************
1016 
1017 
1018 
1019 
1020 //=================================================================================================
1021 //
1022 // ISLOWER SPECIALIZATIONS
1023 //
1024 //=================================================================================================
1025 
1026 //*************************************************************************************************
1028 template< typename MT, bool SO >
1029 struct IsLower< SMatDeclDiagExpr<MT,SO> >
1030  : public TrueType
1031 {};
1033 //*************************************************************************************************
1034 
1035 
1036 
1037 
1038 //=================================================================================================
1039 //
1040 // ISUPPER SPECIALIZATIONS
1041 //
1042 //=================================================================================================
1043 
1044 //*************************************************************************************************
1046 template< typename MT, bool SO >
1047 struct IsUpper< SMatDeclDiagExpr<MT,SO> >
1048  : public TrueType
1049 {};
1051 //*************************************************************************************************
1052 
1053 } // namespace blaze
1054 
1055 #endif
GetConstIterator_t< MT > ConstIterator
Iterator over the elements of the dense matrix.
Definition: SMatDeclDiagExpr.h:146
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatDeclDiagExpr.h:260
#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:975
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
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatDeclDiagExpr.h:282
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
#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
Header file for the IsDiagonal type trait.
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
Expression object for the explicit diagonal declaration of sparse matrices.The SMatDeclDiagExpr class...
Definition: Forward.h:110
If_t< RequiresEvaluation_v< MT >, const ResultType, const SMatDeclDiagExpr &> CompositeType
Data type for composite expression templates.
Definition: SMatDeclDiagExpr.h:143
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SMatDeclDiagExpr.h:229
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 RequiresEvaluation type trait.
SMatDeclDiagExpr(const MT &sm) noexcept
Constructor for the SMatDeclDiagExpr class.
Definition: SMatDeclDiagExpr.h:162
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.The ReturnType_t alias declaration provides ...
Definition: Aliases.h:410
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:80
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:137
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
Header file for all forward declarations for sparse vectors and matrices.
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatDeclDiagExpr.h:294
Header file for the SparseMatrix base class.
Constraint on the data type.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
BLAZE_CREATE_GET_TYPE_MEMBER_TYPE_TRAIT(GetConstIterator, ConstIterator, INVALID_TYPE)
Definition of the GetConstIterator 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:58
Header file for the If class template.
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the diagonal declaration expression...
Definition: SMatDeclDiagExpr.h:110
Header file for the DeclDiagExpr base class.
ElementType_t< MT > ElementType
Resulting element type.
Definition: SMatDeclDiagExpr.h:139
#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
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: SMatDeclDiagExpr.h:239
#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 GetMemberType type trait.
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: SMatDeclDiagExpr.h:219
Header file for the IsLower type trait.
Constraints on the storage order of matrix types.
Header file for the exception macros of the math module.
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: SMatDeclDiagExpr.h:208
Header file for all forward declarations for expression class templates.
Operand operand() const noexcept
Returns the sparse matrix operand.
Definition: SMatDeclDiagExpr.h:270
Header file for the EnableIf class template.
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.The OppositeType_t alias declaration provi...
Definition: Aliases.h:270
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: SMatDeclDiagExpr.h:304
Operand sm_
Sparse matrix of the decldiag expression.
Definition: SMatDeclDiagExpr.h:311
Header file for the Declaration base class.
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.The TransposeType_t alias declaration pro...
Definition: Aliases.h:470
Header file for run time assertion macros.
Utility type for generic codes.
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:131
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatDeclDiagExpr.h:249
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatDeclDiagExpr.h:138
#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
Constraint on the data type.
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
DeclDiagTrait_t< RT > ResultType
Result type for expression template evaluations.
Definition: SMatDeclDiagExpr.h:136
If_t< IsExpression_v< MT >, const MT, const MT &> Operand
Composite data type of the sparse matrix expression.
Definition: SMatDeclDiagExpr.h:149
auto smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:194
Header file for the implementation of the base template of the DiagonalMatrix.
auto smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:162
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatDeclDiagExpr.h:137
ResultType_t< MT > RT
Result type of the sparse matrix expression.
Definition: SMatDeclDiagExpr.h:96
ReturnType_t< MT > ReturnType
Return type for expression template evaluations.
Definition: SMatDeclDiagExpr.h:140
Header file for the IsUpper type trait.
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: SMatDeclDiagExpr.h:154
typename DeclDiagTrait< MT >::Type DeclDiagTrait_t
Auxiliary alias declaration for the DeclDiagTrait type trait.The DeclDiagTrait_t alias declaration pr...
Definition: DeclDiagTrait.h:160
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:951
#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
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatDeclDiagExpr.h:176
auto smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP multiplication assignment of a vector to a dense vector...
Definition: DenseVector.h:191
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
Header file for the TrueType type/value trait base class.
Header file for the IsExpression type trait class.
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatDeclDiagExpr.h:191
Header file for the function trace functionality.