35#ifndef _BLAZE_MATH_EXPRESSIONS_DVECSVECKRONEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DVECSVECKRONEXPR_H_
91 :
public VecVecKronExpr< SparseVector< DVecSVecKronExpr<VT1,VT2,TF>, TF > >
113 static constexpr bool returnExpr = ( !IsTemporary_v<RN1> && !IsTemporary_v<RN2> );
181 if( index >=
lhs_.size() ) {
184 return (*
this)[index];
193 inline size_t size() const noexcept {
204 return lhs_.size() *
rhs_.nonZeros();
234 template<
typename T >
235 inline bool canAlias(
const T* alias )
const noexcept {
236 return (
lhs_.canAlias( alias ) ||
rhs_.canAlias( alias ) );
246 template<
typename T >
247 inline bool isAliased(
const T* alias )
const noexcept {
248 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
270 template<
typename VT >
277 if( rhs.
size() == 0UL ) {
284 const size_t N( y.size() );
285 const auto yend( y.end() );
287 for(
size_t i=0UL; i<x.size(); ++i ) {
288 if( !isDefault<strict>( x[i] ) ) {
289 for(
auto yelem=y.begin(); yelem!=yend; ++yelem )
290 (*lhs)[i*N+yelem->index()] = x[i] * yelem->value();
309 template<
typename VT >
316 if( rhs.
size() == 0UL ) {
323 const size_t N( y.size() );
324 const auto yend( y.end() );
326 for(
size_t i=0UL; i<x.size(); ++i ) {
327 if( !isDefault<strict>( x[i] ) ) {
328 for(
auto yelem=y.begin(); yelem!=yend; ++yelem )
329 (*lhs).append( i*N+yelem->index(), x[i] * yelem->value(),
true );
348 template<
typename VT >
349 friend inline void addAssign( DenseVector<VT,TF>& lhs,
const DVecSVecKronExpr& rhs )
355 if( rhs.size() == 0UL ) {
362 const size_t N( y.size() );
363 const auto yend( y.end() );
365 for(
size_t i=0UL; i<x.size(); ++i ) {
366 if( !isDefault<strict>( x[i] ) ) {
367 for(
auto yelem=y.begin(); yelem!=yend; ++yelem )
368 (*lhs)[i*N+yelem->index()] += x[i] * yelem->value();
392 template<
typename VT >
393 friend inline void subAssign( DenseVector<VT,TF>& lhs,
const DVecSVecKronExpr& rhs )
399 if( rhs.size() == 0UL ) {
406 const size_t N( y.size() );
407 const auto yend( y.end() );
409 for(
size_t i=0UL; i<x.size(); ++i ) {
410 if( !isDefault<strict>( x[i] ) ) {
411 for(
auto yelem=y.begin(); yelem!=yend; ++yelem )
412 (*lhs)[i*N+yelem->index()] -= x[i] * yelem->value();
436 template<
typename VT >
437 friend inline void multAssign( DenseVector<VT,TF>& lhs,
const DVecSVecKronExpr& rhs )
443 if( rhs.size() == 0UL ) {
450 const size_t N( y.size() );
451 const auto yend( y.end() );
453 for(
size_t i=0UL; i<x.size(); ++i ) {
454 if( !isDefault<strict>( x[i] ) )
458 for(
auto yelem=y.begin(); yelem!=yend; ++yelem, ++j ) {
459 for( ; j<yelem->index(); ++j )
460 reset( (*lhs)[i*N+j] );
461 (*lhs)[i*N+yelem->index()] *= x[i] * yelem->value();
465 reset( (*lhs)[i*N+j] );
468 for(
size_t j=0UL; j<N; ++j )
469 reset( (*lhs)[i*N+j] );
515template<
typename VT1
518 , DisableIf_t< IsZero_v<VT2> >* =
nullptr >
519inline const DVecSVecKronExpr<VT1,VT2,TF>
520 dvecsveckron(
const DenseVector<VT1,TF>& lhs,
const SparseVector<VT2,TF>& rhs )
524 return DVecSVecKronExpr<VT1,VT2,TF>( *lhs, *rhs );
543template<
typename VT1
546 , EnableIf_t< IsZero_v<VT2> >* =
nullptr >
548 dvecsveckron(
const DenseVector<VT1,TF>& lhs,
const SparseVector<VT2,TF>& rhs )
552 using ReturnType =
const KronTrait_t< ResultType_t<VT1>, ResultType_t<VT2> >;
557 return ReturnType( (*lhs).size()*(*rhs).size() );
585template<
typename VT1
593 return dvecsveckron( *lhs, *rhs );
Header file for auxiliary alias declarations.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition: Aliases.h:110
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.
Definition: Aliases.h:470
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition: Aliases.h:450
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition: Aliases.h:550
Header file for the alignment flag enumeration.
Header file for run time assertion macros.
Header file for the EnableIf class template.
Header file for the function trace functionality.
Header file for the If class template.
Header file for the isDefault shim.
Header file for the IsExpression type trait class.
Header file for the IsTemporary type trait class.
Header file for the Kron product trait.
Deactivation of problematic macros.
Header file for the type list functionality.
Constraint on the data type.
Expression object for dense vector-sparse vector Kronecker product.
Definition: DVecSVecKronExpr.h:93
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DVecSVecKronExpr.h:247
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: DVecSVecKronExpr.h:113
ReturnType_t< VT1 > RN1
Return type of the left-hand side dense vector expression.
Definition: DVecSVecKronExpr.h:98
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DVecSVecKronExpr.h:167
decltype(std::declval< RN1 >()+std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition: DVecSVecKronExpr.h:116
TransposeType_t< VT1 > TT1
Transpose type of the left-hand side dense vector expression.
Definition: DVecSVecKronExpr.h:102
CompositeType_t< VT2 > CT2
Composite type of the right-hand side sparse vector expression.
Definition: DVecSVecKronExpr.h:101
ReturnType_t< VT2 > RN2
Return type of the right-hand side sparse vector expression.
Definition: DVecSVecKronExpr.h:99
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: DVecSVecKronExpr.h:180
TransposeType_t< VT2 > TT2
Transpose type of the right-hand side sparse vector expression.
Definition: DVecSVecKronExpr.h:103
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DVecSVecKronExpr.h:132
const ResultType CompositeType
Data type for composite expression templates.
Definition: DVecSVecKronExpr.h:135
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense vector operand.
Definition: DVecSVecKronExpr.h:213
DVecSVecKronExpr(const VT1 &lhs, const VT2 &rhs) noexcept
Constructor for the DVecSVecKronExpr class.
Definition: DVecSVecKronExpr.h:155
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DVecSVecKronExpr.h:128
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse vector operand.
Definition: DVecSVecKronExpr.h:223
ResultType_t< VT2 > RT2
Result type of the right-hand side sparse vector expression.
Definition: DVecSVecKronExpr.h:97
size_t nonZeros() const
Returns the number of non-zero elements in the sparse vector.
Definition: DVecSVecKronExpr.h:203
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DVecSVecKronExpr.h:146
ResultType_t< VT1 > RT1
Result type of the left-hand side dense vector expression.
Definition: DVecSVecKronExpr.h:96
CompositeType_t< VT1 > CT1
Composite type of the left-hand side dense vector expression.
Definition: DVecSVecKronExpr.h:100
KronTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DVecSVecKronExpr.h:127
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DVecSVecKronExpr.h:129
LeftOperand lhs_
Left-hand side dense vector of the Kronecker product expression.
Definition: DVecSVecKronExpr.h:254
If_t< IsExpression_v< VT2 >, const VT2, const VT2 & > RightOperand
Composite type of the right-hand side sparse vector expression.
Definition: DVecSVecKronExpr.h:141
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DVecSVecKronExpr.h:235
If_t< IsExpression_v< VT1 >, const VT1, const VT1 & > LeftOperand
Composite type of the left-hand side dense vector expression.
Definition: DVecSVecKronExpr.h:138
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DVecSVecKronExpr.h:193
RightOperand rhs_
Right-hand side sparse vector of the Kronecker product expression.
Definition: DVecSVecKronExpr.h:255
Base class for N-dimensional dense vectors.
Definition: DenseVector.h:77
Base class for sparse vectors.
Definition: SparseVector.h:72
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the Computation base class.
Header file for the DenseVector base class.
Header file for the SparseVector base class.
Header file for the VecVecKronExpr base class.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.
Definition: TransposeFlag.h:63
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ZERO_TYPE(T)
Constraint on the data type.
Definition: Zero.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition: SparseVector.h:61
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition: DenseVector.h:61
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_VECVECKRONEXPR(T1, T2)
Constraint on the data type.
Definition: VecVecKronExpr.h:102
#define BLAZE_CONSTRAINT_MUST_BE_ZERO_TYPE(T)
Constraint on the data type.
Definition: Zero.h:61
typename KronTrait< T1, T2 >::Type KronTrait_t
Auxiliary alias declaration for the KronTrait class template.
Definition: KronTrait.h:137
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition: Matrix.h:806
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
decltype(auto) kron(const DenseVector< VT1, TF > &lhs, const SparseVector< VT2, TF > &rhs)
Computes the Kronecker product of a dense vector and a sparse vector ( ).
Definition: DVecSVecKronExpr.h:589
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition: If.h:108
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition: Exception.h:331
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition: FunctionTrace.h:94
Header file for the exception macros of the math module.
Constraint on the data type.
Header file for the reset shim.
Header file for the serial shim.
Base class for all compute expression templates.
Definition: Computation.h:68
Base class for all vector/vector Kronecker expression templates.
Definition: VecVecKronExpr.h:69
Header file for the IsZero type trait.
Header file for basic type definitions.