LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
LMCAS::SymbolicFactory类 参考

#include </home/runner/work/docs/docs/LMCAS/src/internal/symbolic_ast/base.hpp>

LMCAS::SymbolicFactory 的协作图:

静态 Public 成员函数

static std::shared_ptr< const SymbolicNode > create_add (std::vector< std::shared_ptr< const SymbolicNode > > ops, detail::RewriteBudget *budget=nullptr)
 创建加法节点,自动扁平化嵌套加法并消除零项.
static std::shared_ptr< const SymbolicNode > create_complex (std::shared_ptr< const SymbolicNode > real, std::shared_ptr< const SymbolicNode > imag)
 创建复数节点,自动简化(若虚部为 0,则返回实部).
static std::shared_ptr< const SymbolicNode > create_multiply (std::vector< std::shared_ptr< const SymbolicNode > > ops, detail::RewriteBudget *budget=nullptr)
 创建乘法节点,自动扁平化嵌套乘法并消除单位元.
static std::shared_ptr< const SymbolicNode > create_number (const ::LMCAS::BigInt &v)
static std::shared_ptr< const SymbolicNode > create_number (const ::LMCAS::Rational &v)
static std::shared_ptr< const SymbolicNode > create_number (lmmc_real_t v)
static std::shared_ptr< const SymbolicNode > create_power (std::shared_ptr< const SymbolicNode > base, std::shared_ptr< const SymbolicNode > exponent)
 创建幂运算节点,自动处理指数为 0/1 及底数为 0/1 的情况.
static std::shared_ptr< const SymbolicNode > create_variable (const std::string &name)

详细描述

在文件 base.hpp 第 290 行定义.

成员函数说明

◆ create_add()

std::shared_ptr< const SymbolicNode > LMCAS::SymbolicFactory::create_add ( std::vector< std::shared_ptr< const SymbolicNode > > ops,
detail::RewriteBudget * budget = nullptr )
static

创建加法节点,自动扁平化嵌套加法并消除零项.

参数
ops操作数列表
返回
简化后的节点

在文件 symbolic_factory.cpp 第 12 行定义.

14 {
15 if (ops.empty()) {
17 return create_number(::LMCAS::BigInt(0));
18 }
19 std::size_t nodes = 0;
20 for (const auto& op : ops) {
21 if (!op) {
22 throw std::invalid_argument("create_add operand cannot be null");
23 }
24 if (budget) {
25 nodes = budget->append_size(nodes, budget->measure(op));
26 }
27 }
28 if (ops.size() == 1) {
29 return ops[0];
30 }
31
32 std::vector<std::shared_ptr<const SymbolicNode>> flat_ops;
33 nodes = 0;
34 flat_ops.reserve(ops.size());
35 for (const auto& op : ops) {
36 if (op->is_zero()) {
37 continue;
38 }
39 if (auto add = std::dynamic_pointer_cast<const AddNode>(op)) {
40 if (budget) {
41 for (const auto& child : add->operands()) {
42 nodes = budget->append_size(nodes, budget->measure(child));
43 }
44 }
45 flat_ops.insert(flat_ops.end(), add->operands().begin(), add->operands().end());
46 } else {
47 normalization_append(budget, nodes, flat_ops, op);
48 }
49 }
50
51 if (flat_ops.empty()) {
53 return create_number(::LMCAS::BigInt(0));
54 }
55 if (flat_ops.size() == 1) {
56 return flat_ops[0];
57 }
58 normalization_check_arithmetic<AddNode>(budget, flat_ops, nodes);
59 return LMCAS::detail::make_node<AddNode>(std::move(flat_ops));
60}
static std::shared_ptr< const SymbolicNode > create_number(const ::LMCAS::BigInt &v)
std::size_t measure(const std::shared_ptr< const SymbolicNode > &node)
std::size_t append_size(std::size_t current, std::size_t child)
std::shared_ptr< const Node > make_node(Args &&... args)
std::size_t normalization_check_arithmetic(detail::RewriteBudget *budget, std::size_t extra_nodes, const std::shared_ptr< const Nodes > &... children)
ExprResult add(const ExprPtr &lhs, const ExprPtr &rhs, ComputationContext &context)
const ExprPtr RelationOp op
void normalization_check_children(detail::RewriteBudget *budget, std::size_t roots, const std::shared_ptr< const Nodes > &... children)
void normalization_append(detail::RewriteBudget *budget, std::size_t &nodes, std::vector< std::shared_ptr< const SymbolicNode > > &children, std::shared_ptr< const SymbolicNode > child)

引用了 LMCAS::add(), LMCAS::detail::RewriteBudget::append_size(), create_number(), LMCAS::detail::make_node(), LMCAS::detail::RewriteBudget::measure(), LMCAS::normalization_append(), LMCAS::normalization_check_arithmetic(), LMCAS::normalization_check_children() , 以及 LMCAS::op.

被这些函数引用 LMCAS::detail::anonymous_namespace{complex_quadratic.cpp}::add(), LMCAS::equivalence_detail::anonymous_namespace{equivalence_complex.cpp}::canonicalize_sum(), LMCAS::anonymous_namespace{integration_linearity.cpp}::combine_integration_exponentials(), LMCAS::combine_operands(), LMCAS::DifferentiationVisitor::differentiate_atan2(), LMCAS::NormalizationVisitor::expand_complex_product(), LMCAS::groebner_detail::from_poly_ext(), LMCAS::anonymous_namespace{differentiation_functions.cpp}::inverse_trigonometric_outer(), LMCAS::isolate_linear_coeff(), LMCAS::detail::materialize_integral(), LMCAS::NormalizationVisitor::merge_complex_terms(), LMCAS::RootOfNode::polynomial(), LMCAS::quantity_add(), LMCAS::quantity_subtract(), LMCAS::anonymous_namespace{transcendental_solver_substitution.cpp}::SubstNodeVisitor::replace(), LMCAS::anonymous_namespace{residual_verification.cpp}::replace_root_operands(), LMCAS::anonymous_namespace{transcendental_solver_substitution.cpp}::rewrite_exp_as_u_power(), LMCAS::equivalence_detail::rewrite_exp_log_basic_identity(), LMCAS::equivalence_detail::anonymous_namespace{equivalence_trig.cpp}::rewrite_trig_sum(), LMCAS::anonymous_namespace{differentiation_functions.cpp}::special_outer(), LMCAS::anonymous_namespace{residual_verification.cpp}::FormalResidual::sum(), LMCAS::te_abs_fourier(), LMCAS::detail::SymbolicRewriter::visit(), LMCAS::DifferentiationVisitor::visit(), LMCAS::DifferentiationVisitor::visit(), LMCAS::DifferentiationVisitor::visit(), LMCAS::DifferentiationVisitor::visit() , 以及 LMCAS::RewriteVisitor::visit().

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

◆ create_complex()

std::shared_ptr< const SymbolicNode > LMCAS::SymbolicFactory::create_complex ( std::shared_ptr< const SymbolicNode > real,
std::shared_ptr< const SymbolicNode > imag )
static

创建复数节点,自动简化(若虚部为 0,则返回实部).

在文件 symbolic_factory.cpp 第 167 行定义.

167 {
168 if (!real || !imag) {
169 throw std::invalid_argument("create_complex operands cannot be null");
170 }
171 if (imag->is_zero()) {
172 return real;
173 }
174 return LMCAS::detail::make_node<ComplexNode>(std::move(real), std::move(imag));
175}
ExprResult real(const ExprPtr &expression, ComputationContext &context)
ExprPtr imag

引用了 LMCAS::imag, LMCAS::detail::make_node() , 以及 LMCAS::real().

被这些函数引用 LMCAS::cauchy_integral_impl(), LMCAS::complex(), LMCAS::conjugate_checked(), LMCAS::NormalizationVisitor::expand_complex_product(), LMCAS::is_analytic_impl(), LMCAS::NormalizationVisitor::merge_complex_terms(), LMCAS::equivalence_detail::rewritten_complex(), LMCAS::solve_exact_factor(), LMCAS::detail::SymbolicRewriter::visit(), LMCAS::DifferentiationVisitor::visit(), LMCAS::ExpandVisitor::visit(), LMCAS::NormalizationVisitor::visit() , 以及 LMCAS::RewriteVisitor::visit().

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

◆ create_multiply()

std::shared_ptr< const SymbolicNode > LMCAS::SymbolicFactory::create_multiply ( std::vector< std::shared_ptr< const SymbolicNode > > ops,
detail::RewriteBudget * budget = nullptr )
static

创建乘法节点,自动扁平化嵌套乘法并消除单位元.

参数
ops操作数列表
返回
简化后的节点

在文件 symbolic_factory.cpp 第 83 行定义.

85 {
86 if (ops.empty()) {
88 return create_number(::LMCAS::BigInt(1));
89 }
90
91 std::size_t nodes = 0;
92 for (const auto& op : ops) {
93 if (!op) {
94 throw std::invalid_argument("create_multiply operand cannot be null");
95 }
96 if (budget) {
97 nodes = budget->append_size(nodes, budget->measure(op));
98 }
99 }
100 if (auto zero = discardable_zero_factor(ops, budget)) {
101 return zero;
102 }
103
104 if (ops.size() == 1) {
105 return ops[0];
106 }
107
108 std::vector<std::shared_ptr<const SymbolicNode>> flat_ops;
109 nodes = 0;
110 flat_ops.reserve(ops.size());
111 for (const auto& op : ops) {
112 if (op->is_one()) {
113 continue;
114 }
115 if (auto mul = std::dynamic_pointer_cast<const MultiplyNode>(op)) {
116 if (budget) {
117 for (const auto& child : mul->operands()) {
118 nodes = budget->append_size(nodes, budget->measure(child));
119 }
120 }
121 flat_ops.insert(flat_ops.end(), mul->operands().begin(), mul->operands().end());
122 } else {
123 normalization_append(budget, nodes, flat_ops, op);
124 }
125 }
126
127 if (flat_ops.empty()) {
129 return create_number(::LMCAS::BigInt(1));
130 }
131 if (flat_ops.size() == 1) {
132 return flat_ops[0];
133 }
134 normalization_check_arithmetic<MultiplyNode>(budget, flat_ops, nodes);
135 return LMCAS::detail::make_node<MultiplyNode>(std::move(flat_ops));
136}
detail::SymbolicNodePtr discardable_zero_factor(const std::vector< detail::SymbolicNodePtr > &operands, detail::RewriteBudget *budget)
ExprResult mul(const ExprPtr &lhs, const ExprPtr &rhs, ComputationContext &context)

引用了 LMCAS::detail::RewriteBudget::append_size(), create_number(), LMCAS::detail::make_node(), LMCAS::detail::RewriteBudget::measure(), LMCAS::mul(), LMCAS::normalization_append(), LMCAS::normalization_check_arithmetic(), LMCAS::normalization_check_children() , 以及 LMCAS::op.

被这些函数引用 LMCAS::equivalence_detail::anonymous_namespace{equivalence_complex.cpp}::canonicalize_product(), LMCAS::combine_operands(), LMCAS::convert_unit(), LMCAS::convert_unit(), LMCAS::DifferentiationVisitor::differentiate_atan2(), LMCAS::anonymous_namespace{differentiation_functions.cpp}::elementary_outer(), LMCAS::anonymous_namespace{normalization_numeric_powers.cpp}::extract_small_square_factor(), LMCAS::anonymous_namespace{differentiation_functions.cpp}::inverse_trigonometric_outer(), LMCAS::isolate_linear_coeff(), LMCAS::anonymous_namespace{differentiation_functions.cpp}::logarithmic_outer(), LMCAS::anonymous_namespace{quantity.cpp}::make_quantity(), LMCAS::detail::anonymous_namespace{complex_quadratic.cpp}::multiply(), LMCAS::RootOfNode::polynomial(), LMCAS::anonymous_namespace{residual_verification.cpp}::FormalResidual::product(), LMCAS::quantity_add(), LMCAS::quantity_divide(), LMCAS::quantity_multiply(), LMCAS::quantity_subtract(), LMCAS::anonymous_namespace{transcendental_solver_substitution.cpp}::SubstNodeVisitor::replace(), LMCAS::anonymous_namespace{residual_verification.cpp}::replace_root_operands(), LMCAS::anonymous_namespace{transcendental_solver_substitution.cpp}::rewrite_exp_as_u_power(), LMCAS::equivalence_detail::rewrite_exp_log_basic_identity(), LMCAS::equivalence_detail::anonymous_namespace{equivalence_exp_log.cpp}::rewrite_negative_lambert_exponential(), LMCAS::equivalence_detail::rewrite_trig_basic_identity(), LMCAS::scale_integral_field(), LMCAS::detail::transcendental::anonymous_namespace{transcendental_patterns.cpp}::scaled_function(), LMCAS::anonymous_namespace{expr_serialization.cpp}::Writer::scaled_value(), LMCAS::anonymous_namespace{quantity.cpp}::scaled_value(), LMCAS::solver_detail::solve_linear_system_impl(), LMCAS::anonymous_namespace{differentiation_functions.cpp}::special_outer(), LMCAS::strip_unit(), LMCAS::te_abs_decay(), LMCAS::te_abs_fourier(), LMCAS::te_decay_condition(), LMCAS::te_extract_exp(), LMCAS::te_inverse_pole_term(), LMCAS::groebner_detail::anonymous_namespace{solver_groebner_reconstruction.cpp}::term_node(), LMCAS::anonymous_namespace{differentiation_functions.cpp}::trigonometric_outer(), LMCAS::equivalence_detail::anonymous_namespace{equivalence_trig.cpp}::unwrap_trig_negated_argument(), LMCAS::detail::SymbolicRewriter::visit(), LMCAS::DifferentiationVisitor::visit(), LMCAS::DifferentiationVisitor::visit(), LMCAS::DifferentiationVisitor::visit(), LMCAS::DifferentiationVisitor::visit() , 以及 LMCAS::RewriteVisitor::visit().

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

◆ create_number() [1/3]

std::shared_ptr< const SymbolicNode > LMCAS::SymbolicFactory::create_number ( const ::LMCAS::BigInt & v)
static

在文件 symbolic_factory.cpp 第 7 行定义.

__attribute__((visibility("default"))) VectorCalculusExprResult surface_integral_scalar_checked(const std __attribute__((visibility("default"))) VectorCalculusExprResult surface_integral_scalar_checked(const std __attribute__((visibility("default"))) std const VectorField const std::string const std::string & v

引用了 LMCAS::detail::make_node() , 以及 LMCAS::v.

被这些函数引用 LMCAS::collect_power_denominators(), LMCAS::detail::anonymous_namespace{complex_quadratic.cpp}::construct_roots(), create_add(), create_multiply(), create_power(), LMCAS::DifferentiationVisitor::differentiate_atan2(), LMCAS::anonymous_namespace{differentiation_functions.cpp}::elementary_outer(), LMCAS::groebner_detail::from_poly_ext(), LMCAS::anonymous_namespace{differentiation_functions.cpp}::hyperbolic_outer(), LMCAS::detail::anonymous_namespace{complex_quadratic.cpp}::integer(), LMCAS::anonymous_namespace{differentiation_functions.cpp}::inverse_trigonometric_outer(), LMCAS::isolate_linear_coeff(), LMCAS::anonymous_namespace{differentiation_functions.cpp}::logarithmic_outer(), LMCAS::NormalizationVisitor::merge_complex_terms(), LMCAS::anonymous_namespace{residual_verification.cpp}::FormalResidual::number(), LMCAS::RootOfNode::polynomial(), LMCAS::quantity_divide(), LMCAS::anonymous_namespace{quantity.cpp}::rational_node(), LMCAS::anonymous_namespace{residual_verification.cpp}::FormalResidual::register_new_atom(), LMCAS::anonymous_namespace{residual_verification.cpp}::FormalResidual::rewrite_function(), LMCAS::anonymous_namespace{residual_verification.cpp}::FormalResidual::rewrite_radical(), LMCAS::anonymous_namespace{expr_serialization.cpp}::Writer::scaled_value(), LMCAS::solver_detail::solve_linear_system_impl(), LMCAS::anonymous_namespace{differentiation_functions.cpp}::special_outer(), LMCAS::te_abs_decay(), LMCAS::te_abs_fourier(), LMCAS::te_extract_exp(), LMCAS::te_inverse_pole_term(), LMCAS::transform_detail::te_linear_coefficient(), LMCAS::groebner_detail::anonymous_namespace{solver_groebner_reconstruction.cpp}::term_node(), LMCAS::anonymous_namespace{differentiation_functions.cpp}::trigonometric_outer(), LMCAS::DifferentiationVisitor::visit(), LMCAS::DifferentiationVisitor::visit(), LMCAS::DifferentiationVisitor::visit(), LMCAS::DifferentiationVisitor::visit() , 以及 LMCAS::DifferentiationVisitor::visit().

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

◆ create_number() [2/3]

std::shared_ptr< const SymbolicNode > LMCAS::SymbolicFactory::create_number ( const ::LMCAS::Rational & v)
static

在文件 symbolic_factory.cpp 第 8 行定义.

引用了 LMCAS::detail::make_node() , 以及 LMCAS::v.

函数调用图:

◆ create_number() [3/3]

std::shared_ptr< const SymbolicNode > LMCAS::SymbolicFactory::create_number ( lmmc_real_t v)
static

在文件 symbolic_factory.cpp 第 9 行定义.

引用了 LMCAS::detail::make_node() , 以及 LMCAS::v.

函数调用图:

◆ create_power()

std::shared_ptr< const SymbolicNode > LMCAS::SymbolicFactory::create_power ( std::shared_ptr< const SymbolicNode > base,
std::shared_ptr< const SymbolicNode > exponent )
static

创建幂运算节点,自动处理指数为 0/1 及底数为 0/1 的情况.

参数
base底数节点
exponent指数节点
返回
简化后的节点

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

139 {
140 if (!base || !exponent) {
141 throw std::invalid_argument("create_power operands cannot be null");
142 }
143 ComputationContext context;
144 if (exponent->is_zero()) {
147 return create_number(::LMCAS::BigInt(1));
148 }
149 return LMCAS::detail::make_node<PowerNode>(std::move(base), std::move(exponent));
150 }
151 if (exponent->is_one()) {
152 return base;
153 }
154 if (base->is_zero()) {
157 return create_number(::LMCAS::BigInt(0));
158 }
159 return LMCAS::detail::make_node<PowerNode>(std::move(base), std::move(exponent));
160 }
162 return create_number(::LMCAS::BigInt(1));
163 }
164 return LMCAS::detail::make_node<PowerNode>(std::move(base), std::move(exponent));
165}
Result< Tribool > query_nonzero_value(const Node &node, const FactsQuery &facts, Domain domain, ComputationContext &context)
const FactsQuery & no_facts() noexcept
Result< Tribool > query_positive_value(const Node &node, const FactsQuery &facts, ComputationContext &context)
const std::vector< Polynomial< BigInt > > const BigInt ComputationContext & context
bool normalization_can_discard(const std::shared_ptr< const SymbolicNode > &node, const FactsQuery &facts, Domain domain, ComputationContext &context)
@ Complex
Complex numbers (default, least specific)
@ Real
Real numbers
const ExprPtr & exponent
bool normalization_proved(const Result< Tribool > &result)

引用了 LMCAS::Complex, LMCAS::context, create_number(), LMCAS::exponent, LMCAS::detail::make_node(), LMCAS::detail::no_facts(), LMCAS::normalization_can_discard(), LMCAS::normalization_proved(), LMCAS::detail::query_nonzero_value(), LMCAS::detail::query_positive_value() , 以及 LMCAS::Real.

被这些函数引用 LMCAS::collect_power_denominators(), LMCAS::detail::anonymous_namespace{complex_quadratic.cpp}::construct_roots(), LMCAS::detail::anonymous_namespace{complex_quadratic.cpp}::divide(), LMCAS::RootOfNode::polynomial(), LMCAS::quantity_divide(), LMCAS::quantity_power(), LMCAS::anonymous_namespace{transcendental_solver_substitution.cpp}::SubstNodeVisitor::replace(), LMCAS::anonymous_namespace{residual_verification.cpp}::replace_root_power(), LMCAS::anonymous_namespace{transcendental_solver_substitution.cpp}::rewrite_exp_as_u_power(), LMCAS::te_abs_fourier(), LMCAS::groebner_detail::anonymous_namespace{solver_groebner_reconstruction.cpp}::term_node() , 以及 LMCAS::detail::SymbolicRewriter::visit().

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

◆ create_variable()

std::shared_ptr< const SymbolicNode > LMCAS::SymbolicFactory::create_variable ( const std::string & name)
static

在文件 symbolic_factory.cpp 第 10 行定义.

__attribute__((visibility("default"))) Result< EqvProfile > eqv_profile_from_name(const std const std::string & name

引用了 LMCAS::detail::make_node() , 以及 LMCAS::name.

被这些函数引用 LMCAS::inverse_fourier_transform_core(), LMCAS::isolate_linear_coeff(), LMCAS::RootOfNode::polynomial(), LMCAS::anonymous_namespace{residual_verification.cpp}::replace_exact_root(), LMCAS::anonymous_namespace{expression_analysis.cpp}::FreeSubstitution::rewrite_scoped(), LMCAS::te_abs_fourier(), LMCAS::te_fourier_unevaluated(), LMCAS::te_unevaluated_inv_laplace(), LMCAS::te_unevaluated_laplace(), LMCAS::groebner_detail::anonymous_namespace{solver_groebner_reconstruction.cpp}::variable_node(), LMCAS::wildcard() , 以及 LMCAS::zt_unevaluated().

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

该类的文档由以下文件生成: