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

函数

Result< std::size_t > bounded_binomial (std::size_t n, std::size_t k, std::size_t limit, const std::string &operation)
DifferentialGeometryExprResult checked_geometry_expression (std::shared_ptr< SymbolicExpr > &&result, CasErrc error, const char *message, const std::string &operation)
DifferentialGeometryExprResult exterior_derivative_component (const std::vector< std::shared_ptr< SymbolicExpr > > &form_coeffs, const std::vector< std::string > &vars, const std::map< std::vector< std::size_t >, std::size_t > &coefficient_index, const std::vector< std::size_t > &output_index, detail::RewriteBudget &budget, const std::string &operation)
DifferentialGeometryExprResult exterior_derivative_term (const std::vector< std::shared_ptr< SymbolicExpr > > &form_coeffs, const std::vector< std::string > &vars, const std::map< std::vector< std::size_t >, std::size_t > &coefficient_index, const std::vector< std::size_t > &output_index, std::size_t removed, detail::RewriteBudget &budget, const std::string &operation)
std::vector< std::vector< std::size_t > > index_combinations (std::size_t n, std::size_t k, std::size_t count)
Result< void > validate_expr_vector (const std::vector< std::shared_ptr< SymbolicExpr > > &values, const std::vector< std::string > &vars, const std::string &value_name, const std::string &operation)
Result< std::size_t > validate_form_coefficients (const std::vector< std::shared_ptr< SymbolicExpr > > &form_coeffs, int degree, const std::vector< std::string > &vars, ComputationContext &context, const std::string &operation)
Result< void > validate_form_coordinates (const std::vector< std::string > &vars, const std::string &operation)
Result< void > validate_index (int idx, std::size_t dim, const std::string &name, const std::string &operation)
Result< std::shared_ptr< const MatrixNode > > validate_metric_matrix (const std::shared_ptr< SymbolicExpr > &metric, const std::vector< std::string > *coords, ComputationContext &context, const std::string &operation)

函数说明

◆ bounded_binomial()

Result< std::size_t > LMCAS::anonymous_namespace{differential_geometry.cpp}::bounded_binomial ( std::size_t n,
std::size_t k,
std::size_t limit,
const std::string & operation )

在文件 differential_geometry.cpp 第 118 行定义.

122{
123 if (k > n) return Result<std::size_t>::success(0);
124 k = std::min(k, n - k);
125 std::size_t value = 1;
126 for (std::size_t i = 1; i <= k; ++i) {
127 std::size_t numerator = n - k + i;
128 std::size_t denominator = i;
129 const auto fraction_gcd = std::gcd(numerator, denominator);
130 numerator /= fraction_gcd;
131 denominator /= fraction_gcd;
132 const auto value_gcd = std::gcd(value, denominator);
133 value /= value_gcd;
134 denominator /= value_gcd;
135 if (denominator != 1) {
138 "binomial coefficient reduction was not exact",
139 operation);
140 }
141 if (numerator != 0 && value > limit / numerator) {
144 "differential-form component count exceeds the expansion budget",
145 operation);
146 }
147 value *= numerator;
148 }
149 if (value > limit) {
152 "differential-form component count exceeds the expansion budget",
153 operation);
154 }
156}
static Result failure(CasErrc code, std::string message, std::string operation={})
static Result success(T value)
const std::string const ExprPtr & value
const ExprPtr & denominator

引用了 bounded_binomial(), LMCAS::denominator, LMCAS::Result< T >::failure(), LMCAS::InternalInvariant, LMCAS::ResourceLimit, LMCAS::Result< T >::success() , 以及 LMCAS::value.

被这些函数引用 bounded_binomial() , 以及 validate_form_coefficients().

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

◆ checked_geometry_expression()

DifferentialGeometryExprResult LMCAS::anonymous_namespace{differential_geometry.cpp}::checked_geometry_expression ( std::shared_ptr< SymbolicExpr > && result,
CasErrc error,
const char * message,
const std::string & operation )

在文件 differential_geometry.cpp 第 188 行定义.

193{
194 if (!result || !LMCAS::detail::node(result)) {
195 return DifferentialGeometryExprResult::failure(error, message, operation);
196 }
197 return DifferentialGeometryExprResult::success(std::move(result));
198}
const SymbolicNodePtr & node(const ::LMCAS::SymbolicExpr &expression) noexcept

引用了 checked_geometry_expression(), LMCAS::Result< std::shared_ptr< SymbolicExpr > >::failure(), LMCAS::detail::node() , 以及 LMCAS::Result< std::shared_ptr< SymbolicExpr > >::success().

被这些函数引用 checked_geometry_expression() , 以及 exterior_derivative_component().

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

◆ exterior_derivative_component()

DifferentialGeometryExprResult LMCAS::anonymous_namespace{differential_geometry.cpp}::exterior_derivative_component ( const std::vector< std::shared_ptr< SymbolicExpr > > & form_coeffs,
const std::vector< std::string > & vars,
const std::map< std::vector< std::size_t >, std::size_t > & coefficient_index,
const std::vector< std::size_t > & output_index,
detail::RewriteBudget & budget,
const std::string & operation )

在文件 differential_geometry.cpp 第 292 行定义.

299 {
300 auto component = SymbolicExpr::number(0);
301 for (std::size_t removed = 0; removed < output_index.size(); ++removed) {
302 auto partial = exterior_derivative_term(
303 form_coeffs, vars, coefficient_index, output_index, removed, budget, operation);
304 if (!partial) return partial;
305 component = SymbolicExpr::add(component, partial.value());
306 }
307 component = detail::make_expression_ptr(
308 detail::normalize_node(detail::node(component), budget));
309 return checked_geometry_expression(std::move(component), CasErrc::InternalInvariant,
310 "exterior derivative produced a null component",
311 operation);
312} catch (const CasError& error) {
314} catch (const std::bad_alloc&) {
315 return DifferentialGeometryExprResult::failure(CasErrc::ResourceLimit, "allocation failed", operation);
316} catch (const std::length_error& error) {
318} catch (const std::exception& error) {
320}
DifferentialGeometryExprResult checked_geometry_expression(std::shared_ptr< SymbolicExpr > &&result, CasErrc error, const char *message, const std::string &operation)
DifferentialGeometryExprResult exterior_derivative_term(const std::vector< std::shared_ptr< SymbolicExpr > > &form_coeffs, const std::vector< std::string > &vars, const std::map< std::vector< std::size_t >, std::size_t > &coefficient_index, const std::vector< std::size_t > &output_index, std::size_t removed, detail::RewriteBudget &budget, const std::string &operation)
std::shared_ptr<::LMCAS::SymbolicExpr > make_expression_ptr(SymbolicNodePtr root)
SymbolicNodePtr normalize_node(const SymbolicNodePtr &node, RewriteBudget &budget, const FactsQuery &facts, Domain domain)
__attribute__((visibility("default"))) VectorCalculusFieldResult gradient_checked(const std __attribute__((visibility("default"))) VectorCalculusFieldResult gradient_checked(const std __attribute__((visibility("default"))) VectorField gradient(const std const std::vector< std::string > & vars

引用了 checked_geometry_expression(), exterior_derivative_component(), exterior_derivative_term(), LMCAS::InternalInvariant, LMCAS::detail::make_expression_ptr(), LMCAS::detail::node(), LMCAS::detail::normalize_node() , 以及 LMCAS::vars.

被这些函数引用 exterior_derivative_component().

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

◆ exterior_derivative_term()

DifferentialGeometryExprResult LMCAS::anonymous_namespace{differential_geometry.cpp}::exterior_derivative_term ( const std::vector< std::shared_ptr< SymbolicExpr > > & form_coeffs,
const std::vector< std::string > & vars,
const std::map< std::vector< std::size_t >, std::size_t > & coefficient_index,
const std::vector< std::size_t > & output_index,
std::size_t removed,
detail::RewriteBudget & budget,
const std::string & operation )

在文件 differential_geometry.cpp 第 254 行定义.

262 {
263 auto term_budget = budget.context().consume_steps(4, operation);
264 if (!term_budget) return DifferentialGeometryExprResult::failure(term_budget.error());
265
266 auto source_index = output_index;
267 const std::size_t derivative_variable = source_index[removed];
268 source_index.erase(source_index.begin() + static_cast<std::ptrdiff_t>(removed));
269 const auto source = coefficient_index.find(source_index);
270 if (source == coefficient_index.end()) {
273 "exterior derivative could not locate an input coefficient", operation);
274 }
276 detail::node(form_coeffs[source->second]), vars[derivative_variable], budget));
277 if (removed % 2 != 0) {
278 partial = SymbolicExpr::multiply(SymbolicExpr::number(-1), partial);
279 }
280 budget.measure(detail::node(partial));
281 return DifferentialGeometryExprResult::success(std::move(partial));
282} catch (const CasError& error) {
284} catch (const std::bad_alloc&) {
285 return DifferentialGeometryExprResult::failure(CasErrc::ResourceLimit, "allocation failed", operation);
286} catch (const std::length_error& error) {
288} catch (const std::exception& error) {
290}
Result< void > consume_steps(std::size_t amount=1, const std::string &operation={})
ComputationContext & context() const noexcept
std::size_t measure(const std::shared_ptr< const SymbolicNode > &node)
SymbolicNodePtr differentiate_node(const SymbolicNodePtr &node, const std::string &variable, RewriteBudget &budget, const FactsQuery &facts, Domain domain)

引用了 LMCAS::ComputationContext::consume_steps(), LMCAS::detail::RewriteBudget::context(), LMCAS::detail::differentiate_node(), exterior_derivative_term(), LMCAS::Result< std::shared_ptr< SymbolicExpr > >::failure(), LMCAS::InternalInvariant, LMCAS::detail::make_expression_ptr(), LMCAS::detail::RewriteBudget::measure(), LMCAS::detail::node(), LMCAS::Result< std::shared_ptr< SymbolicExpr > >::success() , 以及 LMCAS::vars.

被这些函数引用 exterior_derivative_component() , 以及 exterior_derivative_term().

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

◆ index_combinations()

std::vector< std::vector< std::size_t > > LMCAS::anonymous_namespace{differential_geometry.cpp}::index_combinations ( std::size_t n,
std::size_t k,
std::size_t count )

在文件 differential_geometry.cpp 第 158 行定义.

161{
162 std::vector<std::vector<std::size_t>> combinations;
163 combinations.reserve(count);
164 if (k > n) return combinations;
165 if (k == 0) {
166 combinations.emplace_back();
167 return combinations;
168 }
169
170 std::vector<std::size_t> current(k);
171 std::iota(current.begin(), current.end(), 0);
172 while (true) {
173 combinations.push_back(current);
174 std::size_t position = k;
175 while (position > 0) {
176 --position;
177 if (current[position] < n - k + position) break;
178 }
179 if (position == 0 && current[0] == n - k) break;
180 ++current[position];
181 for (std::size_t i = position + 1; i < k; ++i) {
182 current[i] = current[i - 1] + 1;
183 }
184 }
185 return combinations;
186}

引用了 index_combinations().

被这些函数引用 index_combinations().

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

◆ validate_expr_vector()

Result< void > LMCAS::anonymous_namespace{differential_geometry.cpp}::validate_expr_vector ( const std::vector< std::shared_ptr< SymbolicExpr > > & values,
const std::vector< std::string > & vars,
const std::string & value_name,
const std::string & operation )

在文件 differential_geometry.cpp 第 86 行定义.

90{
91 if (vars.empty()) {
93 "variable list cannot be empty",
94 operation);
95 }
96 if (values.size() != vars.size()) {
98 value_name + " dimension must match variable count",
99 operation);
100 }
101 for (const auto& var : vars) {
102 if (var.empty()) {
104 "variable names cannot be empty",
105 operation);
106 }
107 }
108 for (const auto& value : values) {
109 if (!value || !LMCAS::detail::node(value)) {
111 value_name + " components cannot be null",
112 operation);
113 }
114 }
115 return Result<void>::success();
116}

引用了 LMCAS::Result< T >::failure(), LMCAS::InvalidArgument, LMCAS::detail::node(), LMCAS::Result< T >::success(), validate_expr_vector(), LMCAS::value , 以及 LMCAS::vars.

被这些函数引用 validate_expr_vector().

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

◆ validate_form_coefficients()

Result< std::size_t > LMCAS::anonymous_namespace{differential_geometry.cpp}::validate_form_coefficients ( const std::vector< std::shared_ptr< SymbolicExpr > > & form_coeffs,
int degree,
const std::vector< std::string > & vars,
ComputationContext & context,
const std::string & operation )

在文件 differential_geometry.cpp 第 221 行定义.

227{
228 auto coordinates = validate_form_coordinates(vars, operation);
229 if (!coordinates) return Result<std::size_t>::failure(coordinates.error());
230 if (degree < 0 || static_cast<std::size_t>(degree) > vars.size()) {
233 "form degree must be between zero and the coordinate dimension", operation);
234 }
235 const auto input_count = bounded_binomial(vars.size(),
236 static_cast<std::size_t>(degree),
237 context.limits().max_expansion_terms,
238 operation);
239 if (!input_count) return input_count;
240 if (form_coeffs.size() != input_count.value()) {
243 "form coefficient count does not match degree and dimension", operation);
244 }
245 for (const auto& coeff : form_coeffs) {
246 if (!coeff || !LMCAS::detail::node(coeff)) {
248 "form coefficients cannot be null", operation);
249 }
250 }
251 return input_count;
252}
Result< std::size_t > bounded_binomial(std::size_t n, std::size_t k, std::size_t limit, const std::string &operation)
Result< void > validate_form_coordinates(const std::vector< std::string > &vars, const std::string &operation)
const std::vector< Polynomial< BigInt > > const BigInt ComputationContext & context

引用了 bounded_binomial(), LMCAS::context, LMCAS::Result< T >::failure(), LMCAS::InvalidArgument, LMCAS::detail::node(), validate_form_coefficients(), validate_form_coordinates() , 以及 LMCAS::vars.

被这些函数引用 validate_form_coefficients().

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

◆ validate_form_coordinates()

Result< void > LMCAS::anonymous_namespace{differential_geometry.cpp}::validate_form_coordinates ( const std::vector< std::string > & vars,
const std::string & operation )

在文件 differential_geometry.cpp 第 200 行定义.

202{
203 if (vars.empty()) {
205 "variable list cannot be empty", operation);
206 }
207 for (std::size_t i = 0; i < vars.size(); ++i) {
208 if (vars[i].empty()) {
210 "variable names cannot be empty", operation);
211 }
212 const auto current = vars.begin() + static_cast<std::ptrdiff_t>(i);
213 if (std::find(vars.begin(), current, vars[i]) != current) {
215 "coordinate variables must be unique", operation);
216 }
217 }
218 return Result<void>::success();
219}

引用了 LMCAS::Result< T >::failure(), LMCAS::InvalidArgument, LMCAS::Result< T >::success(), validate_form_coordinates() , 以及 LMCAS::vars.

被这些函数引用 validate_form_coefficients() , 以及 validate_form_coordinates().

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

◆ validate_index()

Result< void > LMCAS::anonymous_namespace{differential_geometry.cpp}::validate_index ( int idx,
std::size_t dim,
const std::string & name,
const std::string & operation )

在文件 differential_geometry.cpp 第 73 行定义.

77{
78 if (idx < 0 || static_cast<std::size_t>(idx) >= dim) {
80 name + " index is out of bounds",
81 operation);
82 }
83 return Result<void>::success();
84}
__attribute__((visibility("default"))) MatrixRankResult matrix_rank_checked(const std __attribute__((visibility("default"))) MatrixRankResult matrix_rank_checked(const std __attribute__((visibility("default"))) ExpressionResult matrix_rref_checked(const std __attribute__((visibility("default"))) ExpressionResult matrix_rref_checked(const std __attribute__((visibility("default"))) MatrixNullspaceResult matrix_nullspace_checked(const std __attribute__((visibility("default"))) MatrixNullspaceResult matrix_nullspace_checked(const std __attribute__((visibility("default"))) MatrixLinearSolveResult matrix_solve_linear_checked(const std __attribute__((visibility("default"))) MatrixLinearSolveResult matrix_solve_linear_checked(const std int dim
__attribute__((visibility("default"))) Result< EqvProfile > eqv_profile_from_name(const std const std::string & name

引用了 LMCAS::dim, LMCAS::Result< T >::failure(), LMCAS::InvalidArgument, LMCAS::name, LMCAS::Result< T >::success() , 以及 validate_index().

被这些函数引用 validate_index().

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

◆ validate_metric_matrix()

Result< std::shared_ptr< const MatrixNode > > LMCAS::anonymous_namespace{differential_geometry.cpp}::validate_metric_matrix ( const std::shared_ptr< SymbolicExpr > & metric,
const std::vector< std::string > * coords,
ComputationContext & context,
const std::string & operation )

在文件 differential_geometry.cpp 第 21 行定义.

26{
27 auto step = context.consume_steps(1, operation);
28 if (!step) return Result<std::shared_ptr<const MatrixNode>>::failure(step.error());
29 if (!metric || !LMCAS::detail::node(metric)) {
32 "metric tensor cannot be null",
33 operation);
34 }
35 auto matrix = std::dynamic_pointer_cast<const MatrixNode>(LMCAS::detail::node(metric));
36 if (!matrix) {
39 "metric tensor must be a matrix",
40 operation);
41 }
42 if (matrix->rows() != matrix->cols()) {
43 return Result<std::shared_ptr<const MatrixNode>>::failure(
45 "metric tensor must be square",
46 operation);
47 }
48 if (coords) {
49 if (coords->empty()) {
50 return Result<std::shared_ptr<const MatrixNode>>::failure(
52 "coordinate list cannot be empty",
53 operation);
54 }
55 if (coords->size() != matrix->rows()) {
56 return Result<std::shared_ptr<const MatrixNode>>::failure(
58 "coordinate count must match metric dimension",
59 operation);
60 }
61 for (const auto& coord : *coords) {
62 if (coord.empty()) {
63 return Result<std::shared_ptr<const MatrixNode>>::failure(
65 "coordinate names cannot be empty",
66 operation);
67 }
68 }
69 }
70 return Result<std::shared_ptr<const MatrixNode>>::success(matrix);
71}

引用了 LMCAS::context, LMCAS::InvalidArgument, LMCAS::detail::node() , 以及 validate_metric_matrix().

被这些函数引用 validate_metric_matrix().

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