35 #ifndef _BLAZE_MATH_EXPRESSIONS_SVECTDVECMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SVECTDVECMULTEXPR_H_
89 template<
typename VT1
91 class SVecTDVecMultExpr :
public SparseMatrix< SVecTDVecMultExpr<VT1,VT2>, true >
92 ,
private VecTVecMultExpr
132 template<
typename MT >
135 enum { value = useAssign };
145 template<
typename T1,
typename T2,
typename T3 >
146 struct UseVectorizedKernel {
147 enum { value = T1::vectorizable && T3::vectorizable &&
160 template<
typename T1,
typename T2,
typename T3 >
161 struct UseDefaultKernel {
162 enum { value = !UseVectorizedKernel<T1,T2,T3>::value };
270 return it_->value() *
v_;
400 return lhs_.nonZeros() *
rhs_.size();
412 return lhs_.nonZeros();
442 template<
typename T >
444 return (
lhs_.canAlias( alias ) ||
rhs_.canAlias( alias ) );
454 template<
typename T >
456 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
478 template<
typename MT >
494 SVecTDVecMultExpr::selectAssignKernel( ~lhs, x, y );
513 template<
typename MT
521 const ConstIterator
end( x.end() );
523 for( ConstIterator element=x.begin(); element!=
end; ++element ) {
525 for(
size_t j=0UL; j<y.size(); ++j ) {
526 (~A)(element->index(),j) = element->
value() * y[j];
548 template<
typename MT
551 static inline typename EnableIf< UseVectorizedKernel<MT,VT3,VT4> >::Type
552 selectAssignKernel( DenseMatrix<MT,false>& A,
const VT3& x,
const VT4& y )
556 typedef IntrinsicTrait<ElementType> IT;
557 typedef typename IT::Type IntrinsicType;
559 const ConstIterator
begin( x.begin() );
560 const ConstIterator
end ( x.end() );
562 for( ConstIterator element=
begin; element!=
end; ++element )
564 const IntrinsicType x1(
set( element->value() ) );
566 for(
size_t j=0UL; j<(~A).
columns(); j+=IT::size ) {
567 (~A).
store( element->index(), j, x1 * y.load(j) );
590 template<
typename MT >
591 friend inline typename EnableIf< UseAssign<MT> >::Type
609 const ConstIterator
end( x.end() );
611 for(
size_t i=0UL; i<y.size(); ++i ) {
613 for( ConstIterator element=x.begin(); element!=
end; ++element ) {
614 (~lhs)(element->index(),i) = element->
value() * y[i];
634 template<
typename MT >
652 const ConstIterator
end( x.end() );
654 for( ConstIterator element=x.begin(); element!=
end; ++element ) {
656 (~lhs).reserve( element->index(), y.size() );
657 for(
size_t i=0UL; i<y.size(); ++i ) {
658 (~lhs).append( element->index(), i, element->value() * y[i] );
682 template<
typename MT >
683 friend inline typename EnableIf< UseAssign<MT> >::Type
701 const ConstIterator
end( x.end() );
703 for(
size_t i=0UL; i<y.size(); ++i ) {
705 (~lhs).reserve( i, x.nonZeros() );
706 for( ConstIterator element=x.begin(); element!=
end; ++element ) {
707 (~lhs).append( element->index(), i, element->value() * y[i] );
728 template<
typename MT >
744 SVecTDVecMultExpr::selectAddAssignKernel( ~lhs, x, y );
763 template<
typename MT
766 static inline typename EnableIf< UseDefaultKernel<MT,VT3,VT4> >::Type
767 selectAddAssignKernel( DenseMatrix<MT,false>& A,
const VT3& x,
const VT4& y )
771 const ConstIterator
end( x.end() );
773 for( ConstIterator element=x.begin(); element!=
end; ++element ) {
775 for(
size_t i=0UL; i<y.size(); ++i ) {
776 (~A)(element->index(),i) += element->
value() * y[i];
798 template<
typename MT
801 static inline typename EnableIf< UseVectorizedKernel<MT,VT3,VT4> >::Type
802 selectAddAssignKernel( DenseMatrix<MT,false>& A,
const VT3& x,
const VT4& y )
806 typedef IntrinsicTrait<ElementType> IT;
807 typedef typename IT::Type IntrinsicType;
809 const ConstIterator
begin( x.begin() );
810 const ConstIterator
end ( x.end() );
812 for( ConstIterator element=
begin; element!=
end; ++element )
814 const IntrinsicType x1(
set( element->value() ) );
816 for(
size_t j=0UL; j<(~A).
columns(); j+=IT::size ) {
817 (~A).
store( element->index(), j, (~A).
load(element->index(),j) + x1 * y.load(j) );
840 template<
typename MT >
841 friend inline typename EnableIf< UseAssign<MT> >::Type
859 const ConstIterator
end( x.end() );
861 for(
size_t i=0UL; i<y.size(); ++i ) {
863 for( ConstIterator element=x.begin(); element!=
end; ++element ) {
864 (~lhs)(element->index(),i) += element->
value() * y[i];
889 template<
typename MT >
905 SVecTDVecMultExpr::selectSubAssignKernel( ~lhs, x, y );
924 template<
typename MT
927 static inline typename EnableIf< UseDefaultKernel<MT,VT3,VT4> >::Type
928 selectSubAssignKernel( DenseMatrix<MT,false>& A,
const VT3& x,
const VT4& y )
932 const ConstIterator
end( x.end() );
934 for( ConstIterator element=x.begin(); element!=
end; ++element ) {
936 for(
size_t i=0UL; i<y.size(); ++i ) {
937 (~A)(element->index(),i) -= element->
value() * y[i];
959 template<
typename MT
962 static inline typename EnableIf< UseVectorizedKernel<MT,VT3,VT4> >::Type
963 selectSubAssignKernel( DenseMatrix<MT,false>& A,
const VT3& x,
const VT4& y )
967 typedef IntrinsicTrait<ElementType> IT;
968 typedef typename IT::Type IntrinsicType;
970 const ConstIterator
begin( x.begin() );
971 const ConstIterator
end ( x.end() );
973 for( ConstIterator element=
begin; element!=
end; ++element )
975 const IntrinsicType x1(
set( element->value() ) );
977 for(
size_t j=0UL; j<(~A).
columns(); j+=IT::size ) {
978 (~A).
store( element->index(), j, (~A).
load(element->index(),j) - x1 * y.load(j) );
1001 template<
typename MT >
1002 friend inline typename EnableIf< UseAssign<MT> >::Type
1020 const ConstIterator
end( x.end() );
1022 for(
size_t i=0UL; i<y.size(); ++i ) {
1024 for( ConstIterator element=x.begin(); element!=
end; ++element ) {
1025 (~lhs)(element->index(),i) -= element->
value() * y[i];
1094 template<
typename T1
1096 inline const SVecTDVecMultExpr<T1,T2>
1116 template<
typename VT1,
typename VT2 >
1121 typedef typename MultExprTrait< typename SubvectorExprTrait<const VT1>::Type
1122 ,
typename SubvectorExprTrait<const VT2>::Type >::Type Type;
1131 template<
typename VT1,
typename VT2 >
1136 typedef typename MultExprTrait< typename VT1::ReturnType, VT2 >::Type Type;
1145 template<
typename VT1,
typename VT2 >
1150 typedef typename MultExprTrait< VT1, typename VT2::ReturnType >::Type Type;
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SVecTDVecMultExpr.h:210
Pointer difference type of the Blaze library.
ValueType value_type
Type of the underlying pointers.
Definition: SVecTDVecMultExpr.h:218
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
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
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:3703
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SVecTDVecMultExpr.h:171
Iterator over the elements of the sparse vector-dense vector outer product expression.
Definition: SVecTDVecMultExpr.h:197
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: SVecTDVecMultExpr.h:443
RightOperand rightOperand() const
Returns the right-hand side dense vector operand.
Definition: SVecTDVecMultExpr.h:431
#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:4555
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:196
SelectType< IsExpression< VT2 >::value, const VT2, const VT2 & >::Type RightOperand
Composite type of the right-hand side dense vector expression.
Definition: SVecTDVecMultExpr.h:185
Header file for the ColumnExprTrait class template.
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of column i.
Definition: SVecTDVecMultExpr.h:358
Expression object for sparse vector-dense vector outer products.The SVecTDVecMultExpr class represent...
Definition: Forward.h:117
VT1::ResultType RT1
Result type of the left-hand side sparse vector expression.
Definition: SVecTDVecMultExpr.h:97
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2375
size_t index() const
Access to the current index of the sparse element.
Definition: SVecTDVecMultExpr.h:279
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:248
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:84
SelectType< IsComputation< VT1 >::value, const RT1, CT1 >::Type LT
Type for the assignment of the left-hand side dense vector operand.
Definition: SVecTDVecMultExpr.h:188
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of column i.
Definition: SVecTDVecMultExpr.h:369
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
ConstIterator(IteratorType it, RightElement v)
Constructor for the ConstIterator class.
Definition: SVecTDVecMultExpr.h:227
const Element operator*() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SVecTDVecMultExpr.h:249
RightOperand rhs_
Right-hand side dense vector of the multiplication expression.
Definition: SVecTDVecMultExpr.h:463
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Constraint on the data type.
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SVecTDVecMultExpr.h:214
DifferenceType difference_type
Difference between two iterators.
Definition: SVecTDVecMultExpr.h:221
Header file for the SparseMatrix base class.
Constraint on the data type.
Header file for the MultExprTrait class template.
IteratorType it_
Iterator over the elements of the left-hand side sparse vector expression.
Definition: SVecTDVecMultExpr.h:319
SVecTDVecMultExpr(const VT1 &lhs, const VT2 &rhs)
Constructor for the SVecTDVecMultExpr class.
Definition: SVecTDVecMultExpr.h:331
Header file for the ValueIndexPair class.
SelectType< IsComputation< VT2 >::value, const RT2, CT2 >::Type RT
Type for the assignment of the right-hand side dense vector operand.
Definition: SVecTDVecMultExpr.h:191
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.
RemoveReference< LeftOperand >::Type::ConstIterator IteratorType
Iterator type of the sparse vector expression.
Definition: SVecTDVecMultExpr.h:205
size_t columns() const
Returns the current number of columns of the matrix.
Definition: SVecTDVecMultExpr.h:389
VT2::CompositeType CT2
Composite type of the right-hand side dense vector expression.
Definition: SVecTDVecMultExpr.h:102
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SVecTDVecMultExpr.h:301
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2379
MultExprTrait< RN1, RN2 >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: SVecTDVecMultExpr.h:117
Element ValueType
Type of the underlying pointers.
Definition: SVecTDVecMultExpr.h:211
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:179
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
#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
ET2 RightElement
Element type of the dense vector expression.
Definition: SVecTDVecMultExpr.h:208
Constraint on the data type.
VT2::ResultType RT2
Result type of the right-hand side dense vector expression.
Definition: SVecTDVecMultExpr.h:98
size_t rows() const
Returns the current number of rows of the matrix.
Definition: SVecTDVecMultExpr.h:379
RightElement v_
Element of the right-hand side dense vector expression.
Definition: SVecTDVecMultExpr.h:320
Constraint on the data type.
SelectType< useAssign, const ResultType, const SVecTDVecMultExpr & >::Type CompositeType
Data type for composite expression templates.
Definition: SVecTDVecMultExpr.h:179
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2373
SVecTDVecMultExpr< VT1, VT2 > This
Type of this SVecTDVecMultExpr instance.
Definition: SVecTDVecMultExpr.h:169
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 sparse vector expression.
Definition: SVecTDVecMultExpr.h:101
ReferenceType reference
Reference return type.
Definition: SVecTDVecMultExpr.h:220
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SVecTDVecMultExpr.h:290
Header file for the IsNumeric type trait.
VT2::ReturnType RN2
Return type of the right-hand side dense vector expression.
Definition: SVecTDVecMultExpr.h:100
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: SVecTDVecMultExpr.h:176
Header file for the SubmatrixExprTrait class template.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2374
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
IteratorCategory iterator_category
The iterator category.
Definition: SVecTDVecMultExpr.h:217
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:648
Header file for run time assertion macros.
Base template for the MultTrait class.
Definition: MultTrait.h:141
ReturnType value() const
Access to the current value of the sparse element.
Definition: SVecTDVecMultExpr.h:269
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:209
LeftOperand leftOperand() const
Returns the left-hand side sparse vector operand.
Definition: SVecTDVecMultExpr.h:421
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
VT2::ElementType ET2
Element type of the right-hand side dense vector expression.
Definition: SVecTDVecMultExpr.h:104
ResultType::ElementType ElementType
Resulting element type.
Definition: SVecTDVecMultExpr.h:173
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: SVecTDVecMultExpr.h:455
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:239
Header file for the isDefault shim.
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SVecTDVecMultExpr.h:172
ValueType * PointerType
Pointer return type.
Definition: SVecTDVecMultExpr.h:212
VT1::ElementType ET1
Element type of the left-hand side sparse vector expression.
Definition: SVecTDVecMultExpr.h:103
ValueIndexPair< ElementType > Element
Element type of the sparse matrix expression.
Definition: SVecTDVecMultExpr.h:202
Header file for the RemoveReference type trait.
LeftOperand lhs_
Left-hand side sparse vector of the multiplication expression.
Definition: SVecTDVecMultExpr.h:462
Header file for all intrinsic functionality.
PointerType pointer
Pointer return type.
Definition: SVecTDVecMultExpr.h:219
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SVecTDVecMultExpr.h:312
#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
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:69
Header file for the IsComputation type trait class.
const ConstIterator * operator->() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SVecTDVecMultExpr.h:259
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:105
#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:2370
Header file for basic type definitions.
ConstIterator & operator++()
Pre-increment operator.
Definition: SVecTDVecMultExpr.h:238
#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
Header file for the SubvectorExprTrait class template.
ValueType & ReferenceType
Reference return type.
Definition: SVecTDVecMultExpr.h:213
MultTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: SVecTDVecMultExpr.h:170
VT1::ReturnType RN1
Return type of the left-hand side sparse vector expression.
Definition: SVecTDVecMultExpr.h:99
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified column.
Definition: SVecTDVecMultExpr.h:410
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SVecTDVecMultExpr.h:344
Evaluation of the resulting expression type of a multiplication.Via this type trait it is possible to...
Definition: MultExprTrait.h:137
SelectType< IsExpression< VT1 >::value, const VT1, const VT1 & >::Type LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition: SVecTDVecMultExpr.h:182
#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
void store(float *address, const sse_float_t &value)
Aligned store of a vector of 'float' values.
Definition: Store.h:242
Header file for the IsExpression type trait class.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SVecTDVecMultExpr.h:399
Header file for the FunctionTrace class.