LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
numeric_evaluation.hpp
浏览该文件的文档.
1#pragma once
2
3#include "numeric_value.hpp"
4#include <string>
5#include <unordered_map>
6
8#include "lmcas_export.hpp"
9
10namespace LMCAS {
11
12class SymbolicExpr;
13
14using NumericBindings = std::unordered_map<std::string, double>;
15
16/**
17 * @brief Evaluate a real expression using explicit symbol bindings and a computation context.
18 *
19 * Square roots of one or two real squares are evaluated as absolute values
20 * or hypot, avoiding intermediate overflow and underflow in norm expressions.
21 *
22 * @see ISO C11 committee draft N1570, 7.12.7.3 (hypot).
23 * https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
24 *
25 * Exact numeric exponents retain their integer classification and parity on
26 * negative real bases. Non-integral powers of negative real values report
27 * DomainError rather than rounding the exponent into the integer domain.
28 *
29 * @see ISO C11 committee draft N1570, 7.12.7.4 (pow).
30 * https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
31 *
32 * Complex phase on a real argument embeds the value as x + i(+0) and evaluates
33 * its principal argument with atan2(+0, x). Negative reals, including negative
34 * zero and negative-infinity bindings, therefore have phase +pi; positive reals
35 * and positive zero have phase +0. Argument-evaluation failures propagate through Result.
36 *
37 * @see ISO C11 committee draft N1570, 7.3.9.1 (carg), principal argument.
38 * https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
39 */
40LMCAS_API Result<ApproxReal> evaluate_numeric(const SymbolicExpr& expression,
43
44inline Result<ApproxReal> evaluate_numeric(const SymbolicExpr& expression,
45 const NumericBindings& bindings = {}) {
46 ComputationContext context;
47 return evaluate_numeric(expression, bindings, context);
48}
49
50} // namespace LMCAS
#define LMCAS_API
const std::vector< Polynomial< BigInt > > const BigInt ComputationContext & context
const std::vector< Binding > & bindings
Result< ApproxReal > evaluate_numeric(const SymbolicExpr &expression, const NumericBindings &bindings={})
std::unordered_map< std::string, double > NumericBindings