35 #ifndef _BLAZE_MATH_EXPRESSIONS_SVECTSVECMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SVECTSVECMULTEXPR_H_
91 template<
typename VT1
93 class SVecTSVecMultExpr :
public SparseMatrix< SVecTSVecMultExpr<VT1,VT2>, false >
94 ,
private VecTVecMultExpr
149 enum { smpAssignable = 0 };
187 inline ReturnType
at(
size_t i,
size_t j )
const {
188 if( i >=
lhs_.size() ) {
191 if( j >=
rhs_.size() ) {
224 return lhs_.nonZeros() *
rhs_.nonZeros();
265 template<
typename T >
267 return (
lhs_.canAlias( alias ) ||
rhs_.canAlias( alias ) );
277 template<
typename T >
279 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
301 template<
typename MT >
312 LT x(
serial( rhs.lhs_ ) );
313 RT y(
serial( rhs.rhs_ ) );
320 const LeftIterator lend( x.end() );
321 const RightIterator rend( y.end() );
323 for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
325 for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
326 (~lhs)(lelem->index(),relem->index()) = lelem->value() * relem->value();
347 template<
typename MT >
360 LT x(
serial( rhs.lhs_ ) );
361 RT y(
serial( rhs.rhs_ ) );
368 const LeftIterator lend( x.end() );
369 const RightIterator rend( y.end() );
371 for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
373 for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
374 (~lhs)(lelem->index(),relem->index()) = lelem->value() * relem->value();
394 template<
typename MT >
395 friend inline void assign( SparseMatrix<MT,false>& lhs,
const SVecTSVecMultExpr& rhs )
406 LT x(
serial( rhs.lhs_ ) );
407 RT y(
serial( rhs.rhs_ ) );
414 const LeftIterator lend( x.end() );
415 const RightIterator rend( y.end() );
418 for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
420 for( ; index < lelem->index(); ++index ) {
421 (~lhs).finalize( index );
423 for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
424 (~lhs).append( lelem->index(), relem->index(), lelem->value() * relem->value() );
426 (~lhs).finalize( index++ );
430 for( ; index < x.size(); ++index ) {
431 (~lhs).finalize( index );
450 template<
typename MT >
451 friend inline void assign( SparseMatrix<MT,true>& lhs,
const SVecTSVecMultExpr& rhs )
464 LT x(
serial( rhs.lhs_ ) );
465 RT y(
serial( rhs.rhs_ ) );
472 const LeftIterator lend( x.end() );
473 const RightIterator rend( y.end() );
476 for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
478 for( ; index < relem->index(); ++index ) {
479 (~lhs).finalize( index );
481 for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
482 (~lhs).append( lelem->index(), relem->index(), lelem->value() * relem->value() );
484 (~lhs).finalize( index++ );
488 for( ; index < y.size(); ++index ) {
489 (~lhs).finalize( index );
508 template<
typename MT >
509 friend inline void addAssign( DenseMatrix<MT,false>& lhs,
const SVecTSVecMultExpr& rhs )
519 LT x(
serial( rhs.lhs_ ) );
520 RT y(
serial( rhs.rhs_ ) );
527 const LeftIterator lend( x.end() );
528 const RightIterator rend( y.end() );
530 for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
532 for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
533 (~lhs)(lelem->index(),relem->index()) += lelem->value() * relem->value();
554 template<
typename MT >
555 friend inline void addAssign( DenseMatrix<MT,true>& lhs,
const SVecTSVecMultExpr& rhs )
567 LT x(
serial( rhs.lhs_ ) );
568 RT y(
serial( rhs.rhs_ ) );
575 const LeftIterator lend( x.end() );
576 const RightIterator rend( y.end() );
578 for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
580 for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
581 (~lhs)(lelem->index(),relem->index()) += lelem->value() * relem->value();
606 template<
typename MT >
607 friend inline void subAssign( DenseMatrix<MT,false>& lhs,
const SVecTSVecMultExpr& rhs )
617 LT x(
serial( rhs.lhs_ ) );
618 RT y(
serial( rhs.rhs_ ) );
625 const LeftIterator lend( x.end() );
626 const RightIterator rend( y.end() );
628 for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
630 for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
631 (~lhs)(lelem->index(),relem->index()) -= lelem->value() * relem->value();
652 template<
typename MT >
653 friend inline void subAssign( DenseMatrix<MT,true>& lhs,
const SVecTSVecMultExpr& rhs )
665 LT x(
serial( rhs.lhs_ ) );
666 RT y(
serial( rhs.rhs_ ) );
673 const LeftIterator lend( x.end() );
674 const RightIterator rend( y.end() );
676 for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
678 for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
679 (~lhs)(lelem->index(),relem->index()) -= lelem->value() * relem->value();
747 template<
typename T1
749 inline const SVecTSVecMultExpr<T1,T2>
769 template<
typename VT1,
typename VT2 >
770 struct Rows< SVecTSVecMultExpr<VT1,VT2> > :
public Size<VT1>
786 template<
typename VT1,
typename VT2 >
787 struct Columns< SVecTSVecMultExpr<VT1,VT2> > :
public Size<VT2>
803 template<
typename VT1,
typename VT2,
bool AF >
804 struct SubmatrixExprTrait< SVecTSVecMultExpr<VT1,VT2>, AF >
808 typedef typename MultExprTrait< typename SubvectorExprTrait<const VT1,AF>::Type
809 ,
typename SubvectorExprTrait<const VT2,AF>::Type >::Type Type;
818 template<
typename VT1,
typename VT2 >
819 struct RowExprTrait< SVecTSVecMultExpr<VT1,VT2> >
823 typedef typename MultExprTrait< typename VT1::ReturnType, VT2 >::Type Type;
832 template<
typename VT1,
typename VT2 >
833 struct ColumnExprTrait< SVecTSVecMultExpr<VT1,VT2> >
837 typedef typename MultExprTrait< VT1, typename VT2::ReturnType >::Type Type;
VT1::ReturnType RN1
Return type of the left-hand side sparse vector expression.
Definition: SVecTSVecMultExpr.h:101
SelectType< IsComputation< VT1 >::value, const RT1, CT1 >::Type LT
Type for the assignment of the left-hand side dense vector operand.
Definition: SVecTSVecMultExpr.h:141
VT1::CompositeType CT1
Composite type of the left-hand side sparse vector expression.
Definition: SVecTSVecMultExpr.h:103
VT2::ReturnType RN2
Return type of the right-hand side sparse vector expression.
Definition: SVecTSVecMultExpr.h:102
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:87
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:7820
Header file for basic type definitions.
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: SVecTSVecMultExpr.h:278
#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:79
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:207
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SVecTSVecMultExpr.h:187
RightOperand rhs_
Right-hand side sparse vector of the multiplication expression.
Definition: SVecTSVecMultExpr.h:286
Header file for the ColumnExprTrait class template.
ResultType::ElementType ElementType
Resulting element type.
Definition: SVecTSVecMultExpr.h:126
LeftOperand lhs_
Left-hand side sparse vector of the multiplication expression.
Definition: SVecTSVecMultExpr.h:285
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:340
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:259
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:721
Header file for the Computation base class.
RightOperand rightOperand() const
Returns the right-hand side sparse vector operand.
Definition: SVecTSVecMultExpr.h:254
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
size_t columns() const
Returns the current number of columns of the matrix.
Definition: SVecTSVecMultExpr.h:213
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:547
Constraint on the data type.
Header file for the SparseMatrix base class.
Constraint on the transpose flag of vector types.
Constraint on the data type.
Header file for the MultExprTrait class template.
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SVecTSVecMultExpr.h:171
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Header file for the IsTemporary type trait class.
Header file for the multiplication trait.
SelectType< IsComputation< VT2 >::value, const RT2, CT2 >::Type RT
Type for the assignment of the right-hand side dense vector operand.
Definition: SVecTSVecMultExpr.h:144
VT2::ResultType RT2
Result type of the right-hand side sparse vector expression.
Definition: SVecTSVecMultExpr.h:100
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
VT2::CompositeType CT2
Composite type of the right-hand side sparse vector expression.
Definition: SVecTSVecMultExpr.h:104
SVecTSVecMultExpr(const VT1 &lhs, const VT2 &rhs)
Constructor for the SVecTSVecMultExpr class.
Definition: SVecTSVecMultExpr.h:158
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
#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:161
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
Header file for the Columns type trait.
VT1::ResultType RT1
Result type of the left-hand side sparse vector expression.
Definition: SVecTSVecMultExpr.h:99
const ResultType CompositeType
Data type for composite expression templates.
Definition: SVecTSVecMultExpr.h:132
#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:79
Expression object for sparse vector-sparse vector outer products.The SVecTSVecMultExpr class represen...
Definition: Forward.h:137
MultExprTrait< RN1, RN2 >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: SVecTSVecMultExpr.h:117
MultTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: SVecTSVecMultExpr.h:123
Header file for the SelectType class template.
Header file for the RowExprTrait class template.
Header file for all forward declarations for expression class templates.
Constraint on the data type.
Header file for the VecTVecMultExpr base class.
Header file for the serial shim.
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: SVecTSVecMultExpr.h:266
#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:116
Header file for the SubmatrixExprTrait class template.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2587
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
Header file for run time assertion macros.
SVecTSVecMultExpr< VT1, VT2 > This
Type of this SVecTSVecMultExpr instance.
Definition: SVecTSVecMultExpr.h:122
Base template for the MultTrait class.
Definition: MultTrait.h:138
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SVecTSVecMultExpr.h:124
LeftOperand leftOperand() const
Returns the left-hand side sparse vector operand.
Definition: SVecTSVecMultExpr.h:244
Header file for the isDefault shim.
Constraint on the data type.
size_t rows() const
Returns the current number of rows of the matrix.
Definition: SVecTSVecMultExpr.h:203
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: SVecTSVecMultExpr.h:129
Constraint on the data type.
Header file for the RemoveReference type trait.
SelectType< IsExpression< VT2 >::value, const VT2, const VT2 & >::Type RightOperand
Composite type of the right-hand side sparse vector expression.
Definition: SVecTSVecMultExpr.h:138
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:118
#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
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2583
SelectType< IsExpression< VT1 >::value, const VT1, const VT1 & >::Type LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition: SVecTSVecMultExpr.h:135
#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:79
Header file for the SubvectorExprTrait class template.
Header file for exception macros.
Header file for the Size type trait.
Evaluation of the resulting expression type of a multiplication.Via this type trait it is possible to...
Definition: MultExprTrait.h:137
Size type of the Blaze library.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SVecTSVecMultExpr.h:223
#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
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SVecTSVecMultExpr.h:125
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:234