Class PolynomialModule
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
The numpy.polynomial package facade, reachable as polynomial. Its members are
the six basis submodules; each is a first-class object, so Python's import … as P becomes
var P = np.polynomial.polynomial;. (A nested static class cannot model this: C# forbids a member
named polynomial inside a type of that name.)
[ModuleName("np.polynomial")]
public class PolynomialModule
- Inheritance
-
PolynomialModule
- Inherited Members
Remarks
Implemented so far, bit-identical to NumPy 2.4.2 for every dtype NumPy has (values, dtypes, result layouts and error texts; the one dtype divergence is NumSharp's single complex width, #569):
- the evaluation family of every basis —
{p}val,{p}val2d,{p}val3d,{p}grid2d,{p}grid3dand{p}valnd— through one runtime-compiled IL kernel per (basis, dtypes, layout) class, the result laid out as NumPy's last ufunc call lays it out (an F-ordered or permuted x or series keeps its memory order); - the additive family of every basis — the constants
{p}domain/{p}zero/{p}one/{p}x,{p}line,{p}add,{p}sub,{p}trim— and the polyutils substrate (as_series,trimseq,trimcoef,getdomain,mapparms,mapdomain); - the calculus family of every basis —
{p}derand{p}intwith every parameter (m,k,lbnd,scl,axis) — through one runtime-compiled IL kernel per (basis, direction, dtypes) that runs every order in place in one buffer; - the series algebra of every basis —
{p}mulx,{p}mul,{p}div,{p}pow,{p}fromrootsand theX2poly/poly2Xconversions — NumPy's Python statements replayed over a pooled per-thread arena, each statement on the house kernel NumPy's statement runs through (long products byte-exact withNumSharp.Interop.OpenBLAS, bounded-ULP without it); - the Vandermonde family of every basis —
{p}vander,{p}vander2d,{p}vander3d— one whole-array kernel per (basis, dtype, rank), returning NumPy'smoveaxisview; - companion matrices and roots of every basis —
{p}companion,{p}roots(roots of degree ≥ 2 runnp.linalg.eigvals, so they need a LAPACK backend such asNumSharp.Interop.OpenBLAS); - the weight functions
{p}weight, the Chebyshev points and Gauss quadratures (chebpts1,chebpts2,chebgauss,leggauss,laggauss,hermgauss,hermegauss; the last four runnp.linalg.eigvalsh),chebinterpolate, the least-squares fits{p}fit(np.linalg.lstsq) andpolyvalfromroots; - printing: set_default_printstyle(object) and format_float(object, bool);
- the six series classes — NDPolynomial, NDChebyshev, NDLegendre,
NDLaguerre, NDHermite, NDHermiteE (factories Polynomial(object, object, object, string),
Chebyshev(object, object, object, string), …) — NumPy's
ABCPolyBasestatement for statement over the module functions: the arithmetic with Python's operator protocol, evaluation (at a NumPy scalar in scalarmath, as NumPy'sp(x)does), calculus, roots, fits, basis conversion (NumPy's recurrence run at a series) and printing.
The kernels are emitted at run time and have no fallback: under NativeAOT (no dynamic code) a call that reaches one raises PlatformNotSupportedException, and the evaluation, calculus, algebra, Vandermonde and companion paths all reach one.
https://numpy.org/doc/stable/reference/routines.polynomials-package.html
Properties
chebyshev
numpy.polynomial.chebyshev — Chebyshev series of the first kind.
public ChebyshevModule chebyshev { get; }
Property Value
hermite
numpy.polynomial.hermite — physicists' Hermite series.
public HermiteModule hermite { get; }
Property Value
hermite_e
numpy.polynomial.hermite_e — probabilists' Hermite series.
public HermiteEModule hermite_e { get; }
Property Value
laguerre
numpy.polynomial.laguerre — Laguerre series.
public LaguerreModule laguerre { get; }
Property Value
legendre
numpy.polynomial.legendre — Legendre series.
public LegendreModule legendre { get; }
Property Value
polynomial
numpy.polynomial.polynomial — power series c[0] + c[1]*x + c[2]*x**2 + …
(coefficients low degree first; see PowerSeriesModule).
public PowerSeriesModule polynomial { get; }
Property Value
polyutils
numpy.polynomial.polyutils — the helpers every basis is built on (series normalization and the
linear domain maps; see PolyUtilsModule).
public PolyUtilsModule polyutils { get; }
Property Value
Methods
Chebyshev(object, object, object, string)
NumPy's numpy.polynomial.chebyshev.Chebyshev(coef, domain=None, window=None, symbol='x'): a Chebyshev series — a new
NDChebyshev (the class itself; its class methods fit, fromroots, identity,
basis and cast are static members of NDChebyshev).
public NDChebyshev Chebyshev(object coef, object domain = null, object window = null, string symbol = "x")
Parameters
coefobjectThe coefficients, low degree first (see NDChebyshev(object, object, object, string)).
domainobjectThe domain, or null for the class default.
windowobjectThe window, or null for the class default.
symbolstringThe variable's name for printing: a Python identifier.
Returns
- NDChebyshev
The series (dispose it when done).
Remarks
Exceptions
- ValueError
The constructor's errors (an empty or non-1-d series, a domain or window of the wrong length, an invalid symbol).
- TypeError
A null symbol.
- NotSupportedException
Coefficients NumPy keeps as an object array.
Hermite(object, object, object, string)
NumPy's numpy.polynomial.hermite.Hermite(coef, domain=None, window=None, symbol='x'): a (physicists') Hermite series — a new
NDHermite (the class itself; its class methods fit, fromroots, identity,
basis and cast are static members of NDHermite).
public NDHermite Hermite(object coef, object domain = null, object window = null, string symbol = "x")
Parameters
coefobjectThe coefficients, low degree first (see NDHermite(object, object, object, string)).
domainobjectThe domain, or null for the class default.
windowobjectThe window, or null for the class default.
symbolstringThe variable's name for printing: a Python identifier.
Returns
- NDHermite
The series (dispose it when done).
Remarks
Exceptions
- ValueError
The constructor's errors (an empty or non-1-d series, a domain or window of the wrong length, an invalid symbol).
- TypeError
A null symbol.
- NotSupportedException
Coefficients NumPy keeps as an object array.
HermiteE(object, object, object, string)
NumPy's numpy.polynomial.hermite_e.HermiteE(coef, domain=None, window=None, symbol='x'): a (probabilists') HermiteE series — a new
NDHermiteE (the class itself; its class methods fit, fromroots, identity,
basis and cast are static members of NDHermiteE).
public NDHermiteE HermiteE(object coef, object domain = null, object window = null, string symbol = "x")
Parameters
coefobjectThe coefficients, low degree first (see NDHermiteE(object, object, object, string)).
domainobjectThe domain, or null for the class default.
windowobjectThe window, or null for the class default.
symbolstringThe variable's name for printing: a Python identifier.
Returns
- NDHermiteE
The series (dispose it when done).
Remarks
Exceptions
- ValueError
The constructor's errors (an empty or non-1-d series, a domain or window of the wrong length, an invalid symbol).
- TypeError
A null symbol.
- NotSupportedException
Coefficients NumPy keeps as an object array.
Laguerre(object, object, object, string)
NumPy's numpy.polynomial.laguerre.Laguerre(coef, domain=None, window=None, symbol='x'): a Laguerre series — a new
NDLaguerre (the class itself; its class methods fit, fromroots, identity,
basis and cast are static members of NDLaguerre).
public NDLaguerre Laguerre(object coef, object domain = null, object window = null, string symbol = "x")
Parameters
coefobjectThe coefficients, low degree first (see NDLaguerre(object, object, object, string)).
domainobjectThe domain, or null for the class default.
windowobjectThe window, or null for the class default.
symbolstringThe variable's name for printing: a Python identifier.
Returns
- NDLaguerre
The series (dispose it when done).
Remarks
Exceptions
- ValueError
The constructor's errors (an empty or non-1-d series, a domain or window of the wrong length, an invalid symbol).
- TypeError
A null symbol.
- NotSupportedException
Coefficients NumPy keeps as an object array.
Legendre(object, object, object, string)
NumPy's numpy.polynomial.legendre.Legendre(coef, domain=None, window=None, symbol='x'): a Legendre series — a new
NDLegendre (the class itself; its class methods fit, fromroots, identity,
basis and cast are static members of NDLegendre).
public NDLegendre Legendre(object coef, object domain = null, object window = null, string symbol = "x")
Parameters
coefobjectThe coefficients, low degree first (see NDLegendre(object, object, object, string)).
domainobjectThe domain, or null for the class default.
windowobjectThe window, or null for the class default.
symbolstringThe variable's name for printing: a Python identifier.
Returns
- NDLegendre
The series (dispose it when done).
Remarks
Exceptions
- ValueError
The constructor's errors (an empty or non-1-d series, a domain or window of the wrong length, an invalid symbol).
- TypeError
A null symbol.
- NotSupportedException
Coefficients NumPy keeps as an object array.
Polynomial(object, object, object, string)
NumPy's numpy.polynomial.polynomial.Polynomial(coef, domain=None, window=None, symbol='x'): a power series — a new
NDPolynomial (the class itself; its class methods fit, fromroots, identity,
basis and cast are static members of NDPolynomial).
public NDPolynomial Polynomial(object coef, object domain = null, object window = null, string symbol = "x")
Parameters
coefobjectThe coefficients, low degree first (see NDPolynomial(object, object, object, string)).
domainobjectThe domain, or null for the class default.
windowobjectThe window, or null for the class default.
symbolstringThe variable's name for printing: a Python identifier.
Returns
- NDPolynomial
The series (dispose it when done).
Remarks
Exceptions
- ValueError
The constructor's errors (an empty or non-1-d series, a domain or window of the wrong length, an invalid symbol).
- TypeError
A null symbol.
- NotSupportedException
Coefficients NumPy keeps as an object array.
set_default_printstyle(object)
Sets how the series classes print their terms (NumPy's numpy.polynomial.set_default_printstyle):
"unicode" writes superscripts and subscripts (1.0 + 2.0·x + 3.0·x², T₁(x)),
"ascii" plain text (1.0 + 2.0 x + 3.0 x**2, T_1(x)).
public void set_default_printstyle(object style)
Parameters
styleobject"unicode"or"ascii", case-sensitive; a one-elementU/StringDTypearray holding one of them is read as its element, as NumPy's==reads it.
Remarks
The style is ONE process-wide setting, like NumPy's class attribute ABCPolyBase._use_unicode
(not scoped to a thread). NumPy's default is os.name != 'nt': ASCII on Windows, Unicode elsewhere —
NumSharp starts from the same platform rule.
The series classes read it in str(p) (__str__(), ToString());
format(p, "ascii") / "unicode" (__format__(string)) choose per call.
https://numpy.org/doc/stable/reference/generated/numpy.polynomial.set_default_printstyle.html
Exceptions
- ValueError
Any other style:
Unsupported format string '{str(style)}'. Valid options are 'ascii' and 'unicode'— also for a number, null ('None'), bytes or a list; an empty array or one of two or more elements raises NumPy's truth-value ValueError instead.