35#ifndef _BLAZE_MATH_EXPRESSIONS_SVECSVECOUTEREXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_SVECSVECOUTEREXPR_H_
90 :
public VecTVecMultExpr< SparseMatrix< SVecSVecOuterExpr<VT1,VT2>, false > >
189 if( i >=
lhs_.size() ) {
192 if( j >=
rhs_.size() ) {
204 inline size_t rows() const noexcept {
225 return lhs_.nonZeros() *
rhs_.nonZeros();
266 template<
typename T >
267 inline bool canAlias(
const T* alias )
const noexcept {
268 return (
lhs_.canAlias( alias ) ||
rhs_.canAlias( alias ) );
278 template<
typename T >
279 inline bool isAliased(
const T* alias )
const noexcept {
280 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
302 template<
typename MT >
318 const auto lend( x.end() );
319 const auto rend( y.end() );
321 for(
auto lelem=x.begin(); lelem!=lend; ++lelem ) {
323 for(
auto relem=y.begin(); relem!=rend; ++relem ) {
324 (*lhs)(lelem->index(),relem->index()) = lelem->value() * relem->value();
345 template<
typename MT >
363 const auto lend( x.end() );
364 const auto rend( y.end() );
366 for(
auto relem=y.begin(); relem!=rend; ++relem ) {
368 for(
auto lelem=x.begin(); lelem!=lend; ++lelem ) {
369 (*lhs)(lelem->index(),relem->index()) = lelem->value() * relem->value();
389 template<
typename MT >
390 friend inline void assign( SparseMatrix<MT,false>& lhs,
const SVecSVecOuterExpr& rhs )
407 (*lhs).reserve( x.nonZeros() * y.nonZeros() );
410 const auto lend( x.end() );
411 const auto rend( y.end() );
414 for(
auto lelem=x.begin(); lelem!=lend; ++lelem ) {
416 for( ; index < lelem->index(); ++index ) {
417 (*lhs).finalize( index );
419 for(
auto relem=y.begin(); relem!=rend; ++relem ) {
420 (*lhs).append( lelem->index(), relem->index(), lelem->value() * relem->value() );
422 (*lhs).finalize( index++ );
426 for( ; index < x.size(); ++index ) {
427 (*lhs).finalize( index );
446 template<
typename MT >
447 friend inline void assign( SparseMatrix<MT,true>& lhs,
const SVecSVecOuterExpr& rhs )
465 const auto lend( x.end() );
466 const auto rend( y.end() );
469 for(
auto relem=y.begin(); relem!=rend; ++relem ) {
471 for( ; index < relem->index(); ++index ) {
472 (*lhs).finalize( index );
474 for(
auto lelem=x.begin(); lelem!=lend; ++lelem ) {
475 (*lhs).append( lelem->index(), relem->index(), lelem->value() * relem->value() );
477 (*lhs).finalize( index++ );
481 for( ; index < y.size(); ++index ) {
482 (*lhs).finalize( index );
501 template<
typename MT >
502 friend inline void addAssign( DenseMatrix<MT,false>& lhs,
const SVecSVecOuterExpr& rhs )
517 const auto lend( x.end() );
518 const auto rend( y.end() );
520 for(
auto lelem=x.begin(); lelem!=lend; ++lelem ) {
522 for(
auto relem=y.begin(); relem!=rend; ++relem ) {
523 (*lhs)(lelem->index(),relem->index()) += lelem->value() * relem->value();
544 template<
typename MT >
545 friend inline void addAssign( DenseMatrix<MT,true>& lhs,
const SVecSVecOuterExpr& rhs )
562 const auto lend( x.end() );
563 const auto rend( y.end() );
565 for(
auto relem=y.begin(); relem!=rend; ++relem ) {
567 for(
auto lelem=x.begin(); lelem!=lend; ++lelem ) {
568 (*lhs)(lelem->index(),relem->index()) += lelem->value() * relem->value();
593 template<
typename MT >
594 friend inline void subAssign( DenseMatrix<MT,false>& lhs,
const SVecSVecOuterExpr& rhs )
609 const auto lend( x.end() );
610 const auto rend( y.end() );
612 for(
auto lelem=x.begin(); lelem!=lend; ++lelem ) {
614 for(
auto relem=y.begin(); relem!=rend; ++relem ) {
615 (*lhs)(lelem->index(),relem->index()) -= lelem->value() * relem->value();
636 template<
typename MT >
637 friend inline void subAssign( DenseMatrix<MT,true>& lhs,
const SVecSVecOuterExpr& rhs )
654 const auto lend( x.end() );
655 const auto rend( y.end() );
657 for(
auto relem=y.begin(); relem!=rend; ++relem ) {
659 for(
auto lelem=x.begin(); lelem!=lend; ++lelem ) {
660 (*lhs)(lelem->index(),relem->index()) -= lelem->value() * relem->value();
685 template<
typename MT >
686 friend inline void schurAssign( DenseMatrix<MT,false>& lhs,
const SVecSVecOuterExpr& rhs )
701 const auto lend( x.end() );
702 const auto rend( y.end() );
706 for(
auto lelem=x.begin(); lelem!=lend; ++lelem )
708 if(
isDefault( lelem->value() ) )
continue;
710 for( ; i<lelem->index(); ++i ) {
711 for(
size_t j=0UL; j<y.size(); ++j )
712 reset( (*lhs)(i,j) );
717 for(
auto relem=y.begin(); relem!=rend; ++relem, ++j ) {
718 for( ; j<relem->index(); ++j )
719 reset( (*lhs)(i,j) );
720 (*lhs)(lelem->index(),relem->index()) *= lelem->value() * relem->value();
723 for( ; j<y.size(); ++j ) {
724 reset( (*lhs)(i,j) );
730 for( ; i<x.size(); ++i ) {
731 for(
size_t j=0UL; j<y.size(); ++j )
732 reset( (*lhs)(i,j) );
751 template<
typename MT >
752 friend inline void schurAssign( DenseMatrix<MT,true>& lhs,
const SVecSVecOuterExpr& rhs )
769 const auto lend( x.end() );
770 const auto rend( y.end() );
774 for(
auto relem=y.begin(); relem!=rend; ++relem )
776 if(
isDefault( relem->value() ) )
continue;
778 for( ; j<relem->index(); ++j ) {
779 for(
size_t i=0UL; i<x.size(); ++i )
780 reset( (*lhs)(i,j) );
785 for(
auto lelem=x.begin(); lelem!=lend; ++lelem, ++i ) {
786 for( ; i<lelem->index(); ++i )
787 reset( (*lhs)(i,j) );
788 (*lhs)(lelem->index(),relem->index()) *= lelem->value() * relem->value();
791 for( ; i<x.size(); ++i ) {
792 reset( (*lhs)(i,j) );
798 for( ; j<y.size(); ++j ) {
799 for(
size_t i=0UL; i<x.size(); ++i )
800 reset( (*lhs)(i,j) );
854template<
typename VT1
881template<
typename VT1
894 return ReturnType( (*lhs).size(), (*rhs).size() );
927template<
typename VT1
934 return svecsvecouter( *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.
Constraint on the transpose flag of vector types.
Header file for the EnableIf class template.
Header file for the function trace functionality.
Header file for the If class template.
Header file for the IsComputation type trait class.
Header file for the isDefault shim.
Header file for the IsExpression type trait class.
Header file for the IsTemporary type trait class.
Deactivation of problematic macros.
Header file for the multiplication trait.
Constraint on the transpose flag of vector types.
Constraint on the data type.
Constraint on the data type.
Base class for dense matrices.
Definition DenseMatrix.h:82
Expression object for sparse vector-sparse vector outer products.
Definition SVecSVecOuterExpr.h:92
ReturnType_t< VT1 > RN1
Return type of the left-hand side sparse vector expression.
Definition SVecSVecOuterExpr.h:97
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition SVecSVecOuterExpr.h:204
ResultType_t< VT2 > RT2
Result type of the right-hand side sparse vector expression.
Definition SVecSVecOuterExpr.h:96
VecTVecMultExpr< SparseMatrix< This, false > > BaseType
Base type of this SVecSVecOuterExpr instance.
Definition SVecSVecOuterExpr.h:122
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition SVecSVecOuterExpr.h:188
CompositeType_t< VT1 > CT1
Composite type of the left-hand side sparse vector expression.
Definition SVecSVecOuterExpr.h:99
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse vector operand.
Definition SVecSVecOuterExpr.h:245
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition SVecSVecOuterExpr.h:172
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse vector operand.
Definition SVecSVecOuterExpr.h:255
RightOperand rhs_
Right-hand side sparse vector of the multiplication expression.
Definition SVecSVecOuterExpr.h:287
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition SVecSVecOuterExpr.h:130
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition SVecSVecOuterExpr.h:125
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition SVecSVecOuterExpr.h:150
SVecSVecOuterExpr(const VT1 &lhs, const VT2 &rhs) noexcept
Constructor for the SVecSVecOuterExpr class.
Definition SVecSVecOuterExpr.h:159
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition SVecSVecOuterExpr.h:214
decltype(std::declval< RN1 >() *std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition SVecSVecOuterExpr.h:113
ReturnType_t< VT2 > RN2
Return type of the right-hand side sparse vector expression.
Definition SVecSVecOuterExpr.h:98
ResultType_t< VT1 > RT1
Result type of the left-hand side sparse vector expression.
Definition SVecSVecOuterExpr.h:95
ElementType_t< ResultType > ElementType
Resulting element type.
Definition SVecSVecOuterExpr.h:127
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition SVecSVecOuterExpr.h:126
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition SVecSVecOuterExpr.h:279
CompositeType_t< VT2 > CT2
Composite type of the right-hand side sparse vector expression.
Definition SVecSVecOuterExpr.h:100
const ResultType CompositeType
Data type for composite expression templates.
Definition SVecSVecOuterExpr.h:133
LeftOperand lhs_
Left-hand side sparse vector of the multiplication expression.
Definition SVecSVecOuterExpr.h:286
If_t< IsExpression_v< VT1 >, const VT1, const VT1 & > LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition SVecSVecOuterExpr.h:136
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition SVecSVecOuterExpr.h:235
MultTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition SVecSVecOuterExpr.h:124
If_t< IsComputation_v< VT2 >, const RT2, CT2 > RT
Type for the assignment of the right-hand side sparse vector operand.
Definition SVecSVecOuterExpr.h:145
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition SVecSVecOuterExpr.h:267
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition SVecSVecOuterExpr.h:224
If_t< IsExpression_v< VT2 >, const VT2, const VT2 & > RightOperand
Composite type of the right-hand side sparse vector expression.
Definition SVecSVecOuterExpr.h:139
If_t< IsComputation_v< VT1 >, const RT1, CT1 > LT
Type for the assignment of the left-hand side sparse vector operand.
Definition SVecSVecOuterExpr.h:142
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition SVecSVecOuterExpr.h:110
SVecSVecOuterExpr< VT1, VT2 > This
Type of this SVecSVecOuterExpr instance.
Definition SVecSVecOuterExpr.h:119
Base class for sparse vectors.
Definition SparseVector.h:72
Size type of the Blaze library.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the Computation base class.
Header file for the SparseMatrix base class.
Header file for the VecTVecMultExpr base class.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition DMatSerialExpr.h:812
bool isDefault(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the given diagonal matrix is in default state.
Definition DiagonalMatrix.h:169
#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_FORM_VALID_VECTVECMULTEXPR(T1, T2)
Constraint on the data type.
Definition VecTVecMultExpr.h:103
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ZERO_TYPE(T)
Constraint on the data type.
Definition Zero.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition SparseVector.h:61
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE(T)
Constraint on the data type.
Definition ColumnVector.h:61
#define BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE(T)
Constraint on the data type.
Definition RowVector.h:61
#define BLAZE_CONSTRAINT_MUST_BE_ZERO_TYPE(T)
Constraint on the data type.
Definition Zero.h:61
typename MultTrait< T1, T2 >::Type MultTrait_t
Auxiliary alias declaration for the MultTrait class template.
Definition MultTrait.h:165
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 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
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_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 the serial shim.
Base class for all compute expression templates.
Definition Computation.h:68
Base class for all outer product expression templates.
Definition VecTVecMultExpr.h:69
Header file for the IsZero type trait.
Header file for basic type definitions.