35#ifndef _BLAZE_MATH_EXPRESSIONS_SMATSMATSCHUREXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_SMATSMATSCHUREXPR_H_
99 :
public SchurExpr< SparseMatrix< SMatSMatSchurExpr<MT1,MT2>, false > >
132 template<
typename T1,
typename T2,
typename T3 >
133 static constexpr bool UseSymmetricKernel_v =
207 if( i >=
lhs_.rows() ) {
210 if( j >=
lhs_.columns() ) {
222 inline size_t rows() const noexcept {
233 return lhs_.columns();
284 template<
typename T >
285 inline bool canAlias(
const T* alias )
const noexcept {
286 return (
lhs_.canAlias( alias ) ||
rhs_.canAlias( alias ) );
296 template<
typename T >
297 inline bool isAliased(
const T* alias )
const noexcept {
298 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
320 template<
typename MT
340 for(
size_t i=0UL; i<(*lhs).rows(); ++i )
342 const auto lend( A.end(i) );
343 const auto rend( B.end(i) );
345 auto l( A.begin(i) );
346 auto r( B.begin(i) );
348 for( ; l!=lend; ++l ) {
349 while( r!=rend && r->index() < l->index() ) ++r;
351 if( l->index() == r->index() ) {
352 (*lhs)(i,l->index()) = l->value() * r->value();
373 template<
typename MT >
392 (*lhs).reserve(
min( A.nonZeros(), B.nonZeros() ) );
395 for(
size_t i=0UL; i<(*lhs).rows(); ++i )
397 const auto lend( A.end(i) );
398 const auto rend( B.end(i) );
400 auto l( A.begin(i) );
401 auto r( B.begin(i) );
403 for( ; l!=lend; ++l ) {
404 while( r!=rend && r->index() < l->index() ) ++r;
406 if( l->index() == r->index() ) {
407 (*lhs).append( i, l->index(), l->value() * r->value() );
412 (*lhs).finalize( i );
431 template<
typename MT >
432 friend inline auto assign( SparseMatrix<MT,true>& lhs,
const SMatSMatSchurExpr& rhs )
452 const size_t m( rhs.
rows() );
453 const size_t n( rhs.
columns() );
456 std::vector<size_t> nonzeros( n, 0UL );
457 for(
size_t i=0UL; i<m; ++i )
459 const auto lend( A.end(i) );
460 const auto rend( B.end(i) );
462 auto l( A.begin(i) );
463 auto r( B.begin(i) );
465 for( ; l!=lend; ++l ) {
466 while( r!=rend && r->index() < l->index() ) ++r;
468 if( l->index() == r->index() ) {
469 ++nonzeros[l->index()];
476 for(
size_t j=0UL; j<n; ++j ) {
477 (*lhs).reserve( j, nonzeros[j] );
481 for(
size_t i=0UL; i<m; ++i )
483 const auto lend( A.end(i) );
484 const auto rend( B.end(i) );
486 auto l( A.begin(i) );
487 auto r( B.begin(i) );
489 for( ; l!=lend; ++l ) {
490 while( r!=rend && r->index() < l->index() ) ++r;
492 if( l->index() == r->index() ) {
493 (*lhs).append( i, l->index(), l->value() * r->value() );
515 template<
typename MT >
543 template<
typename MT
545 friend inline auto addAssign( DenseMatrix<MT,SO>& lhs,
const SMatSMatSchurExpr& rhs )
563 for(
size_t i=0UL; i<(*lhs).rows(); ++i )
565 const auto lend( A.end(i) );
566 const auto rend( B.end(i) );
568 auto l( A.begin(i) );
569 auto r( B.begin(i) );
571 for( ; l!=lend; ++l ) {
572 while( r!=rend && r->index() < l->index() ) ++r;
574 if( l->index() == r->index() ) {
575 (*lhs)(i,l->index()) += l->value() * r->value();
597 template<
typename MT >
598 friend inline auto addAssign( Matrix<MT,true>& lhs,
const SMatSMatSchurExpr& rhs )
630 template<
typename MT
632 friend inline auto subAssign( DenseMatrix<MT,SO>& lhs,
const SMatSMatSchurExpr& rhs )
650 for(
size_t i=0UL; i<(*lhs).rows(); ++i )
652 const auto lend( A.end(i) );
653 const auto rend( B.end(i) );
655 auto l( A.begin(i) );
656 auto r( B.begin(i) );
658 for( ; l!=lend; ++l ) {
659 while( r!=rend && r->index() < l->index() ) ++r;
661 if( l->index() == r->index() ) {
662 (*lhs)(i,l->index()) -= l->value() * r->value();
684 template<
typename MT >
685 friend inline auto subAssign( Matrix<MT,true>& lhs,
const SMatSMatSchurExpr& rhs )
717 template<
typename MT
719 friend inline auto schurAssign( DenseMatrix<MT,SO>& lhs,
const SMatSMatSchurExpr& rhs )
737 for(
size_t i=0UL; i<(*lhs).rows(); ++i )
739 const auto lend( A.end(i) );
740 const auto rend( B.end(i) );
742 auto l( A.begin(i) );
743 auto r( B.begin(i) );
747 for( ; l!=lend; ++l ) {
748 while( r!=rend && r->index() < l->index() ) ++r;
750 if( l->index() == r->index() ) {
751 for( ; j<l->index(); ++j )
752 reset( (*lhs)(i,j) );
753 (*lhs)(i,l->index()) *= l->value() * r->value();
759 for( ; j<(*lhs).columns(); ++j )
760 reset( (*lhs)(i,j) );
779 template<
typename MT >
780 friend inline auto schurAssign( Matrix<MT,true>& lhs,
const SMatSMatSchurExpr& rhs )
844 template<
typename MT
907template<
typename MT1
943template<
typename MT1
962 return ReturnType( (*lhs).rows() );
981template<
typename MT1
1003 return ReturnType( (*lhs).rows(), (*lhs).columns() );
1035template<
typename MT1
1037inline decltype(
auto)
1042 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() ) {
1046 return smatsmatschur( *lhs, *rhs );
Header file for auxiliary alias declarations.
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.
Definition Aliases.h:470
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.
Definition Aliases.h:310
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition Aliases.h:110
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition Aliases.h:550
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition Aliases.h:190
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition Aliases.h:450
Header file for run time assertion macros.
Header file for the EnableIf class template.
Header file for the function trace functionality.
Constraint on the data type.
Header file for the If class template.
Header file for the IntegralConstant class template.
Header file for the IsColumnMajorMatrix type trait.
Header file for the IsExpression type trait class.
Header file for the IsLower type trait.
Header file for the IsStrictlyLower type trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Header file for the IsTemporary type trait class.
Header file for the IsUniLower type trait.
Header file for the IsUniUpper type trait.
Header file for the IsUpper type trait.
Header file for the MAYBE_UNUSED function template.
Constraints on the storage order of matrix types.
Header file for the Schur product trait.
Constraint on the data type.
Constraint on the data type.
Base class for dense matrices.
Definition DenseMatrix.h:82
Expression object for sparse matrix-sparse matrix Schur product.
Definition SMatSMatSchurExpr.h:101
ResultType_t< MT1 > RT1
Result type of the left-hand side sparse matrix expression.
Definition SMatSMatSchurExpr.h:104
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition SMatSMatSchurExpr.h:206
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition SMatSMatSchurExpr.h:191
SMatSMatSchurExpr< MT1, MT2 > This
Type of this SMatSMatSchurExpr instance.
Definition SMatSMatSchurExpr.h:141
LeftOperand lhs_
Left-hand side sparse matrix of the Schur product expression.
Definition SMatSMatSchurExpr.h:304
CompositeType_t< MT2 > CT2
Composite type of the right-hand side sparse matrix expression.
Definition SMatSMatSchurExpr.h:109
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition SMatSMatSchurExpr.h:166
If_t< IsExpression_v< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition SMatSMatSchurExpr.h:161
RightOperand rhs_
Right-hand side sparse matrix of the Schur product expression.
Definition SMatSMatSchurExpr.h:305
ElementType_t< ResultType > ElementType
Resulting element type.
Definition SMatSMatSchurExpr.h:149
SchurExpr< SparseMatrix< This, false > > BaseType
Base type of this SMatSMatSchurExpr instance.
Definition SMatSMatSchurExpr.h:144
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse matrix operand.
Definition SMatSMatSchurExpr.h:263
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition SMatSMatSchurExpr.h:253
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition SMatSMatSchurExpr.h:119
ReturnType_t< MT2 > RN2
ReturnType type of the right-hand side sparse matrix expression.
Definition SMatSMatSchurExpr.h:107
ReturnType_t< MT1 > RN1
ReturnType type of the left-hand side sparse matrix expression.
Definition SMatSMatSchurExpr.h:106
CompositeType_t< MT1 > CT1
Composite type of the left-hand side sparse matrix expression.
Definition SMatSMatSchurExpr.h:108
ResultType_t< MT2 > RT2
Result type of the right-hand side sparse matrix expression.
Definition SMatSMatSchurExpr.h:105
If_t< IsExpression_v< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition SMatSMatSchurExpr.h:158
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse matrix operand.
Definition SMatSMatSchurExpr.h:273
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition SMatSMatSchurExpr.h:232
SMatSMatSchurExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the SMatSMatSchurExpr class.
Definition SMatSMatSchurExpr.h:175
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition SMatSMatSchurExpr.h:152
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition SMatSMatSchurExpr.h:242
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition SMatSMatSchurExpr.h:297
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition SMatSMatSchurExpr.h:147
decltype(std::declval< RN1 >() *std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition SMatSMatSchurExpr.h:122
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition SMatSMatSchurExpr.h:148
const ResultType CompositeType
Data type for composite expression templates.
Definition SMatSMatSchurExpr.h:155
SchurTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition SMatSMatSchurExpr.h:146
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition SMatSMatSchurExpr.h:285
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition SMatSMatSchurExpr.h:222
Base class for sparse matrices.
Definition SparseMatrix.h:77
Constraint on the data type.
Constraint on the data type.
Header file for the Computation base class.
Header file for the SchurExpr base class.
Header file for the SparseMatrix base class.
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition DMatDMatMapExpr.h:1339
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition DMatTransExpr.h:766
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition DMatSerialExpr.h:812
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.
Definition Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.
Definition RowMajorMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ZERO_TYPE(T)
Constraint on the data type.
Definition Zero.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition SparseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_IDENTITY_MATRIX_TYPE(T)
Constraint on the data type.
Definition Identity.h:60
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_SCHUREXPR(T1, T2)
Constraint on the data type.
Definition SchurExpr.h:103
#define BLAZE_CONSTRAINT_MUST_BE_ZERO_TYPE(T)
Constraint on the data type.
Definition Zero.h:61
typename SchurTrait< T1, T2 >::Type SchurTrait_t
Auxiliary alias declaration for the SchurTrait class template.
Definition SchurTrait.h:137
constexpr bool IsStrictlyUpper_v
Auxiliary variable template for the IsStrictlyUpper type trait.
Definition IsStrictlyUpper.h:173
constexpr bool IsSymmetric_v
Auxiliary variable template for the IsSymmetric type trait.
Definition IsSymmetric.h:172
constexpr bool IsUniUpper_v
Auxiliary variable template for the IsUniUpper type trait.
Definition IsUniUpper.h:173
constexpr bool IsStrictlyLower_v
Auxiliary variable template for the IsStrictlyLower type trait.
Definition IsStrictlyLower.h:173
constexpr bool IsUpper_v
Auxiliary variable template for the IsUpper type trait.
Definition IsUpper.h:175
constexpr bool IsZero_v
Auxiliary variable template for the IsZero type trait.
Definition IsZero.h:166
constexpr bool IsColumnMajorMatrix_v
Auxiliary variable template for the IsColumnMajorMatrix type trait.
Definition IsColumnMajorMatrix.h:129
constexpr bool IsTemporary_v
Auxiliary variable template for the IsTemporary type trait.
Definition IsTemporary.h:88
constexpr bool IsLower_v
Auxiliary variable template for the IsLower type trait.
Definition IsLower.h:175
constexpr bool IsUniLower_v
Auxiliary variable template for the IsUniLower type trait.
Definition IsUniLower.h:173
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition Matrix.h:806
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition Assert.h:101
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
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition MaybeUnused.h:81
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:138
#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
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition If.h:108
typename EnableIf<!Condition, T >::Type DisableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:175
Header file for the exception macros of the math module.
Header file for all forward declarations for expression class templates.
Header file for all forward declarations for sparse vectors and matrices.
Header file for the serial shim.
Base class for all compute expression templates.
Definition Computation.h:68
Base class for all Schur product expression templates.
Definition SchurExpr.h:68
Header file for the IsZero type trait.
Header file for basic type definitions.
Header file for the generic max algorithm.
Header file for the generic min algorithm.