2010-06-25 10:26:24 +02:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
|
|
|
|
// for linear algebra.
|
|
|
|
|
//
|
2015-10-28 11:42:14 +01:00
|
|
|
// Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>
|
2010-06-25 10:26:24 +02:00
|
|
|
//
|
2012-07-13 14:42:47 -04:00
|
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
|
|
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
|
|
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2010-06-25 10:26:24 +02:00
|
|
|
|
|
|
|
|
#ifndef EIGEN_SPARSEDENSEPRODUCT_H
|
|
|
|
|
#define EIGEN_SPARSEDENSEPRODUCT_H
|
|
|
|
|
|
2023-08-21 16:25:22 +00:00
|
|
|
// IWYU pragma: private
|
2021-09-10 19:12:26 +00:00
|
|
|
#include "./InternalHeaderCheck.h"
|
|
|
|
|
|
2012-04-15 11:06:28 +01:00
|
|
|
namespace Eigen {
|
|
|
|
|
|
2014-07-01 17:53:18 +02:00
|
|
|
namespace internal {
|
2014-07-19 14:55:56 +02:00
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
struct product_promote_storage_type<Sparse, Dense, OuterProduct> {
|
|
|
|
|
typedef Sparse ret;
|
|
|
|
|
};
|
|
|
|
|
template <>
|
|
|
|
|
struct product_promote_storage_type<Dense, Sparse, OuterProduct> {
|
|
|
|
|
typedef Sparse ret;
|
|
|
|
|
};
|
|
|
|
|
|
2014-07-01 17:53:18 +02:00
|
|
|
template <typename SparseLhsType, typename DenseRhsType, typename DenseResType, typename AlphaType,
|
|
|
|
|
int LhsStorageOrder = ((SparseLhsType::Flags & RowMajorBit) == RowMajorBit) ? RowMajor : ColMajor,
|
|
|
|
|
bool ColPerCol = ((DenseRhsType::Flags & RowMajorBit) == 0) || DenseRhsType::ColsAtCompileTime == 1>
|
|
|
|
|
struct sparse_time_dense_product_impl;
|
|
|
|
|
|
|
|
|
|
template <typename SparseLhsType, typename DenseRhsType, typename DenseResType>
|
|
|
|
|
struct sparse_time_dense_product_impl<SparseLhsType, DenseRhsType, DenseResType, typename DenseResType::Scalar,
|
|
|
|
|
RowMajor, true> {
|
2022-03-16 16:43:40 +00:00
|
|
|
typedef internal::remove_all_t<SparseLhsType> Lhs;
|
|
|
|
|
typedef internal::remove_all_t<DenseRhsType> Rhs;
|
|
|
|
|
typedef internal::remove_all_t<DenseResType> Res;
|
2014-07-01 17:53:18 +02:00
|
|
|
typedef typename evaluator<Lhs>::InnerIterator LhsInnerIterator;
|
2015-09-02 21:38:40 +02:00
|
|
|
typedef evaluator<Lhs> LhsEval;
|
2014-07-01 17:53:18 +02:00
|
|
|
static void run(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res,
|
|
|
|
|
const typename Res::Scalar& alpha) {
|
2015-06-26 10:32:34 +02:00
|
|
|
LhsEval lhsEval(lhs);
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2015-06-26 10:32:34 +02:00
|
|
|
Index n = lhs.outerSize();
|
|
|
|
|
#ifdef EIGEN_HAS_OPENMP
|
|
|
|
|
Index threads = Eigen::nbThreads();
|
|
|
|
|
#endif
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2014-07-01 17:53:18 +02:00
|
|
|
for (Index c = 0; c < rhs.cols(); ++c) {
|
2015-06-26 10:32:34 +02:00
|
|
|
#ifdef EIGEN_HAS_OPENMP
|
|
|
|
|
// This 20000 threshold has been found experimentally on 2D and 3D Poisson problems.
|
|
|
|
|
// It basically represents the minimal amount of work to be done to be worth it.
|
2015-07-21 22:52:21 +02:00
|
|
|
if (threads > 1 && lhsEval.nonZerosEstimate() > 20000) {
|
2016-01-27 18:03:51 +01:00
|
|
|
#pragma omp parallel for schedule(dynamic, (n + threads * 4 - 1) / (threads * 4)) num_threads(threads)
|
2015-06-26 10:32:34 +02:00
|
|
|
for (Index i = 0; i < n; ++i) processRow(lhsEval, rhs, res, alpha, i, c);
|
|
|
|
|
} else
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
for (Index i = 0; i < n; ++i) processRow(lhsEval, rhs, res, alpha, i, c);
|
2014-07-01 17:53:18 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2015-06-26 10:32:34 +02:00
|
|
|
static void processRow(const LhsEval& lhsEval, const DenseRhsType& rhs, DenseResType& res,
|
|
|
|
|
const typename Res::Scalar& alpha, Index i, Index col) {
|
2021-12-15 18:46:25 +00:00
|
|
|
// Two accumulators, which breaks the dependency chain on the accumulator
|
|
|
|
|
// and allows more instruction-level parallelism in the following loop
|
|
|
|
|
typename Res::Scalar tmp_a(0);
|
|
|
|
|
typename Res::Scalar tmp_b(0);
|
|
|
|
|
for (LhsInnerIterator it(lhsEval, i); it; ++it) {
|
|
|
|
|
tmp_a += it.value() * rhs.coeff(it.index(), col);
|
|
|
|
|
++it;
|
|
|
|
|
if (it) {
|
|
|
|
|
tmp_b += it.value() * rhs.coeff(it.index(), col);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
res.coeffRef(i, col) += alpha * (tmp_a + tmp_b);
|
2015-06-26 10:32:34 +02:00
|
|
|
}
|
2014-07-01 17:53:18 +02:00
|
|
|
};
|
|
|
|
|
|
2015-06-26 10:32:34 +02:00
|
|
|
// FIXME: what is the purpose of the following specialization? Is it for the BlockedSparse format?
|
2016-06-02 22:16:37 +02:00
|
|
|
// -> let's disable it for now as it is conflicting with generic scalar*matrix and matrix*scalar operators
|
2022-01-10 20:53:29 +00:00
|
|
|
// template<typename T1, typename T2/*, int Options_, typename StrideType_*/>
|
|
|
|
|
// struct ScalarBinaryOpTraits<T1, Ref<T2/*, Options_, StrideType_*/> >
|
2016-06-02 22:16:37 +02:00
|
|
|
// {
|
|
|
|
|
// enum {
|
|
|
|
|
// Defined = 1
|
|
|
|
|
// };
|
|
|
|
|
// typedef typename CwiseUnaryOp<scalar_multiple2_op<T1, typename T2::Scalar>, T2>::PlainObject ReturnType;
|
|
|
|
|
// };
|
|
|
|
|
|
2014-07-01 17:53:18 +02:00
|
|
|
template <typename SparseLhsType, typename DenseRhsType, typename DenseResType, typename AlphaType>
|
|
|
|
|
struct sparse_time_dense_product_impl<SparseLhsType, DenseRhsType, DenseResType, AlphaType, ColMajor, true> {
|
2022-03-16 16:43:40 +00:00
|
|
|
typedef internal::remove_all_t<SparseLhsType> Lhs;
|
|
|
|
|
typedef internal::remove_all_t<DenseRhsType> Rhs;
|
|
|
|
|
typedef internal::remove_all_t<DenseResType> Res;
|
2018-04-25 10:14:48 +02:00
|
|
|
typedef evaluator<Lhs> LhsEval;
|
|
|
|
|
typedef typename LhsEval::InnerIterator LhsInnerIterator;
|
2014-07-01 17:53:18 +02:00
|
|
|
static void run(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res, const AlphaType& alpha) {
|
2018-04-25 10:14:48 +02:00
|
|
|
LhsEval lhsEval(lhs);
|
2014-07-01 17:53:18 +02:00
|
|
|
for (Index c = 0; c < rhs.cols(); ++c) {
|
|
|
|
|
for (Index j = 0; j < lhs.outerSize(); ++j) {
|
|
|
|
|
// typename Res::Scalar rhs_j = alpha * rhs.coeff(j,c);
|
Relax mixing-type constraints for binary coefficient-wise operators:
- Replace internal::scalar_product_traits<A,B> by Eigen::ScalarBinaryOpTraits<A,B,OP>
- Remove the "functor_is_product_like" helper (was pretty ugly)
- Currently, OP is not used, but it is available to the user for fine grained tuning
- Currently, only the following operators have been generalized: *,/,+,-,=,*=,/=,+=,-=
- TODO: generalize all other binray operators (comparisons,pow,etc.)
- TODO: handle "scalar op array" operators (currently only * is handled)
- TODO: move the handling of the "void" scalar type to ScalarBinaryOpTraits
2016-06-06 15:11:41 +02:00
|
|
|
typename ScalarBinaryOpTraits<AlphaType, typename Rhs::Scalar>::ReturnType rhs_j(alpha * rhs.coeff(j, c));
|
2014-07-01 17:53:18 +02:00
|
|
|
for (LhsInnerIterator it(lhsEval, j); it; ++it) res.coeffRef(it.index(), c) += it.value() * rhs_j;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <typename SparseLhsType, typename DenseRhsType, typename DenseResType>
|
|
|
|
|
struct sparse_time_dense_product_impl<SparseLhsType, DenseRhsType, DenseResType, typename DenseResType::Scalar,
|
|
|
|
|
RowMajor, false> {
|
2022-03-16 16:43:40 +00:00
|
|
|
typedef internal::remove_all_t<SparseLhsType> Lhs;
|
|
|
|
|
typedef internal::remove_all_t<DenseRhsType> Rhs;
|
|
|
|
|
typedef internal::remove_all_t<DenseResType> Res;
|
2018-04-25 10:14:48 +02:00
|
|
|
typedef evaluator<Lhs> LhsEval;
|
|
|
|
|
typedef typename LhsEval::InnerIterator LhsInnerIterator;
|
2014-07-01 17:53:18 +02:00
|
|
|
static void run(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res,
|
|
|
|
|
const typename Res::Scalar& alpha) {
|
2018-04-25 10:14:48 +02:00
|
|
|
Index n = lhs.rows();
|
|
|
|
|
LhsEval lhsEval(lhs);
|
|
|
|
|
|
|
|
|
|
#ifdef EIGEN_HAS_OPENMP
|
|
|
|
|
Index threads = Eigen::nbThreads();
|
|
|
|
|
// This 20000 threshold has been found experimentally on 2D and 3D Poisson problems.
|
|
|
|
|
// It basically represents the minimal amount of work to be done to be worth it.
|
|
|
|
|
if (threads > 1 && lhsEval.nonZerosEstimate() * rhs.cols() > 20000) {
|
|
|
|
|
#pragma omp parallel for schedule(dynamic, (n + threads * 4 - 1) / (threads * 4)) num_threads(threads)
|
|
|
|
|
for (Index i = 0; i < n; ++i) processRow(lhsEval, rhs, res, alpha, i);
|
|
|
|
|
} else
|
|
|
|
|
#endif
|
2014-07-01 17:53:18 +02:00
|
|
|
{
|
2018-04-25 10:14:48 +02:00
|
|
|
for (Index i = 0; i < n; ++i) processRow(lhsEval, rhs, res, alpha, i);
|
2014-07-01 17:53:18 +02:00
|
|
|
}
|
|
|
|
|
}
|
2018-04-25 10:14:48 +02:00
|
|
|
|
|
|
|
|
static void processRow(const LhsEval& lhsEval, const DenseRhsType& rhs, Res& res, const typename Res::Scalar& alpha,
|
|
|
|
|
Index i) {
|
|
|
|
|
typename Res::RowXpr res_i(res.row(i));
|
|
|
|
|
for (LhsInnerIterator it(lhsEval, i); it; ++it) res_i += (alpha * it.value()) * rhs.row(it.index());
|
|
|
|
|
}
|
2014-07-01 17:53:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <typename SparseLhsType, typename DenseRhsType, typename DenseResType>
|
|
|
|
|
struct sparse_time_dense_product_impl<SparseLhsType, DenseRhsType, DenseResType, typename DenseResType::Scalar,
|
|
|
|
|
ColMajor, false> {
|
2022-03-16 16:43:40 +00:00
|
|
|
typedef internal::remove_all_t<SparseLhsType> Lhs;
|
|
|
|
|
typedef internal::remove_all_t<DenseRhsType> Rhs;
|
|
|
|
|
typedef internal::remove_all_t<DenseResType> Res;
|
2014-07-01 17:53:18 +02:00
|
|
|
typedef typename evaluator<Lhs>::InnerIterator LhsInnerIterator;
|
|
|
|
|
static void run(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res,
|
|
|
|
|
const typename Res::Scalar& alpha) {
|
2015-09-02 21:38:40 +02:00
|
|
|
evaluator<Lhs> lhsEval(lhs);
|
2014-07-01 17:53:18 +02:00
|
|
|
for (Index j = 0; j < lhs.outerSize(); ++j) {
|
|
|
|
|
typename Rhs::ConstRowXpr rhs_j(rhs.row(j));
|
|
|
|
|
for (LhsInnerIterator it(lhsEval, j); it; ++it) res.row(it.index()) += (alpha * it.value()) * rhs_j;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <typename SparseLhsType, typename DenseRhsType, typename DenseResType, typename AlphaType>
|
|
|
|
|
inline void sparse_time_dense_product(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res,
|
|
|
|
|
const AlphaType& alpha) {
|
|
|
|
|
sparse_time_dense_product_impl<SparseLhsType, DenseRhsType, DenseResType, AlphaType>::run(lhs, rhs, res, alpha);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // end namespace internal
|
|
|
|
|
|
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
|
|
template <typename Lhs, typename Rhs, int ProductType>
|
|
|
|
|
struct generic_product_impl<Lhs, Rhs, SparseShape, DenseShape, ProductType>
|
2015-06-09 18:33:24 +02:00
|
|
|
: generic_product_impl_base<Lhs, Rhs, generic_product_impl<Lhs, Rhs, SparseShape, DenseShape, ProductType> > {
|
|
|
|
|
typedef typename Product<Lhs, Rhs>::Scalar Scalar;
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2014-07-01 17:53:18 +02:00
|
|
|
template <typename Dest>
|
2015-06-09 18:33:24 +02:00
|
|
|
static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha) {
|
2015-09-29 11:11:40 +02:00
|
|
|
typedef typename nested_eval<Lhs, ((Rhs::Flags & RowMajorBit) == 0) ? 1 : Rhs::ColsAtCompileTime>::type LhsNested;
|
|
|
|
|
typedef typename nested_eval<Rhs, ((Lhs::Flags & RowMajorBit) == 0) ? 1 : Dynamic>::type RhsNested;
|
2014-07-01 17:53:18 +02:00
|
|
|
LhsNested lhsNested(lhs);
|
|
|
|
|
RhsNested rhsNested(rhs);
|
2015-06-09 18:33:24 +02:00
|
|
|
internal::sparse_time_dense_product(lhsNested, rhsNested, dst, alpha);
|
2014-07-01 17:53:18 +02:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-06 16:11:26 +02:00
|
|
|
template <typename Lhs, typename Rhs, int ProductType>
|
|
|
|
|
struct generic_product_impl<Lhs, Rhs, SparseTriangularShape, DenseShape, ProductType>
|
|
|
|
|
: generic_product_impl<Lhs, Rhs, SparseShape, DenseShape, ProductType> {};
|
|
|
|
|
|
2014-07-01 17:53:18 +02:00
|
|
|
template <typename Lhs, typename Rhs, int ProductType>
|
|
|
|
|
struct generic_product_impl<Lhs, Rhs, DenseShape, SparseShape, ProductType>
|
2015-06-09 18:33:24 +02:00
|
|
|
: generic_product_impl_base<Lhs, Rhs, generic_product_impl<Lhs, Rhs, DenseShape, SparseShape, ProductType> > {
|
|
|
|
|
typedef typename Product<Lhs, Rhs>::Scalar Scalar;
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2015-06-09 18:33:24 +02:00
|
|
|
template <typename Dst>
|
|
|
|
|
static void scaleAndAddTo(Dst& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha) {
|
2015-09-29 11:11:40 +02:00
|
|
|
typedef typename nested_eval<Lhs, ((Rhs::Flags & RowMajorBit) == 0) ? Dynamic : 1>::type LhsNested;
|
|
|
|
|
typedef typename nested_eval<Rhs, ((Lhs::Flags & RowMajorBit) == RowMajorBit) ? 1 : Lhs::RowsAtCompileTime>::type
|
|
|
|
|
RhsNested;
|
2014-07-01 17:53:18 +02:00
|
|
|
LhsNested lhsNested(lhs);
|
|
|
|
|
RhsNested rhsNested(rhs);
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2014-10-06 16:11:26 +02:00
|
|
|
// transpose everything
|
2015-06-09 18:33:24 +02:00
|
|
|
Transpose<Dst> dstT(dst);
|
|
|
|
|
internal::sparse_time_dense_product(rhsNested.transpose(), lhsNested.transpose(), dstT, alpha);
|
2014-07-01 17:53:18 +02:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-06 16:11:26 +02:00
|
|
|
template <typename Lhs, typename Rhs, int ProductType>
|
|
|
|
|
struct generic_product_impl<Lhs, Rhs, DenseShape, SparseTriangularShape, ProductType>
|
|
|
|
|
: generic_product_impl<Lhs, Rhs, DenseShape, SparseShape, ProductType> {};
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2014-09-16 16:06:32 -07:00
|
|
|
template <typename LhsT, typename RhsT, bool NeedToTranspose>
|
2014-07-19 14:55:56 +02:00
|
|
|
struct sparse_dense_outer_product_evaluator {
|
|
|
|
|
protected:
|
2022-03-16 16:43:40 +00:00
|
|
|
typedef std::conditional_t<NeedToTranspose, RhsT, LhsT> Lhs1;
|
|
|
|
|
typedef std::conditional_t<NeedToTranspose, LhsT, RhsT> ActualRhs;
|
2014-09-16 16:06:32 -07:00
|
|
|
typedef Product<LhsT, RhsT, DefaultProduct> ProdXprType;
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2014-07-19 14:55:56 +02:00
|
|
|
// if the actual left-hand side is a dense vector,
|
2014-09-23 14:28:23 +02:00
|
|
|
// then build a sparse-view so that we can seamlessly iterate over it.
|
2022-03-16 16:43:40 +00:00
|
|
|
typedef std::conditional_t<is_same<typename internal::traits<Lhs1>::StorageKind, Sparse>::value, Lhs1,
|
|
|
|
|
SparseView<Lhs1> >
|
|
|
|
|
ActualLhs;
|
|
|
|
|
typedef std::conditional_t<is_same<typename internal::traits<Lhs1>::StorageKind, Sparse>::value, Lhs1 const&,
|
|
|
|
|
SparseView<Lhs1> >
|
|
|
|
|
LhsArg;
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2015-09-02 21:38:40 +02:00
|
|
|
typedef evaluator<ActualLhs> LhsEval;
|
|
|
|
|
typedef evaluator<ActualRhs> RhsEval;
|
2014-09-16 16:06:32 -07:00
|
|
|
typedef typename evaluator<ActualLhs>::InnerIterator LhsIterator;
|
2014-07-19 14:55:56 +02:00
|
|
|
typedef typename ProdXprType::Scalar Scalar;
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2014-07-19 14:55:56 +02:00
|
|
|
public:
|
2014-09-16 16:06:32 -07:00
|
|
|
enum { Flags = NeedToTranspose ? RowMajorBit : 0, CoeffReadCost = HugeCost };
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2014-07-19 14:55:56 +02:00
|
|
|
class InnerIterator : public LhsIterator {
|
|
|
|
|
public:
|
|
|
|
|
InnerIterator(const sparse_dense_outer_product_evaluator& xprEval, Index outer)
|
|
|
|
|
: LhsIterator(xprEval.m_lhsXprImpl, 0),
|
|
|
|
|
m_outer(outer),
|
|
|
|
|
m_empty(false),
|
2014-09-16 16:06:32 -07:00
|
|
|
m_factor(get(xprEval.m_rhsXprImpl, outer, typename internal::traits<ActualRhs>::StorageKind())) {}
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2015-02-13 18:57:41 +01:00
|
|
|
EIGEN_STRONG_INLINE Index outer() const { return m_outer; }
|
|
|
|
|
EIGEN_STRONG_INLINE Index row() const { return NeedToTranspose ? m_outer : LhsIterator::index(); }
|
|
|
|
|
EIGEN_STRONG_INLINE Index col() const { return NeedToTranspose ? LhsIterator::index() : m_outer; }
|
2014-07-19 14:55:56 +02:00
|
|
|
|
|
|
|
|
EIGEN_STRONG_INLINE Scalar value() const { return LhsIterator::value() * m_factor; }
|
|
|
|
|
EIGEN_STRONG_INLINE operator bool() const { return LhsIterator::operator bool() && (!m_empty); }
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2014-07-19 14:55:56 +02:00
|
|
|
protected:
|
|
|
|
|
Scalar get(const RhsEval& rhs, Index outer, Dense = Dense()) const { return rhs.coeff(outer); }
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2014-07-19 14:55:56 +02:00
|
|
|
Scalar get(const RhsEval& rhs, Index outer, Sparse = Sparse()) {
|
|
|
|
|
typename RhsEval::InnerIterator it(rhs, outer);
|
|
|
|
|
if (it && it.index() == 0 && it.value() != Scalar(0)) return it.value();
|
|
|
|
|
m_empty = true;
|
|
|
|
|
return Scalar(0);
|
|
|
|
|
}
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2014-07-19 14:55:56 +02:00
|
|
|
Index m_outer;
|
|
|
|
|
bool m_empty;
|
|
|
|
|
Scalar m_factor;
|
|
|
|
|
};
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2014-09-23 14:28:23 +02:00
|
|
|
sparse_dense_outer_product_evaluator(const Lhs1& lhs, const ActualRhs& rhs)
|
2014-09-16 16:06:32 -07:00
|
|
|
: m_lhs(lhs), m_lhsXprImpl(m_lhs), m_rhsXprImpl(rhs) {
|
2015-10-28 11:42:14 +01:00
|
|
|
EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
|
|
|
|
|
}
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2014-07-19 14:55:56 +02:00
|
|
|
// transpose case
|
2014-09-16 16:06:32 -07:00
|
|
|
sparse_dense_outer_product_evaluator(const ActualRhs& rhs, const Lhs1& lhs)
|
|
|
|
|
: m_lhs(lhs), m_lhsXprImpl(m_lhs), m_rhsXprImpl(rhs) {
|
2015-10-28 11:42:14 +01:00
|
|
|
EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
|
|
|
|
|
}
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2014-07-19 14:55:56 +02:00
|
|
|
protected:
|
|
|
|
|
const LhsArg m_lhs;
|
2015-09-02 22:10:39 +02:00
|
|
|
evaluator<ActualLhs> m_lhsXprImpl;
|
|
|
|
|
evaluator<ActualRhs> m_rhsXprImpl;
|
2014-07-19 14:55:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// sparse * dense outer product
|
|
|
|
|
template <typename Lhs, typename Rhs>
|
2015-10-14 10:14:47 +02:00
|
|
|
struct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, OuterProduct, SparseShape, DenseShape>
|
2014-07-19 14:55:56 +02:00
|
|
|
: sparse_dense_outer_product_evaluator<Lhs, Rhs, Lhs::IsRowMajor> {
|
|
|
|
|
typedef sparse_dense_outer_product_evaluator<Lhs, Rhs, Lhs::IsRowMajor> Base;
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2014-07-19 14:55:56 +02:00
|
|
|
typedef Product<Lhs, Rhs> XprType;
|
|
|
|
|
typedef typename XprType::PlainObject PlainObject;
|
|
|
|
|
|
2014-09-23 14:28:23 +02:00
|
|
|
explicit product_evaluator(const XprType& xpr) : Base(xpr.lhs(), xpr.rhs()) {}
|
2014-07-19 14:55:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <typename Lhs, typename Rhs>
|
2015-10-14 10:14:47 +02:00
|
|
|
struct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, OuterProduct, DenseShape, SparseShape>
|
2014-07-19 14:55:56 +02:00
|
|
|
: sparse_dense_outer_product_evaluator<Lhs, Rhs, Rhs::IsRowMajor> {
|
|
|
|
|
typedef sparse_dense_outer_product_evaluator<Lhs, Rhs, Rhs::IsRowMajor> Base;
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2014-07-19 14:55:56 +02:00
|
|
|
typedef Product<Lhs, Rhs> XprType;
|
|
|
|
|
typedef typename XprType::PlainObject PlainObject;
|
|
|
|
|
|
2014-09-23 14:28:23 +02:00
|
|
|
explicit product_evaluator(const XprType& xpr) : Base(xpr.lhs(), xpr.rhs()) {}
|
2014-07-19 14:55:56 +02:00
|
|
|
};
|
|
|
|
|
|
2014-07-01 17:53:18 +02:00
|
|
|
} // end namespace internal
|
|
|
|
|
|
2012-04-15 11:06:28 +01:00
|
|
|
} // end namespace Eigen
|
|
|
|
|
|
2010-06-25 10:26:24 +02:00
|
|
|
#endif // EIGEN_SPARSEDENSEPRODUCT_H
|