15#include "./InternalHeaderCheck.h"
19template <
typename Decomposition,
typename RhsType,
typename StorageKind>
37template <
typename Decomposition,
typename RhsType,
typename StorageKind>
40template <
typename Decomposition,
typename RhsType>
41struct solve_traits<Decomposition, RhsType, Dense> {
43 typename make_proper_matrix_type<
typename RhsType::Scalar, Decomposition::ColsAtCompileTime,
44 RhsType::ColsAtCompileTime, RhsType::PlainObject::Options,
45 Decomposition::MaxColsAtCompileTime, RhsType::MaxColsAtCompileTime>::type;
48template <
typename Decomposition,
typename RhsType>
49struct traits<Solve<Decomposition, RhsType> >
51 typename solve_traits<Decomposition, RhsType, typename internal::traits<RhsType>::StorageKind>::PlainObject> {
53 typename solve_traits<Decomposition, RhsType, typename internal::traits<RhsType>::StorageKind>::PlainObject;
55 typename promote_index_type<typename Decomposition::StorageIndex, typename RhsType::StorageIndex>::type;
56 using BaseTraits = traits<PlainObject>;
57 enum { Flags = BaseTraits::Flags &
RowMajorBit, CoeffReadCost = HugeCost };
62template <
typename Decomposition,
typename RhsType>
63class Solve :
public SolveImpl<Decomposition, RhsType, typename internal::traits<RhsType>::StorageKind> {
65 using PlainObject =
typename internal::traits<Solve>::PlainObject;
66 using StorageIndex =
typename internal::traits<Solve>::StorageIndex;
68 Solve(
const Decomposition &dec,
const RhsType &rhs) : m_dec(dec), m_rhs(rhs) {}
70 EIGEN_DEVICE_FUNC
constexpr Index rows()
const noexcept {
return m_dec.cols(); }
71 EIGEN_DEVICE_FUNC
constexpr Index cols()
const noexcept {
return m_rhs.cols(); }
73 EIGEN_DEVICE_FUNC
constexpr const Decomposition &dec()
const {
return m_dec; }
74 EIGEN_DEVICE_FUNC
constexpr const RhsType &rhs()
const {
return m_rhs; }
77 const Decomposition &m_dec;
78 const typename internal::ref_selector<RhsType>::type m_rhs;
82template <
typename Decomposition,
typename RhsType>
83class SolveImpl<Decomposition, RhsType,
Dense> :
public MatrixBase<Solve<Decomposition, RhsType> > {
88 EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
91 Scalar coeff(Index row, Index col)
const;
92 Scalar coeff(Index i)
const;
96template <
typename Decomposition,
typename RhsType,
typename StorageKind>
97class SolveImpl :
public internal::generic_xpr_base<Solve<Decomposition, RhsType>, MatrixXpr, StorageKind>::type {
99 using Base =
typename internal::generic_xpr_base<Solve<Decomposition, RhsType>, MatrixXpr, StorageKind>::type;
105template <
typename Decomposition,
typename RhsType>
106struct evaluator<Solve<Decomposition, RhsType> >
107 :
public evaluator<typename Solve<Decomposition, RhsType>::PlainObject> {
108 using SolveType = Solve<Decomposition, RhsType>;
109 using PlainObject =
typename SolveType::PlainObject;
110 using Base = evaluator<PlainObject>;
114 EIGEN_DEVICE_FUNC
explicit evaluator(
const SolveType &solve) : m_result(solve.rows(), solve.cols()) {
115 internal::construct_at<Base>(
this, m_result);
116 solve.dec()._solve_impl(solve.rhs(), m_result);
120 PlainObject m_result;
126template <
typename DstXprType,
typename DecType,
typename RhsType,
typename Scalar>
127struct Assignment<DstXprType, Solve<DecType, RhsType>, internal::assign_op<Scalar, Scalar>, Dense2Dense> {
128 using SrcXprType = Solve<DecType, RhsType>;
129 static void run(DstXprType &dst,
const SrcXprType &src,
const internal::assign_op<Scalar, Scalar> &) {
130 Index dstRows = src.rows();
131 Index dstCols = src.cols();
132 if ((dst.rows() != dstRows) || (dst.cols() != dstCols)) dst.resize(dstRows, dstCols);
134 src.dec()._solve_impl(src.rhs(), dst);
139template <
typename DstXprType,
typename DecType,
typename RhsType,
typename Scalar>
140struct Assignment<DstXprType, Solve<Transpose<const DecType>, RhsType>, internal::assign_op<Scalar, Scalar>,
142 using SrcXprType = Solve<Transpose<const DecType>, RhsType>;
143 static void run(DstXprType &dst,
const SrcXprType &src,
const internal::assign_op<Scalar, Scalar> &) {
144 Index dstRows = src.rows();
145 Index dstCols = src.cols();
146 if ((dst.rows() != dstRows) || (dst.cols() != dstCols)) dst.resize(dstRows, dstCols);
148 src.dec().nestedExpression().template _solve_impl_transposed<false>(src.rhs(), dst);
153template <
typename DstXprType,
typename DecType,
typename RhsType,
typename Scalar>
156 Solve<CwiseUnaryOp<internal::scalar_conjugate_op<typename DecType::Scalar>, const Transpose<const DecType> >,
158 internal::assign_op<Scalar, Scalar>, Dense2Dense> {
160 Solve<CwiseUnaryOp<internal::scalar_conjugate_op<typename DecType::Scalar>,
const Transpose<const DecType>>,
162 static void run(DstXprType &dst,
const SrcXprType &src,
const internal::assign_op<Scalar, Scalar> &) {
163 Index dstRows = src.rows();
164 Index dstCols = src.cols();
165 if ((dst.rows() != dstRows) || (dst.cols() != dstCols)) dst.resize(dstRows, dstCols);
167 src.dec().nestedExpression().nestedExpression().template _solve_impl_transposed<true>(src.rhs(), dst);
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:53
Pseudo expression representing a solving operation.
Definition Solve.h:63
constexpr unsigned int EvalBeforeNestingBit
Definition Constants.h:75
constexpr unsigned int RowMajorBit
Definition Constants.h:71
Definition Constants.h:542