LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
LMCAS::Irrational::EnclosureRound结构体 参考
LMCAS::Irrational::EnclosureRound 的协作图:

Public 类型

using Bounds = detail::ExactConstantInterval

Public 成员函数

 EnclosureRound (ComputationContext &context, std::size_t precision)
const Bounds & constant (bool use_pi)
Bounds multiply_positive (const Bounds &a, const Bounds &b)
Bounds power (Bounds base, const BigInt &exponent)
const Bounds & radical (const BigInt &radicand)

静态 Public 成员函数

static Result< Sign > refine_sign (const Terms &numerator, const Terms &denominator, bool numerator_zero, bool transcendental, ComputationContext &context, detail::ExactBoundArithmetic &arithmetic, const char *operation)
static int separated_sign (const Bounds &bounds)
static bool validate_terms (const Terms &terms, detail::ExactBoundArithmetic &arithmetic, bool &transcendental)

Public 属性

detail::ExactBoundArithmetic arithmetic
ComputationContext & context
std::optional< Bounds > e
std::optional< Bounds > pi
std::size_t precision
std::map< BigInt, Bounds > radicals

详细描述

在文件 irrational_arithmetic.cpp 第 137 行定义.

成员类型定义说明

◆ Bounds

构造及析构函数说明

◆ EnclosureRound()

LMCAS::Irrational::EnclosureRound::EnclosureRound ( ComputationContext & context,
std::size_t precision )
inline

在文件 irrational_arithmetic.cpp 第 146 行定义.

引用了 arithmetic, context , 以及 precision.

被这些函数引用 refine_sign().

这是这个函数的调用关系图:

成员函数说明

◆ constant()

const Bounds & LMCAS::Irrational::EnclosureRound::constant ( bool use_pi)
inline

在文件 irrational_arithmetic.cpp 第 176 行定义.

176 {
177 auto& cached = use_pi ? pi : e;
178 if (!cached) {
179 auto bounds = use_pi ? detail::exact_pi_bounds(precision, context)
180 : detail::exact_e_bounds(precision, context);
181 if (!bounds) throw bounds.error();
182 cached = std::move(bounds.value());
183 }
184 return *cached;
185 }
Result< ExactConstantInterval > exact_e_bounds(std::size_t precision_bits, ComputationContext &context)
Result< ExactConstantInterval > exact_pi_bounds(std::size_t precision_bits, ComputationContext &context)

引用了 context, e, LMCAS::detail::exact_e_bounds(), LMCAS::detail::exact_pi_bounds(), pi , 以及 precision.

函数调用图:

◆ multiply_positive()

Bounds LMCAS::Irrational::EnclosureRound::multiply_positive ( const Bounds & a,
const Bounds & b )
inline

在文件 irrational_arithmetic.cpp 第 187 行定义.

187 {
188 return {arithmetic.mul(a.first, b.first), arithmetic.mul(a.second, b.second)};
189 }
Rational mul(const Rational &a, const Rational &b) const
const MultiPoly & b
__attribute__((visibility("default"))) VectorCalculusExprResult curve_integral_scalar_checked(const std __attribute__((visibility("default"))) VectorCalculusExprResult curve_integral_scalar_checked(const std __attribute__((visibility("default"))) std const VectorField const std::string const std::shared_ptr< SymbolicExpr > & a

引用了 LMCAS::a, arithmetic, LMCAS::b , 以及 LMCAS::detail::ExactBoundArithmetic::mul().

被这些函数引用 power().

函数调用图:
这是这个函数的调用关系图:

◆ power()

Bounds LMCAS::Irrational::EnclosureRound::power ( Bounds base,
const BigInt & exponent )
inline

在文件 irrational_arithmetic.cpp 第 191 行定义.

191 {
192 arithmetic.bits(exponent.bit_length());
193 BigInt remaining = exponent.abs();
194 Bounds result{Rational(1), Rational(1)};
195 while (!remaining.is_zero()) {
197 if (remaining.is_odd()) result = multiply_positive(result, base);
198 remaining >>= 1;
199 if (!remaining.is_zero()) base = multiply_positive(base, base);
200 }
201 if (exponent.is_negative())
202 return {arithmetic.div(Rational(1), result.second),
203 arithmetic.div(Rational(1), result.first)};
204 return result;
205 }
Rational div(const Rational &a, const Rational &b) const
@ Rational
Rational numbers
const ExprPtr & exponent
Bounds multiply_positive(const Bounds &a, const Bounds &b)

引用了 arithmetic, LMCAS::detail::ExactBoundArithmetic::bits(), LMCAS::detail::ExactBoundArithmetic::div(), LMCAS::exponent, multiply_positive() , 以及 LMCAS::detail::ExactBoundArithmetic::step().

函数调用图:

◆ radical()

const Bounds & LMCAS::Irrational::EnclosureRound::radical ( const BigInt & radicand)
inline

在文件 irrational_arithmetic.cpp 第 150 行定义.

150 {
151 auto found = radicals.find(radicand);
152 if (found != radicals.end()) return found->second;
154 if (radicand.is_negative() || radicand.is_zero())
155 throw CasError{CasErrc::InternalInvariant,
156 "nonpositive normalized radicand", "Irrational::sign_checked"};
157 if (radicand == BigInt(1))
158 return radicals.emplace(radicand, Bounds{Rational(1), Rational(1)}).first->second;
159 const BigInt scale = arithmetic.dyadic_scale(precision);
160 const auto shift = arithmetic.growth(precision, precision);
161 arithmetic.growth(radicand.bit_length(), shift);
162 if (shift > std::numeric_limits<mp_size_t>::max())
163 throw CasError{CasErrc::ResourceLimit,
164 "radical shift size exceeded", "Irrational::sign_checked"};
165 const BigInt scaled = radicand << static_cast<mp_size_t>(shift);
167 const BigInt lower = scaled.sqrt();
168 arithmetic.growth(lower.bit_length(), lower.bit_length());
169 const bool exact = lower * lower == scaled;
170 arithmetic.growth(lower.bit_length(), 1);
171 const BigInt upper = exact ? lower : lower + BigInt(1);
172 return radicals.emplace(radicand, Bounds{Rational(lower, scale),
173 Rational(upper, scale)}).first->second;
174 }
std::size_t growth(std::size_t a, std::size_t b) const
BigInt dyadic_scale(std::size_t precision) const
__attribute__((visibility("default"))) ExprResult function(const std __attribute__((visibility("default"))) ExprResult finite_set(std ExprPtr upper
const ExprPtr & lower

引用了 arithmetic, LMCAS::detail::ExactBoundArithmetic::dyadic_scale(), LMCAS::detail::ExactBoundArithmetic::growth(), LMCAS::InternalInvariant, LMCAS::lower, precision, radicals, LMCAS::ResourceLimit, LMCAS::detail::ExactBoundArithmetic::step() , 以及 LMCAS::upper.

函数调用图:

◆ refine_sign()

Result< Sign > LMCAS::Irrational::EnclosureRound::refine_sign ( const Terms & numerator,
const Terms & denominator,
bool numerator_zero,
bool transcendental,
ComputationContext & context,
detail::ExactBoundArithmetic & arithmetic,
const char * operation )
inlinestatic

不同规范无平方因子根式在 Q 上线性无关,故非空纯根式和非零,细化过程在数学上终止; 实际执行仍受调用方资源预算限制。

在文件 irrational_arithmetic.cpp 第 232 行定义.

234 {
235 /**
236 * @brief 不同规范无平方因子根式在 Q 上线性无关,故非空纯根式和非零,细化过程在数学上终止;
237 * 实际执行仍受调用方资源预算限制。
238 */
239 for (std::size_t precision = 32;;) {
242 const auto denominator_bounds = terms_bounds(denominator, round);
243 const int denominator_sign = separated_sign(denominator_bounds);
244 if (denominator_sign != 0) {
245 if (numerator_zero) { return Sign::Zero; }
246 const auto numerator_bounds = terms_bounds(numerator, round);
247 const int numerator_sign = separated_sign(numerator_bounds);
248 if (numerator_sign != 0) {
249 return numerator_sign == denominator_sign ? Sign::Positive : Sign::Negative;
250 }
251 }
252 if (transcendental && precision == 4096) {
254 "pi/e enclosure did not separate zero at 4096 bits", operation);
255 }
256 if (precision > std::numeric_limits<std::size_t>::max() / 2) {
258 "refinement size exceeded", operation);
259 }
260 precision *= 2;
261 }
262 }
static Result failure(CasErrc code, std::string message, std::string operation={})
const ExprPtr & denominator
ExprResult round(const ExprPtr &expression, ComputationContext &context)
static int separated_sign(const Bounds &bounds)
EnclosureRound(ComputationContext &context, std::size_t precision)

引用了 EnclosureRound(), arithmetic, context, LMCAS::denominator, LMCAS::Result< T >::failure(), LMCAS::Inconclusive, LMCAS::Negative, LMCAS::Positive, precision, LMCAS::ResourceLimit, LMCAS::round(), separated_sign(), LMCAS::detail::ExactBoundArithmetic::step() , 以及 LMCAS::Zero.

函数调用图:

◆ separated_sign()

int LMCAS::Irrational::EnclosureRound::separated_sign ( const Bounds & bounds)
inlinestatic

在文件 irrational_arithmetic.cpp 第 225 行定义.

225 {
226 const auto lower = bounds.first.get_numerator();
227 if (!lower.is_zero() && !lower.is_negative()) { return 1; }
228 if (bounds.second.get_numerator().is_negative()) { return -1; }
229 return 0;
230 }

引用了 LMCAS::lower.

被这些函数引用 refine_sign().

这是这个函数的调用关系图:

◆ validate_terms()

bool LMCAS::Irrational::EnclosureRound::validate_terms ( const Terms & terms,
detail::ExactBoundArithmetic & arithmetic,
bool & transcendental )
inlinestatic

在文件 irrational_arithmetic.cpp 第 207 行定义.

208 {
209 bool zero = true;
210 for (const auto& term : terms) {
212 arithmetic.bits(term.second.get_numerator().bit_length());
213 arithmetic.bits(term.second.get_denominator().bit_length());
214 arithmetic.bits(term.first.radicand.bit_length());
215 arithmetic.bits(term.first.pi_power.bit_length());
216 arithmetic.bits(term.first.e_power.bit_length());
217 if (term.second.is_zero()) { continue; }
218 zero = false;
219 transcendental |= !term.first.pi_power.is_zero() ||
220 !term.first.e_power.is_zero();
221 }
222 return zero;
223 }

引用了 arithmetic, LMCAS::detail::ExactBoundArithmetic::bits() , 以及 LMCAS::detail::ExactBoundArithmetic::step().

函数调用图:

类成员变量说明

◆ arithmetic

detail::ExactBoundArithmetic LMCAS::Irrational::EnclosureRound::arithmetic

◆ context

ComputationContext& LMCAS::Irrational::EnclosureRound::context

在文件 irrational_arithmetic.cpp 第 139 行定义.

被这些函数引用 EnclosureRound(), constant() , 以及 refine_sign().

◆ e

std::optional<Bounds> LMCAS::Irrational::EnclosureRound::e

在文件 irrational_arithmetic.cpp 第 144 行定义.

被这些函数引用 constant().

◆ pi

std::optional<Bounds> LMCAS::Irrational::EnclosureRound::pi

在文件 irrational_arithmetic.cpp 第 143 行定义.

被这些函数引用 constant().

◆ precision

std::size_t LMCAS::Irrational::EnclosureRound::precision

在文件 irrational_arithmetic.cpp 第 140 行定义.

被这些函数引用 EnclosureRound(), constant(), radical() , 以及 refine_sign().

◆ radicals

std::map<BigInt, Bounds> LMCAS::Irrational::EnclosureRound::radicals

在文件 irrational_arithmetic.cpp 第 142 行定义.

被这些函数引用 radical().


该结构体的文档由以下文件生成: