LMCAS
Lamina Computer Algebra System
Toggle main menu visibility
载入中...
搜索中...
未找到
mixed_transcendental_deduplication.cpp
浏览该文件的文档.
1
#include "
solve_mixed_transcendental.hpp
"
2
#include <algorithm>
3
#include <cmath>
4
5
namespace
LMCAS
{
6
7
std::vector<lmmc_real_t>
deduplicate_roots
(
8
std::vector<NumericRoot>&
roots
,
9
lmmc_real_t tolerance,
10
int
max_roots)
11
{
12
if
(
roots
.empty()) {
13
return
{};
14
}
15
16
std::sort(
roots
.begin(),
roots
.end(),
17
[](
const
NumericRoot
&
a
,
const
NumericRoot
&
b
) {
18
return a.value < b.value;
19
});
20
lmmc_real_t threshold = 10.0 * tolerance;
21
std::vector<NumericRoot> survivors;
22
survivors.reserve(
roots
.size());
23
survivors.push_back(
roots
[0]);
24
25
for
(
size_t
i = 1; i <
roots
.size(); ++i) {
26
NumericRoot
& last = survivors.back();
27
if
(std::fabs(
roots
[i].
value
- last.
value
) < threshold) {
28
if
(
roots
[i].residual < last.
residual
) {
29
last =
roots
[i];
30
}
31
}
else
{
32
survivors.push_back(
roots
[i]);
33
}
34
}
35
std::vector<lmmc_real_t> result;
36
result.reserve(survivors.size());
37
for
(
const
auto
&
r
: survivors) {
38
result.push_back(
r
.
value
);
39
}
40
41
if
(max_roots > 0 && result.size() >
static_cast<
std::size_t
>
(max_roots)) {
42
result.resize(
static_cast<
size_t
>
(max_roots));
43
}
44
45
return
result;
46
}
47
48
}
LMCAS::Result::value
T & value()
定义
result.hpp:67
LMCAS
定义
assumption.hpp:11
LMCAS::r
__attribute__((visibility("default"))) ComplexSymbolicResult complex_exp_form_checked(std __attribute__((visibility("default"))) ComplexSymbolicResult complex_exp_form_checked(std __attribute__((visibility("default"))) ComplexSymbolicResult complex_trig_form_checked(std __attribute__((visibility("default"))) ComplexSymbolicResult complex_trig_form_checked(std __attribute__((visibility("default"))) ComplexRootsResult solve_complex_nth_root_checked(std __attribute__((visibility("default"))) ComplexRootsResult solve_complex_nth_root_checked(std __attribute__((visibility("default"))) ComplexRootsResult solve_complex_quadratic_checked(std __attribute__((visibility("default"))) ComplexRootsResult solve_complex_quadratic_checked(std std::shared_ptr< SymbolicExpr > r
定义
symbolic_complex.hpp:209
LMCAS::deduplicate_roots
std::vector< lmmc_real_t > deduplicate_roots(std::vector< NumericRoot > &roots, lmmc_real_t tolerance, int max_roots)
定义
mixed_transcendental_deduplication.cpp:7
LMCAS::b
const MultiPoly & b
定义
multivariate_factor.hpp:92
LMCAS::a
__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
定义
vector_calculus_curves.hpp:50
LMCAS::roots
ExprSetResult roots(const ExprPtr &expression, const std::string &variable, ComputationContext &context, const SolveOptions &options)
定义
expr_solving.cpp:80
LMCAS::value
const std::string const ExprPtr & value
定义
expr.hpp:293
LMCAS::NumericRoot::value
lmmc_real_t value
根的数值
定义
solve_strategies.hpp:33
LMCAS::NumericRoot::residual
lmmc_real_t residual
残差(将根代入方程后的绝对值)
定义
solve_strategies.hpp:34
LMCAS::NumericRoot
数值根结果,包含根值,残差和迭代次数.
定义
solve_strategies.hpp:32
solve_mixed_transcendental.hpp
混合超越方程求解:符号预处理 + 自适应根隔离 + Newton-Raphson 精化.
src
mixed_transcendental_deduplication.cpp
生成于
, 为 LMCAS使用
1.18.0