10#ifndef EIGEN_SPARSEDENSEPRODUCT_H
11#define EIGEN_SPARSEDENSEPRODUCT_H
26template<
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType>
38 Index n = lhs.outerSize();
39#ifdef EIGEN_HAS_OPENMP
40 Eigen::initParallel();
41 Index threads = Eigen::nbThreads();
44 for(Index c=0; c<rhs.cols(); ++c)
46#ifdef EIGEN_HAS_OPENMP
49 if(threads>1 &&
lhsEval.nonZerosEstimate() > 20000)
51 #pragma omp parallel for schedule(static) num_threads(threads)
52 for(Index i=0; i<n; ++i)
53 processRow(
lhsEval,rhs,res,alpha,i,c);
58 for(Index i=0; i<n; ++i)
59 processRow(
lhsEval,rhs,res,alpha,i,c);
66 typename Res::Scalar tmp(0);
68 tmp += it.value() * rhs.coeff(it.index(),col);
69 res.coeffRef(i,col) += alpha * tmp;
75template<
typename T1,
typename T2>
83template<
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType,
typename AlphaType>
93 for(Index c=0; c<rhs.cols(); ++c)
95 for(Index
j=0;
j<lhs.outerSize(); ++
j)
100 res.coeffRef(it.index(),c) += it.value() *
rhs_j;
106template<
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType>
116 for(Index
j=0;
j<lhs.outerSize(); ++
j)
118 typename Res::RowXpr
res_j(res.row(
j));
120 res_j += (alpha*it.value()) * rhs.row(it.index());
125template<
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType>
135 for(Index
j=0;
j<lhs.outerSize(); ++
j)
137 typename Rhs::ConstRowXpr
rhs_j(rhs.row(
j));
139 res.row(it.index()) += (alpha*it.value()) *
rhs_j;
144template<
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType,
typename AlphaType>
154template<
typename Lhs,
typename Rhs,
int ProductType>
160 template<
typename Dest>
161 static void scaleAndAddTo(
Dest&
dst,
const Lhs& lhs,
const Rhs& rhs,
const Scalar& alpha)
163 typedef typename nested_eval<Lhs,((Rhs::Flags&
RowMajorBit)==0) ? 1 : Rhs::ColsAtCompileTime>::type LhsNested;
171template<
typename Lhs,
typename Rhs,
int ProductType>
176template<
typename Lhs,
typename Rhs,
int ProductType>
182 template<
typename Dst>
183 static void scaleAndAddTo(Dst&
dst,
const Lhs& lhs,
const Rhs& rhs,
const Scalar& alpha)
196template<
typename Lhs,
typename Rhs,
int ProductType>
201template<
typename LhsT,
typename RhsT,
bool NeedToTranspose>
219 typedef typename ProdXprType::Scalar Scalar;
224 CoeffReadCost = HugeCost
231 : LhsIterator(
xprEval.m_lhsXprImpl, 0),
237 EIGEN_STRONG_INLINE Index outer()
const {
return m_outer; }
238 EIGEN_STRONG_INLINE Index row()
const {
return NeedToTranspose ? m_outer : LhsIterator::index(); }
239 EIGEN_STRONG_INLINE Index col()
const {
return NeedToTranspose ? LhsIterator::index() : m_outer; }
241 EIGEN_STRONG_INLINE Scalar value()
const {
return LhsIterator::value() * m_factor; }
242 EIGEN_STRONG_INLINE
operator bool()
const {
return LhsIterator::operator bool() && (!m_empty); }
247 return rhs.coeff(outer);
252 typename RhsEval::InnerIterator it(rhs, outer);
253 if (it && it.index()==0 && it.value()!=Scalar(0))
265 : m_lhs(lhs), m_lhsXprImpl(m_lhs), m_rhsXprImpl(rhs)
267 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
272 : m_lhs(lhs), m_lhsXprImpl(m_lhs), m_rhsXprImpl(rhs)
274 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
284template<
typename Lhs,
typename Rhs>
291 typedef typename XprType::PlainObject PlainObject;
299template<
typename Lhs,
typename Rhs>
306 typedef typename XprType::PlainObject PlainObject;
Expression of the product of two arbitrary matrices or vectors.
Definition Product.h:111
A matrix or vector expression mapping an existing expression.
Definition Ref.h:188
Pseudo expression representing a solving operation.
Definition Solve.h:63
Definition SparseDenseProduct.h:228
@ ColMajor
Storage order is column major (see TopicStorageOrders).
Definition Constants.h:320
@ RowMajor
Storage order is row major (see TopicStorageOrders).
Definition Constants.h:322
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:61
Definition Constants.h:511
The type used to identify a dense storage.
Definition Constants.h:490
Definition Constants.h:520
The type used to identify a general sparse storage.
Definition Constants.h:493
Definition SparseUtil.h:137
Definition CoreEvaluators.h:82
Definition ProductEvaluators.h:320
Definition ProductEvaluators.h:81
Definition XprHelper.h:398
Definition ForwardDeclarations.h:165
Definition SparseDenseProduct.h:203
Definition SparseDenseProduct.h:24
Definition ForwardDeclarations.h:17