Implement the missing bits to make Solve compatible with sparse rhs

This commit is contained in:
Gael Guennebaud 2014-09-01 14:50:59 +02:00
parent e6cc24cbd6
commit bc065c75d2
3 changed files with 29 additions and 0 deletions

View File

@ -99,6 +99,15 @@ private:
Scalar coeff(Index i) const; Scalar coeff(Index i) const;
}; };
#ifdef EIGEN_TEST_EVALUATORS
// Generic API dispatcher
template<typename Decomposition, typename RhsType, typename StorageKind>
class SolveImpl : public internal::generic_xpr_base<Solve<Decomposition,RhsType>, MatrixXpr, StorageKind>::type
{
public:
typedef typename internal::generic_xpr_base<Solve<Decomposition,RhsType>, MatrixXpr, StorageKind>::type Base;
};
#endif
namespace internal { namespace internal {

View File

@ -284,6 +284,18 @@ struct Assignment<DstXprType, SrcXprType, internal::assign_op<typename DstXprTyp
} }
}; };
// Specialization for "dst = dec.solve(rhs)"
// NOTE we need to specialize it for Sparse2Sparse to avoid ambiguous specialization error
template<typename DstXprType, typename DecType, typename RhsType, typename Scalar>
struct Assignment<DstXprType, Solve<DecType,RhsType>, internal::assign_op<Scalar>, Sparse2Sparse, Scalar>
{
typedef Solve<DecType,RhsType> SrcXprType;
static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<Scalar> &)
{
src.dec()._solve_impl(src.rhs(), dst);
}
};
} // end namespace internal } // end namespace internal
#endif // EIGEN_TEST_EVALUATORS #endif // EIGEN_TEST_EVALUATORS

View File

@ -156,6 +156,14 @@ template<typename T> struct plain_matrix_type<T,Sparse>
typedef SparseMatrix<_Scalar, _Options, _Index> type; typedef SparseMatrix<_Scalar, _Options, _Index> type;
}; };
#ifdef EIGEN_TEST_EVALUATORS
template<typename Decomposition, typename RhsType>
struct solve_traits<Decomposition,RhsType,Sparse>
{
typedef typename sparse_eval<RhsType, RhsType::RowsAtCompileTime, RhsType::ColsAtCompileTime>::type PlainObject;
};
#endif
template<typename Derived> template<typename Derived>
struct generic_xpr_base<Derived, MatrixXpr, Sparse> struct generic_xpr_base<Derived, MatrixXpr, Sparse>
{ {