35 #ifndef _BLAZE_MATH_EXPRESSIONS_DVECSVECOUTEREXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_DVECSVECOUTEREXPR_H_ 99 template<
typename VT1
102 :
public VecTVecMultExpr< SparseMatrix< DVecSVecOuterExpr<VT1,VT2>, false > >
143 template<
typename MT >
146 enum :
bool { value = useAssign };
156 template<
typename T1,
typename T2,
typename T3 >
157 struct UseVectorizedKernel {
158 enum :
bool { value = useOptimizedKernels &&
159 T1::simdEnabled && T2::simdEnabled &&
172 template<
typename T1,
typename T2,
typename T3 >
173 struct UseDefaultKernel {
174 enum :
bool { value = !UseVectorizedKernel<T1,T2,T3>::value };
262 return Element( v_ * it_->value(), it_->index() );
282 return v_ * it_->value();
303 return it_ == rhs.
it_;
314 return it_ != rhs.
it_;
325 return it_ - rhs.
it_;
339 enum :
bool { smpAssignable =
false };
383 if( i >=
lhs_.size() ) {
386 if( j >=
rhs_.size() ) {
420 inline size_t rows() const noexcept {
441 return lhs_.size() *
rhs_.nonZeros();
453 return rhs_.nonZeros();
522 template<
typename T >
523 inline bool canAlias(
const T* alias )
const noexcept {
524 return (
lhs_.canAlias( alias ) ||
rhs_.canAlias( alias ) );
534 template<
typename T >
535 inline bool isAliased(
const T* alias )
const noexcept {
536 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
561 template<
typename MT >
580 const ConstIterator
begin( y.begin() );
581 const ConstIterator
end ( y.end() );
583 for(
size_t i=0UL; i<x.size(); ++i ) {
584 for( ConstIterator element=
begin; element!=
end; ++element ) {
585 (~lhs)(i,element->index()) = x[i] * element->
value();
605 template<
typename MT >
623 DVecSVecOuterExpr::selectAssignKernel( ~lhs, x, y );
642 template<
typename MT
654 for(
size_t i=0UL; i<x.size(); ++i ) {
655 (~A)(i,element->index()) = x[i] * element->
value();
676 template<
typename MT
686 const size_t M( (~A).
rows() );
688 const size_t ipos( remainder ? ( M &
size_t(-SIMDSIZE) ) : M );
700 for( ; i<ipos; i+=SIMDSIZE ) {
701 (~A).store( i, element->index(), x.load(i) * y1 );
703 for( ; remainder && i<M; ++i ) {
704 (~A)(i,element->index()) = x[i] * element->value();
726 template<
typename MT >
746 const ConstIterator
begin( y.begin() );
747 const ConstIterator
end ( y.end() );
752 for(
size_t i=0UL; i<x.size(); ++i ) {
754 for( ConstIterator element=
begin; element!=
end; ++element ) {
755 (~lhs).append( i, element->index(), x[i] * element->value() );
758 (~lhs).finalize( i );
777 template<
typename MT >
797 const ConstIterator
begin( y.begin() );
798 const ConstIterator
end ( y.end() );
807 for( ConstIterator element=
begin; element!=
end; ++element ) {
809 for( ; index < element->index(); ++index ) {
810 (~lhs).finalize( index );
812 for(
size_t i=0UL; i<x.size(); ++i ) {
813 (~lhs).append( i, element->index(), x[i] * element->value() );
815 (~lhs).finalize( index++ );
819 for( ; index < y.size(); ++index ) {
820 (~lhs).finalize( index );
842 template<
typename MT >
861 const ConstIterator
begin( y.begin() );
862 const ConstIterator
end ( y.end() );
864 for(
size_t i=0UL; i<x.size(); ++i ) {
866 for( ConstIterator element=
begin; element!=
end; ++element ) {
867 (~lhs)(i,element->index()) += x[i] * element->
value();
888 template<
typename MT >
906 DVecSVecOuterExpr::selectAddAssignKernel( ~lhs, x, y );
925 template<
typename MT
938 for(
size_t i=0UL; i<x.size(); ++i ) {
939 (~A)(i,element->index()) += x[i] * element->
value();
961 template<
typename MT
971 const size_t M( (~A).
rows() );
973 const size_t ipos( remainder ? ( M &
size_t(-SIMDSIZE) ) : M );
981 if(
isDefault( element->value() ) )
continue;
987 for( ; i<ipos; i+=SIMDSIZE ) {
988 (~A).store( i, element->index(), (~A).load(i,element->index()) + x.load(i) * y1 );
990 for( ; remainder && i<M; ++i ) {
991 (~A)(i,element->index()) += x[i] * element->value();
1018 template<
typename MT >
1037 const ConstIterator
begin( y.begin() );
1038 const ConstIterator
end ( y.end() );
1040 for(
size_t i=0UL; i<x.size(); ++i ) {
1042 for( ConstIterator element=
begin; element!=
end; ++element ) {
1043 (~lhs)(i,element->index()) -= x[i] * element->
value();
1064 template<
typename MT >
1082 DVecSVecOuterExpr::selectSubAssignKernel( ~lhs, x, y );
1101 template<
typename MT
1114 for(
size_t i=0UL; i<x.size(); ++i ) {
1115 (~A)(i,element->index()) -= x[i] * element->
value();
1137 template<
typename MT
1147 const size_t M( (~A).
rows() );
1149 const size_t ipos( remainder ? ( M &
size_t(-SIMDSIZE) ) : M );
1157 if(
isDefault( element->value() ) )
continue;
1163 for( ; i<ipos; i+=SIMDSIZE ) {
1164 (~A).store( i, element->index(), (~A).load(i,element->index()) - x.load(i) * y1 );
1166 for( ; remainder && i<M; ++i ) {
1167 (~A)(i,element->index()) -= x[i] * element->value();
1194 template<
typename MT >
1213 const ConstIterator
end( y.end() );
1215 for(
size_t i=0UL; i<x.size(); ++i )
1219 for( ConstIterator element=y.begin(); element!=
end; ++element, ++j ) {
1220 for( ; j<element->index(); ++j )
1221 reset( (~lhs)(i,j) );
1222 (~lhs)(i,element->index()) *= x[i] * element->value();
1225 for( ; j<y.size(); ++j ) {
1226 reset( (~lhs)(i,j) );
1246 template<
typename MT >
1264 DVecSVecOuterExpr::selectSchurAssignKernel( ~lhs, x, y );
1283 template<
typename MT
1297 if(
isDefault( element->value() ) )
continue;
1299 for( ; j<element->index(); ++j ) {
1300 for(
size_t i=0UL; i<x.size(); ++i )
1304 for(
size_t i=0UL; i<x.size(); ++i ) {
1305 (~A)(i,element->index()) *= x[i] * element->value();
1311 for( ; j<y.size(); ++j ) {
1312 for(
size_t i=0UL; i<x.size(); ++i )
1333 template<
typename MT
1343 const size_t M( (~A).
rows() );
1344 const size_t N( (~A).
columns() );
1346 const size_t ipos( remainder ? ( M &
size_t(-SIMDSIZE) ) : M );
1356 if(
isDefault( element->value() ) )
continue;
1358 for( ; j<element->index(); ++j ) {
1359 for(
size_t i=0UL; i<M; ++i )
1367 for( ; i<ipos; i+=SIMDSIZE ) {
1368 (~A).store( i, element->index(), (~A).load(i,element->index()) * ( x.load(i) * y1 ) );
1370 for( ; remainder && i<M; ++i ) {
1371 (~A)(i,element->index()) *= x[i] * element->value();
1378 for(
size_t i=0UL; i<M; ++i )
1447 template<
typename VT1
1449 inline decltype(
auto)
1470 template<
typename VT1,
typename VT2 >
1471 struct Rows< DVecSVecOuterExpr<VT1,VT2> >
1488 template<
typename VT1,
typename VT2 >
1489 struct Columns< DVecSVecOuterExpr<VT1,VT2> >
ConstIterator_< RemoveReference_< RightOperand > > IteratorType
Iterator type of the sparse vector expression.
Definition: DVecSVecOuterExpr.h:220
CompositeType_< VT2 > CT2
Composite type of the right-hand side sparse vector expression.
Definition: DVecSVecOuterExpr.h:112
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DVecSVecOuterExpr.h:535
Pointer difference type of the Blaze library.
Header file for auxiliary alias declarations.
Compile time check whether the given type is a computational expression template.This type trait clas...
Definition: IsComputation.h:72
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:79
ResultType_< VT1 > RT1
Result type of the left-hand side dense vector expression.
Definition: DVecSVecOuterExpr.h:107
LeftElement v_
Element of the left-hand side dense vector expression.
Definition: DVecSVecOuterExpr.h:331
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.
Header file for the UNUSED_PARAMETER function template.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:356
Header file for basic type definitions.
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DVecSVecOuterExpr.h:430
ElementType_< VT2 > ET2
Element type of the right-hand side sparse vector expression.
Definition: DVecSVecOuterExpr.h:114
#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.
IfTrue_< useAssign, const ResultType, const DVecSVecOuterExpr &> CompositeType
Data type for composite expression templates.
Definition: DVecSVecOuterExpr.h:191
Expression object for dense vector-sparse vector outer products.The DVecSVecOuterExpr class represent...
Definition: DVecSVecOuterExpr.h:101
Header file for the IsSame and IsStrictlySame type traits.
const Element operator*() const
Direct access to the sparse matrix element at the current iterator position.
Definition: DVecSVecOuterExpr.h:261
Availability of a SIMD multiplication for the given data types.Depending on the available instruction...
Definition: HasSIMDMult.h:172
typename SIMDTrait< T >::Type SIMDTrait_
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_ alias declaration provide...
Definition: SIMDTrait.h:316
ElementType_< ResultType > ElementType
Resulting element type.
Definition: DVecSVecOuterExpr.h:185
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:560
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DVecSVecOuterExpr.h:382
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:250
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 constant is set to true, the nested type definition Type is TrueType, and the class derives from TrueType. Otherwise value is set to false, Type is FalseType, and the class derives from FalseType.
Definition: IsSame.h:140
If_< IsExpression< VT2 >, const VT2, const VT2 &> RightOperand
Composite type of the right-hand side sparse vector expression.
Definition: DVecSVecOuterExpr.h:197
System settings for performance optimizations.
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:343
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:78
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:129
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
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:363
Header file for the SparseMatrix base class.
Constraint on the transpose flag of vector types.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: DVecSVecOuterExpr.h:440
Constraint on the data type.
size_t index() const
Access to the current index of the sparse element.
Definition: DVecSVecOuterExpr.h:291
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: DVecSVecOuterExpr.h:410
typename MultExprTrait< T1, T2 >::Type MultExprTrait_
Auxiliary alias declaration for the MultExprTrait class template.The MultExprTrait_ alias declaration...
Definition: MultExprTrait.h:112
Header file for the MultExprTrait class template.
IteratorType it_
Iterator over the elements of the right-hand side sparse vector expression.
Definition: DVecSVecOuterExpr.h:332
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
IteratorCategory iterator_category
The iterator category.
Definition: DVecSVecOuterExpr.h:229
Header file for the ValueIndexPair class.
Header file for the IsTemporary type trait class.
Header file for the multiplication trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
DVecSVecOuterExpr(const VT1 &lhs, const VT2 &rhs) noexcept
Constructor for the DVecSVecOuterExpr class.
Definition: DVecSVecOuterExpr.h:353
Iterator over the elements of the dense vector-sparse vector outer product expression.
Definition: DVecSVecOuterExpr.h:209
ConstIterator lowerBound(size_t i, size_t j) const
Returns an iterator to the first index not less then the given index.
Definition: DVecSVecOuterExpr.h:477
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DVecSVecOuterExpr.h:523
#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:104
Compile time check for data types with padding.This type trait tests whether the given data type empl...
Definition: IsPadded.h:76
#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.
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DVecSVecOuterExpr.h:313
If_< IsExpression< VT1 >, const VT1, const VT1 &> LeftOperand
Composite type of the left-hand side dense vector expression.
Definition: DVecSVecOuterExpr.h:194
ResultType_< VT2 > RT2
Result type of the right-hand side sparse vector expression.
Definition: DVecSVecOuterExpr.h:108
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3087
CompositeType_< VT1 > CT1
Composite type of the left-hand side dense vector expression.
Definition: DVecSVecOuterExpr.h:111
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Header file for all SIMD functionality.
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:61
Constraint on the data type.
If_< IsComputation< VT2 >, const RT2, CT2 > RT
Type for the assignment of the right-hand side dense vector operand.
Definition: DVecSVecOuterExpr.h:203
Header file for the exception macros of the math module.
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DVecSVecOuterExpr.h:302
Constraint on the data type.
const IfTrue_< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DVecSVecOuterExpr.h:188
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 EnableIf class template.
ReturnType value() const
Access to the current value of the sparse element.
Definition: DVecSVecOuterExpr.h:281
ElementType_< VT1 > ET1
Element type of the left-hand side dense vector expression.
Definition: DVecSVecOuterExpr.h:113
Header file for the IsNumeric type trait.
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse vector operand.
Definition: DVecSVecOuterExpr.h:511
ConstIterator find(size_t i, size_t j) const
Searches for a specific matrix element.
Definition: DVecSVecOuterExpr.h:464
#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 HasSIMDMult type trait.
Header file for run time assertion macros.
ET1 LeftElement
Element type of the dense vector expression.
Definition: DVecSVecOuterExpr.h:217
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:154
ConstIterator upperBound(size_t i, size_t j) const
Returns an iterator to the first index greater then the given index.
Definition: DVecSVecOuterExpr.h:490
MultExprTrait_< RN1, RN2 > ExprReturnType
Expression return type for the subscript operator.
Definition: DVecSVecOuterExpr.h:127
Header file for the reset shim.
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:296
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
Header file for the isDefault shim.
Constraint on the data type.
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: DVecSVecOuterExpr.h:324
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:819
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
ReturnType_< VT1 > RN1
Return type of the left-hand side dense vector expression.
Definition: DVecSVecOuterExpr.h:109
Constraint on the data type.
Header file for the RemoveReference type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
Base class for all outer product expression templates.The VecTVecMultExpr class serves as a tag for a...
Definition: VecTVecMultExpr.h:67
typename T::OppositeType OppositeType_
Alias declaration for nested OppositeType type definitions.The OppositeType_ alias declaration provid...
Definition: Aliases.h:263
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: DVecSVecOuterExpr.h:222
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3082
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
#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:61
LeftOperand lhs_
Left-hand side dense vector of the multiplication expression.
Definition: DVecSVecOuterExpr.h:542
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:73
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DVecSVecOuterExpr.h:366
RightOperand rhs_
Right-hand side sparse vector of the multiplication expression.
Definition: DVecSVecOuterExpr.h:543
Header file for the IsComputation type trait class.
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:66
ConstIterator(LeftElement v, IteratorType it)
Constructor for the ConstIterator class.
Definition: DVecSVecOuterExpr.h:239
ReturnType_< VT2 > RN2
Return type of the right-hand side sparse vector expression.
Definition: DVecSVecOuterExpr.h:110
Compile time evaluation of the size of a vector.The Size type trait evaluates the size of the given v...
Definition: Size.h:74
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: DVecSVecOuterExpr.h:399
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:130
If_< IsComputation< VT1 >, const RT1, CT1 > LT
Type for the assignment of the left-hand side dense vector operand.
Definition: DVecSVecOuterExpr.h:200
Compile time evaluation of the number of columns of a matrix.The Columns type trait evaluates the num...
Definition: Columns.h:75
ConstIterator & operator++()
Pre-increment operator.
Definition: DVecSVecOuterExpr.h:250
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense vector operand.
Definition: DVecSVecOuterExpr.h:501
#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
Compile time evaluation of the number of rows of a matrix.The Rows type trait evaluates the number of...
Definition: Rows.h:75
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:600
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:423
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: DVecSVecOuterExpr.h:451
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DVecSVecOuterExpr.h:420
Header file for the Size type trait.
#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
Constraint on the transpose flag of vector types.
Header file for the IsExpression type trait class.
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DVecSVecOuterExpr.h:184
Header file for the function trace functionality.
const ConstIterator * operator->() const
Direct access to the sparse matrix element at the current iterator position.
Definition: DVecSVecOuterExpr.h:271
MultTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DVecSVecOuterExpr.h:182
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DVecSVecOuterExpr.h:183