LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
numeric_probe.hpp
浏览该文件的文档.
1#pragma once
2
4
5#include <cmath>
6#include <optional>
7
8namespace LMCAS::detail {
9
10inline std::optional<double> try_finite_numeric(
11 const SymbolicExpr& expression,
13{
14 auto evaluated = evaluate_numeric(expression, NumericBindings{}, context);
15 if (!evaluated) {
16 switch (evaluated.error().code) {
20 return std::nullopt;
21 default:
22 throw evaluated.error();
23 }
24 }
25 if (!evaluated.value().is_finite()) {
26 return std::nullopt;
27 }
28 if (!std::isfinite(evaluated.value().value)) {
30 "numeric evaluation produced a nonfinite result",
31 "evaluate_numeric"};
32 }
33 return evaluated.value().value;
34}
35
36
37} // namespace LMCAS::detail
多元 Hensel 提升(单变量步)
std::optional< double > try_finite_numeric(const SymbolicExpr &expression, ComputationContext &context)
std::size_t std::size_t ComputationContext & context
Result< ApproxReal > evaluate_numeric(const SymbolicExpr &expression, const NumericBindings &bindings={})
std::unordered_map< std::string, double > NumericBindings