35#ifndef _BLAZE_MATH_EXPRESSIONS_SMATDECLDIAGEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_SMATDECLDIAGEXPR_H_
90 :
public DeclDiagExpr< SparseMatrix< SMatDeclDiagExpr<MT,SO>, SO > >
109 static constexpr bool useAssign = RequiresEvaluation_v<MT>;
113 template<
typename MT2 >
114 static constexpr bool UseAssign_v =
useAssign;
126 template<
typename MT2 >
127 static constexpr bool UseSMPAssign_v = ( MT2::smpAssignable &&
useAssign );
195 if( i >=
sm_.rows() ) {
198 if( j >=
sm_.columns() ) {
232 inline size_t rows() const noexcept {
243 return sm_.columns();
253 return sm_.nonZeros();
264 return sm_.nonZeros(i);
284 template<
typename T >
285 inline bool canAlias(
const T* alias )
const noexcept {
286 return sm_.canAlias( alias );
296 template<
typename T >
297 inline bool isAliased(
const T* alias )
const noexcept {
298 return sm_.isAliased( alias );
308 return sm_.canSMPAssign();
329 template<
typename MT2
339 assign( *lhs, rhs.sm_ );
356 template<
typename MT2
366 assign( *lhs, rhs.sm_ );
383 template<
typename MT2
385 friend inline auto addAssign( DenseMatrix<MT2,SO2>& lhs,
const SMatDeclDiagExpr& rhs )
386 -> EnableIf_t< UseAssign_v<MT2> >
393 addAssign( *lhs, rhs.sm_ );
410 template<
typename MT2
412 friend inline auto addAssign( SparseMatrix<MT2,SO2>& lhs,
const SMatDeclDiagExpr& rhs )
413 -> EnableIf_t< UseAssign_v<MT2> >
420 addAssign( *lhs, rhs.sm_ );
437 template<
typename MT2
439 friend inline auto subAssign( DenseMatrix<MT2,SO2>& lhs,
const SMatDeclDiagExpr& rhs )
440 -> EnableIf_t< UseAssign_v<MT2> >
447 subAssign( *lhs, rhs.sm_ );
464 template<
typename MT2
466 friend inline auto subAssign( SparseMatrix<MT2,SO2>& lhs,
const SMatDeclDiagExpr& rhs )
467 -> EnableIf_t< UseAssign_v<MT2> >
474 subAssign( *lhs, rhs.sm_ );
491 template<
typename MT2
493 friend inline auto schurAssign( DenseMatrix<MT2,SO2>& lhs,
const SMatDeclDiagExpr& rhs )
494 -> EnableIf_t< UseAssign_v<MT2> >
501 schurAssign( *lhs, rhs.sm_ );
518 template<
typename MT2
520 friend inline auto schurAssign( SparseMatrix<MT2,SO2>& lhs,
const SMatDeclDiagExpr& rhs )
521 -> EnableIf_t< UseAssign_v<MT2> >
528 schurAssign( *lhs, rhs.sm_ );
545 template<
typename MT2
547 friend inline auto multAssign( DenseMatrix<MT2,SO2>& lhs,
const SMatDeclDiagExpr& rhs )
548 -> EnableIf_t< UseAssign_v<MT2> >
555 multAssign( *lhs, rhs.sm_ );
572 template<
typename MT2
574 friend inline auto multAssign( SparseMatrix<MT2,SO2>& lhs,
const SMatDeclDiagExpr& rhs )
575 -> EnableIf_t< UseAssign_v<MT2> >
582 multAssign( *lhs, rhs.sm_ );
599 template<
typename MT2
602 -> EnableIf_t< UseSMPAssign_v<MT2> >
626 template<
typename MT2
629 -> EnableIf_t< UseSMPAssign_v<MT2> >
653 template<
typename MT2
656 -> EnableIf_t< UseSMPAssign_v<MT2> >
680 template<
typename MT2
683 -> EnableIf_t< UseSMPAssign_v<MT2> >
707 template<
typename MT2
710 -> EnableIf_t< UseSMPAssign_v<MT2> >
734 template<
typename MT2
737 -> EnableIf_t< UseSMPAssign_v<MT2> >
761 template<
typename MT2
764 -> EnableIf_t< UseSMPAssign_v<MT2> >
788 template<
typename MT2
791 -> EnableIf_t< UseSMPAssign_v<MT2> >
816 template<
typename MT2
819 -> EnableIf_t< UseSMPAssign_v<MT2> >
844 template<
typename MT2
847 -> EnableIf_t< UseSMPAssign_v<MT2> >
891 , DisableIf_t< IsDiagonal_v<MT> >* =
nullptr >
892inline const SMatDeclDiagExpr<MT,SO> decldiag_backend(
const SparseMatrix<MT,SO>& sm )
898 return SMatDeclDiagExpr<MT,SO>( *sm );
917 , EnableIf_t< IsDiagonal_v<MT> >* =
nullptr >
918inline const MT& decldiag_backend(
const SparseMatrix<MT,SO>& sm )
958 return decldiag_backend( *sm );
973template<
typename MT,
bool SO >
974struct IsSymmetric< SMatDeclDiagExpr<MT,SO> >
991template<
typename MT,
bool SO >
992struct IsLower< SMatDeclDiagExpr<MT,SO> >
1009template<
typename MT,
bool SO >
1010struct IsUpper< SMatDeclDiagExpr<MT,SO> >
Header file for auxiliary alias declarations.
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.
Definition: Aliases.h:470
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition: Aliases.h:450
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.
Definition: Aliases.h:310
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition: Aliases.h:550
Header file for run time assertion macros.
Header file for the decldiag trait.
Constraint on the data type.
Header file for the EnableIf class template.
Header file for the function trace functionality.
Header file for the GetMemberType type trait.
Header file for the If class template.
Header file for the IntegralConstant class template.
Utility type for generic codes.
Header file for the IsDiagonal type trait.
Header file for the IsExpression type trait class.
Header file for the IsLower type trait.
Header file for the IsSymmetric type trait.
Header file for the IsUpper type trait.
Header file for the implementation of the base template of the DiagonalMatrix.
Base class for dense matrices.
Definition: DenseMatrix.h:82
Expression object for the explicit diagonal declaration of sparse matrices.
Definition: SMatDeclDiagExpr.h:92
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatDeclDiagExpr.h:285
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: SMatDeclDiagExpr.h:242
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: SMatDeclDiagExpr.h:307
Operand operand() const noexcept
Returns the sparse matrix operand.
Definition: SMatDeclDiagExpr.h:273
SMatDeclDiagExpr(const MT &sm) noexcept
Constructor for the SMatDeclDiagExpr class.
Definition: SMatDeclDiagExpr.h:165
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the diagonal declaration expression.
Definition: SMatDeclDiagExpr.h:109
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatDeclDiagExpr.h:141
BLAZE_CREATE_GET_TYPE_MEMBER_TYPE_TRAIT(GetConstIterator, ConstIterator, INVALID_TYPE)
Definition of the GetConstIterator type trait.
If_t< IsExpression_v< MT >, const MT, const MT & > Operand
Composite data type of the sparse matrix expression.
Definition: SMatDeclDiagExpr.h:152
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatDeclDiagExpr.h:194
ElementType_t< MT > ElementType
Resulting element type.
Definition: SMatDeclDiagExpr.h:142
ResultType_t< MT > RT
Result type of the sparse matrix expression.
Definition: SMatDeclDiagExpr.h:95
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatDeclDiagExpr.h:179
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: SMatDeclDiagExpr.h:211
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: SMatDeclDiagExpr.h:157
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatDeclDiagExpr.h:140
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatDeclDiagExpr.h:263
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SMatDeclDiagExpr.h:232
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: SMatDeclDiagExpr.h:222
If_t< RequiresEvaluation_v< MT >, const ResultType, const SMatDeclDiagExpr & > CompositeType
Data type for composite expression templates.
Definition: SMatDeclDiagExpr.h:146
DeclDiagTrait_t< RT > ResultType
Result type for expression template evaluations.
Definition: SMatDeclDiagExpr.h:139
ReturnType_t< MT > ReturnType
Return type for expression template evaluations.
Definition: SMatDeclDiagExpr.h:143
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatDeclDiagExpr.h:297
GetConstIterator_t< MT > ConstIterator
Iterator over the elements of the dense matrix.
Definition: SMatDeclDiagExpr.h:149
Operand sm_
Sparse matrix of the decldiag expression.
Definition: SMatDeclDiagExpr.h:314
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatDeclDiagExpr.h:252
Base class for sparse matrices.
Definition: SparseMatrix.h:77
Constraint on the data type.
Header file for the DeclDiagExpr base class.
Header file for the Declaration base class.
Header file for the SparseMatrix base class.
decltype(auto) decldiag(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as diagonal.
Definition: DMatDeclDiagExpr.h:978
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: SparseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_DIAGONAL_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Diagonal.h:79
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.
Definition: StorageOrder.h:63
typename DeclDiagTrait< MT >::Type DeclDiagTrait_t
Auxiliary alias declaration for the DeclDiagTrait type trait.
Definition: DeclDiagTrait.h:145
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:1383
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
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
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
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:192
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
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
BoolConstant< true > TrueType
Type traits base class.
Definition: IntegralConstant.h:132
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition: If.h:108
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition: Exception.h:331
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition: FunctionTrace.h:94
Header file for the exception macros of the math module.
Constraints on the storage order of matrix types.
Header file for all forward declarations for expression class templates.
Header file for all forward declarations for sparse vectors and matrices.
Base class for all decldiag expression templates.
Definition: DeclDiagExpr.h:68
Base class for all declaration expression templates.
Definition: Declaration.h:76
Header file for the RequiresEvaluation type trait.
Header file for basic type definitions.