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

函数

ExpressionResult differentiate_surface_checked (const std::shared_ptr< SymbolicExpr > &expr, const std::string &var, const std::string &operation, ComputationContext &context)
PlaneSymbolicResult scaled_tangent_plane (const std::vector< double > &gradient_values, double gradient_scale, const std::vector< double > &point_values, double point_scale, const std::string &operation)
VectorExprListResult surface_gradient_at_point_checked (const SurfaceSymbolic &surf, const std::vector< std::shared_ptr< SymbolicExpr > > &point, const std::string &operation, ComputationContext &context)
Result< double > surface_gradient_scale_checked (const std::vector< std::shared_ptr< SymbolicExpr > > &gradient, ComputationContext &context, const std::string &operation, std::vector< double > &values, const std::string &singular_message)

函数说明

◆ differentiate_surface_checked()

ExpressionResult LMCAS::anonymous_namespace{symbolic_geometry_surface.cpp}::differentiate_surface_checked ( const std::shared_ptr< SymbolicExpr > & expr,
const std::string & var,
const std::string & operation,
ComputationContext & context )

在文件 symbolic_geometry_surface.cpp 第 18 行定义.

22 {
23
24 detail::RewriteBudget transform_budget(context, (context).limits().max_recursion_depth,
25 (context).limits().max_ast_nodes, "transform");
26 try {
27 auto derivative = detail::make_expression_ptr(detail::differentiate_node(detail::node(expr), var, transform_budget));
28 return simplify_checked(
29 derivative, operation,
30 "surface derivative is outside the supported domain", context);
31 } catch (const std::length_error& error) { return ExpressionResult::failure(CasErrc::ResourceLimit, error.what(), operation); } catch (const std::exception&) {
34 "surface derivative is outside the supported domain",
35 operation);
36 }
37} catch (const CasError& error) {
38 return ExpressionResult::failure(error);
39} catch (const std::bad_alloc&) {
40 return ExpressionResult::failure(CasErrc::ResourceLimit, "allocation failed", operation);
41} catch (const std::length_error& error) {
42 return ExpressionResult::failure(CasErrc::ResourceLimit, error.what(), operation);
43} catch (const std::exception& error) {
44 return ExpressionResult::failure(CasErrc::InternalInvariant, error.what(), operation);
45}
static Result failure(CasErrc code, std::string message, std::string operation={})
SymbolicNodePtr differentiate_node(const SymbolicNodePtr &node, const std::string &variable, RewriteBudget &budget, const FactsQuery &facts, Domain domain)
std::shared_ptr<::LMCAS::SymbolicExpr > make_expression_ptr(SymbolicNodePtr root)
const SymbolicNodePtr & node(const ::LMCAS::SymbolicExpr &expression) noexcept
ExpressionResult simplify_checked(const std::shared_ptr< SymbolicExpr > &expr, const std::string &operation, const std::string &message, ComputationContext &context)
const std::vector< Polynomial< BigInt > > const BigInt ComputationContext & context

引用了 LMCAS::context, LMCAS::detail::differentiate_node(), differentiate_surface_checked(), LMCAS::Result< std::shared_ptr< SymbolicExpr > >::failure(), LMCAS::InternalInvariant, LMCAS::detail::make_expression_ptr(), LMCAS::detail::node(), LMCAS::ResourceLimit , 以及 LMCAS::geometry_detail::simplify_checked().

被这些函数引用 differentiate_surface_checked() , 以及 surface_gradient_at_point_checked().

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

◆ scaled_tangent_plane()

PlaneSymbolicResult LMCAS::anonymous_namespace{symbolic_geometry_surface.cpp}::scaled_tangent_plane ( const std::vector< double > & gradient_values,
double gradient_scale,
const std::vector< double > & point_values,
double point_scale,
const std::string & operation )

在文件 symbolic_geometry_surface.cpp 第 113 行定义.

119{
120 double normalized_dot = 0.0;
121 for (size_t i = 0; i < point_values.size(); ++i) {
122 normalized_dot = std::fma(
123 gradient_values[i] / gradient_scale,
124 point_values[i] / point_scale,
125 normalized_dot);
126 }
127 const double plane_constant = normalized_dot * point_scale;
128 if (!std::isfinite(plane_constant)) {
131 "tangent plane constant is outside the supported domain",
132 operation);
133 }
134
135 PlaneSymbolic plane;
136 plane.normal.reserve(gradient_values.size());
137 for (double component : gradient_values) {
138 plane.normal.push_back(
139 SymbolicExpr::number(component / gradient_scale));
140 }
141 plane.d = SymbolicExpr::number(plane_constant);
142 return PlaneSymbolicResult::success(std::move(plane));
143}
static Result success(PlaneSymbolic value)
const PlaneSymbolic & plane
std::vector< std::shared_ptr< SymbolicExpr > > normal
法向量。
std::shared_ptr< SymbolicExpr > d
常数项。

引用了 LMCAS::PlaneSymbolic::d, LMCAS::Result< PlaneSymbolic >::failure(), LMCAS::PlaneSymbolic::normal, LMCAS::NumericFailure, LMCAS::plane, scaled_tangent_plane() , 以及 LMCAS::Result< PlaneSymbolic >::success().

被这些函数引用 scaled_tangent_plane().

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

◆ surface_gradient_at_point_checked()

VectorExprListResult LMCAS::anonymous_namespace{symbolic_geometry_surface.cpp}::surface_gradient_at_point_checked ( const SurfaceSymbolic & surf,
const std::vector< std::shared_ptr< SymbolicExpr > > & point,
const std::string & operation,
ComputationContext & context )

在文件 symbolic_geometry_surface.cpp 第 47 行定义.

51 {
52
53 detail::RewriteBudget transform_budget(context, (context).limits().max_recursion_depth,
54 (context).limits().max_ast_nodes, "transform");
55 std::vector<std::shared_ptr<SymbolicExpr>> gradient;
56 gradient.reserve(surf.vars.size());
57 for (size_t i = 0; i < surf.vars.size(); ++i) {
58 auto derivative = differentiate_surface_checked(surf.F, surf.vars[i], operation, context);
59 if (!derivative) return VectorExprListResult::failure(derivative.error());
60 auto substituted = derivative.value();
61 for (size_t j = 0; j < surf.vars.size(); ++j) {
62 substituted = detail::make_expression_ptr(detail::substitute_node(detail::node(substituted), surf.vars[j], detail::node(point[j]), transform_budget));
63 if (!substituted || !LMCAS::detail::node(substituted)) {
66 "surface derivative substitution is outside the supported domain",
67 operation);
68 }
69 }
70 auto simplified = simplify_checked(
71 substituted, operation,
72 "surface derivative substitution is outside the supported domain", context);
73 if (!simplified) return VectorExprListResult::failure(simplified.error());
74 gradient.push_back(std::move(simplified.value()));
75 }
76 return VectorExprListResult::success(std::move(gradient));
77} catch (const CasError& error) {
79} catch (const std::bad_alloc&) {
80 return VectorExprListResult::failure(CasErrc::ResourceLimit, "allocation failed", operation);
81} catch (const std::length_error& error) {
82 return VectorExprListResult::failure(CasErrc::ResourceLimit, error.what(), operation);
83} catch (const std::exception& error) {
84 return VectorExprListResult::failure(CasErrc::InternalInvariant, error.what(), operation);
85}
ExpressionResult differentiate_surface_checked(const std::shared_ptr< SymbolicExpr > &expr, const std::string &var, const std::string &operation, ComputationContext &context)
SymbolicNodePtr substitute_node(const SymbolicNodePtr &node, const std::string &variable, const SymbolicNodePtr &replacement, RewriteBudget &budget, const FactsQuery &facts, Domain domain)
const std::string const LimitExprPtr & point
std::shared_ptr< SymbolicExpr > F
曲面方程左端,等于零。
VectorField gradient(const std::shared_ptr< SymbolicExpr > &f, const std::vector< std::string > &vars)
std::vector< std::string > vars
坐标变量名 {x,y,z}。

引用了 LMCAS::context, differentiate_surface_checked(), LMCAS::SurfaceSymbolic::F, LMCAS::Result< std::vector< std::shared_ptr< SymbolicExpr > > >::failure(), LMCAS::gradient(), LMCAS::Inconclusive, LMCAS::detail::make_expression_ptr(), LMCAS::detail::node(), LMCAS::point, LMCAS::geometry_detail::simplify_checked(), LMCAS::detail::substitute_node(), LMCAS::Result< std::vector< std::shared_ptr< SymbolicExpr > > >::success(), surface_gradient_at_point_checked() , 以及 LMCAS::SurfaceSymbolic::vars.

被这些函数引用 surface_gradient_at_point_checked().

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

◆ surface_gradient_scale_checked()

Result< double > LMCAS::anonymous_namespace{symbolic_geometry_surface.cpp}::surface_gradient_scale_checked ( const std::vector< std::shared_ptr< SymbolicExpr > > & gradient,
ComputationContext & context,
const std::string & operation,
std::vector< double > & values,
const std::string & singular_message )

在文件 symbolic_geometry_surface.cpp 第 87 行定义.

93{
94 auto scaled = numeric_vector_scale_checked(
95 gradient, context, operation, &values);
96 if (!scaled) {
97 if (scaled.error().code == CasErrc::Cancelled ||
98 scaled.error().code == CasErrc::ResourceLimit) {
99 return Result<double>::failure(scaled.error());
100 }
103 "surface gradient nonzero condition cannot be verified",
104 operation);
105 }
106 if (scaled.value() == 0.0) {
108 CasErrc::DomainError, singular_message, operation);
109 }
110 return scaled;
111}
Result< double > numeric_vector_scale_checked(const std::vector< std::shared_ptr< SymbolicExpr > > &expressions, ComputationContext &context, const std::string &operation, std::vector< double > *values=nullptr)

引用了 LMCAS::Cancelled, LMCAS::context, LMCAS::DomainError, LMCAS::Result< T >::failure(), LMCAS::gradient(), LMCAS::Inconclusive, LMCAS::geometry_detail::numeric_vector_scale_checked(), LMCAS::ResourceLimit , 以及 surface_gradient_scale_checked().

被这些函数引用 surface_gradient_scale_checked().

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