LMCAS
Lamina Computer Algebra System
Toggle main menu visibility
载入中...
搜索中...
未找到
mixed_transcendental_evaluation.cpp
浏览该文件的文档.
1
#include "
internal/expression_transform.hpp
"
2
#include "
internal/mixed_transcendental_support.hpp
"
3
#include "
internal/numeric_probe.hpp
"
4
5
#include <cmath>
6
#include <limits>
7
8
namespace
LMCAS::detail
{
9
10
lmmc_real_t
mixed_evaluate_at
(
11
const
std::shared_ptr<SymbolicExpr>& expr,
12
const
std::string& var, lmmc_real_t x,
RewriteBudget
&
budget
) {
13
auto
substituted =
make_expression_ptr
(
substitute_node
(
14
node
(expr), var,
node
(SymbolicExpr::number(
static_cast<
double
>
(x))),
budget
));
15
auto
value
=
try_finite_numeric
(*substituted,
budget
.
context
());
16
return
value
?
static_cast<
lmmc_real_t
>
(*value)
17
: std::numeric_limits<lmmc_real_t>::quiet_NaN();
18
}
19
20
lmmc_real_t
mixed_evaluate_with_retry
(
21
const
std::shared_ptr<SymbolicExpr>& expr,
22
const
std::string& var, lmmc_real_t x,
23
lmmc_real_t half_width,
RewriteBudget
&
budget
,
int
max_retries) {
24
auto
value
=
mixed_evaluate_at
(expr, var, x,
budget
);
25
if
(!std::isnan(
value
)) {
return
value
; }
26
auto
offset = half_width;
27
for
(
int
i = 0; i < max_retries; ++i) {
28
offset *= 0.5;
29
value
=
mixed_evaluate_at
(expr, var, x + offset,
budget
);
30
if
(!std::isnan(
value
)) {
return
value
; }
31
value
=
mixed_evaluate_at
(expr, var, x - offset,
budget
);
32
if
(!std::isnan(
value
)) {
return
value
; }
33
}
34
return
std::numeric_limits<lmmc_real_t>::quiet_NaN();
35
}
36
37
bool
consume_mixed_step
(
38
ComputationContext
&
context
, std::optional<CasError>* failure,
39
bool
* complete) {
40
auto
step =
context
.consume_steps(1,
"solve_mixed_transcendental_checked"
);
41
if
(step) {
return
true
; }
42
if
(failure) { *failure = step.
error
(); }
43
if
(complete) { *complete =
false
; }
44
return
false
;
45
}
46
47
}
LMCAS::ComputationContext
定义
computation_context.hpp:99
LMCAS::Result::error
CasError & error()
定义
result.hpp:77
LMCAS::detail::RewriteBudget
定义
rewrite_budget.hpp:15
LMCAS::detail::RewriteBudget::context
ComputationContext & context() const noexcept
定义
rewrite_budget.hpp:24
expression_transform.hpp
mixed_transcendental_support.hpp
LMCAS::detail
多元 Hensel 提升(单变量步)
定义
assumption_context.hpp:31
LMCAS::detail::make_expression_ptr
std::shared_ptr<::LMCAS::SymbolicExpr > make_expression_ptr(SymbolicNodePtr root)
定义
base.hpp:111
LMCAS::detail::node
const SymbolicNodePtr & node(const ::LMCAS::SymbolicExpr &expression) noexcept
定义
base.hpp:91
LMCAS::detail::consume_mixed_step
bool consume_mixed_step(ComputationContext &context, std::optional< CasError > *failure, bool *complete)
定义
mixed_transcendental_evaluation.cpp:37
LMCAS::detail::try_finite_numeric
std::optional< double > try_finite_numeric(const SymbolicExpr &expression, ComputationContext &context)
定义
numeric_probe.hpp:10
LMCAS::detail::budget
RewriteBudget & budget
定义
expression_transform.hpp:16
LMCAS::detail::context
std::size_t std::size_t ComputationContext & context
定义
exact_algebraic.hpp:27
LMCAS::detail::mixed_evaluate_with_retry
lmmc_real_t mixed_evaluate_with_retry(const std::shared_ptr< SymbolicExpr > &expr, const std::string &var, lmmc_real_t x, lmmc_real_t half_width, RewriteBudget &budget, int max_retries=3)
定义
mixed_transcendental_evaluation.cpp:20
LMCAS::detail::mixed_evaluate_at
lmmc_real_t mixed_evaluate_at(const std::shared_ptr< SymbolicExpr > &expr, const std::string &var, lmmc_real_t x, RewriteBudget &budget)
定义
mixed_transcendental_evaluation.cpp:10
LMCAS::detail::substitute_node
SymbolicNodePtr substitute_node(const SymbolicNodePtr &node, const std::string &variable, const SymbolicNodePtr &replacement, RewriteBudget &budget, const FactsQuery &facts, Domain domain)
定义
symbolic_core.cpp:247
LMCAS::value
const std::string const ExprPtr & value
定义
expr.hpp:293
numeric_probe.hpp
src
mixed_transcendental_evaluation.cpp
生成于
, 为 LMCAS使用
1.18.0