10 #ifndef EIGEN_SPARSEDENSEPRODUCT_H 11 #define EIGEN_SPARSEDENSEPRODUCT_H 37 template<
typename Lhs,
typename Rhs,
bool Tr>
43 typedef typename Lhs::Index
Index;
54 ColsAtCompileTime = Tr ? int(
traits<Lhs>::ColsAtCompileTime) : int(
traits<Rhs>::ColsAtCompileTime),
55 MaxRowsAtCompileTime = Tr ? int(
traits<Rhs>::MaxRowsAtCompileTime) : int(
traits<Lhs>::MaxRowsAtCompileTime),
56 MaxColsAtCompileTime = Tr ? int(
traits<Lhs>::MaxColsAtCompileTime) : int(
traits<Rhs>::MaxColsAtCompileTime),
60 CoeffReadCost = LhsCoeffReadCost + RhsCoeffReadCost +
NumTraits<Scalar>::MulCost
66 template<
typename Lhs,
typename Rhs,
bool Tr>
78 typedef typename Traits::LhsNested LhsNested;
79 typedef typename Traits::RhsNested RhsNested;
80 typedef typename Traits::_LhsNested _LhsNested;
81 typedef typename Traits::_RhsNested _RhsNested;
88 : m_lhs(lhs), m_rhs(
rhs)
94 : m_lhs(lhs), m_rhs(rhs)
110 template<
typename Lhs,
typename Rhs,
bool Transpose>
113 typedef typename _LhsNested::InnerIterator
Base;
117 : Base(prod.lhs(), 0), m_outer(outer), m_factor(prod.
rhs().coeff(outer))
121 inline Index
outer()
const {
return m_outer; }
125 inline Scalar
value()
const {
return Base::value() * m_factor; }
133 template<
typename Lhs,
typename Rhs>
135 :
traits<ProductBase<SparseTimeDenseProduct<Lhs,Rhs>, Lhs, Rhs> >
141 template<
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType,
143 bool ColPerCol = ((DenseRhsType::Flags&
RowMajorBit)==0) || DenseRhsType::ColsAtCompileTime==1>
146 template<
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType>
154 static void run(
const SparseLhsType& lhs,
const DenseRhsType&
rhs, DenseResType& res,
const typename Res::Scalar& alpha)
156 for(Index c=0; c<rhs.cols(); ++c)
158 int n = lhs.outerSize();
159 for(Index j=0; j<n; ++j)
161 typename Res::Scalar tmp(0);
162 for(LhsInnerIterator it(lhs,j); it ;++it)
163 tmp += it.value() * rhs.coeff(it.index(),c);
164 res.coeffRef(j,c) = alpha * tmp;
170 template<
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType>
178 static void run(
const SparseLhsType& lhs,
const DenseRhsType&
rhs, DenseResType& res,
const typename Res::Scalar& alpha)
180 for(Index c=0; c<rhs.cols(); ++c)
182 for(Index j=0; j<lhs.outerSize(); ++j)
184 typename Res::Scalar rhs_j = alpha * rhs.coeff(j,c);
185 for(LhsInnerIterator it(lhs,j); it ;++it)
186 res.coeffRef(it.index(),c) += it.value() * rhs_j;
192 template<
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType>
200 static void run(
const SparseLhsType& lhs,
const DenseRhsType&
rhs, DenseResType& res,
const typename Res::Scalar& alpha)
202 for(Index j=0; j<lhs.outerSize(); ++j)
205 for(LhsInnerIterator it(lhs,j); it ;++it)
206 res_j += (alpha*it.value()) * rhs.row(it.index());
211 template<
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType>
219 static void run(
const SparseLhsType& lhs,
const DenseRhsType&
rhs, DenseResType& res,
const typename Res::Scalar& alpha)
221 for(Index j=0; j<lhs.outerSize(); ++j)
224 for(LhsInnerIterator it(lhs,j); it ;++it)
225 res.row(it.index()) += (alpha*it.value()) * rhs_j;
230 template<
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType,
typename AlphaType>
238 template<
typename Lhs,
typename Rhs>
240 :
public ProductBase<SparseTimeDenseProduct<Lhs,Rhs>, Lhs, Rhs>
248 template<
typename Dest>
void scaleAndAddTo(Dest& dest,
const Scalar& alpha)
const 260 template<
typename Lhs,
typename Rhs>
262 :
traits<ProductBase<DenseTimeSparseProduct<Lhs,Rhs>, Lhs, Rhs> >
268 template<
typename Lhs,
typename Rhs>
270 :
public ProductBase<DenseTimeSparseProduct<Lhs,Rhs>, Lhs, Rhs>
291 template<
typename Derived>
292 template<
typename OtherDerived>
301 #endif // EIGEN_SPARSEDENSEPRODUCT_H
Block< Derived, 1, internal::traits< Derived >::ColsAtCompileTime, IsRowMajor > RowXpr
void sparse_time_dense_product(const SparseLhsType &lhs, const DenseRhsType &rhs, DenseResType &res, const AlphaType &alpha)
#define EIGEN_PRODUCT_PUBLIC_INTERFACE(Derived)
return ReturnType(abs2(x.value()), x.derivatives()*(Scalar(2)*x.value()))
internal::remove_all< DenseRhsType >::type Rhs
#define EIGEN_STRONG_INLINE
internal::traits< Derived >::Scalar Scalar
EIGEN_STRONG_INLINE Index rows() const
remove_all< RhsNested >::type _RhsNested
Lhs::InnerIterator LhsInnerIterator
EIGEN_STRONG_INLINE Index cols() const
SparseTimeDenseProduct< Lhs, Rhs > Type
Expression of the transpose of a matrix.
iterative scaling algorithm to equilibrate rows and column norms in matrices
SparseMatrixBase< SparseDenseOuterProduct > Base
SparseDenseOuterProduct< Lhs, Rhs, false > Type
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
EIGEN_STRONG_INLINE InnerIterator(const SparseDenseOuterProduct &prod, Index outer)
internal::remove_all< DenseRhsType >::type Rhs
const unsigned int RowMajorBit
scalar_product_traits< typename traits< Lhs >::Scalar, typename traits< Rhs >::Scalar >::ReturnType Scalar
EIGEN_STRONG_INLINE const _LhsNested & lhs() const
Lhs::InnerIterator LhsInnerIterator
Base class of any sparse matrices or sparse expressions.
void scaleAndAddTo(Dest &dest, const Scalar &alpha) const
Lhs::InnerIterator LhsInnerIterator
static void run(const SparseLhsType &lhs, const DenseRhsType &rhs, DenseResType &res, const typename Res::Scalar &alpha)
DenseTimeSparseProduct< Lhs, Rhs > Type
const ScalarMultipleReturnType operator*(const Scalar &scalar) const
SparseDenseOuterProduct::Index Index
EIGEN_STRONG_INLINE SparseDenseOuterProduct(const Rhs &rhs, const Lhs &lhs)
const Block< const Derived, 1, internal::traits< Derived >::ColsAtCompileTime, IsRowMajor > ConstRowXpr
internal::remove_all< DenseResType >::type Res
Lhs::InnerIterator LhsInnerIterator
internal::remove_all< DenseResType >::type Res
internal::traits< Derived >::Index Index
void rhs(const real_t *x, real_t *f)
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
internal::remove_all< DenseRhsType >::type Rhs
internal::remove_all< SparseLhsType >::type Lhs
static void run(const SparseLhsType &lhs, const DenseRhsType &rhs, DenseResType &res, const typename Res::Scalar &alpha)
EIGEN_STRONG_INLINE const _RhsNested & rhs() const
internal::remove_all< SparseLhsType >::type Lhs
_LhsNested::InnerIterator Base
static void run(const SparseLhsType &lhs, const DenseRhsType &rhs, DenseResType &res, const typename Res::Scalar &alpha)
internal::remove_all< DenseRhsType >::type Rhs
SparseDenseOuterProduct< Rhs, Lhs, true > Type
internal::remove_all< DenseResType >::type Res
remove_all< LhsNested >::type _LhsNested
Base class for all dense matrices, vectors, and expressions.
internal::remove_all< SparseLhsType >::type Lhs
internal::remove_all< SparseLhsType >::type Lhs
internal::remove_all< DenseResType >::type Res
static void run(const SparseLhsType &lhs, const DenseRhsType &rhs, DenseResType &res, const typename Res::Scalar &alpha)
void scaleAndAddTo(Dest &dest, const Scalar &alpha) const