35 #ifndef _BLAZE_MATH_EXPRESSIONS_SVECDVECOUTEREXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_SVECDVECOUTEREXPR_H_ 99 template<
typename VT1
101 class SVecDVecOuterExpr
102 :
public VecTVecMultExpr< SparseMatrix< SVecDVecOuterExpr<VT1,VT2>, true > >
103 ,
private Computation
142 template<
typename MT >
145 enum :
bool { value = useAssign };
155 template<
typename T1,
typename T2,
typename T3 >
156 struct UseVectorizedKernel {
157 enum :
bool { value = useOptimizedKernels &&
158 T1::simdEnabled && T3::simdEnabled &&
171 template<
typename T1,
typename T2,
typename T3 >
172 struct UseDefaultKernel {
173 enum :
bool { value = !UseVectorizedKernel<T1,T2,T3>::value };
261 return Element( it_->value() * v_, it_->index() );
281 return it_->value() * v_;
302 return it_ == rhs.
it_;
313 return it_ != rhs.
it_;
324 return it_ - rhs.
it_;
338 enum :
bool { smpAssignable =
false };
382 if( i >=
lhs_.size() ) {
385 if( j >=
rhs_.size() ) {
419 inline size_t rows() const noexcept {
440 return lhs_.nonZeros() *
rhs_.size();
452 return lhs_.nonZeros();
521 template<
typename T >
522 inline bool canAlias(
const T* alias )
const noexcept {
523 return (
lhs_.canAlias( alias ) ||
rhs_.canAlias( alias ) );
533 template<
typename T >
534 inline bool isAliased(
const T* alias )
const noexcept {
535 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
557 template<
typename MT >
575 SVecDVecOuterExpr::selectAssignKernel( ~lhs, x, y );
594 template<
typename MT
606 for(
size_t j=0UL; j<y.size(); ++j ) {
607 (~A)(element->index(),j) = element->
value() * y[j];
629 template<
typename MT
639 const size_t N( (~A).
columns() );
641 const size_t jpos( remainder ? ( N &
size_t(-SIMDSIZE) ) : N );
653 for( ; j<jpos; j+=SIMDSIZE ) {
654 (~A).store( element->index(), j, x1 * y.load(j) );
656 for( ; remainder && j<N; ++j ) {
657 (~A)(element->index(),j) = element->value() * y[j];
680 template<
typename MT >
699 const ConstIterator
end( x.end() );
701 for(
size_t i=0UL; i<y.size(); ++i ) {
703 for( ConstIterator element=x.begin(); element!=
end; ++element ) {
704 (~lhs)(element->index(),i) = element->
value() * y[i];
724 template<
typename MT >
744 const ConstIterator
begin( x.begin() );
745 const ConstIterator
end ( x.end() );
750 (~lhs).reserve(
begin->
index(), rhs.nonZeros() );
754 for( ConstIterator element=
begin; element!=
end; ++element ) {
756 for( ; index < element->index(); ++index ) {
757 (~lhs).finalize( index );
759 for(
size_t i=0UL; i<y.size(); ++i ) {
760 (~lhs).append( element->index(), i, element->value() * y[i] );
762 (~lhs).finalize( index++ );
766 for( ; index < x.size(); ++index ) {
767 (~lhs).finalize( index );
789 template<
typename MT >
809 const ConstIterator
begin( x.begin() );
810 const ConstIterator
end ( x.end() );
815 for(
size_t i=0UL; i<y.size(); ++i ) {
817 for( ConstIterator element=
begin; element!=
end; ++element ) {
818 (~lhs).append( element->index(), i, element->value() * y[i] );
821 (~lhs).finalize( i );
840 template<
typename MT >
858 SVecDVecOuterExpr::selectAddAssignKernel( ~lhs, x, y );
877 template<
typename MT
889 for(
size_t i=0UL; i<y.size(); ++i ) {
890 (~A)(element->index(),i) += element->
value() * y[i];
912 template<
typename MT
922 const size_t N( (~A).
columns() );
924 const size_t jpos( remainder ? ( N &
size_t(-SIMDSIZE) ) : N );
932 if(
isDefault( element->value() ) )
continue;
938 for( ; j<jpos; j+=SIMDSIZE ) {
939 (~A).store( element->index(), j, (~A).load(element->index(),j) + x1 * y.load(j) );
941 for( ; remainder && j<N; ++j ) {
942 (~A)(element->index(),j) += element->value() * y[j];
965 template<
typename MT >
984 const ConstIterator
end( x.end() );
986 for(
size_t i=0UL; i<y.size(); ++i ) {
988 for( ConstIterator element=x.begin(); element!=
end; ++element ) {
989 (~lhs)(element->index(),i) += element->
value() * y[i];
1014 template<
typename MT >
1032 SVecDVecOuterExpr::selectSubAssignKernel( ~lhs, x, y );
1051 template<
typename MT
1063 for(
size_t i=0UL; i<y.size(); ++i ) {
1064 (~A)(element->index(),i) -= element->
value() * y[i];
1086 template<
typename MT
1096 const size_t N( (~A).
columns() );
1098 const size_t jpos( remainder ? ( N &
size_t(-SIMDSIZE) ) : N );
1106 if(
isDefault( element->value() ) )
continue;
1112 for( ; j<jpos; j+=SIMDSIZE ) {
1113 (~A).store( element->index(), j, (~A).load(element->index(),j) - x1 * y.load(j) );
1115 for( ; remainder && j<N; ++j ) {
1116 (~A)(element->index(),j) -= element->value() * y[j];
1139 template<
typename MT >
1158 const ConstIterator
end( x.end() );
1160 for(
size_t i=0UL; i<y.size(); ++i ) {
1162 for( ConstIterator element=x.begin(); element!=
end; ++element ) {
1163 (~lhs)(element->index(),i) -= element->
value() * y[i];
1188 template<
typename MT >
1206 SVecDVecOuterExpr::selectSchurAssignKernel( ~lhs, x, y );
1225 template<
typename MT
1239 if(
isDefault( element->value() ) )
continue;
1241 for( ; i<element->index(); ++i ) {
1242 for(
size_t j=0UL; j<y.size(); ++j )
1246 for(
size_t j=0UL; j<y.size(); ++j ) {
1247 (~A)(element->index(),j) *= element->value() * y[j];
1253 for( ; i<x.size(); ++i ) {
1254 for(
size_t j=0UL; j<y.size(); ++j )
1275 template<
typename MT
1285 const size_t M( (~A).
rows() );
1286 const size_t N( (~A).
columns() );
1288 const size_t jpos( remainder ? ( N &
size_t(-SIMDSIZE) ) : N );
1298 if(
isDefault( element->value() ) )
continue;
1300 for( ; i<element->index(); ++i ) {
1301 for(
size_t j=0UL; j<N; ++j )
1309 for( ; j<jpos; j+=SIMDSIZE ) {
1310 (~A).store( element->index(), j, (~A).load(element->index(),j) * ( x1 * y.load(j) ) );
1312 for( ; remainder && j<N; ++j ) {
1313 (~A)(element->index(),j) *= element->value() * y[j];
1320 for(
size_t j=0UL; j<N; ++j )
1343 template<
typename MT >
1362 const ConstIterator
end( x.end() );
1364 for(
size_t j=0UL; j<y.size(); ++j )
1368 for( ConstIterator element=x.begin(); element!=
end; ++element, ++i ) {
1369 for( ; i<element->index(); ++i )
1370 reset( (~lhs)(i,j) );
1371 (~lhs)(element->index(),j) *= element->value() * y[j];
1374 for( ; i<x.size(); ++i ) {
1375 reset( (~lhs)(i,j) );
1444 template<
typename VT1
1446 inline decltype(
auto)
1467 template<
typename VT1,
typename VT2 >
1468 struct Rows< SVecDVecOuterExpr<VT1,VT2> >
1485 template<
typename VT1,
typename VT2 >
1486 struct Columns< SVecDVecOuterExpr<VT1,VT2> >
If_< IsExpression< VT2 >, const VT2, const VT2 &> RightOperand
Composite type of the right-hand side dense vector expression.
Definition: SVecDVecOuterExpr.h:196
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SVecDVecOuterExpr.h:381
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
MultTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: SVecDVecOuterExpr.h:181
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.
SVecDVecOuterExpr(const VT1 &lhs, const VT2 &rhs) noexcept
Constructor for the SVecDVecOuterExpr class.
Definition: SVecDVecOuterExpr.h:352
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SVecDVecOuterExpr.h:534
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified column.
Definition: SVecDVecOuterExpr.h:450
RightOperand rhs_
Right-hand side dense vector of the multiplication expression.
Definition: SVecDVecOuterExpr.h:542
#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.
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: SVecDVecOuterExpr.h:429
Header file for the IsSame and IsStrictlySame type traits.
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SVecDVecOuterExpr.h:221
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
ConstIterator & operator++()
Pre-increment operator.
Definition: SVecDVecOuterExpr.h:249
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:560
IteratorType it_
Iterator over the elements of the left-hand side sparse vector expression.
Definition: SVecDVecOuterExpr.h:330
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
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
ET2 RightElement
Element type of the dense vector expression.
Definition: SVecDVecOuterExpr.h:219
CompositeType_< VT2 > CT2
Composite type of the right-hand side dense vector expression.
Definition: SVecDVecOuterExpr.h:112
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:78
RightElement v_
Element of the right-hand side dense vector expression.
Definition: SVecDVecOuterExpr.h:331
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.
If_< IsExpression< VT1 >, const VT1, const VT1 &> LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition: SVecDVecOuterExpr.h:193
Constraint on the transpose flag of vector types.
Constraint on the data type.
ConstIterator find(size_t i, size_t j) const
Searches for a specific matrix element.
Definition: SVecDVecOuterExpr.h:463
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.
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
RightOperand rightOperand() const noexcept
Returns the right-hand side dense vector operand.
Definition: SVecDVecOuterExpr.h:510
Header file for the ValueIndexPair class.
ReturnType_< VT1 > RN1
Return type of the left-hand side sparse vector expression.
Definition: SVecDVecOuterExpr.h:109
Header file for the IsTemporary type trait class.
const IfTrue_< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: SVecDVecOuterExpr.h:187
Header file for the multiplication trait.
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SVecDVecOuterExpr.h:301
const Element operator*() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SVecDVecOuterExpr.h:260
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
#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.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3087
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.
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SVecDVecOuterExpr.h:182
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse vector operand.
Definition: SVecDVecOuterExpr.h:500
LeftOperand lhs_
Left-hand side sparse vector of the multiplication expression.
Definition: SVecDVecOuterExpr.h:541
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
ConstIterator(IteratorType it, RightElement v)
Constructor for the ConstIterator class.
Definition: SVecDVecOuterExpr.h:238
size_t index() const
Access to the current index of the sparse element.
Definition: SVecDVecOuterExpr.h:290
ElementType_< ResultType > ElementType
Resulting element type.
Definition: SVecDVecOuterExpr.h:184
Constraint on the data type.
Header file for the exception macros of the math module.
IteratorCategory iterator_category
The iterator category.
Definition: SVecDVecOuterExpr.h:228
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SVecDVecOuterExpr.h:323
CompositeType_< VT1 > CT1
Composite type of the left-hand side sparse vector expression.
Definition: SVecDVecOuterExpr.h:111
ElementType_< VT1 > ET1
Element type of the left-hand side sparse vector expression.
Definition: SVecDVecOuterExpr.h:113
Constraint on the data type.
Header file for all forward declarations for expression class templates.
Constraint on the data type.
Header file for the VecTVecMultExpr base class.
Iterator over the elements of the sparse vector-dense vector outer product expression.
Definition: SVecDVecOuterExpr.h:208
Header file for the EnableIf class template.
ResultType_< VT2 > RT2
Result type of the right-hand side dense vector expression.
Definition: SVecDVecOuterExpr.h:108
ElementType_< VT2 > ET2
Element type of the right-hand side dense vector expression.
Definition: SVecDVecOuterExpr.h:114
Header file for the IsNumeric type trait.
IfTrue_< useAssign, const ResultType, const SVecDVecOuterExpr &> CompositeType
Data type for composite expression templates.
Definition: SVecDVecOuterExpr.h:190
#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.
Expression object for sparse vector-dense vector outer products.The SVecDVecOuterExpr class represent...
Definition: Forward.h:134
Header file for run time assertion macros.
const ConstIterator * operator->() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SVecDVecOuterExpr.h:270
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of column i.
Definition: SVecDVecOuterExpr.h:409
ReturnType value() const
Access to the current value of the sparse element.
Definition: SVecDVecOuterExpr.h:280
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SVecDVecOuterExpr.h:183
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
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SVecDVecOuterExpr.h:522
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SVecDVecOuterExpr.h:312
Header file for the reset shim.
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SVecDVecOuterExpr.h:419
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.
ResultType_< VT1 > RT1
Result type of the left-hand side sparse vector expression.
Definition: SVecDVecOuterExpr.h:107
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_< VT2 > RN2
Return type of the right-hand side dense vector expression.
Definition: SVecDVecOuterExpr.h:110
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
typename T::OppositeType OppositeType_
Alias declaration for nested OppositeType type definitions.The OppositeType_ alias declaration provid...
Definition: Aliases.h:263
If_< IsComputation< VT1 >, const RT1, CT1 > LT
Type for the assignment of the left-hand side dense vector operand.
Definition: SVecDVecOuterExpr.h:199
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
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:73
If_< IsComputation< VT2 >, const RT2, CT2 > RT
Type for the assignment of the right-hand side dense vector operand.
Definition: SVecDVecOuterExpr.h:202
Header file for the IsComputation type trait class.
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of column i.
Definition: SVecDVecOuterExpr.h:398
Compile time evaluation of the size of a vector.The Size type trait evaluates the size of the given v...
Definition: Size.h:74
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:130
Compile time evaluation of the number of columns of a matrix.The Columns type trait evaluates the num...
Definition: Columns.h:75
ConstIterator_< RemoveReference_< LeftOperand > > IteratorType
Iterator type of the sparse vector expression.
Definition: SVecDVecOuterExpr.h:216
#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
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SVecDVecOuterExpr.h:439
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:600
ConstIterator upperBound(size_t i, size_t j) const
Returns an iterator to the first index greater then the given index.
Definition: SVecDVecOuterExpr.h:489
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
MultExprTrait_< RN1, RN2 > ExprReturnType
Expression return type for the subscript operator.
Definition: SVecDVecOuterExpr.h:127
ConstIterator lowerBound(size_t i, size_t j) const
Returns an iterator to the first index not less then the given index.
Definition: SVecDVecOuterExpr.h:476
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
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SVecDVecOuterExpr.h:365
Constraint on the transpose flag of vector types.
Header file for the IsExpression type trait class.
Header file for the function trace functionality.