LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
LMCAS::detail::complex_root 命名空间参考

命名空间

namespace  anonymous_namespace{complex_root_projection.cpp}
namespace  anonymous_namespace{complex_root_rectangles.cpp}
namespace  anonymous_namespace{complex_root_winding.cpp}

类

struct  CoordinateProjections
struct  RationalRectangle
struct  RectangleCount

类型定义

using Poly = Polynomial<Rational>

函数

Poly clear_denominators (Poly polynomial)
Result< CoordinateProjections > coordinate_projections (const Poly &polynomial, ComputationContext &context, const std::string &operation)
Result< RectangleCount > count_rectangle_roots (const Poly &polynomial, const RationalRectangle &rectangle, ComputationContext &context, const std::string &operation)
Result< std::vector< ComplexIsolation > > isolate_nonreal_roots (const Poly &polynomial, std::size_t complex_count, ComputationContext &context, const std::string &operation)
int rational_sign (const Rational &value)
Result< void > refine_interval (const Poly &polynomial, RationalInterval &interval, ComputationContext &context, const std::string &operation)
Poly scale_poly (Poly polynomial, const Rational &scalar)

类说明

◆ LMCAS::detail::complex_root::CoordinateProjections

struct LMCAS::detail::complex_root::CoordinateProjections

在文件 complex_root_isolation.hpp 第 23 行定义.

LMCAS::detail::complex_root::CoordinateProjections 的协作图:
类成员
Poly imaginary
Poly real

◆ LMCAS::detail::complex_root::RationalRectangle

struct LMCAS::detail::complex_root::RationalRectangle

在文件 complex_root_isolation.hpp 第 11 行定义.

LMCAS::detail::complex_root::RationalRectangle 的协作图:
类成员
Rational imaginary_lower
Rational imaginary_upper
Rational real_lower
Rational real_upper

◆ LMCAS::detail::complex_root::RectangleCount

struct LMCAS::detail::complex_root::RectangleCount

在文件 complex_root_isolation.hpp 第 18 行定义.

LMCAS::detail::complex_root::RectangleCount 的协作图:
类成员
bool boundary_clear = false
size_t count = 0

类型定义说明

◆ Poly

在文件 complex_root_isolation.hpp 第 9 行定义.

函数说明

◆ clear_denominators()

Poly LMCAS::detail::complex_root::clear_denominators ( Poly polynomial)

在文件 complex_root_projection.cpp 第 16 行定义.

16 {
17 BigInt common_denominator(1);
18 for (const auto& coefficient : polynomial.coeffs) {
19 common_denominator *= coefficient.get_denominator();
20 }
21 for (auto& coefficient : polynomial.coeffs) {
22 coefficient = Rational(
23 coefficient.get_numerator() *
24 (common_denominator / coefficient.get_denominator()));
25 }
26 polynomial.trim();
27 return polynomial;
28}
std::vector< CoeffType > coeffs
系数数组,coeffs[i] 为 x^i 的系数
void trim()
去除高次零系数

引用了 clear_denominators(), LMCAS::Polynomial< CoeffType >::coeffs , 以及 LMCAS::Polynomial< CoeffType >::trim().

被这些函数引用 clear_denominators() , 以及 LMCAS::detail::anonymous_namespace{complex_root_isolation.cpp}::isolate_unfactored().

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

◆ coordinate_projections()

Result< CoordinateProjections > LMCAS::detail::complex_root::coordinate_projections ( const Poly & polynomial,
ComputationContext & context,
const std::string & operation )

在文件 complex_root_projection.cpp 第 284 行定义.

286 {
287 const ComplexBivariate parts = complex_bivariate_parts(polynomial);
288 auto real = sylvester_resultant(
289 coefficients_in_y(parts.real, "_re"),
290 coefficients_in_y(parts.imaginary, "_re"),
291 "_re", context, operation + ".resultant.real");
293 auto imaginary = sylvester_resultant(
294 coefficients_in_x(parts.real, "_im"),
295 coefficients_in_x(parts.imaginary, "_im"),
296 "_im", context, operation + ".resultant.imaginary");
297 if (!imaginary) return Result<CoordinateProjections>::failure(imaginary.error());
298 if (real.value().degree() <= 0 || imaginary.value().degree() <= 0) {
301 "complex coordinate resultant was identically zero", operation);
302 }
303 return Result<CoordinateProjections>::success(CoordinateProjections{
304 real.value().square_free_part().make_monic(),
305 imaginary.value().square_free_part().make_monic()});
306}
CasError & error()
static Result failure(CasErrc code, std::string message, std::string operation={})
static Result success(T value)
ComputationContext const std::string & operation
std::size_t std::size_t ComputationContext & context
ExprResult real(const ExprPtr &expression, ComputationContext &context)

引用了 LMCAS::detail::context, coordinate_projections(), LMCAS::Result< T >::error(), LMCAS::Result< T >::failure(), LMCAS::InternalInvariant, LMCAS::detail::operation, LMCAS::real(), LMCAS::Result< T >::success() , 以及 LMCAS::Result< T >::value().

被这些函数引用 coordinate_projections() , 以及 LMCAS::detail::complex_root::anonymous_namespace{complex_root_rectangles.cpp}::prepare_projection_grid().

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

◆ count_rectangle_roots()

Result< RectangleCount > LMCAS::detail::complex_root::count_rectangle_roots ( const Poly & polynomial,
const RationalRectangle & rectangle,
ComputationContext & context,
const std::string & operation )

在文件 complex_root_winding.cpp 第 232 行定义.

234 {
235 auto step = context.consume_steps(1, operation);
236 if (!step) return Result<RectangleCount>::failure(step.error());
237 const auto edges = rectangle_edges(polynomial, rectangle);
238 for (const auto& [real, imaginary] : edges) {
239 auto clear = edge_is_clear(real, imaginary, context, operation);
240 if (!clear) return Result<RectangleCount>::failure(clear.error());
241 if (!clear.value()) {
243 }
244 }
245 BigInt shear_magnitude(0);
246 int shear_direction = 1;
247 while (true) {
249 if (!step) return Result<RectangleCount>::failure(step.error());
250 auto bits = context.require_integer_bits(shear_magnitude.bit_length(), operation);
251 if (!bits) return Result<RectangleCount>::failure(bits.error());
252 const Rational shear(shear_direction > 0 ? shear_magnitude : -shear_magnitude);
253 if (shear_is_valid(edges, shear)) {
254 return count_sheared_edges(edges, shear, polynomial.degree(), context, operation);
255 }
256 if (shear_direction > 0) {
257 shear_direction = -1;
258 if (shear_magnitude.is_zero()) shear_magnitude = BigInt(1);
259 } else {
260 shear_direction = 1;
261 shear_magnitude += BigInt(1);
262 }
263 }
264}
Result< void > consume_steps(std::size_t amount=1, const std::string &operation={})
Result< void > require_integer_bits(std::size_t amount, const std::string &operation={}) const
int degree() const
获取多项式的次数

引用了 LMCAS::detail::context, count_rectangle_roots(), LMCAS::Polynomial< CoeffType >::degree(), LMCAS::Result< T >::failure(), LMCAS::detail::operation, LMCAS::real() , 以及 LMCAS::Result< T >::success().

被这些函数引用 count_rectangle_roots() , 以及 LMCAS::detail::complex_root::anonymous_namespace{complex_root_rectangles.cpp}::isolate_grid_row().

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

◆ isolate_nonreal_roots()

Result< std::vector< ComplexIsolation > > LMCAS::detail::complex_root::isolate_nonreal_roots ( const Poly & polynomial,
std::size_t complex_count,
ComputationContext & context,
const std::string & operation )

在文件 complex_root_rectangles.cpp 第 211 行定义.

213 {
214 auto prepared = prepare_projection_grid(polynomial, context, operation);
215 if (!prepared) return Result<std::vector<ComplexIsolation>>::failure(prepared.error());
216 auto& grid = prepared.value();
217 auto conjugate = certify_conjugate_projections(grid, complex_count, context, operation);
218 if (!conjugate) return Result<std::vector<ComplexIsolation>>::failure(conjugate.error());
219 const Rational bound = strict_cauchy_root_bound(polynomial);
220 grid.real_bands = projection_bands(grid.real_roots, bound);
221 grid.imaginary_bands = projection_bands(grid.imaginary_roots, bound);
222 std::vector<ComplexIsolation> roots;
223 roots.reserve(complex_count);
224 for (std::size_t real_index = 0; real_index < grid.real_bands.size(); ++real_index) {
225 auto isolated = isolate_grid_row(polynomial, grid, real_index, roots, context, operation);
226 if (!isolated) return Result<std::vector<ComplexIsolation>>::failure(isolated.error());
227 }
228 if (roots.size() != complex_count) {
231 "projection-band rectangles did not cover every non-real root", operation);
232 }
233 std::sort(roots.begin(), roots.end(),
234 [](const ComplexIsolation& left, const ComplexIsolation& right) {
235 if (left.real_projection.root_index != right.real_projection.root_index) {
236 return left.real_projection.root_index < right.real_projection.root_index;
237 }
238 return left.imaginary_projection.root_index < right.imaginary_projection.root_index;
239 });
240 return Result<std::vector<ComplexIsolation>>::success(std::move(roots));
241}
Rational strict_cauchy_root_bound(const Polynomial< Rational > &polynomial)
const ExprPtr & right
ExprSetResult roots(const ExprPtr &expression, const std::string &variable, ComputationContext &context, const SolveOptions &options)

引用了 LMCAS::detail::context, LMCAS::detail::ComplexIsolation::imaginary_projection, LMCAS::InternalInvariant, isolate_nonreal_roots(), LMCAS::detail::operation, LMCAS::right, LMCAS::detail::ExactRealAlgebraic::root_index, LMCAS::roots() , 以及 LMCAS::detail::strict_cauchy_root_bound().

被这些函数引用 isolate_nonreal_roots() , 以及 LMCAS::detail::anonymous_namespace{complex_root_isolation.cpp}::isolate_unfactored().

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

◆ rational_sign()

int LMCAS::detail::complex_root::rational_sign ( const Rational & value)

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

8 {
9 if (value < Rational(0)) return -1;
10 if (value > Rational(0)) return 1;
11 return 0;
12}
const std::string const ExprPtr & value

引用了 rational_sign() , 以及 LMCAS::value.

被这些函数引用 LMCAS::detail::complex_root::anonymous_namespace{complex_root_winding.cpp}::pole_index(), rational_sign() , 以及 refine_interval().

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

◆ refine_interval()

Result< void > LMCAS::detail::complex_root::refine_interval ( const Poly & polynomial,
RationalInterval & interval,
ComputationContext & context,
const std::string & operation )

在文件 complex_root_rectangles.cpp 第 14 行定义.

18 {
19 auto step = context.consume_steps(1, operation);
20 if (!step) return step;
21 if (interval.first == interval.second) return Result<void>::success();
22 const Rational midpoint =
23 (interval.first + interval.second) / Rational(2);
24 const Rational middle_value = polynomial.eval(midpoint);
25 if (middle_value == Rational(0)) {
26 interval = {midpoint, midpoint};
27 return Result<void>::success();
28 }
29 const int lower_sign = rational_sign(polynomial.eval(interval.first));
30 if (lower_sign == 0) {
31 interval.second = interval.first;
32 } else if (lower_sign != rational_sign(middle_value)) {
33 interval.second = midpoint;
34 } else {
35 interval.first = midpoint;
36 }
37 return Result<void>::success();
38}
CoeffType eval(const CoeffType &val) const
对多项式求值(Horner 法)
ExprResult interval(ExprPtr lower, ExprPtr upper, bool lower_closed, bool upper_closed)

引用了 LMCAS::detail::context, LMCAS::Polynomial< CoeffType >::eval(), LMCAS::interval(), LMCAS::detail::operation, rational_sign(), refine_interval() , 以及 LMCAS::Result< T >::success().

被这些函数引用 refine_interval(), LMCAS::detail::complex_root::anonymous_namespace{complex_root_winding.cpp}::refine_pole_interval(), LMCAS::detail::complex_root::anonymous_namespace{complex_root_rectangles.cpp}::refine_projection_interval() , 以及 LMCAS::detail::complex_root::anonymous_namespace{complex_root_rectangles.cpp}::separate_imaginary_axis().

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

◆ scale_poly()

Poly LMCAS::detail::complex_root::scale_poly ( Poly polynomial,
const Rational & scalar )

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

8 {
9 for (auto& coefficient : polynomial.coeffs) {
10 coefficient = coefficient * scalar;
11 }
12 polynomial.trim();
13 return polynomial;
14}

引用了 LMCAS::Polynomial< CoeffType >::coeffs, scale_poly() , 以及 LMCAS::Polynomial< CoeffType >::trim().

被这些函数引用 LMCAS::detail::complex_root::anonymous_namespace{complex_root_winding.cpp}::count_sheared_edges(), LMCAS::detail::complex_root::anonymous_namespace{complex_root_projection.cpp}::resultant_determinant(), scale_poly() , 以及 LMCAS::detail::complex_root::anonymous_namespace{complex_root_winding.cpp}::shear_is_valid().

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