12#include "lmmc/config.h"
26 Null, Int, Float, BigInt,
28 Infinity, Array, Matrix,
36 using DataType = std::variant<
40 std::shared_ptr<SymbolicExpr>,
42 std::vector<std::vector<Value>>>;
49 Type kind() const noexcept {
return type; }
52 const DataType& storage() const noexcept {
return data; }
57 Value() : type(Type::Null), data(std::in_place_index<0>, nullptr) {}
59 Value(std::nullptr_t) : type(Type::Null), data(std::in_place_index<0>, nullptr) {}
60 Value(
int i) : type(Type::Int), data(i) {}
62 Value(const ::LMCAS::BigInt& bi) : type(Type::BigInt), data(bi) {}
63 Value(const ::LMCAS::Rational& r) : type(Type::
Rational), data(
r) {}
64 Value(const ::LMCAS::Irrational& ir) : type(Type::Irrational), data(ir) {}
65 Value(
const std::shared_ptr<SymbolicExpr>& sym)
66 : type(Type::Symbolic), data(require_symbolic(
sym)) {}
67 Value(
const std::vector<Value>& arr);
68 Value(
const std::vector<std::vector<Value>>& mat)
72 Value(
const std::string& s) : type(Type::String), data(nullptr), _str_cache(s) {}
73 Value(
const char* s) : type(Type::String), data(nullptr), _str_cache(s ? s :
"") {}
75 bool is_null()
const {
return type == Type::Null; }
76 bool is_string()
const {
return type == Type::String; }
77 bool is_infinity()
const {
return type == Type::Infinity; }
78 bool is_int()
const {
return type == Type::Int; }
79 bool is_float()
const {
return type == Type::Float; }
80 bool is_array()
const {
return type == Type::Array; }
81 bool is_matrix()
const {
return type == Type::Matrix; }
82 bool is_bigint()
const {
return type == Type::BigInt; }
83 bool is_rational()
const {
return type == Type::Rational; }
84 bool is_irrational()
const {
return type == Type::Irrational; }
85 bool is_symbolic()
const {
return type == Type::Symbolic; }
86 bool is_numeric()
const;
89 LMCAS::Result<lmmc_real_t> as_number_checked()
const;
93 LMCAS::Result<::LMCAS::Rational> as_rational_checked()
const;
97 LMCAS::Result<::LMCAS::Irrational> as_irrational_checked()
const;
101 LMCAS::Result<std::shared_ptr<SymbolicExpr>> as_symbolic_checked()
const;
108 bool as_symbolic_compatible()
const;
114 std::string to_string()
const;
116 bool operator==(
const Value& other)
const;
118 bool operator<(
const Value& other)
const;
121 LMCAS::Result<Value> vector_add_checked(
const Value& other)
const;
125 LMCAS::Result<Value> dot_product_checked(
const Value& other)
const;
130 const Value& other)
const;
134 static std::shared_ptr<SymbolicExpr> require_symbolic(
135 const std::shared_ptr<SymbolicExpr>& expression);
138 std::vector<std::vector<Value>> matrix);
140 std::string _str_cache;
任意精度整数 BigInt,底层调用 LMMP 实现高性能大数运算。
Result< void > validate_matrix(const ExactMatrixData &matrix, const std::string &operation)
__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
@ Rational
Rational numbers
ExpressionResult matrix_multiply_checked(const std::shared_ptr< SymbolicExpr > &A, const std::shared_ptr< SymbolicExpr > &B, ComputationContext &context)
ExprResult sym(const std::string &name)
精确有理数 Rational,基于 BigInt 分子/分母表示,自动约分。
符号表达式主类 SymbolicExpr 及其工厂方法,运算接口.