LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
LMCAS::anonymous_namespace{solve_mixed_transcendental.cpp} 命名空间参考

类

class  MixedRootCollection

函数

MixedTranscendentalResult classify_constant_equation (const std::shared_ptr< SymbolicExpr > &expr, bool unresolved_parameters, const SolveOptions &opts, ComputationContext &context)
bool is_mixed_terminal_error (CasErrc code)
MixedTranscendentalResult solve_mixed_equation (const std::shared_ptr< SymbolicExpr > &expr, const std::string &var, const SolveOptions &opts, ComputationContext &context)
std::optional< CasError > validate_mixed_input (const std::shared_ptr< SymbolicExpr > &expr, const std::string &var, const SolveOptions &opts)

变量

constexpr const char * mixed_operation = "solve_mixed_transcendental_checked"

函数说明

◆ classify_constant_equation()

MixedTranscendentalResult LMCAS::anonymous_namespace{solve_mixed_transcendental.cpp}::classify_constant_equation ( const std::shared_ptr< SymbolicExpr > & expr,
bool unresolved_parameters,
const SolveOptions & opts,
ComputationContext & context )

在文件 solve_mixed_transcendental.cpp 第 57 行定义.

59 {
61 if (unresolved_parameters) {
64 "equation depends on unresolved parameters but not the solve variable"});
65 }
66 auto evaluated = evaluate_numeric(*expr, {}, context);
67 if (!evaluated && is_mixed_terminal_error(evaluated.error().code)) {
68 return MixedTranscendentalResult::failure(evaluated.error());
69 }
70 if (!evaluated || !std::isfinite(evaluated.value().value)) {
73 "constant equation could not be evaluated in the real domain"});
74 }
75 if (std::abs(evaluated.value().value) <= opts.tolerance) {
78 "equation is identically zero; every real value satisfies it"});
79 }
81}
static Result failure(CasErrc code, std::string message, std::string operation={})
static Result success(MathResult< std::vector< std::shared_ptr< SymbolicExpr > > > value)
const std::vector< Polynomial< BigInt > > const BigInt ComputationContext & context
lmmc_real_t tolerance
收敛容差
Result< ApproxReal > evaluate_numeric(const SymbolicExpr &expression, const NumericBindings &bindings={})

引用了 classify_constant_equation(), LMCAS::Complete, LMCAS::context, LMCAS::evaluate_numeric(), LMCAS::Result< MathResult< std::vector< std::shared_ptr< SymbolicExpr > > > >::failure(), LMCAS::Inconclusive, is_mixed_terminal_error(), LMCAS::Result< MathResult< std::vector< std::shared_ptr< SymbolicExpr > > > >::success() , 以及 LMCAS::SolveOptions::tolerance.

被这些函数引用 classify_constant_equation() , 以及 solve_mixed_equation().

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

◆ is_mixed_terminal_error()

bool LMCAS::anonymous_namespace{solve_mixed_transcendental.cpp}::is_mixed_terminal_error ( CasErrc code)

在文件 solve_mixed_transcendental.cpp 第 50 行定义.

引用了 LMCAS::DomainError, LMCAS::Inconclusive, is_mixed_terminal_error(), LMCAS::UnboundSymbol , 以及 LMCAS::UnsupportedExpression.

被这些函数引用 LMCAS::anonymous_namespace{solve_mixed_transcendental.cpp}::MixedRootCollection::accept_symbolic_witness(), classify_constant_equation(), LMCAS::anonymous_namespace{solve_mixed_transcendental.cpp}::MixedRootCollection::handle_symbolic_evaluation_error(), is_mixed_terminal_error() , 以及 LMCAS::anonymous_namespace{solve_mixed_transcendental.cpp}::MixedRootCollection::polish_value().

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

◆ solve_mixed_equation()

MixedTranscendentalResult LMCAS::anonymous_namespace{solve_mixed_transcendental.cpp}::solve_mixed_equation ( const std::shared_ptr< SymbolicExpr > & expr,
const std::string & var,
const SolveOptions & opts,
ComputationContext & context )

在文件 solve_mixed_transcendental.cpp 第 463 行定义.

465 {
466 auto step = context.consume_steps(1, mixed_operation);
467 if (!step) {
468 return MixedTranscendentalResult::failure(step.error());
469 }
470 const auto variables = free_variables(detail::node(expr));
471 if (variables.find(var) == variables.end()) {
472 return classify_constant_equation(expr, !variables.empty(), opts, context);
473 }
474 auto interval = determine_search_interval(expr, var, opts);
475 if (!interval) {
477 CasErrc::InvalidArgument, "无法确定有效搜索区间", mixed_operation);
478 }
479 if (!std::isfinite(interval->lo) || !std::isfinite(interval->hi) ||
480 interval->lo >= interval->hi) {
482 CasErrc::InvalidArgument, "搜索区间必须为有限递增区间", mixed_operation);
483 }
484 MixedRootCollection collection(expr, var, *interval, opts, context);
485 auto failure = collection.solve(context);
486 if (failure) {
487 return MixedTranscendentalResult::failure(std::move(*failure));
488 }
489 return collection.finish();
490}
QuantityResult failure(CasErrc code, std::string message)
MixedTranscendentalResult classify_constant_equation(const std::shared_ptr< SymbolicExpr > &expr, bool unresolved_parameters, const SolveOptions &opts, ComputationContext &context)
const SymbolicNodePtr & node(const ::LMCAS::SymbolicExpr &expression) noexcept
ExprResult interval(ExprPtr lower, ExprPtr upper, bool lower_closed, bool upper_closed)
std::optional< SearchInterval > determine_search_interval(const std::shared_ptr< SymbolicExpr > &expr, const std::string &var, const SolveOptions &opts)
std::set< std::string > free_variables(const detail::SymbolicNodePtr &expression, detail::RewriteBudget *budget)

引用了 classify_constant_equation(), LMCAS::context, LMCAS::determine_search_interval(), LMCAS::Result< MathResult< std::vector< std::shared_ptr< SymbolicExpr > > > >::failure(), LMCAS::anonymous_namespace{solve_mixed_transcendental.cpp}::MixedRootCollection::finish(), LMCAS::free_variables(), LMCAS::interval(), LMCAS::InvalidArgument, mixed_operation, LMCAS::detail::node(), LMCAS::anonymous_namespace{solve_mixed_transcendental.cpp}::MixedRootCollection::solve() , 以及 solve_mixed_equation().

被这些函数引用 solve_mixed_equation().

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

◆ validate_mixed_input()

std::optional< CasError > LMCAS::anonymous_namespace{solve_mixed_transcendental.cpp}::validate_mixed_input ( const std::shared_ptr< SymbolicExpr > & expr,
const std::string & var,
const SolveOptions & opts )

在文件 solve_mixed_transcendental.cpp 第 25 行定义.

27 {
28 if (!expr || !detail::node(expr)) {
29 return CasError{
30 CasErrc::InvalidArgument, "待求解表达式不能为空", mixed_operation};
31 }
32 if (var.empty()) {
33 return CasError{
34 CasErrc::InvalidArgument, "求解变量不能为空", mixed_operation};
35 }
36 if (!std::isfinite(opts.tolerance) || opts.tolerance <= 0.0 ||
37 opts.max_newton_iterations <= 0 || opts.max_roots == 0 || opts.max_roots < -1) {
38 return CasError{
39 CasErrc::InvalidArgument, "求解选项包含无效界限", mixed_operation};
40 }
41 if (opts.has_search_interval &&
42 (!std::isfinite(opts.search_lo) || !std::isfinite(opts.search_hi) ||
43 opts.search_lo >= opts.search_hi)) {
44 return CasError{
45 CasErrc::InvalidArgument, "搜索区间必须为有限递增区间", mixed_operation};
46 }
47 return std::nullopt;
48}
bool has_search_interval
是否指定了搜索区间
lmmc_real_t search_lo
搜索区间下界(默认 -10)
lmmc_real_t search_hi
搜索区间上界(默认 10)
int max_roots
数值候选数量预算;精确解集和整数解族保持完整。
int max_newton_iterations
Newton 迭代最大次数

引用了 LMCAS::SolveOptions::has_search_interval, LMCAS::InvalidArgument, LMCAS::SolveOptions::max_newton_iterations, LMCAS::SolveOptions::max_roots, mixed_operation, LMCAS::detail::node(), LMCAS::SolveOptions::search_hi, LMCAS::SolveOptions::search_lo, LMCAS::SolveOptions::tolerance , 以及 validate_mixed_input().

被这些函数引用 validate_mixed_input().

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

变量说明

◆ mixed_operation

const char* LMCAS::anonymous_namespace{solve_mixed_transcendental.cpp}::mixed_operation = "solve_mixed_transcendental_checked"
constexpr