35 #ifndef _BLAZE_MATH_EXPRESSIONS_DVECTSVECMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DVECTSVECMULTEXPR_H_
91 template<
typename VT1
135 template<
typename MT >
138 enum { value = useAssign };
148 template<
typename T1,
typename T2,
typename T3 >
149 struct UseVectorizedKernel {
150 enum { value = T1::vectorizable && T2::vectorizable &&
163 template<
typename T1,
typename T2,
typename T3 >
164 struct UseDefaultKernel {
165 enum { value = !UseVectorizedKernel<T1,T2,T3>::value };
199 enum { smpAssignable = 0 };
278 return v_ *
it_->value();
408 return lhs_.size() *
rhs_.nonZeros();
420 return rhs_.nonZeros();
450 template<
typename T >
452 return (
lhs_.canAlias( alias ) ||
rhs_.canAlias( alias ) );
462 template<
typename T >
464 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
489 template<
typename MT >
508 const ConstIterator
begin( y.begin() );
509 const ConstIterator
end ( y.end() );
511 for(
size_t i=0UL; i<(~lhs).
rows(); ++i ) {
512 for( ConstIterator element=
begin; element!=
end; ++element ) {
513 (~lhs)(i,element->index()) = x[i] * element->
value();
533 template<
typename MT >
549 DVecTSVecMultExpr::selectAssignKernel( ~lhs, x, y );
568 template<
typename MT
571 static inline typename EnableIf< UseDefaultKernel<MT,VT3,VT4> >::Type
572 selectAssignKernel( DenseMatrix<MT,true>& A,
const VT3& x,
const VT4& y )
576 const ConstIterator
begin( y.begin() );
577 const ConstIterator
end ( y.end() );
579 for( ConstIterator element=
begin; element!=
end; ++element ) {
580 for(
size_t i=0UL; i<(~A).
rows(); ++i ) {
581 (~A)(i,element->index()) = x[i] * element->
value();
602 template<
typename MT
605 static inline typename EnableIf< UseVectorizedKernel<MT,VT3,VT4> >::Type
606 selectAssignKernel( DenseMatrix<MT,true>& A,
const VT3& x,
const VT4& y )
610 typedef IntrinsicTrait<ElementType> IT;
611 typedef typename IT::Type IntrinsicType;
613 const ConstIterator
begin( y.begin() );
614 const ConstIterator
end ( y.end() );
616 for( ConstIterator element=
begin; element!=
end; ++element )
618 const IntrinsicType y1(
set( element->value() ) );
620 for(
size_t i=0UL; i<(~A).
rows(); i+=IT::size ) {
621 (~A).
store( i, element->index(), x.load(i) * y1 );
643 template<
typename MT >
644 friend inline typename EnableIf< UseAssign<MT> >::Type
654 LT x(
serial( rhs.lhs_ ) );
655 RT y(
serial( rhs.rhs_ ) );
662 const ConstIterator
begin( y.begin() );
663 const ConstIterator
end ( y.end() );
665 for(
size_t i=0UL; i<x.size(); ++i ) {
667 (~lhs).reserve( i, y.nonZeros() );
668 for( ConstIterator element=
begin; element!=
end; ++element ) {
669 (~lhs).append( i, element->index(), x[i] * element->value() );
690 template<
typename MT >
700 LT x(
serial( rhs.lhs_ ) );
701 RT y(
serial( rhs.rhs_ ) );
708 const ConstIterator
begin( y.begin() );
709 const ConstIterator
end ( y.end() );
711 for( ConstIterator element=
begin; element!=
end; ++element ) {
713 (~lhs).reserve( element->index(), x.size() );
714 for(
size_t i=0UL; i<(~lhs).
rows(); ++i ) {
715 (~lhs).append( i, element->index(), x[i] * element->value() );
739 template<
typename MT >
740 friend inline typename EnableIf< UseAssign<MT> >::Type
750 LT x(
serial( rhs.lhs_ ) );
751 RT y(
serial( rhs.rhs_ ) );
758 const ConstIterator
begin( y.begin() );
759 const ConstIterator
end ( y.end() );
761 for(
size_t i=0UL; i<(~lhs).
rows(); ++i ) {
762 for( ConstIterator element=
begin; element!=
end; ++element ) {
763 (~lhs)(i,element->index()) += x[i] * element->
value();
783 template<
typename MT >
791 LT x(
serial( rhs.lhs_ ) );
792 RT y(
serial( rhs.rhs_ ) );
799 DVecTSVecMultExpr::selectAddAssignKernel( ~lhs, x, y );
818 template<
typename MT
821 static inline typename EnableIf< UseDefaultKernel<MT,VT3,VT4> >::Type
822 selectAddAssignKernel( DenseMatrix<MT,true>& A,
const VT3& x,
const VT4& y )
826 const ConstIterator
begin( y.begin() );
827 const ConstIterator
end ( y.end() );
829 for( ConstIterator element=
begin; element!=
end; ++element ) {
830 for(
size_t i=0UL; i<(~A).
rows(); ++i ) {
831 (~A)(i,element->index()) += x[i] * element->
value();
852 template<
typename MT
855 static inline typename EnableIf< UseVectorizedKernel<MT,VT3,VT4> >::Type
856 selectAddAssignKernel( DenseMatrix<MT,true>& A,
const VT3& x,
const VT4& y )
860 typedef IntrinsicTrait<ElementType> IT;
861 typedef typename IT::Type IntrinsicType;
863 const ConstIterator
begin( y.begin() );
864 const ConstIterator
end ( y.end() );
866 for( ConstIterator element=
begin; element!=
end; ++element )
868 const IntrinsicType y1(
set( element->value() ) );
870 for(
size_t i=0UL; i<(~A).
rows(); i+=IT::size ) {
871 (~A).
store( i, element->index(), (~A).
load(i,element->index()) + x.load(i) * y1 );
898 template<
typename MT >
899 friend inline typename EnableIf< UseAssign<MT> >::Type
909 LT x(
serial( rhs.lhs_ ) );
910 RT y(
serial( rhs.rhs_ ) );
917 const ConstIterator
begin( y.begin() );
918 const ConstIterator
end ( y.end() );
920 for(
size_t i=0UL; i<(~lhs).
rows(); ++i ) {
921 for( ConstIterator element=
begin; element!=
end; ++element ) {
922 (~lhs)(i,element->index()) -= x[i] * element->
value();
942 template<
typename MT >
950 LT x(
serial( rhs.lhs_ ) );
951 RT y(
serial( rhs.rhs_ ) );
958 DVecTSVecMultExpr::selectSubAssignKernel( ~lhs, x, y );
977 template<
typename MT
980 static inline typename EnableIf< UseDefaultKernel<MT,VT3,VT4> >::Type
981 selectSubAssignKernel( DenseMatrix<MT,true>& A,
const VT3& x,
const VT4& y )
985 const ConstIterator
begin( y.begin() );
986 const ConstIterator
end ( y.end() );
988 for( ConstIterator element=
begin; element!=
end; ++element ) {
989 for(
size_t i=0UL; i<(~A).
rows(); ++i ) {
990 (~A)(i,element->index()) -= x[i] * element->
value();
1011 template<
typename MT
1014 static inline typename EnableIf< UseVectorizedKernel<MT,VT3,VT4> >::Type
1015 selectSubAssignKernel( DenseMatrix<MT,true>& A,
const VT3& x,
const VT4& y )
1019 typedef IntrinsicTrait<ElementType> IT;
1020 typedef typename IT::Type IntrinsicType;
1022 const ConstIterator
begin( y.begin() );
1023 const ConstIterator
end ( y.end() );
1025 for( ConstIterator element=
begin; element!=
end; ++element )
1027 const IntrinsicType y1(
set( element->value() ) );
1029 for(
size_t i=0UL; i<(~A).
rows(); i+=IT::size ) {
1030 (~A).
store( i, element->index(), (~A).
load(i,element->index()) - x.load(i) * y1 );
1098 template<
typename T1
1100 inline const DVecTSVecMultExpr<T1,T2>
1120 template<
typename VT1,
typename VT2,
bool AF >
1125 typedef typename MultExprTrait< typename SubvectorExprTrait<const VT1,AF>::Type
1126 ,
typename SubvectorExprTrait<const VT2,AF>::Type >::Type Type;
1135 template<
typename VT1,
typename VT2 >
1140 typedef typename MultExprTrait< typename VT1::ReturnType, VT2 >::Type Type;
1149 template<
typename VT1,
typename VT2 >
1154 typedef typename MultExprTrait< VT1, typename VT2::ReturnType >::Type Type;
ValueType * PointerType
Pointer return type.
Definition: DVecTSVecMultExpr.h:220
Pointer difference type of the Blaze library.
VT1::ReturnType RN1
Return type of the left-hand side dense vector expression.
Definition: DVecTSVecMultExpr.h:101
Compile time check whether the given type is a computational expression template.This type trait clas...
Definition: IsComputation.h:89
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:98
PointerType pointer
Pointer return type.
Definition: DVecTSVecMultExpr.h:227
EnableIf< IsIntegral< T > >::Type store(T *address, const typename Store< T, sizeof(T)>::Type &value)
Aligned store of a vector of integral values.
Definition: Store.h:223
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:87
EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:222
VT2::ElementType ET2
Element type of the right-hand side sparse vector expression.
Definition: DVecTSVecMultExpr.h:106
ValueType & ReferenceType
Reference return type.
Definition: DVecTSVecMultExpr.h:221
Header file for the UNUSED_PARAMETER function template.
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:4329
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: DVecTSVecMultExpr.h:463
SelectType< IsComputation< VT1 >::value, const RT1, CT1 >::Type LT
Type for the assignment of the left-hand side dense vector operand.
Definition: DVecTSVecMultExpr.h:191
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DVecTSVecMultExpr.h:222
size_t rows() const
Returns the current number of rows of the matrix.
Definition: DVecTSVecMultExpr.h:387
#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: TransposeFlag.h:159
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4642
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:199
Header file for the ColumnExprTrait class template.
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DVecTSVecMultExpr.h:309
const ConstIterator * operator->() const
Direct access to the sparse matrix element at the current iterator position.
Definition: DVecTSVecMultExpr.h:267
VT1::ElementType ET1
Element type of the left-hand side dense vector expression.
Definition: DVecTSVecMultExpr.h:105
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2408
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:251
IteratorType it_
Iterator over the elements of the right-hand side sparse vector expression.
Definition: DVecTSVecMultExpr.h:328
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:84
size_t index() const
Access to the current index of the sparse element.
Definition: DVecTSVecMultExpr.h:287
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: DVecTSVecMultExpr.h:218
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:690
Header file for the Computation base class.
Type relationship analysis.This class tests if the two data types A and B are equal. For this type comparison, the cv-qualifiers of both data types are ignored. If A and B are the same data type (ignoring the cv-qualifiers), then the value member enumeration is set to 1, the nested type definition Type is TrueType, and the class derives from TrueType. Otherwise value is set to 0, Type is FalseType, and the class derives from FalseType.
Definition: IsSame.h:158
SelectType< IsExpression< VT2 >::value, const VT2, const VT2 & >::Type RightOperand
Composite type of the right-hand side sparse vector expression.
Definition: DVecTSVecMultExpr.h:188
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DVecTSVecMultExpr.h:352
Element ValueType
Type of the underlying pointers.
Definition: DVecTSVecMultExpr.h:219
const Element operator*() const
Direct access to the sparse matrix element at the current iterator position.
Definition: DVecTSVecMultExpr.h:257
DVecTSVecMultExpr(const VT1 &lhs, const VT2 &rhs)
Constructor for the DVecTSVecMultExpr class.
Definition: DVecTSVecMultExpr.h:339
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:107
Constraint on the data type.
MultExprTrait< RN1, RN2 >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: DVecTSVecMultExpr.h:119
Header file for the SparseMatrix base class.
Constraint on the data type.
Header file for the MultExprTrait class template.
ValueType value_type
Type of the underlying pointers.
Definition: DVecTSVecMultExpr.h:226
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: DVecTSVecMultExpr.h:366
Header file for the ValueIndexPair class.
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.
ConstIterator & operator++()
Pre-increment operator.
Definition: DVecTSVecMultExpr.h:246
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2412
LeftOperand lhs_
Left-hand side dense vector of the multiplication expression.
Definition: DVecTSVecMultExpr.h:470
ResultType::ElementType ElementType
Resulting element type.
Definition: DVecTSVecMultExpr.h:176
Expression object for dense vector-sparse vector outer products.The DVecTSVecMultExpr class represent...
Definition: DVecTSVecMultExpr.h:93
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: DVecTSVecMultExpr.h:451
ConstIterator(LeftElement v, IteratorType it)
Constructor for the ConstIterator class.
Definition: DVecTSVecMultExpr.h:235
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DVecTSVecMultExpr.h:298
void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:271
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
IteratorCategory iterator_category
The iterator category.
Definition: DVecTSVecMultExpr.h:225
#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
Constraint on the data type.
Constraint on the data type.
DifferenceType difference_type
Difference between two iterators.
Definition: DVecTSVecMultExpr.h:229
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2406
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.
VT1::CompositeType CT1
Composite type of the left-hand side dense vector expression.
Definition: DVecTSVecMultExpr.h:103
Header file for the EnableIf class template.
Header file for the serial shim.
RightOperand rightOperand() const
Returns the right-hand side sparse vector operand.
Definition: DVecTSVecMultExpr.h:439
Header file for the IsNumeric type trait.
LeftOperand leftOperand() const
Returns the left-hand side dense vector operand.
Definition: DVecTSVecMultExpr.h:429
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: DVecTSVecMultExpr.h:377
Iterator over the elements of the dense vector-sparse vector outer product expression.
Definition: DVecTSVecMultExpr.h:205
Header file for the SubmatrixExprTrait class template.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2407
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
VT1::ResultType RT1
Result type of the left-hand side dense vector expression.
Definition: DVecTSVecMultExpr.h:99
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:748
size_t columns() const
Returns the current number of columns of the matrix.
Definition: DVecTSVecMultExpr.h:397
Header file for run time assertion macros.
Base template for the MultTrait class.
Definition: MultTrait.h:141
RightOperand rhs_
Right-hand side sparse vector of the multiplication expression.
Definition: DVecTSVecMultExpr.h:471
void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:301
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DVecTSVecMultExpr.h:175
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
DVecTSVecMultExpr< VT1, VT2 > This
Type of this DVecTSVecMultExpr instance.
Definition: DVecTSVecMultExpr.h:172
ValueIndexPair< ElementType > Element
Element type of the sparse matrix expression.
Definition: DVecTSVecMultExpr.h:210
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: DVecTSVecMultExpr.h:418
void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:331
Header file for the isDefault shim.
ReferenceType reference
Reference return type.
Definition: DVecTSVecMultExpr.h:228
ReturnType value() const
Access to the current value of the sparse element.
Definition: DVecTSVecMultExpr.h:277
Header file for the RemoveReference type trait.
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DVecTSVecMultExpr.h:174
Base class for all outer product expression templates.The VecTVecMultExpr class serves as a tag for a...
Definition: VecTVecMultExpr.h:66
ET1 LeftElement
Element type of the dense vector expression.
Definition: DVecTSVecMultExpr.h:213
Header file for all intrinsic functionality.
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:79
VT2::ReturnType RN2
Return type of the right-hand side sparse vector expression.
Definition: DVecTSVecMultExpr.h:102
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:69
MultTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: DVecTSVecMultExpr.h:173
Header file for the IsComputation type trait class.
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: DVecTSVecMultExpr.h:179
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:59
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:108
#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:2403
LeftElement v_
Element of the left-hand side dense vector expression.
Definition: DVecTSVecMultExpr.h:327
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: DVecTSVecMultExpr.h:320
SelectType< useAssign, const ResultType, const DVecTSVecMultExpr & >::Type CompositeType
Data type for composite expression templates.
Definition: DVecTSVecMultExpr.h:182
Header file for basic type definitions.
#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: TransposeFlag.h:81
RemoveReference< RightOperand >::Type::ConstIterator IteratorType
Iterator type of the sparse vector expression.
Definition: DVecTSVecMultExpr.h:216
Header file for the SubvectorExprTrait class template.
VT2::CompositeType CT2
Composite type of the right-hand side sparse vector expression.
Definition: DVecTSVecMultExpr.h:104
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: DVecTSVecMultExpr.h:407
SelectType< IsExpression< VT1 >::value, const VT1, const VT1 & >::Type LeftOperand
Composite type of the left-hand side dense vector expression.
Definition: DVecTSVecMultExpr.h:185
VT2::ResultType RT2
Result type of the right-hand side sparse vector expression.
Definition: DVecTSVecMultExpr.h:100
Evaluation of the resulting expression type of a multiplication.Via this type trait it is possible to...
Definition: MultExprTrait.h:137
#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
EnableIf< IsIntegral< T >, Set< T, sizeof(T)> >::Type::Type set(T value)
Sets all values in the vector to the given integral value.
Definition: Set.h:209
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.
SelectType< IsComputation< VT2 >::value, const RT2, CT2 >::Type RT
Type for the assignment of the right-hand side dense vector operand.
Definition: DVecTSVecMultExpr.h:194