35 #ifndef _BLAZE_MATH_EXPRESSIONS_SVECDVECOUTEREXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_SVECDVECOUTEREXPR_H_ 97 template<
typename VT1
99 class SVecDVecOuterExpr
100 :
public VecTVecMultExpr< SparseMatrix< SVecDVecOuterExpr<VT1,VT2>, true > >
101 ,
private Computation
140 template<
typename MT >
143 enum :
bool { value = useAssign };
153 template<
typename T1,
typename T2,
typename T3 >
154 struct UseVectorizedKernel {
155 enum :
bool { value = useOptimizedKernels &&
156 T1::simdEnabled && T3::simdEnabled &&
169 template<
typename T1,
typename T2,
typename T3 >
170 struct UseDefaultKernel {
171 enum :
bool { value = !UseVectorizedKernel<T1,T2,T3>::value };
259 return Element( it_->value() * v_, it_->index() );
279 return it_->value() * v_;
300 return it_ == rhs.
it_;
311 return it_ != rhs.
it_;
322 return it_ - rhs.
it_;
336 enum :
bool { smpAssignable =
false };
380 if( i >=
lhs_.size() ) {
383 if( j >=
rhs_.size() ) {
417 inline size_t rows() const noexcept {
438 return lhs_.nonZeros() *
rhs_.size();
450 return lhs_.nonZeros();
519 template<
typename T >
520 inline bool canAlias(
const T* alias )
const noexcept {
521 return (
lhs_.canAlias( alias ) ||
rhs_.canAlias( alias ) );
531 template<
typename T >
532 inline bool isAliased(
const T* alias )
const noexcept {
533 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
555 template<
typename MT >
573 SVecDVecOuterExpr::selectAssignKernel( ~lhs, x, y );
592 template<
typename MT
604 for(
size_t j=0UL; j<y.size(); ++j ) {
605 (~A)(element->index(),j) = element->
value() * y[j];
627 template<
typename MT
637 const size_t N( (~A).
columns() );
639 const size_t jpos( remainder ? ( N &
size_t(-SIMDSIZE) ) : N );
651 for( ; j<jpos; j+=SIMDSIZE ) {
652 (~A).store( element->index(), j, x1 * y.load(j) );
654 for( ; remainder && j<N; ++j ) {
655 (~A)(element->index(),j) = element->value() * y[j];
678 template<
typename MT >
697 const ConstIterator
end( x.end() );
699 for(
size_t i=0UL; i<y.size(); ++i ) {
701 for( ConstIterator element=x.begin(); element!=
end; ++element ) {
702 (~lhs)(element->index(),i) = element->
value() * y[i];
722 template<
typename MT >
743 (~lhs).reserve( x.nonZeros() * y.size() );
746 const ConstIterator
begin( x.begin() );
747 const ConstIterator
end ( x.end() );
752 (~lhs).reserve(
begin->
index(), rhs.nonZeros() );
756 for( ConstIterator element=
begin; element!=
end; ++element ) {
758 for( ; index < element->index(); ++index ) {
759 (~lhs).finalize( index );
761 for(
size_t i=0UL; i<y.size(); ++i ) {
762 (~lhs).append( element->index(), i, element->value() * y[i] );
764 (~lhs).finalize( index++ );
768 for( ; index < x.size(); ++index ) {
769 (~lhs).finalize( index );
791 template<
typename MT >
811 const ConstIterator
begin( x.begin() );
812 const ConstIterator
end ( x.end() );
817 for(
size_t i=0UL; i<y.size(); ++i ) {
819 for( ConstIterator element=
begin; element!=
end; ++element ) {
820 (~lhs).append( element->index(), i, element->value() * y[i] );
823 (~lhs).finalize( i );
842 template<
typename MT >
860 SVecDVecOuterExpr::selectAddAssignKernel( ~lhs, x, y );
879 template<
typename MT
891 for(
size_t i=0UL; i<y.size(); ++i ) {
892 (~A)(element->index(),i) += element->
value() * y[i];
914 template<
typename MT
924 const size_t N( (~A).
columns() );
926 const size_t jpos( remainder ? ( N &
size_t(-SIMDSIZE) ) : N );
934 if(
isDefault( element->value() ) )
continue;
940 for( ; j<jpos; j+=SIMDSIZE ) {
941 (~A).store( element->index(), j, (~A).load(element->index(),j) + x1 * y.load(j) );
943 for( ; remainder && j<N; ++j ) {
944 (~A)(element->index(),j) += element->value() * y[j];
967 template<
typename MT >
986 const ConstIterator
end( x.end() );
988 for(
size_t i=0UL; i<y.size(); ++i ) {
990 for( ConstIterator element=x.begin(); element!=
end; ++element ) {
991 (~lhs)(element->index(),i) += element->
value() * y[i];
1016 template<
typename MT >
1034 SVecDVecOuterExpr::selectSubAssignKernel( ~lhs, x, y );
1053 template<
typename MT
1065 for(
size_t i=0UL; i<y.size(); ++i ) {
1066 (~A)(element->index(),i) -= element->
value() * y[i];
1088 template<
typename MT
1098 const size_t N( (~A).
columns() );
1100 const size_t jpos( remainder ? ( N &
size_t(-SIMDSIZE) ) : N );
1108 if(
isDefault( element->value() ) )
continue;
1114 for( ; j<jpos; j+=SIMDSIZE ) {
1115 (~A).store( element->index(), j, (~A).load(element->index(),j) - x1 * y.load(j) );
1117 for( ; remainder && j<N; ++j ) {
1118 (~A)(element->index(),j) -= element->value() * y[j];
1141 template<
typename MT >
1160 const ConstIterator
end( x.end() );
1162 for(
size_t i=0UL; i<y.size(); ++i ) {
1164 for( ConstIterator element=x.begin(); element!=
end; ++element ) {
1165 (~lhs)(element->index(),i) -= element->
value() * y[i];
1190 template<
typename MT >
1208 SVecDVecOuterExpr::selectSchurAssignKernel( ~lhs, x, y );
1227 template<
typename MT
1241 if(
isDefault( element->value() ) )
continue;
1243 for( ; i<element->index(); ++i ) {
1244 for(
size_t j=0UL; j<y.size(); ++j )
1248 for(
size_t j=0UL; j<y.size(); ++j ) {
1249 (~A)(element->index(),j) *= element->value() * y[j];
1255 for( ; i<x.size(); ++i ) {
1256 for(
size_t j=0UL; j<y.size(); ++j )
1277 template<
typename MT
1287 const size_t M( (~A).
rows() );
1288 const size_t N( (~A).
columns() );
1290 const size_t jpos( remainder ? ( N &
size_t(-SIMDSIZE) ) : N );
1300 if(
isDefault( element->value() ) )
continue;
1302 for( ; i<element->index(); ++i ) {
1303 for(
size_t j=0UL; j<N; ++j )
1311 for( ; j<jpos; j+=SIMDSIZE ) {
1312 (~A).store( element->index(), j, (~A).load(element->index(),j) * ( x1 * y.load(j) ) );
1314 for( ; remainder && j<N; ++j ) {
1315 (~A)(element->index(),j) *= element->value() * y[j];
1322 for(
size_t j=0UL; j<N; ++j )
1345 template<
typename MT >
1364 const ConstIterator
end( x.end() );
1366 for(
size_t j=0UL; j<y.size(); ++j )
1370 for( ConstIterator element=x.begin(); element!=
end; ++element, ++i ) {
1371 for( ; i<element->index(); ++i )
1372 reset( (~lhs)(i,j) );
1373 (~lhs)(element->index(),j) *= element->value() * y[j];
1376 for( ; i<x.size(); ++i ) {
1377 reset( (~lhs)(i,j) );
1446 template<
typename VT1
1448 inline decltype(
auto)
1469 template<
typename VT1,
typename VT2 >
1470 struct Size< SVecDVecOuterExpr<VT1,VT2>, 0UL >
1471 :
public Size<VT1,0UL>
1474 template<
typename VT1,
typename VT2 >
1475 struct Size< SVecDVecOuterExpr<VT1,VT2>, 1UL >
1476 :
public Size<VT2,0UL>
If_< IsExpression< VT2 >, const VT2, const VT2 &> RightOperand
Composite type of the right-hand side dense vector expression.
Definition: SVecDVecOuterExpr.h:194
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SVecDVecOuterExpr.h:379
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
MultTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: SVecDVecOuterExpr.h:179
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.
SVecDVecOuterExpr(const VT1 &lhs, const VT2 &rhs) noexcept
Constructor for the SVecDVecOuterExpr class.
Definition: SVecDVecOuterExpr.h:350
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SVecDVecOuterExpr.h:532
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified column.
Definition: SVecDVecOuterExpr.h:448
RightOperand rhs_
Right-hand side dense vector of the multiplication expression.
Definition: SVecDVecOuterExpr.h:540
#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:427
Header file for the IsSame and IsStrictlySame type traits.
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SVecDVecOuterExpr.h:219
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:247
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
IteratorType it_
Iterator over the elements of the left-hand side sparse vector expression.
Definition: SVecDVecOuterExpr.h:328
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
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:217
CompositeType_< VT2 > CT2
Composite type of the right-hand side dense vector expression.
Definition: SVecDVecOuterExpr.h:110
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:80
RightElement v_
Element of the right-hand side dense vector expression.
Definition: SVecDVecOuterExpr.h:329
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:191
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:461
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:508
Header file for the ValueIndexPair class.
ReturnType_< VT1 > RN1
Return type of the left-hand side sparse vector expression.
Definition: SVecDVecOuterExpr.h:107
Header file for the IsTemporary type trait class.
const IfTrue_< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: SVecDVecOuterExpr.h:185
Header file for the multiplication trait.
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SVecDVecOuterExpr.h:299
const Element operator*() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SVecDVecOuterExpr.h:258
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
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
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
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:180
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse vector operand.
Definition: SVecDVecOuterExpr.h:498
LeftOperand lhs_
Left-hand side sparse vector of the multiplication expression.
Definition: SVecDVecOuterExpr.h:539
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
ConstIterator(IteratorType it, RightElement v)
Constructor for the ConstIterator class.
Definition: SVecDVecOuterExpr.h:236
size_t index() const
Access to the current index of the sparse element.
Definition: SVecDVecOuterExpr.h:288
ElementType_< ResultType > ElementType
Resulting element type.
Definition: SVecDVecOuterExpr.h:182
Constraint on the data type.
Header file for the exception macros of the math module.
IteratorCategory iterator_category
The iterator category.
Definition: SVecDVecOuterExpr.h:226
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SVecDVecOuterExpr.h:321
CompositeType_< VT1 > CT1
Composite type of the left-hand side sparse vector expression.
Definition: SVecDVecOuterExpr.h:109
ElementType_< VT1 > ET1
Element type of the left-hand side sparse vector expression.
Definition: SVecDVecOuterExpr.h:111
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:206
Header file for the EnableIf class template.
ResultType_< VT2 > RT2
Result type of the right-hand side dense vector expression.
Definition: SVecDVecOuterExpr.h:106
ElementType_< VT2 > ET2
Element type of the right-hand side dense vector expression.
Definition: SVecDVecOuterExpr.h:112
Header file for the IsNumeric type trait.
IfTrue_< useAssign, const ResultType, const SVecDVecOuterExpr &> CompositeType
Data type for composite expression templates.
Definition: SVecDVecOuterExpr.h:188
#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:268
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of column i.
Definition: SVecDVecOuterExpr.h:407
ReturnType value() const
Access to the current value of the sparse element.
Definition: SVecDVecOuterExpr.h:278
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SVecDVecOuterExpr.h:181
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:520
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SVecDVecOuterExpr.h:310
Header file for the reset shim.
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SVecDVecOuterExpr.h:417
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:105
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_< VT2 > RN2
Return type of the right-hand side dense vector expression.
Definition: SVecDVecOuterExpr.h:108
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:197
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
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:200
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:396
Compile time evaluation of the size of vectors and matrices.The Size type trait evaluates the size of...
Definition: Size.h:80
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:130
ConstIterator_< RemoveReference_< LeftOperand > > IteratorType
Iterator type of the sparse vector expression.
Definition: SVecDVecOuterExpr.h:214
#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
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SVecDVecOuterExpr.h:437
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
ConstIterator upperBound(size_t i, size_t j) const
Returns an iterator to the first index greater then the given index.
Definition: SVecDVecOuterExpr.h:487
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:125
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:474
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:363
Constraint on the transpose flag of vector types.
Header file for the IsExpression type trait class.
Header file for the function trace functionality.