Class NDPolyClass
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
NumPy's class object of one numpy.polynomial series class (Chebyshev, Polynomial, ...): the class
attributes domain, window, maxpower and basis_name under
NumPy's names, and the class's __name__ / __module__. Reached as
NDChebyshev.Class (NumPy's Chebyshev) and as __class__ of a series (Python's
p.class): NumPy's Chebyshev.domain is NDChebyshev.Class.domain.
public sealed class NDPolyClass
- Inheritance
-
NDPolyClass
- Inherited Members
Remarks
Why an object and not statics. C# cannot declare a static NDChebyshev.domain beside the
instance p.domain: the static would hide the instance member, and p.domain would stop compiling.
The instance attributes keep NumPy's names on the series; the class attributes keep them here.
Shared, process-wide state. There is one object per class. Assigning domain,
window or maxpower changes every series of the class that has none of its own,
on every thread, from then on (NumPy's Chebyshev.domain = ... is a global change too). The class
methods, a convert to the class and every constructor without a domain read the attribute at the moment
they run.
The class itself. Wherever NumSharp takes a class as a Type
(convert(kind: ...)), the object converts implicitly: p.convert(kind: q.__class__) is NumPy's
p.convert(kind=q.__class__). The class methods are the static members of the C# class
(NDChebyshev.fit(...)), not members of this object.
Properties
__module__
NumPy's Chebyshev.module: the module that defines the class
('numpy.polynomial.chebyshev'; the power series' is 'numpy.polynomial.polynomial').
public string __module__ { get; }
Property Value
__name__
NumPy's Chebyshev.name: the class name NumPy prints in repr(p) and in Python's operator
errors ('Chebyshev', never the C# name NDChebyshev).
public string __name__ { get; }
Property Value
__qualname__
NumPy's Chebyshev.qualname: the class name (the classes are not nested, so it equals
__name__).
public string __qualname__ { get; }
Property Value
basis_name
NumPy's class attribute Chebyshev.basis_name: the letter the default term printers write (T,
P, L, H, He); null for the power series, which prints powers of the symbol instead.
Read-only: NumPy's attribute is writable so that a subclass can name its basis, and NumSharp's classes are
sealed.
public string basis_name { get; }
Property Value
domain
NumPy's class attribute Chebyshev.domain: [-1, 1] ([0, 1] for Laguerre), a float64 array
created on first read. Every series of the class created without a domain reads THIS object
(p.domain returns it itself, NumPy's p.domain is Chebyshev.domain), so writing into its elements
changes all of them. Assigning stores a view of the given array, which those series read from then on.
public NDArray domain { get; set; }
Property Value
Remarks
The array lives as long as the process and holds one extra buffer reference, so a caller's Dispose() of
it (using var d = p.domain;) cannot free memory every later series reads. An assignment keeps the
previous array alive for the same reason (series or callers may still hold it); assigning the current array
back changes nothing, so the attribute keeps its identity, as in NumPy.
Exceptions
- ArgumentNullException
Assigning null (NumPy would store None, and every series reading the attribute would then fail).
maxpower
NumPy's class attribute Chebyshev.maxpower: the largest power pow allows on a series of the
class that has no maxpower of its own — a boxed Python int, 100 until assigned; null
is None (no limit). Any value Python can compare with an int works (NumPy's power > maxpower decides).
public object maxpower { get; set; }
Property Value
window
NumPy's class attribute Chebyshev.window: [-1, 1] ([0, 1] for Laguerre), shared and
assigned like domain.
public NDArray window { get; set; }
Property Value
Exceptions
- ArgumentNullException
Assigning null.
Methods
ToString()
Python's str(Chebyshev) / repr(Chebyshev):
<class 'numpy.polynomial.chebyshev.Chebyshev'> — also what NumPy's truediv and
format errors print for the class.
public override string ToString()
Returns
- string
The text.
Operators
implicit operator Type(NDPolyClass)
The class as the C# Type NumSharp takes where NumPy takes a class: p.convert(kind:
NDLegendre.Class) and p.convert(kind: q.class) are NumPy's p.convert(kind=Legendre) and
p.convert(kind=q.class).
public static implicit operator Type(NDPolyClass cls)
Parameters
clsNDPolyClassThe class object, or null.
Returns
- Type
The C# type (
typeof(NDLegendre), ...), or null for null (so a null class keeps meaning "this series' class" inconvert).