LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
LMCAS::polynomial_solver_detail 命名空间参考

类

struct  SymbolicQuarticDepression

函数

bool bounded_rational_root_search (const Polynomial< Rational > &polynomial)
bool convert_to_rational_poly (const Polynomial< SymbolicPolyCoeff > &poly, Polynomial< Rational > &output, ComputationContext &context)
std::vector< std::shared_ptr< SymbolicExpr > > exact_polynomial_roots (const Polynomial< Rational > &polynomial, ComputationContext &context)
bool is_purely_numeric (const std::shared_ptr< SymbolicExpr > &expr)
std::shared_ptr< SymbolicExpr > negate (const std::shared_ptr< SymbolicExpr > &expr)
std::shared_ptr< SymbolicExpr > num (int value)
std::vector< std::shared_ptr< SymbolicExpr > > solve_biquadratic_impl (const std::shared_ptr< SymbolicExpr > &a, const std::shared_ptr< SymbolicExpr > &b, const std::shared_ptr< SymbolicExpr > &c, const std::string &variable, ComputationContext &context)
std::vector< std::shared_ptr< SymbolicExpr > > solve_by_factoring_impl (const Polynomial< SymbolicPolyCoeff > &polynomial, const std::string &variable, ComputationContext &context)
std::vector< std::shared_ptr< SymbolicExpr > > solve_cubic_impl (const std::shared_ptr< SymbolicExpr > &a, const std::shared_ptr< SymbolicExpr > &b, const std::shared_ptr< SymbolicExpr > &c, const std::shared_ptr< SymbolicExpr > &d, const std::string &variable, ComputationContext &context)
std::vector< std::shared_ptr< SymbolicExpr > > solve_quadratic_internal (const std::shared_ptr< SymbolicExpr > &a, const std::shared_ptr< SymbolicExpr > &b, const std::shared_ptr< SymbolicExpr > &c, ComputationContext &context)
std::vector< std::shared_ptr< SymbolicExpr > > solve_quartic_impl (const std::shared_ptr< SymbolicExpr > &a, const std::shared_ptr< SymbolicExpr > &b, const std::shared_ptr< SymbolicExpr > &c, const std::shared_ptr< SymbolicExpr > &d, const std::shared_ptr< SymbolicExpr > &e, const std::string &variable, ComputationContext &context)
std::shared_ptr< SymbolicExpr > sub (const std::shared_ptr< SymbolicExpr > &a, const std::shared_ptr< SymbolicExpr > &b)
SymbolicQuarticDepression symbolic_quartic_depression (const std::shared_ptr< SymbolicExpr > &a, const std::shared_ptr< SymbolicExpr > &b, const std::shared_ptr< SymbolicExpr > &c, const std::shared_ptr< SymbolicExpr > &d, const std::shared_ptr< SymbolicExpr > &e, ComputationContext &context)
std::vector< std::shared_ptr< SymbolicExpr > > symbolic_quartic_roots (const SymbolicQuarticDepression &depression, const std::string &variable, ComputationContext &context)

类说明

◆ LMCAS::polynomial_solver_detail::SymbolicQuarticDepression

struct LMCAS::polynomial_solver_detail::SymbolicQuarticDepression

在文件 polynomial_solver_support.hpp 第 19 行定义.

LMCAS::polynomial_solver_detail::SymbolicQuarticDepression 的协作图:
类成员
shared_ptr< SymbolicExpr > p
shared_ptr< SymbolicExpr > q
shared_ptr< SymbolicExpr > r
shared_ptr< SymbolicExpr > shift

函数说明

◆ bounded_rational_root_search()

bool LMCAS::polynomial_solver_detail::bounded_rational_root_search ( const Polynomial< Rational > & polynomial)

find_rational_roots 在枚举因子前移除零根。 大小限制针对本原整数多项式的实际首尾系数; 各分母虽小,其最小公倍数仍可能很大。

在文件 solve_polynomial_cubic.cpp 第 95 行定义.

96 {
97 if (polynomial.degree() <= 1) return true;
98 if (polynomial.lead_coeff() != Rational(1)) {
99 return bounded_rational_root_search(polynomial.make_monic());
100 }
101 BigInt denominator_lcm(1);
102 for (const auto& coefficient : polynomial.coeffs) {
103 denominator_lcm = BigInt::lcm(
104 denominator_lcm, coefficient.get_denominator());
105 if (denominator_lcm.bit_length() > 32) return false;
106 }
107 /**
108 * @brief find_rational_roots 在枚举因子前移除零根。
109 * 大小限制针对本原整数多项式的实际首尾系数;
110 * 各分母虽小,其最小公倍数仍可能很大。
111 */
112 for (const auto& coefficient : polynomial.coeffs) {
113 if (coefficient != Rational(0)) {
114 return (coefficient * Rational(denominator_lcm))
115 .get_numerator().bit_length() <= 32;
116 }
117 }
118 return true;
119}
std::vector< CoeffType > coeffs
系数数组,coeffs[i] 为 x^i 的系数
CoeffType lead_coeff() const
获取首项系数
int degree() const
获取多项式的次数
Polynomial make_monic() const
首一化(使首项系数为 1)
bool bounded_rational_root_search(const Polynomial< Rational > &polynomial)

引用了 bounded_rational_root_search(), LMCAS::Polynomial< CoeffType >::coeffs, LMCAS::Polynomial< CoeffType >::degree(), LMCAS::Polynomial< CoeffType >::lead_coeff() , 以及 LMCAS::Polynomial< CoeffType >::make_monic().

被这些函数引用 bounded_rational_root_search(), LMCAS::exact_factor_roots(), solve_by_factoring_impl() , 以及 LMCAS::solve_exact_factor().

函数调用图:
这是这个函数的调用关系图:

◆ convert_to_rational_poly()

bool LMCAS::polynomial_solver_detail::convert_to_rational_poly ( const Polynomial< SymbolicPolyCoeff > & poly,
Polynomial< Rational > & output,
ComputationContext & context )

在文件 solve_polynomial_normalization.cpp 第 23 行定义.

26{
27
28 detail::RewriteBudget transform_budget(context, (context).limits().max_recursion_depth,
29 (context).limits().max_ast_nodes, "transform");
30 out_poly = Polynomial<Rational>(sym_poly.variable_name);
31 out_poly.coeffs.resize(sym_poly.coeffs.size(), Rational(0));
32
33 for (size_t i = 0; i < sym_poly.coeffs.size(); ++i) {
34 auto coeff_expr = sym_poly.coeffs[i].val;
35 if (!coeff_expr) {
36 out_poly.coeffs[i] = Rational(0);
37 continue;
38 }
39
40 auto simplified = detail::make_expression_ptr(detail::normalize_node(detail::node(coeff_expr), transform_budget));
41 auto num_node = std::dynamic_pointer_cast<const NumberNode>(
42 LMCAS::detail::node(simplified));
43 if (!num_node) {
44 return false;
45 }
46 if (std::holds_alternative<Rational>(num_node->value())) {
47 out_poly.coeffs[i] = std::get<Rational>(num_node->value());
48 } else {
49 out_poly.coeffs[i] =
50 Rational(std::get<BigInt>(num_node->value()));
51 }
52 }
53
54 out_poly.trim();
55 return true;
56}
一元多项式模板类
std::shared_ptr<::LMCAS::SymbolicExpr > make_expression_ptr(SymbolicNodePtr root)
const SymbolicNodePtr & node(const ::LMCAS::SymbolicExpr &expression) noexcept
SymbolicNodePtr normalize_node(const SymbolicNodePtr &node, RewriteBudget &budget, const FactsQuery &facts, Domain domain)
const std::vector< Polynomial< BigInt > > const BigInt ComputationContext & context
@ Rational
Rational numbers

引用了 LMCAS::Polynomial< CoeffType >::coeffs, LMCAS::context, convert_to_rational_poly(), LMCAS::detail::make_expression_ptr(), LMCAS::detail::node(), LMCAS::detail::normalize_node(), LMCAS::Polynomial< CoeffType >::trim() , 以及 LMCAS::Polynomial< CoeffType >::variable_name.

被这些函数引用 convert_to_rational_poly(), solve_by_factoring_impl(), solve_cubic_impl() , 以及 solve_quartic_impl().

函数调用图:
这是这个函数的调用关系图:

◆ exact_polynomial_roots()

std::vector< std::shared_ptr< SymbolicExpr > > LMCAS::polynomial_solver_detail::exact_polynomial_roots ( const Polynomial< Rational > & polynomial,
ComputationContext & context )

在文件 solve_polynomial_cubic.cpp 第 173 行定义.

174 {
175 if (polynomial.is_zero()) {
176 throw std::invalid_argument(
177 "polynomial solver: identically zero equation has no finite root list");
178 }
179 std::vector<std::shared_ptr<SymbolicExpr>> roots;
180 for (const auto& [factor, multiplicity] :
181 square_free_factorization(polynomial)) {
182 auto factor_roots = exact_factor_roots(factor, context);
183 for (int repeat = 0; repeat < multiplicity; ++repeat) {
184 roots.insert(roots.end(), factor_roots.begin(), factor_roots.end());
185 }
186 }
187 return roots;
188}
bool is_zero() const
判断是否为零多项式
std::vector< std::pair< Polynomial< Rational >, int > > square_free_factorization(const Polynomial< Rational > &poly)
ExprSetResult roots(const ExprPtr &expression, const std::string &variable, ComputationContext &context, const SolveOptions &options)
static std::vector< std::shared_ptr< SymbolicExpr > > exact_factor_roots(Polynomial< Rational > polynomial, ComputationContext &context)

引用了 LMCAS::context, LMCAS::exact_factor_roots(), LMCAS::Polynomial< CoeffType >::is_zero(), LMCAS::roots() , 以及 LMCAS::square_free_factorization().

被这些函数引用 solve_cubic_impl() , 以及 solve_quartic_impl().

函数调用图:
这是这个函数的调用关系图:

◆ is_purely_numeric()

bool LMCAS::polynomial_solver_detail::is_purely_numeric ( const std::shared_ptr< SymbolicExpr > & expr)

在文件 solve_polynomial_normalization.cpp 第 8 行定义.

8 {
9 return !expr || free_variables(LMCAS::detail::node(expr)).empty();
10}
std::set< std::string > free_variables(const detail::SymbolicNodePtr &expression, detail::RewriteBudget *budget)

引用了 LMCAS::free_variables(), is_purely_numeric() , 以及 LMCAS::detail::node().

被这些函数引用 is_purely_numeric(), solve_biquadratic_impl() , 以及 LMCAS::solve_degenerate_cubic().

函数调用图:
这是这个函数的调用关系图:

◆ negate()

std::shared_ptr< SymbolicExpr > LMCAS::polynomial_solver_detail::negate ( const std::shared_ptr< SymbolicExpr > & expr)

在文件 solve_polynomial_normalization.cpp 第 12 行定义.

12 {
13 return SymbolicExpr::multiply(SymbolicExpr::number(-1), x);
14}

引用了 negate().

被这些函数引用 LMCAS::detail::definite::anonymous_namespace{integration_definite_segments.cpp}::logical_predicate_truth(), negate(), LMCAS::detail::anonymous_namespace{exact_matrix_solve.cpp}::rational_linear_solve(), solve_biquadratic_impl(), LMCAS::solve_degenerate_cubic(), LMCAS::detail::solve_linear_exact(), solve_quadratic_internal(), sub(), LMCAS::symbolic_cubic_roots() , 以及 symbolic_quartic_roots().

函数调用图:
这是这个函数的调用关系图:

◆ num()

std::shared_ptr< SymbolicExpr > LMCAS::polynomial_solver_detail::num ( int value)

在文件 solve_polynomial_normalization.cpp 第 20 行定义.

20{ return SymbolicExpr::number(n); }

引用了 num().

被这些函数引用 LMCAS::berlekamp_detail::bk_reduce_to_mod_coeffs(), LMCAS::detail::inequality_support::determine_leading_sign(), LMCAS::groebner_detail::div_mono(), LMCAS::detail::inequality_support::exact_numeric_sign(), LMCAS::anonymous_namespace{mixed_transcendental_search.cpp}::extract_real_value(), LMCAS::get_integer_value(), LMCAS::is_even_integer_number(), LMCAS::is_integer_number(), LMCAS::is_positive_integer_number(), LMCAS::is_zero_number(), LMCAS::ode_root_detail::anonymous_namespace{ode_characteristic_roots.cpp}::iterate_characteristic_roots(), LMCAS::solver_detail::multiply_no_expand(), LMCAS::InferenceEngine::Impl::natural_number(), num(), LMCAS::InferenceEngine::Impl::number_integer(), LMCAS::InferenceEngine::Impl::number_negative(), LMCAS::InferenceEngine::Impl::number_nonnegative(), LMCAS::InferenceEngine::Impl::number_nonpositive(), LMCAS::InferenceEngine::Impl::number_nonzero(), LMCAS::InferenceEngine::Impl::number_positive(), LMCAS::InferenceEngine::Impl::operand_sign(), LMCAS::InferenceEngine::Impl::query_natural(), LMCAS::InferenceEngine::Impl::query_rational(), LMCAS::anonymous_namespace{integration_rational_collection.cpp}::rd_collect_power(), LMCAS::anonymous_namespace{integration_rational_collection.cpp}::rd_collect_rational(), LMCAS::anonymous_namespace{integration_rational_collection.cpp}::rd_collect_sum(), LMCAS::detail::series_support::series_get_double(), solve_biquadratic_impl(), LMCAS::solve_linear1_ode(), solve_quadratic_internal(), LMCAS::anonymous_namespace{limit_visitor_taylor.cpp}::substitute_infinity_series(), LMCAS::symbolic_cubic_roots(), LMCAS::symbolic_node_to_multipoly(), symbolic_quartic_depression(), symbolic_quartic_roots(), LMCAS::tf_detect_multiplicative_structure(), LMCAS::anonymous_namespace{solver_assumptions.cpp}::try_get_numeric_value(), LMCAS::anonymous_namespace{integration_weierstrass.cpp}::weier_rational_power(), LMCAS::anonymous_namespace{integration_weierstrass.cpp}::weier_to_rational(), LMCAS::zc_rational_reconstruction() , 以及 LMCAS::zc_reconstruct_candidate().

函数调用图:
这是这个函数的调用关系图:

◆ solve_biquadratic_impl()

std::vector< std::shared_ptr< SymbolicExpr > > LMCAS::polynomial_solver_detail::solve_biquadratic_impl ( const std::shared_ptr< SymbolicExpr > & a,
const std::shared_ptr< SymbolicExpr > & b,
const std::shared_ptr< SymbolicExpr > & c,
const std::string & variable,
ComputationContext & context )

在文件 solve_polynomial_quadratic.cpp 第 47 行定义.

51 {
52 detail::RewriteBudget transform_budget(context, (context).limits().max_recursion_depth,
53 (context).limits().max_ast_nodes, "transform");
54 auto a_simplified = detail::make_expression_ptr(detail::normalize_node(detail::node(a), transform_budget));
55 if (a_simplified->get_number_value_is_zero()) {
56 auto b_simplified = detail::make_expression_ptr(detail::normalize_node(detail::node(b), transform_budget));
57 if (!b_simplified->get_number_value_is_zero()) {
59 }
60
61 auto c_simplified = detail::make_expression_ptr(detail::normalize_node(detail::node(c), transform_budget));
62 if (c_simplified->get_number_value_is_zero()) {
63 throw std::invalid_argument(
64 "solve_biquadratic: identically zero equation has no finite root list");
65 }
66 if (is_purely_numeric(c_simplified)) {
67 return {};
68 }
69 throw std::invalid_argument(
70 "solve_biquadratic: equation is independent of the requested variable");
71 }
72
73 auto u_roots = solve_quadratic_internal(a, b, c, context);
74
75 std::vector<std::shared_ptr<SymbolicExpr>> results;
76 for (const auto& u : u_roots) {
77 auto pos_root = detail::make_expression_ptr(detail::normalize_node(detail::node(SymbolicExpr::sqrt(u)), transform_budget));
78 auto neg_root = detail::make_expression_ptr(detail::normalize_node(detail::node(negate(SymbolicExpr::sqrt(u))), transform_budget));
79 results.push_back(pos_root);
80 results.push_back(neg_root);
81 }
82
83 return results;
84}
std::shared_ptr< SymbolicExpr > num(int value)
std::shared_ptr< SymbolicExpr > negate(const std::shared_ptr< SymbolicExpr > &expr)
bool is_purely_numeric(const std::shared_ptr< SymbolicExpr > &expr)
std::vector< std::shared_ptr< SymbolicExpr > > solve_quadratic_internal(const std::shared_ptr< SymbolicExpr > &a, const std::shared_ptr< SymbolicExpr > &b, const std::shared_ptr< SymbolicExpr > &c, ComputationContext &context)
const VectorField const VectorField & c
const MultiPoly & b
__attribute__((visibility("default"))) VectorCalculusExprResult curve_integral_scalar_checked(const std __attribute__((visibility("default"))) VectorCalculusExprResult curve_integral_scalar_checked(const std __attribute__((visibility("default"))) std const VectorField const std::string const std::shared_ptr< SymbolicExpr > & a
__attribute__((visibility("default"))) VectorCalculusExprResult surface_integral_scalar_checked(const std __attribute__((visibility("default"))) VectorCalculusExprResult surface_integral_scalar_checked(const std __attribute__((visibility("default"))) std const VectorField const std::string & u

引用了 LMCAS::a, LMCAS::b, LMCAS::c, LMCAS::context, is_purely_numeric(), LMCAS::detail::make_expression_ptr(), negate(), LMCAS::detail::node(), LMCAS::detail::normalize_node(), num(), solve_quadratic_internal() , 以及 LMCAS::u.

被这些函数引用 LMCAS::exact_factor_roots(), LMCAS::solve_biquadratic(), LMCAS::solve_higher_exact_roots() , 以及 solve_quartic_impl().

函数调用图:
这是这个函数的调用关系图:

◆ solve_by_factoring_impl()

std::vector< std::shared_ptr< SymbolicExpr > > LMCAS::polynomial_solver_detail::solve_by_factoring_impl ( const Polynomial< SymbolicPolyCoeff > & polynomial,
const std::string & variable,
ComputationContext & context )

在文件 solve_polynomial.cpp 第 68 行定义.

70 {
71
72 if (poly.is_zero() || poly.degree() < 1) { return {}; }
73
74 if (poly.degree() <= 2) {
75 return solve_closed_form_poly(poly, var, context);
76 }
77
78 std::vector<std::shared_ptr<SymbolicExpr>> results;
79
80 Polynomial<Rational> rat_poly;
81 if (!convert_to_rational_poly(poly, rat_poly, context)) {
82 if (poly.degree() <= 4) {
83 return solve_closed_form_poly(poly, var, context);
84 }
86 }
87
88 // Keep rational boundaries exact before cubic/quartic floating formulas.
89 auto rational_roots = bounded_rational_root_search(rat_poly) ?
90 find_rational_roots(rat_poly) : std::vector<Rational>{};
91
92 for (const auto& r : rational_roots) {
93 results.push_back(SymbolicExpr::number(r));
94 }
95
96 Polynomial<Rational> quotient = rat_poly;
97 for (const auto& r : rational_roots) {
98 Polynomial<Rational> linear_factor({-r, Rational(1)}, var);
99 auto [q, rem] = quotient.div_mod(linear_factor);
100 if (!rem.is_zero()) { throw std::logic_error("solve_by_factoring: inexact root division"); }
101 quotient = q;
102 }
103
104 if (quotient.degree() <= 0) {
105 return results;
106 }
107
108 if (quotient.degree() <= 4) {
109 auto sym_quotient = rational_to_symbolic_poly(quotient);
110 auto factor_roots = solve_closed_form_poly(sym_quotient, var, context);
111 results.insert(results.end(), factor_roots.begin(), factor_roots.end());
112 return results;
113 }
114
115 auto sqfree_factors = square_free_factorization(quotient);
116
117 for (const auto& [factor, multiplicity] : sqfree_factors) {
118 append_factor_solutions(factor, multiplicity, var, results, context);
119 }
120
121 return results;
122}
std::vector< std::shared_ptr< SymbolicExpr > > make_rootof_solutions_impl(const Polynomial< SymbolicPolyCoeff > &polynomial, const std::string &variable, ComputationContext &context)
bool convert_to_rational_poly(const Polynomial< SymbolicPolyCoeff > &poly, Polynomial< Rational > &output, ComputationContext &context)
__attribute__((visibility("default"))) ComplexSymbolicResult complex_exp_form_checked(std __attribute__((visibility("default"))) ComplexSymbolicResult complex_exp_form_checked(std __attribute__((visibility("default"))) ComplexSymbolicResult complex_trig_form_checked(std __attribute__((visibility("default"))) ComplexSymbolicResult complex_trig_form_checked(std __attribute__((visibility("default"))) ComplexRootsResult solve_complex_nth_root_checked(std __attribute__((visibility("default"))) ComplexRootsResult solve_complex_nth_root_checked(std __attribute__((visibility("default"))) ComplexRootsResult solve_complex_quadratic_checked(std __attribute__((visibility("default"))) ComplexRootsResult solve_complex_quadratic_checked(std std::shared_ptr< SymbolicExpr > r
std::vector< Rational > find_rational_roots(const Polynomial< Rational > &poly)
static std::vector< std::shared_ptr< SymbolicExpr > > solve_closed_form_poly(const Polynomial< SymbolicPolyCoeff > &poly, const std::string &var, ComputationContext &context)
static Polynomial< SymbolicPolyCoeff > rational_to_symbolic_poly(const Polynomial< Rational > &rat_poly)
static void append_factor_solutions(const Polynomial< Rational > &factor, int multiplicity, const std::string &var, std::vector< std::shared_ptr< SymbolicExpr > > &results, ComputationContext &context)

引用了 LMCAS::append_factor_solutions(), bounded_rational_root_search(), LMCAS::context, convert_to_rational_poly(), LMCAS::Polynomial< CoeffType >::degree(), LMCAS::Polynomial< CoeffType >::div_mod(), LMCAS::find_rational_roots(), LMCAS::Polynomial< CoeffType >::is_zero(), LMCAS::detail::make_rootof_solutions_impl(), LMCAS::r, LMCAS::rational_to_symbolic_poly(), LMCAS::solve_closed_form_poly() , 以及 LMCAS::square_free_factorization().

被这些函数引用 LMCAS::detail::inequality_support::append_factor_roots(), LMCAS::detail::inequality_support::find_roots_with_multiplicity(), LMCAS::solve_by_factoring() , 以及 LMCAS::detail::inequality_support::solve_symbolic_poly().

函数调用图:
这是这个函数的调用关系图:

◆ solve_cubic_impl()

std::vector< std::shared_ptr< SymbolicExpr > > LMCAS::polynomial_solver_detail::solve_cubic_impl ( const std::shared_ptr< SymbolicExpr > & a,
const std::shared_ptr< SymbolicExpr > & b,
const std::shared_ptr< SymbolicExpr > & c,
const std::shared_ptr< SymbolicExpr > & d,
const std::string & variable,
ComputationContext & context )

在文件 solve_polynomial_cubic.cpp 第 190 行定义.

195 {
196 detail::RewriteBudget transform_budget(context, (context).limits().max_recursion_depth,
197 (context).limits().max_ast_nodes, "transform");
202 if (convert_to_rational_poly(symbolic, exact, context)) {
203 return exact_polynomial_roots(exact, context);
204 }
205 if (detail::make_expression_ptr(detail::normalize_node(detail::node(a), transform_budget))->get_number_value_is_zero()) {
206 return solve_degenerate_cubic(b, c, d, context);
207 }
208 return symbolic_cubic_roots(a, b, c, d, context);
209}
std::vector< std::shared_ptr< SymbolicExpr > > exact_polynomial_roots(const Polynomial< Rational > &polynomial, ComputationContext &context)
const std::string & variable
static std::vector< std::shared_ptr< SymbolicExpr > > solve_degenerate_cubic(const std::shared_ptr< SymbolicExpr > &b, const std::shared_ptr< SymbolicExpr > &c, const std::shared_ptr< SymbolicExpr > &d, ComputationContext &context)
static std::vector< std::shared_ptr< SymbolicExpr > > symbolic_cubic_roots(const std::shared_ptr< SymbolicExpr > &a, const std::shared_ptr< SymbolicExpr > &b, const std::shared_ptr< SymbolicExpr > &c, const std::shared_ptr< SymbolicExpr > &d, ComputationContext &context)

引用了 LMCAS::SymbolicPolyCoeff::SymbolicPolyCoeff(), LMCAS::a, LMCAS::b, LMCAS::c, LMCAS::context, convert_to_rational_poly(), exact_polynomial_roots(), LMCAS::detail::make_expression_ptr(), LMCAS::detail::node(), LMCAS::detail::normalize_node(), LMCAS::solve_degenerate_cubic(), LMCAS::symbolic_cubic_roots() , 以及 LMCAS::variable.

被这些函数引用 LMCAS::solve_closed_form_poly(), LMCAS::solve_cubic(), solve_quartic_impl() , 以及 symbolic_quartic_roots().

函数调用图:
这是这个函数的调用关系图:

◆ solve_quadratic_internal()

std::vector< std::shared_ptr< SymbolicExpr > > LMCAS::polynomial_solver_detail::solve_quadratic_internal ( const std::shared_ptr< SymbolicExpr > & a,
const std::shared_ptr< SymbolicExpr > & b,
const std::shared_ptr< SymbolicExpr > & c,
ComputationContext & context )

在文件 solve_polynomial_quadratic.cpp 第 10 行定义.

12 {
13 detail::RewriteBudget transform_budget(context, (context).limits().max_recursion_depth,
14 (context).limits().max_ast_nodes, "transform");
15 auto b2 = SymbolicExpr::power(b, num(2));
16 auto four_ac = SymbolicExpr::multiply(num(4), SymbolicExpr::multiply(a, c));
17 auto delta = detail::make_expression_ptr(detail::normalize_node(detail::node(sub(b2, four_ac)), transform_budget));
18
19 auto neg_b = negate(b);
20 auto two_a = SymbolicExpr::multiply(num(2), a);
21 if (delta && delta->is_zero()) {
22 return { detail::make_expression_ptr(detail::normalize_node(detail::node(SymbolicExpr::divide(neg_b, two_a)), transform_budget)) };
23 }
24
25 auto sqrt_delta = SymbolicExpr::sqrt(delta);
27 auto exact_delta = detail::exact_rational_value(detail::node(delta));
28 if (exact_b && *exact_b != Rational(0) &&
29 exact_delta && *exact_delta > Rational(0)) {
30 auto numerator = *exact_b < Rational(0)
31 ? SymbolicExpr::add(neg_b, sqrt_delta)
32 : sub(neg_b, sqrt_delta);
34 detail::node(SymbolicExpr::divide(numerator, two_a)), transform_budget));
36 detail::node(SymbolicExpr::divide(
37 SymbolicExpr::multiply(num(2), c), numerator)), transform_budget));
38 return {x1, x2};
39 }
40 auto x1 = detail::make_expression_ptr(detail::normalize_node(detail::node(SymbolicExpr::divide(SymbolicExpr::add(neg_b, sqrt_delta), two_a)), transform_budget));
41 auto x2 = detail::make_expression_ptr(detail::normalize_node(detail::node(SymbolicExpr::divide(sub(neg_b, sqrt_delta), two_a)), transform_budget));
42
43 return { x1, x2 };
44}
std::optional< Rational > exact_rational_value(const NumberNode &number)
std::shared_ptr< SymbolicExpr > sub(const std::shared_ptr< SymbolicExpr > &a, const std::shared_ptr< SymbolicExpr > &b)

引用了 LMCAS::a, LMCAS::b, LMCAS::c, LMCAS::context, LMCAS::detail::exact_rational_value(), LMCAS::detail::make_expression_ptr(), negate(), LMCAS::detail::node(), LMCAS::detail::normalize_node(), num(), solve_quadratic_internal() , 以及 sub().

被这些函数引用 LMCAS::exact_factor_roots(), solve_biquadratic_impl(), LMCAS::solve_closed_form_poly(), LMCAS::solve_degenerate_cubic(), solve_quadratic_internal() , 以及 symbolic_quartic_roots().

函数调用图:
这是这个函数的调用关系图:

◆ solve_quartic_impl()

std::vector< std::shared_ptr< SymbolicExpr > > LMCAS::polynomial_solver_detail::solve_quartic_impl ( const std::shared_ptr< SymbolicExpr > & a,
const std::shared_ptr< SymbolicExpr > & b,
const std::shared_ptr< SymbolicExpr > & c,
const std::shared_ptr< SymbolicExpr > & d,
const std::shared_ptr< SymbolicExpr > & e,
const std::string & variable,
ComputationContext & context )

在文件 solve_polynomial_quartic.cpp 第 11 行定义.

17 {
18 detail::RewriteBudget transform_budget(context, (context).limits().max_recursion_depth,
19 (context).limits().max_ast_nodes, "transform");
20
21 auto a_simp = detail::make_expression_ptr(detail::normalize_node(detail::node(a), transform_budget));
22 if (a_simp->get_number_value_is_zero()) {
23
24 return solve_cubic_impl(b, c, d, e, var, context);
25 }
26
27 {
31 var);
32 Polynomial<Rational> rational_poly;
33 if (convert_to_rational_poly(symbolic_poly, rational_poly, context)) {
34 return exact_polynomial_roots(rational_poly, context);
35 }
36 }
37
38 auto b_simp = detail::make_expression_ptr(detail::normalize_node(detail::node(b), transform_budget));
39 auto d_simp = detail::make_expression_ptr(detail::normalize_node(detail::node(d), transform_budget));
40 if (b_simp->get_number_value_is_zero() && d_simp->get_number_value_is_zero()) {
41 return solve_biquadratic_impl(a, c, e, var, context);
42 }
43
46}
std::vector< std::shared_ptr< SymbolicExpr > > solve_cubic_impl(const std::shared_ptr< SymbolicExpr > &a, const std::shared_ptr< SymbolicExpr > &b, const std::shared_ptr< SymbolicExpr > &c, const std::shared_ptr< SymbolicExpr > &d, const std::string &variable, ComputationContext &context)
std::vector< std::shared_ptr< SymbolicExpr > > solve_biquadratic_impl(const std::shared_ptr< SymbolicExpr > &a, const std::shared_ptr< SymbolicExpr > &b, const std::shared_ptr< SymbolicExpr > &c, const std::string &variable, ComputationContext &context)
std::vector< std::shared_ptr< SymbolicExpr > > symbolic_quartic_roots(const SymbolicQuarticDepression &depression, const std::string &variable, ComputationContext &context)
SymbolicQuarticDepression symbolic_quartic_depression(const std::shared_ptr< SymbolicExpr > &a, const std::shared_ptr< SymbolicExpr > &b, const std::shared_ptr< SymbolicExpr > &c, const std::shared_ptr< SymbolicExpr > &d, const std::shared_ptr< SymbolicExpr > &e, ComputationContext &context)
ExprResult e()

引用了 LMCAS::SymbolicPolyCoeff::SymbolicPolyCoeff(), LMCAS::a, LMCAS::b, LMCAS::c, LMCAS::context, convert_to_rational_poly(), LMCAS::e(), exact_polynomial_roots(), LMCAS::detail::make_expression_ptr(), LMCAS::detail::node(), LMCAS::detail::normalize_node(), solve_biquadratic_impl(), solve_cubic_impl(), symbolic_quartic_depression() , 以及 symbolic_quartic_roots().

被这些函数引用 LMCAS::solve_closed_form_poly() , 以及 LMCAS::solve_quartic().

函数调用图:
这是这个函数的调用关系图:

◆ sub()

std::shared_ptr< SymbolicExpr > LMCAS::polynomial_solver_detail::sub ( const std::shared_ptr< SymbolicExpr > & a,
const std::shared_ptr< SymbolicExpr > & b )

在文件 solve_polynomial_normalization.cpp 第 16 行定义.

16 {
17 return SymbolicExpr::add(a, negate(b));
18}

引用了 LMCAS::a, LMCAS::b, negate() , 以及 sub().

被这些函数引用 solve_quadratic_internal(), sub(), symbolic_quartic_depression() , 以及 symbolic_quartic_roots().

函数调用图:
这是这个函数的调用关系图:

◆ symbolic_quartic_depression()

SymbolicQuarticDepression LMCAS::polynomial_solver_detail::symbolic_quartic_depression ( const std::shared_ptr< SymbolicExpr > & a,
const std::shared_ptr< SymbolicExpr > & b,
const std::shared_ptr< SymbolicExpr > & c,
const std::shared_ptr< SymbolicExpr > & d,
const std::shared_ptr< SymbolicExpr > & e,
ComputationContext & context )

在文件 solve_polynomial_quartic_symbolic.cpp 第 10 行定义.

13 {
14
15 detail::RewriteBudget transform_budget(context, (context).limits().max_recursion_depth,
16 (context).limits().max_ast_nodes, "transform");
17 auto a2 = SymbolicExpr::power(a, num(2));
18 auto a3 = SymbolicExpr::power(a, num(3));
19 auto a4 = SymbolicExpr::power(a, num(4));
20 auto b2 = SymbolicExpr::power(b, num(2));
21 auto b3 = SymbolicExpr::power(b, num(3));
22 auto b4 = SymbolicExpr::power(b, num(4));
23
24 auto eight_ac = SymbolicExpr::multiply(num(8), SymbolicExpr::multiply(a, c));
25 auto three_b2 = SymbolicExpr::multiply(num(3), b2);
26 auto p = detail::make_expression_ptr(detail::normalize_node(detail::node(SymbolicExpr::divide(sub(eight_ac, three_b2), SymbolicExpr::multiply(num(8), a2))), transform_budget));
27
28 auto four_abc = SymbolicExpr::multiply(num(4), SymbolicExpr::multiply(a, SymbolicExpr::multiply(b, c)));
29 auto eight_a2d = SymbolicExpr::multiply(num(8), SymbolicExpr::multiply(a2, d));
30 auto q_num = SymbolicExpr::add(sub(b3, four_abc), eight_a2d);
31 auto q = detail::make_expression_ptr(detail::normalize_node(detail::node(SymbolicExpr::divide(q_num, SymbolicExpr::multiply(num(8), a3))), transform_budget));
32
33 auto neg3_b4 = SymbolicExpr::multiply(num(-3), b4);
34 auto t256_a3e = SymbolicExpr::multiply(num(256), SymbolicExpr::multiply(a3, e));
35 auto neg64_a2bd = SymbolicExpr::multiply(num(-64), SymbolicExpr::multiply(a2, SymbolicExpr::multiply(b, d)));
36 auto t16_ab2c = SymbolicExpr::multiply(num(16), SymbolicExpr::multiply(a, SymbolicExpr::multiply(b2, c)));
37 auto r_num = SymbolicExpr::add(SymbolicExpr::add(SymbolicExpr::add(neg3_b4, t256_a3e), neg64_a2bd), t16_ab2c);
38 auto r = detail::make_expression_ptr(detail::normalize_node(detail::node(SymbolicExpr::divide(r_num, SymbolicExpr::multiply(num(256), a4))), transform_budget));
39
40 auto shift = detail::make_expression_ptr(detail::normalize_node(detail::node(SymbolicExpr::divide(b, SymbolicExpr::multiply(num(4), a))), transform_budget));
41 return {p, q, r, shift};
42}

引用了 LMCAS::a, LMCAS::b, LMCAS::c, LMCAS::context, LMCAS::e(), LMCAS::detail::make_expression_ptr(), LMCAS::detail::node(), LMCAS::detail::normalize_node(), num(), LMCAS::r, sub() , 以及 symbolic_quartic_depression().

被这些函数引用 solve_quartic_impl() , 以及 symbolic_quartic_depression().

函数调用图:
这是这个函数的调用关系图:

◆ symbolic_quartic_roots()

std::vector< std::shared_ptr< SymbolicExpr > > LMCAS::polynomial_solver_detail::symbolic_quartic_roots ( const SymbolicQuarticDepression & depression,
const std::string & variable,
ComputationContext & context )

在文件 solve_polynomial_quartic_symbolic.cpp 第 44 行定义.

46 {
47 detail::RewriteBudget transform_budget(context, (context).limits().max_recursion_depth,
48 (context).limits().max_ast_nodes, "transform");
49 const auto& [p, q, r, shift] = depression;
50 auto q_simp = detail::make_expression_ptr(detail::normalize_node(detail::node(q), transform_budget));
51 if (q_simp->get_number_value_is_zero()) {
52
53 auto u_roots = solve_quadratic_internal(num(1), p, r, context);
54 std::vector<std::shared_ptr<SymbolicExpr>> results;
55 for (const auto& u : u_roots) {
56
57 auto pos_y = detail::make_expression_ptr(detail::normalize_node(detail::node(SymbolicExpr::sqrt(u)), transform_budget));
58 auto neg_y = detail::make_expression_ptr(detail::normalize_node(detail::node(negate(SymbolicExpr::sqrt(u))), transform_budget));
59 results.push_back(detail::make_expression_ptr(detail::normalize_node(detail::node(sub(pos_y, shift)), transform_budget)));
60 results.push_back(detail::make_expression_ptr(detail::normalize_node(detail::node(sub(neg_y, shift)), transform_budget)));
61 }
62 return results;
63 }
64
65 auto p2 = SymbolicExpr::power(p, num(2));
66 auto q2 = SymbolicExpr::power(q, num(2));
67 auto eight_p = SymbolicExpr::multiply(num(8), p);
68 auto two_p2_minus_8r = detail::make_expression_ptr(detail::normalize_node(detail::node(sub(SymbolicExpr::multiply(num(2), p2), SymbolicExpr::multiply(num(8), r))), transform_budget));
69 auto neg_q2 = detail::make_expression_ptr(detail::normalize_node(detail::node(negate(q2)), transform_budget));
70
71 auto cubic_roots = solve_cubic_impl(num(8), eight_p, two_p2_minus_8r, neg_q2, var, context);
72
73 std::shared_ptr<SymbolicExpr> m = nullptr;
74 if (!cubic_roots.empty()) {
75 m = cubic_roots[0];
76 }
77
78 if (!m) return {};
79
80 auto two_m = SymbolicExpr::multiply(num(2), m);
81 auto s = detail::make_expression_ptr(detail::normalize_node(detail::node(SymbolicExpr::sqrt(two_m)), transform_budget));
82
83 auto p_half = detail::make_expression_ptr(detail::normalize_node(detail::node(SymbolicExpr::divide(p, num(2))), transform_budget));
84
85 auto m_plus_p_half = detail::make_expression_ptr(detail::normalize_node(detail::node(SymbolicExpr::add(m, p_half)), transform_budget));
86
87 auto q_over_2s = detail::make_expression_ptr(detail::normalize_node(detail::node(SymbolicExpr::divide(q, SymbolicExpr::multiply(num(2), s))), transform_budget));
88
89 auto quad1_c = detail::make_expression_ptr(detail::normalize_node(detail::node(sub(m_plus_p_half, q_over_2s)), transform_budget));
90
91 auto neg_s = detail::make_expression_ptr(detail::normalize_node(detail::node(negate(s)), transform_budget));
92 auto quad2_c = detail::make_expression_ptr(detail::normalize_node(detail::node(SymbolicExpr::add(m_plus_p_half, q_over_2s)), transform_budget));
93
94 auto y_roots1 = solve_quadratic_internal(num(1), s, quad1_c, context);
95 auto y_roots2 = solve_quadratic_internal(num(1), neg_s, quad2_c, context);
96
97 std::vector<std::shared_ptr<SymbolicExpr>> results;
98 for (const auto& y : y_roots1) {
99 results.push_back(detail::make_expression_ptr(detail::normalize_node(detail::node(sub(y, shift)), transform_budget)));
100 }
101 for (const auto& y : y_roots2) {
102 results.push_back(detail::make_expression_ptr(detail::normalize_node(detail::node(sub(y, shift)), transform_budget)));
103 }
104
105 return results;
106}
__attribute__((visibility("default"))) LineSymbolicResult line_from_two_points_checked(const std __attribute__((visibility("default"))) LineSymbolicResult line_from_two_points_checked(const std __attribute__((visibility("default"))) PlaneSymbolicResult plane_from_three_points_checked(const std __attribute__((visibility("default"))) PlaneSymbolicResult plane_from_three_points_checked(const std const PlaneSymbolic & p2

引用了 LMCAS::context, LMCAS::detail::make_expression_ptr(), negate(), LMCAS::detail::node(), LMCAS::detail::normalize_node(), num(), LMCAS::p2, LMCAS::r, solve_cubic_impl(), solve_quadratic_internal(), sub(), symbolic_quartic_roots() , 以及 LMCAS::u.

被这些函数引用 solve_quartic_impl() , 以及 symbolic_quartic_roots().

函数调用图:
这是这个函数的调用关系图: