LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
LMCAS::anonymous_namespace{normalization_numeric_powers.cpp} 命名空间参考

函数

std::shared_ptr< const SymbolicNode > extract_small_square_factor (const BigInt &value, const BigInt &root, detail::RewriteBudget *budget)
std::shared_ptr< const SymbolicNode > half_numeric_power (const NumberNode &base, detail::RewriteBudget *budget)
std::shared_ptr< const SymbolicNode > integer_numeric_power (const std::shared_ptr< const NumberNode > &base, const BigInt &exponent)
bool is_half_exponent (const NumberNode &exponent)
std::shared_ptr< const NumberNode > reciprocal_exact_number (const NumberNode &number)
std::shared_ptr< const NumberNode > small_exact_power (const NumberNode &base, const BigInt &exponent)

函数说明

◆ extract_small_square_factor()

std::shared_ptr< const SymbolicNode > LMCAS::anonymous_namespace{normalization_numeric_powers.cpp}::extract_small_square_factor ( const BigInt & value,
const BigInt & root,
detail::RewriteBudget * budget )

在文件 normalization_numeric_powers.cpp 第 64 行定义.

65 {
66 if (value <= BigInt(0) || value >= BigInt(1000000)) {
67 return nullptr;
68 }
69 for (BigInt factor = root; factor >= BigInt(2); factor -= BigInt(1)) {
70 const BigInt square = factor * factor;
71 if (!(value % square).is_zero()) {
72 continue;
73 }
74 if (budget) { budget->require_nodes(5); }
75 auto coefficient = detail::make_node<NumberNode>(factor);
76 auto radicand = detail::make_node<NumberNode>(value / square);
77 auto half = detail::make_node<NumberNode>(Rational(1, 2));
78 auto radical = detail::make_node<PowerNode>(radicand, half);
79 return SymbolicFactory::create_multiply({coefficient, radical}, budget);
80 }
81 return nullptr;
82}
static std::shared_ptr< const SymbolicNode > create_multiply(std::vector< std::shared_ptr< const SymbolicNode > > ops, detail::RewriteBudget *budget=nullptr)
创建乘法节点,自动扁平化嵌套乘法并消除单位元.
void require_nodes(std::size_t nodes) const
std::shared_ptr< const Node > make_node(Args &&... args)
@ Rational
Rational numbers
const std::string const ExprPtr & value

引用了 LMCAS::SymbolicFactory::create_multiply(), extract_small_square_factor(), LMCAS::detail::make_node(), LMCAS::detail::RewriteBudget::require_nodes() , 以及 LMCAS::value.

被这些函数引用 extract_small_square_factor() , 以及 half_numeric_power().

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

◆ half_numeric_power()

std::shared_ptr< const SymbolicNode > LMCAS::anonymous_namespace{normalization_numeric_powers.cpp}::half_numeric_power ( const NumberNode & base,
detail::RewriteBudget * budget )

在文件 normalization_numeric_powers.cpp 第 84 行定义.

85 {
86 if (const auto* integer = std::get_if<BigInt>(&base.value())) {
87 if (*integer < BigInt(0)) {
88 return nullptr;
89 }
90 const BigInt root = integer->sqrt();
91 if (root * root == *integer) {
93 }
94 return extract_small_square_factor(*integer, root, budget);
95 }
96 if (auto root = normalization_exact_square_root(base)) {
97 return root;
98 }
99 return nullptr;
100}
const std::variant< BigInt, Rational > & value() const noexcept
std::shared_ptr< const SymbolicNode > extract_small_square_factor(const BigInt &value, const BigInt &root, detail::RewriteBudget *budget)
ExprResult integer(Integer)=delete
std::shared_ptr< const NumberNode > normalization_exact_square_root(const NumberNode &number)

引用了 extract_small_square_factor(), half_numeric_power(), LMCAS::integer, LMCAS::detail::make_node(), LMCAS::normalization_exact_square_root() , 以及 LMCAS::NumberNode::value().

被这些函数引用 half_numeric_power().

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

◆ integer_numeric_power()

std::shared_ptr< const SymbolicNode > LMCAS::anonymous_namespace{normalization_numeric_powers.cpp}::integer_numeric_power ( const std::shared_ptr< const NumberNode > & base,
const BigInt & exponent )

在文件 normalization_numeric_powers.cpp 第 35 行定义.

36 {
37 const bool small = exponent > BigInt(-64) && exponent < BigInt(64);
38 if (exponent == BigInt(-1)) {
39 return reciprocal_exact_number(*base);
40 }
41 if (exponent.is_zero()) {
42 return detail::make_node<NumberNode>(BigInt(1));
43 }
44 if (!small) {
45 return nullptr;
46 }
47 auto powered = small_exact_power(*base, exponent);
48 if (!powered) {
49 return nullptr;
50 }
51 if (exponent > BigInt(0)) {
52 return powered;
53 }
54 return reciprocal_exact_number(*powered);
55}
std::shared_ptr< const NumberNode > small_exact_power(const NumberNode &base, const BigInt &exponent)
std::shared_ptr< const NumberNode > reciprocal_exact_number(const NumberNode &number)
const ExprPtr & exponent

引用了 LMCAS::exponent, integer_numeric_power(), LMCAS::detail::make_node(), reciprocal_exact_number() , 以及 small_exact_power().

被这些函数引用 integer_numeric_power().

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

◆ is_half_exponent()

bool LMCAS::anonymous_namespace{normalization_numeric_powers.cpp}::is_half_exponent ( const NumberNode & exponent)

在文件 normalization_numeric_powers.cpp 第 57 行定义.

57 {
58 if (const auto* rational = std::get_if<Rational>(&exponent.value())) {
59 return *rational == Rational(1, 2);
60 }
61 return false;
62}
ExprResult rational(const Rational &value)

引用了 LMCAS::exponent, is_half_exponent() , 以及 LMCAS::rational().

被这些函数引用 is_half_exponent().

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

◆ reciprocal_exact_number()

std::shared_ptr< const NumberNode > LMCAS::anonymous_namespace{normalization_numeric_powers.cpp}::reciprocal_exact_number ( const NumberNode & number)

在文件 normalization_numeric_powers.cpp 第 6 行定义.

6 {
7 if (const auto* integer = std::get_if<BigInt>(&number.value())) {
8 return detail::make_node<NumberNode>(Rational(BigInt(1), *integer));
9 }
10 if (const auto* rational = std::get_if<Rational>(&number.value())) {
11 if (!rational->get_numerator().is_zero()) {
13 Rational(rational->get_denominator(), rational->get_numerator()));
14 }
15 }
16 return nullptr;
17}

引用了 LMCAS::integer, LMCAS::detail::make_node(), LMCAS::rational(), reciprocal_exact_number() , 以及 LMCAS::NumberNode::value().

被这些函数引用 integer_numeric_power() , 以及 reciprocal_exact_number().

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

◆ small_exact_power()

std::shared_ptr< const NumberNode > LMCAS::anonymous_namespace{normalization_numeric_powers.cpp}::small_exact_power ( const NumberNode & base,
const BigInt & exponent )

在文件 normalization_numeric_powers.cpp 第 19 行定义.

20 {
21 const auto count = exponent.abs().try_to_uint64();
22 if (const auto* integer = std::get_if<BigInt>(&base.value())) {
23 BigInt value(1);
24 for (std::uint64_t k = 0; k < *count; ++k) value = value * *integer;
26 }
27 if (const auto* rational = std::get_if<Rational>(&base.value())) {
28 Rational value(1);
29 for (std::uint64_t k = 0; k < *count; ++k) value = value * *rational;
31 }
32 return nullptr;
33}

引用了 LMCAS::exponent, LMCAS::integer, LMCAS::detail::make_node(), LMCAS::rational(), small_exact_power(), LMCAS::NumberNode::value() , 以及 LMCAS::value.

被这些函数引用 integer_numeric_power() , 以及 small_exact_power().

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