11#ifndef EIGEN_SOLVEWITHGUESS_H
12#define EIGEN_SOLVEWITHGUESS_H
15#include "./InternalHeaderCheck.h"
19template <
typename Decomposition,
typename RhsType,
typename GuessType>
37template <
typename Decomposition,
typename RhsType,
typename GuessType>
38struct traits<SolveWithGuess<Decomposition, RhsType, GuessType> > : traits<Solve<Decomposition, RhsType> > {};
42template <
typename Decomposition,
typename RhsType,
typename GuessType>
43class SolveWithGuess :
public internal::generic_xpr_base<SolveWithGuess<Decomposition, RhsType, GuessType>, MatrixXpr,
44 typename internal::traits<RhsType>::StorageKind>::type {
46 using Scalar =
typename internal::traits<SolveWithGuess>::Scalar;
47 using PlainObject =
typename internal::traits<SolveWithGuess>::PlainObject;
48 using Base =
typename internal::generic_xpr_base<SolveWithGuess<Decomposition, RhsType, GuessType>,
MatrixXpr,
49 typename internal::traits<RhsType>::StorageKind>::type;
50 using Nested =
typename internal::ref_selector<SolveWithGuess>::type;
52 SolveWithGuess(
const Decomposition &dec,
const RhsType &rhs,
const GuessType &guess)
53 : m_dec(dec), m_rhs(rhs), m_guess(guess) {}
55 EIGEN_DEVICE_FUNC
constexpr Index rows()
const noexcept {
return m_dec.cols(); }
56 EIGEN_DEVICE_FUNC
constexpr Index cols()
const noexcept {
return m_rhs.cols(); }
58 EIGEN_DEVICE_FUNC
const Decomposition &dec()
const {
return m_dec; }
59 EIGEN_DEVICE_FUNC
const RhsType &rhs()
const {
return m_rhs; }
60 EIGEN_DEVICE_FUNC
const GuessType &guess()
const {
return m_guess; }
63 const Decomposition &m_dec;
65 const GuessType &m_guess;
68 Scalar coeff(Index row, Index col)
const;
69 Scalar coeff(Index i)
const;
75template <
typename Decomposition,
typename RhsType,
typename GuessType>
76struct evaluator<
SolveWithGuess<Decomposition, RhsType, GuessType> >
77 :
public evaluator<typename SolveWithGuess<Decomposition, RhsType, GuessType>::PlainObject> {
79 using PlainObject =
typename SolveType::PlainObject;
80 using Base = evaluator<PlainObject>;
82 evaluator(
const SolveType &solve) : m_result(solve.rows(), solve.cols()) {
83 internal::construct_at<Base>(
this, m_result);
84 m_result = solve.guess();
85 solve.dec()._solve_with_guess_impl(solve.rhs(), m_result);
95template <
typename DstXprType,
typename DecType,
typename RhsType,
typename GuessType,
typename Scalar>
96struct Assignment<DstXprType, SolveWithGuess<DecType, RhsType, GuessType>, internal::assign_op<Scalar, Scalar>,
98 using SrcXprType = SolveWithGuess<DecType, RhsType, GuessType>;
99 static void run(DstXprType &dst,
const SrcXprType &src,
const internal::assign_op<Scalar, Scalar> &) {
100 Index dstRows = src.rows();
101 Index dstCols = src.cols();
102 if ((dst.rows() != dstRows) || (dst.cols() != dstCols)) dst.resize(dstRows, dstCols);
105 src.dec()._solve_with_guess_impl(src.rhs(), dst);
Pseudo expression representing a solving operation.
Definition SolveWithGuess.h:44
Definition Constants.h:557