Macaulay2 Engine
Loading...
Searching...
No Matches
polyroots.cpp File Reference

rawRoots(...) — univariate polynomial root finder over RR / CC. More...

#include "interface/factory.h"
#include "interface/ring.h"
#include <mps/mps.h>
#include <stdlib.h>
#include "aring-CCC.hpp"
#include "aring.hpp"
#include "error.h"
#include "monoid.hpp"
#include "polyring.hpp"
#include "relem.hpp"
#include "ring.hpp"
#include "ringelem.hpp"

Go to the source code of this file.

Macros

#define register
#define abs(x)
#define max(a, b)

Functions

engine_RawRingElementArrayOrNull rawRoots (const RingElement *p, long prec, int unique)

Detailed Description

rawRoots(...) — univariate polynomial root finder over RR / CC.

Note
AI-generated documentation. Verify against the source before relying on it.

Implementation behind interface/factory.h's rawRoots, the engine entry point reachable from M2 as roots(f) and roots(f, Precision => ...). Given a univariate polynomial over RR_n or CC_n, returns a one-row Matrix of all complex roots (counted with multiplicity); requesting real roots only is a flag that drops conjugate pairs back at the M2 level. Low-degree polynomials use closed-form formulas (degrees 1-4); higher degrees dispatch to MPSolve for arbitrary precision, FLINT's arb complex-roots routine for MPFR precision, or LAPACK eigenvalues of the companion matrix for hardware precision on small inputs.

The MPSolve include neutralises the obsolete C++ register keyword first (#define register then #undef) so the vendored header compiles under C++17. The function is bundled under interface/factory.h for historical reasons — root finding once travelled with the Factory factorisation library, even though the heavy lifting has since moved to MPSolve and FLINT.

See also
interface/factory.h
NAG.hpp
eigen.hpp

Definition in file polyroots.cpp.