35 #ifndef _BLAZE_MATH_EXPRESSIONS_DVECSVECOUTEREXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_DVECSVECOUTEREXPR_H_ 97 template<
typename VT1
100 :
public VecTVecMultExpr< SparseMatrix< DVecSVecOuterExpr<VT1,VT2>, false > >
141 template<
typename MT >
144 enum :
bool { value = useAssign };
154 template<
typename T1,
typename T2,
typename T3 >
155 struct UseVectorizedKernel {
156 enum :
bool { value = useOptimizedKernels &&
157 T1::simdEnabled && T2::simdEnabled &&
170 template<
typename T1,
typename T2,
typename T3 >
171 struct UseDefaultKernel {
172 enum :
bool { value = !UseVectorizedKernel<T1,T2,T3>::value };
260 return Element( v_ * it_->value(), it_->index() );
280 return v_ * it_->value();
301 return it_ == rhs.
it_;
312 return it_ != rhs.
it_;
323 return it_ - rhs.
it_;
337 enum :
bool { smpAssignable =
false };
381 if( i >=
lhs_.size() ) {
384 if( j >=
rhs_.size() ) {
418 inline size_t rows() const noexcept {
439 return lhs_.size() *
rhs_.nonZeros();
451 return rhs_.nonZeros();
520 template<
typename T >
521 inline bool canAlias(
const T* alias )
const noexcept {
522 return (
lhs_.canAlias( alias ) ||
rhs_.canAlias( alias ) );
532 template<
typename T >
533 inline bool isAliased(
const T* alias )
const noexcept {
534 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
559 template<
typename MT >
578 const ConstIterator
begin( y.begin() );
579 const ConstIterator
end ( y.end() );
581 for(
size_t i=0UL; i<x.size(); ++i ) {
582 for( ConstIterator element=
begin; element!=
end; ++element ) {
583 (~lhs)(i,element->index()) = x[i] * element->
value();
603 template<
typename MT >
621 DVecSVecOuterExpr::selectAssignKernel( ~lhs, x, y );
640 template<
typename MT
652 for(
size_t i=0UL; i<x.size(); ++i ) {
653 (~A)(i,element->index()) = x[i] * element->
value();
674 template<
typename MT
684 const size_t M( (~A).
rows() );
686 const size_t ipos( remainder ? ( M &
size_t(-SIMDSIZE) ) : M );
698 for( ; i<ipos; i+=SIMDSIZE ) {
699 (~A).store( i, element->index(), x.load(i) * y1 );
701 for( ; remainder && i<M; ++i ) {
702 (~A)(i,element->index()) = x[i] * element->value();
724 template<
typename MT >
745 (~lhs).reserve( x.size() * y.nonZeros() );
748 const ConstIterator
begin( y.begin() );
749 const ConstIterator
end ( y.end() );
754 for(
size_t i=0UL; i<x.size(); ++i ) {
756 for( ConstIterator element=
begin; element!=
end; ++element ) {
757 (~lhs).append( i, element->index(), x[i] * element->value() );
760 (~lhs).finalize( i );
779 template<
typename MT >
799 const ConstIterator
begin( y.begin() );
800 const ConstIterator
end ( y.end() );
809 for( ConstIterator element=
begin; element!=
end; ++element ) {
811 for( ; index < element->index(); ++index ) {
812 (~lhs).finalize( index );
814 for(
size_t i=0UL; i<x.size(); ++i ) {
815 (~lhs).append( i, element->index(), x[i] * element->value() );
817 (~lhs).finalize( index++ );
821 for( ; index < y.size(); ++index ) {
822 (~lhs).finalize( index );
844 template<
typename MT >
863 const ConstIterator
begin( y.begin() );
864 const ConstIterator
end ( y.end() );
866 for(
size_t i=0UL; i<x.size(); ++i ) {
868 for( ConstIterator element=
begin; element!=
end; ++element ) {
869 (~lhs)(i,element->index()) += x[i] * element->
value();
890 template<
typename MT >
908 DVecSVecOuterExpr::selectAddAssignKernel( ~lhs, x, y );
927 template<
typename MT
940 for(
size_t i=0UL; i<x.size(); ++i ) {
941 (~A)(i,element->index()) += x[i] * element->
value();
963 template<
typename MT
973 const size_t M( (~A).
rows() );
975 const size_t ipos( remainder ? ( M &
size_t(-SIMDSIZE) ) : M );
983 if(
isDefault( element->value() ) )
continue;
989 for( ; i<ipos; i+=SIMDSIZE ) {
990 (~A).store( i, element->index(), (~A).load(i,element->index()) + x.load(i) * y1 );
992 for( ; remainder && i<M; ++i ) {
993 (~A)(i,element->index()) += x[i] * element->value();
1020 template<
typename MT >
1039 const ConstIterator
begin( y.begin() );
1040 const ConstIterator
end ( y.end() );
1042 for(
size_t i=0UL; i<x.size(); ++i ) {
1044 for( ConstIterator element=
begin; element!=
end; ++element ) {
1045 (~lhs)(i,element->index()) -= x[i] * element->
value();
1066 template<
typename MT >
1084 DVecSVecOuterExpr::selectSubAssignKernel( ~lhs, x, y );
1103 template<
typename MT
1116 for(
size_t i=0UL; i<x.size(); ++i ) {
1117 (~A)(i,element->index()) -= x[i] * element->
value();
1139 template<
typename MT
1149 const size_t M( (~A).
rows() );
1151 const size_t ipos( remainder ? ( M &
size_t(-SIMDSIZE) ) : M );
1159 if(
isDefault( element->value() ) )
continue;
1165 for( ; i<ipos; i+=SIMDSIZE ) {
1166 (~A).store( i, element->index(), (~A).load(i,element->index()) - x.load(i) * y1 );
1168 for( ; remainder && i<M; ++i ) {
1169 (~A)(i,element->index()) -= x[i] * element->value();
1196 template<
typename MT >
1215 const ConstIterator
end( y.end() );
1217 for(
size_t i=0UL; i<x.size(); ++i )
1221 for( ConstIterator element=y.begin(); element!=
end; ++element, ++j ) {
1222 for( ; j<element->index(); ++j )
1223 reset( (~lhs)(i,j) );
1224 (~lhs)(i,element->index()) *= x[i] * element->value();
1227 for( ; j<y.size(); ++j ) {
1228 reset( (~lhs)(i,j) );
1248 template<
typename MT >
1266 DVecSVecOuterExpr::selectSchurAssignKernel( ~lhs, x, y );
1285 template<
typename MT
1299 if(
isDefault( element->value() ) )
continue;
1301 for( ; j<element->index(); ++j ) {
1302 for(
size_t i=0UL; i<x.size(); ++i )
1306 for(
size_t i=0UL; i<x.size(); ++i ) {
1307 (~A)(i,element->index()) *= x[i] * element->value();
1313 for( ; j<y.size(); ++j ) {
1314 for(
size_t i=0UL; i<x.size(); ++i )
1335 template<
typename MT
1345 const size_t M( (~A).
rows() );
1346 const size_t N( (~A).
columns() );
1348 const size_t ipos( remainder ? ( M &
size_t(-SIMDSIZE) ) : M );
1358 if(
isDefault( element->value() ) )
continue;
1360 for( ; j<element->index(); ++j ) {
1361 for(
size_t i=0UL; i<M; ++i )
1369 for( ; i<ipos; i+=SIMDSIZE ) {
1370 (~A).store( i, element->index(), (~A).load(i,element->index()) * ( x.load(i) * y1 ) );
1372 for( ; remainder && i<M; ++i ) {
1373 (~A)(i,element->index()) *= x[i] * element->value();
1380 for(
size_t i=0UL; i<M; ++i )
1449 template<
typename VT1
1451 inline decltype(
auto)
1472 template<
typename VT1,
typename VT2 >
1473 struct Size< DVecSVecOuterExpr<VT1,VT2>, 0UL >
1474 :
public Size<VT1,0UL>
1477 template<
typename VT1,
typename VT2 >
1478 struct Size< DVecSVecOuterExpr<VT1,VT2>, 1UL >
1479 :
public Size<VT2,0UL>
ConstIterator_< RemoveReference_< RightOperand > > IteratorType
Iterator type of the sparse vector expression.
Definition: DVecSVecOuterExpr.h:218
CompositeType_< VT2 > CT2
Composite type of the right-hand side sparse vector expression.
Definition: DVecSVecOuterExpr.h:110
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DVecSVecOuterExpr.h:533
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:71
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:105
LeftElement v_
Element of the left-hand side dense vector expression.
Definition: DVecSVecOuterExpr.h:329
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:69
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:522
Header file for basic type definitions.
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DVecSVecOuterExpr.h:428
ElementType_< VT2 > ET2
Element type of the right-hand side sparse vector expression.
Definition: DVecSVecOuterExpr.h:112
#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:189
Expression object for dense vector-sparse vector outer products.The DVecSVecOuterExpr class represent...
Definition: DVecSVecOuterExpr.h:99
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:259
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:183
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DVecSVecOuterExpr.h:380
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:291
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:195
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:80
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:438
Constraint on the data type.
size_t index() const
Access to the current index of the sparse element.
Definition: DVecSVecOuterExpr.h:289
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: DVecSVecOuterExpr.h:408
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:330
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:227
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:58
Header file for the If class template.
DVecSVecOuterExpr(const VT1 &lhs, const VT2 &rhs) noexcept
Constructor for the DVecSVecOuterExpr class.
Definition: DVecSVecOuterExpr.h:351
Iterator over the elements of the dense vector-sparse vector outer product expression.
Definition: DVecSVecOuterExpr.h:207
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:475
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DVecSVecOuterExpr.h:521
#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
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DVecSVecOuterExpr.h:311
If_< IsExpression< VT1 >, const VT1, const VT1 &> LeftOperand
Composite type of the left-hand side dense vector expression.
Definition: DVecSVecOuterExpr.h:192
ResultType_< VT2 > RT2
Result type of the right-hand side sparse vector expression.
Definition: DVecSVecOuterExpr.h:106
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
CompositeType_< VT1 > CT1
Composite type of the left-hand side dense vector expression.
Definition: DVecSVecOuterExpr.h:109
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:76
#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:201
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:300
Constraint on the data type.
const IfTrue_< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DVecSVecOuterExpr.h:186
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:279
ElementType_< VT1 > ET1
Element type of the left-hand side dense vector expression.
Definition: DVecSVecOuterExpr.h:111
Header file for the IsNumeric type trait.
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse vector operand.
Definition: DVecSVecOuterExpr.h:509
ConstIterator find(size_t i, size_t j) const
Searches for a specific matrix element.
Definition: DVecSVecOuterExpr.h:462
#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:215
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:488
MultExprTrait_< RN1, RN2 > ExprReturnType
Expression return type for the subscript operator.
Definition: DVecSVecOuterExpr.h:125
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:322
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:816
#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:107
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:220
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
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:540
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:364
RightOperand rhs_
Right-hand side sparse vector of the multiplication expression.
Definition: DVecSVecOuterExpr.h:541
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:237
ReturnType_< VT2 > RN2
Return type of the right-hand side sparse vector expression.
Definition: DVecSVecOuterExpr.h:108
Compile time evaluation of the size of vectors and matrices.The Size type trait evaluates the size of...
Definition: Size.h:80
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: DVecSVecOuterExpr.h:397
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:198
ConstIterator & operator++()
Pre-increment operator.
Definition: DVecSVecOuterExpr.h:248
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense vector operand.
Definition: DVecSVecOuterExpr.h:499
#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
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
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:449
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DVecSVecOuterExpr.h:418
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:182
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:269
MultTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DVecSVecOuterExpr.h:180
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DVecSVecOuterExpr.h:181