35#ifndef _BLAZE_MATH_EXPRESSIONS_TSMATTSMATSCHUREXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_TSMATTSMATSCHUREXPR_H_
98 :
public SchurExpr< SparseMatrix< TSMatTSMatSchurExpr<MT1,MT2>, true > >
131 template<
typename T1,
typename T2,
typename T3 >
132 static constexpr bool UseSymmetricKernel_v =
206 if( i >=
lhs_.rows() ) {
209 if( j >=
lhs_.columns() ) {
221 inline size_t rows() const noexcept {
232 return lhs_.columns();
283 template<
typename T >
284 inline bool canAlias(
const T* alias )
const noexcept {
285 return (
lhs_.canAlias( alias ) ||
rhs_.canAlias( alias ) );
295 template<
typename T >
296 inline bool isAliased(
const T* alias )
const noexcept {
297 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
320 template<
typename MT
340 for(
size_t j=0UL; j<(*lhs).columns(); ++j )
342 const auto lend( A.end(j) );
343 const auto rend( B.end(j) );
345 auto l( A.begin(j) );
346 auto r( B.begin(j) );
348 for( ; l!=lend; ++l ) {
349 while( r!=rend && r->index() < l->index() ) ++r;
351 if( l->index() == r->index() ) {
352 (*lhs)(l->index(),j) = l->value() * r->value();
374 template<
typename MT >
395 const size_t m( rhs.rows() );
396 const size_t n( rhs.columns() );
399 std::vector<size_t> nonzeros( m, 0UL );
400 for(
size_t j=0UL; j<n; ++j )
402 const auto lend( A.end(j) );
403 const auto rend( B.end(j) );
405 auto l( A.begin(j) );
406 auto r( B.begin(j) );
408 for( ; l!=lend; ++l ) {
409 while( r!=rend && r->index() < l->index() ) ++r;
411 if( l->index() == r->index() ) {
412 ++nonzeros[l->index()];
419 for(
size_t i=0UL; i<m; ++i ) {
420 (*lhs).reserve( i, nonzeros[i] );
424 for(
size_t j=0UL; j<n; ++j )
426 const auto lend( A.end(j) );
427 const auto rend( B.end(j) );
429 auto l( A.begin(j) );
430 auto r( B.begin(j) );
432 for( ; l!=lend; ++l ) {
433 while( r!=rend && r->index() < l->index() ) ++r;
435 if( l->index() == r->index() ) {
436 (*lhs).append( l->index(), j, l->value() * r->value() );
458 template<
typename MT >
477 (*lhs).reserve(
min( A.nonZeros(), B.nonZeros() ) );
480 for(
size_t j=0UL; j<(*lhs).columns(); ++j )
482 const auto lend( A.end(j) );
483 const auto rend( B.end(j) );
485 auto l( A.begin(j) );
486 auto r( B.begin(j) );
488 for( ; l!=lend; ++l ) {
489 while( r!=rend && r->index() < l->index() ) ++r;
491 if( l->index() == r->index() ) {
492 (*lhs).append( l->index(), j, l->value() * r->value() );
497 (*lhs).finalize( j );
516 template<
typename MT >
527 assign( *lhs,
trans( rhs.lhs_ ) %
trans( rhs.rhs_ ) );
545 template<
typename MT
565 for(
size_t j=0UL; j<(*lhs).columns(); ++j )
567 const auto lend( A.end(j) );
568 const auto rend( B.end(j) );
570 auto l( A.begin(j) );
571 auto r( B.begin(j) );
573 for( ; l!=lend; ++l ) {
574 while( r!=rend && r->index() < l->index() ) ++r;
576 if( l->index() == r->index() ) {
577 (*lhs)(l->index(),j) += l->value() * r->value();
599 template<
typename MT >
610 addAssign( *lhs,
trans( rhs.lhs_ ) %
trans( rhs.rhs_ ) );
632 template<
typename MT
652 for(
size_t j=0UL; j<(*lhs).columns(); ++j )
654 const auto lend( A.end(j) );
655 const auto rend( B.end(j) );
657 auto l( A.begin(j) );
658 auto r( B.begin(j) );
660 for( ; l!=lend; ++l ) {
661 while( r!=rend && r->index() < l->index() ) ++r;
663 if( l->index() == r->index() ) {
664 (*lhs)(l->index(),j) -= l->value() * r->value();
686 template<
typename MT >
697 subAssign( *lhs,
trans( rhs.lhs_ ) %
trans( rhs.rhs_ ) );
719 template<
typename MT
739 for(
size_t j=0UL; j<(*lhs).columns(); ++j )
741 const auto lend( A.end(j) );
742 const auto rend( B.end(j) );
744 auto l( A.begin(j) );
745 auto r( B.begin(j) );
749 for( ; l!=lend; ++l ) {
750 while( r!=rend && r->index() < l->index() ) ++r;
752 if( l->index() == r->index() ) {
753 for( ; i<l->index(); ++i )
754 reset( (*lhs)(i,j) );
755 (*lhs)(l->index(),j) *= l->value() * r->value();
761 for( ; i<(*lhs).rows(); ++i )
762 reset( (*lhs)(i,j) );
781 template<
typename MT >
792 schurAssign( *lhs,
trans( rhs.lhs_ ) %
trans( rhs.rhs_ ) );
846 template<
typename MT
908template<
typename MT1
943template<
typename MT1
948 tsmattsmatschur(
const SparseMatrix<MT1,true>& lhs,
const SparseMatrix<MT2,true>& rhs )
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() ) {
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.
Constraints on the storage order of matrix types.
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 IsExpression type trait class.
Header file for the IsLower type trait.
Header file for the IsRowMajorMatrix 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.
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
Base class for sparse matrices.
Definition SparseMatrix.h:77
Expression object for transpose sparse matrix-transpose sparse matrix Schur product.
Definition TSMatTSMatSchurExpr.h:100
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition TSMatTSMatSchurExpr.h:231
LeftOperand lhs_
Left-hand side sparse matrix of the Schur product expression.
Definition TSMatTSMatSchurExpr.h:303
If_t< IsExpression_v< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition TSMatTSMatSchurExpr.h:157
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition TSMatTSMatSchurExpr.h:205
RightOperand rhs_
Right-hand side sparse matrix of the Schur product expression.
Definition TSMatTSMatSchurExpr.h:304
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition TSMatTSMatSchurExpr.h:165
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition TSMatTSMatSchurExpr.h:284
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition TSMatTSMatSchurExpr.h:118
LeftOperand leftOperand() const noexcept
Returns the left-hand side transpose sparse matrix operand.
Definition TSMatTSMatSchurExpr.h:262
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition TSMatTSMatSchurExpr.h:221
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition TSMatTSMatSchurExpr.h:151
CompositeType_t< MT1 > CT1
Composite type of the left-hand side sparse matrix expression.
Definition TSMatTSMatSchurExpr.h:107
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition TSMatTSMatSchurExpr.h:146
TSMatTSMatSchurExpr< MT1, MT2 > This
Type of this TSMatTSMatSchurExpr instance.
Definition TSMatTSMatSchurExpr.h:140
decltype(std::declval< RN1 >() *std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition TSMatTSMatSchurExpr.h:121
ResultType_t< MT2 > RT2
Result type of the right-hand side sparse matrix expression.
Definition TSMatTSMatSchurExpr.h:104
const ResultType CompositeType
Data type for composite expression templates.
Definition TSMatTSMatSchurExpr.h:154
If_t< IsExpression_v< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition TSMatTSMatSchurExpr.h:160
ResultType_t< MT1 > RT1
Result type of the left-hand side sparse matrix expression.
Definition TSMatTSMatSchurExpr.h:103
CompositeType_t< MT2 > CT2
Composite type of the right-hand side sparse matrix expression.
Definition TSMatTSMatSchurExpr.h:108
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition TSMatTSMatSchurExpr.h:241
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition TSMatTSMatSchurExpr.h:252
SchurExpr< SparseMatrix< This, true > > BaseType
Base type of this TSMatTSMatSchurExpr instance.
Definition TSMatTSMatSchurExpr.h:143
SchurTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition TSMatTSMatSchurExpr.h:145
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition TSMatTSMatSchurExpr.h:296
ReturnType_t< MT1 > RN1
Return type of the left-hand side sparse matrix expression.
Definition TSMatTSMatSchurExpr.h:105
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition TSMatTSMatSchurExpr.h:190
ReturnType_t< MT2 > RN2
Return type of the right-hand side sparse matrix expression.
Definition TSMatTSMatSchurExpr.h:106
TSMatTSMatSchurExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the TSMatTSMatSchurExpr class.
Definition TSMatTSMatSchurExpr.h:174
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition TSMatTSMatSchurExpr.h:147
ElementType_t< ResultType > ElementType
Resulting element type.
Definition TSMatTSMatSchurExpr.h:148
RightOperand rightOperand() const noexcept
Returns the right-hand side transpose sparse matrix operand.
Definition TSMatTSMatSchurExpr.h:272
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_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_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.
Definition ColumnMajorMatrix.h:61
#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 IsRowMajorMatrix_v
Auxiliary variable template for the IsRowMajorMatrix type trait.
Definition IsRowMajorMatrix.h:129
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 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
const TSMatTSMatSchurExpr< MT1, MT2 > tsmattsmatschur(const SparseMatrix< MT1, true > &lhs, const SparseMatrix< MT2, true > &rhs)
Backend implementation of the Schur product between two column-major sparse matrices ( ).
Definition TSMatTSMatSchurExpr.h:918
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 min algorithm.