31 enum class Type { SQRT, PI, E, LOG, COMPLEX };
33 Irrational() =
default;
35 static Result<Irrational> sqrt_checked(
const BigInt& n, lmmc_real_t coefficient,
36 ComputationContext& context);
37 static Result<Irrational> sqrt_checked(
const BigInt& n,
38 lmmc_real_t coefficient = 1.0);
39 static Irrational
pi(lmmc_real_t coefficient = 1.0);
40 static Irrational
e(lmmc_real_t coefficient = 1.0);
41 static Irrational constant(lmmc_real_t value);
42 static Irrational constant(
const Rational& value);
44 void to_complex() { type_ = Type::COMPLEX; }
45 Type get_type()
const {
return type_; }
46 Irrational operator+(
const Irrational& other)
const;
47 Irrational operator-(
const Irrational& other)
const;
48 Irrational operator*(
const Irrational& other)
const;
49 Irrational operator*(
const Rational& scalar)
const;
50 Irrational operator*(lmmc_real_t scalar)
const;
51 Irrational operator/(
const Irrational& other)
const;
52 Irrational operator-()
const;
53 Irrational
pow(
const BigInt& exponent)
const;
54 bool operator==(
const Irrational& other)
const;
55 bool operator<(
const Irrational& other)
const;
56 bool operator<=(
const Irrational& other)
const;
57 bool operator>(
const Irrational& other)
const;
58 bool operator>=(
const Irrational& other)
const;
60 bool is_rational()
const;
61 Result<Rational> as_rational_checked()
const;
62 bool is_positive()
const;
63 bool is_negative()
const;
65 Result<Sign> sign_checked(ComputationContext& context)
const;
66 Result<Sign> sign_checked()
const;
67 Result<Irrational> abs_checked(ComputationContext& context)
const;
68 Result<Irrational> abs_checked()
const;
76 Irrational
abs()
const;
78 lmmc_real_t to_double()
const;
79 std::string to_string()
const;
80 std::shared_ptr<SymbolicExpr> to_symbolic()
const;
89 bool operator<(
const Basis& other)
const;
90 bool operator==(
const Basis& other)
const;
91 bool is_constant()
const;
92 std::string to_string()
const;
93 lmmc_real_t to_double()
const;
94 std::shared_ptr<SymbolicExpr> to_symbolic()
const;
96 using Terms = std::map<Basis, Rational>;
97 Type type_ = Type::COMPLEX;
99 Terms denominator_{{Basis{},
Rational(1)}};
101 static Terms multiply_terms(
const Terms& left,
const Terms& right);
102 static void add_term(Terms& terms,
const Basis& basis,
const Rational& coefficient);
103 static std::string terms_to_string(
const Terms& terms);
104 static lmmc_real_t terms_to_double(
const Terms& terms);
105 static std::shared_ptr<SymbolicExpr> terms_to_symbolic(
const Terms& terms);
106 struct EnclosureRound;
107 static std::pair<Rational, Rational> terms_bounds(
108 const Terms& terms, EnclosureRound& round);
109 static Result<std::pair<BigInt, BigInt>> extract_square_factors(
110 const BigInt& n, ComputationContext& context);
Core enumerations and forward declarations for the Assumption System.
bool is_zero(const SymbolicExpr &expression)
ExprResult pow(const ExprPtr &base, const ExprPtr &exponent, ComputationContext &context)
@ Rational
Rational numbers
ExprResult simplify(const ExprPtr &expression, ComputationContext &context)
ExprResult abs(const ExprPtr &expression, ComputationContext &context)
std::ostream & operator<<(std::ostream &os, const Polynomial< T > &p)
多项式流输出运算符
精确有理数 Rational,基于 BigInt 分子/分母表示,自动约分。