35 #ifndef _BLAZE_MATH_EXPRESSIONS_SVECTSVECMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SVECTSVECMULTEXPR_H_
92 template<
typename VT1
94 class SVecTSVecMultExpr :
public SparseMatrix< SVecTSVecMultExpr<VT1,VT2>, false >
95 ,
private VecTVecMultExpr
150 enum :
bool { smpAssignable =
false };
188 inline ReturnType
at(
size_t i,
size_t j )
const {
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 >
313 LT x(
serial( rhs.lhs_ ) );
314 RT y(
serial( rhs.rhs_ ) );
321 const LeftIterator lend( x.end() );
322 const RightIterator rend( y.end() );
324 for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
326 for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
327 (~lhs)(lelem->index(),relem->index()) = lelem->value() * relem->value();
348 template<
typename MT >
361 LT x(
serial( rhs.lhs_ ) );
362 RT y(
serial( rhs.rhs_ ) );
369 const LeftIterator lend( x.end() );
370 const RightIterator rend( y.end() );
372 for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
374 for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
375 (~lhs)(lelem->index(),relem->index()) = lelem->value() * relem->value();
395 template<
typename MT >
396 friend inline void assign( SparseMatrix<MT,false>& lhs,
const SVecTSVecMultExpr& rhs )
404 typedef ConstIterator_< RemoveReference_<LT> > LeftIterator;
405 typedef ConstIterator_< RemoveReference_<RT> > RightIterator;
407 LT x(
serial( rhs.lhs_ ) );
408 RT y(
serial( rhs.rhs_ ) );
415 const LeftIterator lend( x.end() );
416 const RightIterator rend( y.end() );
419 for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
421 for( ; index < lelem->index(); ++index ) {
422 (~lhs).finalize( index );
424 for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
425 (~lhs).append( lelem->index(), relem->index(), lelem->value() * relem->value() );
427 (~lhs).finalize( index++ );
431 for( ; index < x.size(); ++index ) {
432 (~lhs).finalize( index );
451 template<
typename MT >
452 friend inline void assign( SparseMatrix<MT,true>& lhs,
const SVecTSVecMultExpr& rhs )
462 typedef ConstIterator_< RemoveReference_<LT> > LeftIterator;
463 typedef ConstIterator_< RemoveReference_<RT> > RightIterator;
465 LT x(
serial( rhs.lhs_ ) );
466 RT y(
serial( rhs.rhs_ ) );
473 const LeftIterator lend( x.end() );
474 const RightIterator rend( y.end() );
477 for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
479 for( ; index < relem->index(); ++index ) {
480 (~lhs).finalize( index );
482 for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
483 (~lhs).append( lelem->index(), relem->index(), lelem->value() * relem->value() );
485 (~lhs).finalize( index++ );
489 for( ; index < y.size(); ++index ) {
490 (~lhs).finalize( index );
509 template<
typename MT >
510 friend inline void addAssign( DenseMatrix<MT,false>& lhs,
const SVecTSVecMultExpr& rhs )
517 typedef ConstIterator_< RemoveReference_<LT> > LeftIterator;
518 typedef ConstIterator_< RemoveReference_<RT> > RightIterator;
520 LT x(
serial( rhs.lhs_ ) );
521 RT y(
serial( rhs.rhs_ ) );
528 const LeftIterator lend( x.end() );
529 const RightIterator rend( y.end() );
531 for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
533 for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
534 (~lhs)(lelem->index(),relem->index()) += lelem->value() * relem->value();
555 template<
typename MT >
556 friend inline void addAssign( DenseMatrix<MT,true>& lhs,
const SVecTSVecMultExpr& rhs )
565 typedef ConstIterator_< RemoveReference_<LT> > LeftIterator;
566 typedef ConstIterator_< RemoveReference_<RT> > RightIterator;
568 LT x(
serial( rhs.lhs_ ) );
569 RT y(
serial( rhs.rhs_ ) );
576 const LeftIterator lend( x.end() );
577 const RightIterator rend( y.end() );
579 for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
581 for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
582 (~lhs)(lelem->index(),relem->index()) += lelem->value() * relem->value();
607 template<
typename MT >
608 friend inline void subAssign( DenseMatrix<MT,false>& lhs,
const SVecTSVecMultExpr& rhs )
615 typedef ConstIterator_< RemoveReference_<LT> > LeftIterator;
616 typedef ConstIterator_< RemoveReference_<RT> > RightIterator;
618 LT x(
serial( rhs.lhs_ ) );
619 RT y(
serial( rhs.rhs_ ) );
626 const LeftIterator lend( x.end() );
627 const RightIterator rend( y.end() );
629 for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
631 for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
632 (~lhs)(lelem->index(),relem->index()) -= lelem->value() * relem->value();
653 template<
typename MT >
654 friend inline void subAssign( DenseMatrix<MT,true>& lhs,
const SVecTSVecMultExpr& rhs )
663 typedef ConstIterator_< RemoveReference_<LT> > LeftIterator;
664 typedef ConstIterator_< RemoveReference_<RT> > RightIterator;
666 LT x(
serial( rhs.lhs_ ) );
667 RT y(
serial( rhs.rhs_ ) );
674 const LeftIterator lend( x.end() );
675 const RightIterator rend( y.end() );
677 for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
679 for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
680 (~lhs)(lelem->index(),relem->index()) -= lelem->value() * relem->value();
748 template<
typename T1
750 inline const SVecTSVecMultExpr<T1,T2>
770 template<
typename VT1,
typename VT2 >
771 struct Rows< SVecTSVecMultExpr<VT1,VT2> > :
public Size<VT1>
787 template<
typename VT1,
typename VT2 >
788 struct Columns< SVecTSVecMultExpr<VT1,VT2> > :
public Size<VT2>
804 template<
typename VT1,
typename VT2,
bool AF >
805 struct SubmatrixExprTrait< SVecTSVecMultExpr<VT1,VT2>, AF >
809 using Type = MultExprTrait_< SubvectorExprTrait_<const VT1,AF>
810 , SubvectorExprTrait_<const VT2,AF> >;
819 template<
typename VT1,
typename VT2 >
820 struct RowExprTrait< SVecTSVecMultExpr<VT1,VT2> >
824 using Type = MultExprTrait_< ReturnType_<VT1>, VT2 >;
833 template<
typename VT1,
typename VT2 >
834 struct ColumnExprTrait< SVecTSVecMultExpr<VT1,VT2> >
838 using Type = MultExprTrait_< VT1, ReturnType_<VT2> >;
Header file for auxiliary alias declarations.
If_< IsExpression< VT2 >, const VT2, const VT2 & > RightOperand
Composite type of the right-hand side sparse vector expression.
Definition: SVecTSVecMultExpr.h:139
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SVecTSVecMultExpr.h:204
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:70
Header file for the Rows type trait.
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7800
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:346
Header file for basic type definitions.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a column dense or sparse vector type...
Definition: ColumnVector.h:61
Header file for the serial shim.
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SVecTSVecMultExpr.h:188
RightOperand rhs_
Right-hand side sparse vector of the multiplication expression.
Definition: SVecTSVecMultExpr.h:287
Header file for the ColumnExprTrait class template.
LeftOperand lhs_
Left-hand side sparse vector of the multiplication expression.
Definition: SVecTSVecMultExpr.h:286
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:723
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:245
Header file for the Computation base class.
ReturnType_< VT2 > RN2
Return type of the right-hand side sparse vector expression.
Definition: SVecTSVecMultExpr.h:103
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:323
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SVecTSVecMultExpr.h:267
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Constraint on the data type.
typename IfTrue< Condition, T1, T2 >::Type IfTrue_
Auxiliary alias declaration for the IfTrue class template.The IfTrue_ alias declaration provides a co...
Definition: If.h:109
ReturnType_< VT1 > RN1
Return type of the left-hand side sparse vector expression.
Definition: SVecTSVecMultExpr.h:102
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:343
Header file for the SparseMatrix base class.
Constraint on the transpose flag of vector types.
Constraint on the data type.
SVecTSVecMultExpr(const VT1 &lhs, const VT2 &rhs) noexcept
Constructor for the SVecTSVecMultExpr class.
Definition: SVecTSVecMultExpr.h:159
typename MultExprTrait< T1, T2 >::Type MultExprTrait_
Auxiliary alias declaration for the MultExprTrait class template.The MultExprTrait_ alias declaration...
Definition: MultExprTrait.h:344
Header file for the MultExprTrait class template.
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SVecTSVecMultExpr.h:172
Header file for the IsTemporary type trait class.
Header file for the multiplication trait.
If_< IsExpression< VT1 >, const VT1, const VT1 & > LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition: SVecTSVecMultExpr.h:136
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_VECTVECMULTEXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid vector/vector ...
Definition: VecTVecMultExpr.h:105
#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
Header file for the Columns type trait.
CompositeType_< VT1 > CT1
Composite type of the left-hand side sparse vector expression.
Definition: SVecTSVecMultExpr.h:104
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
const IfTrue_< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: SVecTSVecMultExpr.h:130
const ResultType CompositeType
Data type for composite expression templates.
Definition: SVecTSVecMultExpr.h:133
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type...
Definition: SparseVector.h:61
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SVecTSVecMultExpr.h:125
Expression object for sparse vector-sparse vector outer products.The SVecTSVecMultExpr class represen...
Definition: Forward.h:127
ResultType_< VT2 > RT2
Result type of the right-hand side sparse vector expression.
Definition: SVecTSVecMultExpr.h:101
Header file for the exception macros of the math module.
Header file for the RowExprTrait class template.
Header file for all forward declarations for expression class templates.
ResultType_< VT1 > RT1
Result type of the left-hand side sparse vector expression.
Definition: SVecTSVecMultExpr.h:100
Constraint on the data type.
Header file for the VecTVecMultExpr base class.
MultTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: SVecTSVecMultExpr.h:124
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SVecTSVecMultExpr.h:126
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SVecTSVecMultExpr.h:279
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
Header file for the SubmatrixExprTrait class template.
Header file for run time assertion macros.
SVecTSVecMultExpr< VT1, VT2 > This
Type of this SVecTSVecMultExpr instance.
Definition: SVecTSVecMultExpr.h:123
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse vector operand.
Definition: SVecTSVecMultExpr.h:255
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:160
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse vector operand.
Definition: SVecTSVecMultExpr.h:245
Header file for the isDefault shim.
CompositeType_< VT2 > CT2
Composite type of the right-hand side sparse vector expression.
Definition: SVecTSVecMultExpr.h:105
Constraint on the data type.
If_< IsComputation< VT1 >, const RT1, CT1 > LT
Type for the assignment of the left-hand side dense vector operand.
Definition: SVecTSVecMultExpr.h:142
Constraint on the data type.
Header file for the RemoveReference type trait.
typename T::OppositeType OppositeType_
Alias declaration for nested OppositeType type definitions.The OppositeType_ alias declaration provid...
Definition: Aliases.h:243
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: SVecTSVecMultExpr.h:214
MultExprTrait_< RN1, RN2 > ExprReturnType
Expression return type for the subscript operator.
Definition: SVecTSVecMultExpr.h:118
Header file for the IsComputation type trait class.
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:110
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
#define BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a row dense or sparse vector type (i...
Definition: RowVector.h:61
Header file for the SubvectorExprTrait class template.
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:403
ElementType_< ResultType > ElementType
Resulting element type.
Definition: SVecTSVecMultExpr.h:127
Header file for the Size type trait.
Size type of the Blaze library.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SVecTSVecMultExpr.h:224
#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
If_< IsComputation< VT2 >, const RT2, CT2 > RT
Type for the assignment of the right-hand side dense vector operand.
Definition: SVecTSVecMultExpr.h:145
Constraint on the transpose flag of vector types.
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SVecTSVecMultExpr.h:235