Class TensorEngine
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
The matrix products beyond dot / matmul - inner, vdot, vecdot, matvec,
vecmat - NumPy's C core: each asks Blas first and falls back to NumSharp's managed kernels, so
a backend changes which implementation runs and never whether an answer exists.
public abstract class TensorEngine
- Inheritance
-
TensorEngine
- Derived
- Inherited Members
Remarks
Every member reads Blas into a LOCAL before using it. That is not style -
the property is settable and a concurrent OpenBlasEngine.Disable() turns a test-then-call
into a null dereference (measured at ~2 % of calls; see docs/stale-docs/GEMM_PARITY.md section 9).
numpy.linalg's factorisations are not here: they are the Linalg sub-engine's
(LinalgEngine), whose default, DefaultLinalgEngine, runs NumPy's
_linalg.py statements over ten kernels that ask the same Blas property. The ten
_umath_linalg members this class shipped in 0.70.0 (Cholesky, Det, Slogdet, Eig, Eigh, Inv, Solve,
Lstsq, Qr, Svd) moved there in 0.80.0 (the np-layer dtype plan's phase PE, E2) as
DefaultLinalgEngine.CholeskyKernel ... SvdKernel.
Properties
Blas
An external BLAS this engine delegates its matrix products to, or null (the default) to compute them with NumSharp's own managed SIMD kernels.
public IBlasBackend Blas { get; set; }
Property Value
Remarks
NumSharp.Core is 100 % managed C# and never assigns this. It is set by an optional
package — NumSharp.Interop.OpenBLAS does it from a [ModuleInitializer], so
referencing that package is the whole opt-in — and can be cleared again by assigning
null. A backend only answers for what it implements (see
IBlasBackend); everything else falls back to the managed kernels.
The property belongs to this engine instance, which every array bound to it shares, so assigning it reaches those arrays, existing ones included. An engine assigned to Default later starts with its own value (null unless set): copy this one over to keep an installed backend.
Default
The engine an array binds when nothing else decides, and the engine of the np.* functions that take no array (np.zeros, np.arange, np.linspace, np.fft.fftfreq, the window functions): every array created without an engine of its own binds the engine this property returns at that moment. Assign an engine (a DefaultEngine subclass that overrides some members, typically) to have every array created from then on compute on it.
public static TensorEngine Default { get; set; }
Property Value
- TensorEngine
The assigned engine, or the built-in DefaultEngine (the instance
BackendFactory.GetEngine<DefaultEngine>()returns); never null. Assigning null restores the built-in engine. GetEngine(BackendType) returns this property.
Remarks
An array binds its engine once, when it is created, so an assignment reaches the arrays created afterwards and every array that already exists keeps the engine it bound (assign TensorEngine to move one). An engine binds the results it computes to itself and a view binds its source's engine, so the arrays derived from an existing array stay on that array's engine after the default changes.
Footgun: Blas, Linalg and Fft belong to each engine instance, and a
new engine starts with none of what was assigned to the previous default. NumSharp.Interop.OpenBLAS
installs its backend on the engine that is the default when the package loads, so an engine assigned later
computes its matrix products with the managed kernels until its own Blas is set: copy it over
(engine.Blas = TensorEngine.Default.Blas;) before the assignment.
Process-wide and not synchronized: an array created on another thread while the property changes binds either engine. Assign it at startup, or around single-threaded work (tests that assign it must not run in parallel with tests that create arrays).
Fft
numpy.fft's functions for the arrays bound to this engine: every np.fft transform and frequency helper
calls one member of this sub-engine (fftfreq / rfftfreq, which take no array, through the
default engine). DefaultFftEngine (NumPy's _pocketfft.py statements over kernels that run
NumSharp's managed pocketfft port) until something else is assigned.
public FftEngine Fft { get; set; }
Property Value
- FftEngine
The assigned engine, or the shared DefaultFftEngine; never null. Assigning null restores the default.
Remarks
Assign a DefaultFftEngine subclass to compute the transforms another way (MKL, FFTW, cuFFT)
while NumPy's length, norm, axis and out= checks and the N-D, real and Hermitian compositions stay
(override its protected virtual kernels), or an FftEngine of your own to replace whole
functions. fftshift and ifftshift are not members: they roll the array object.
The property belongs to this engine instance, which every array bound to it shares, so an assignment reaches
every array bound to the engine, existing ones included, from the next np.fft call on: each call reads
the property once, so one already running finishes with the engine it read. Do not assign it while another
thread runs np.fft functions whose results you compare: they may straddle the change. An engine assigned to
Default later starts with the shared default here.
Linalg
numpy.linalg's functions for the arrays bound to this engine: every np.linalg function calls one member
of this sub-engine (a subclass operand handed in as its plain view). DefaultLinalgEngine
(NumPy's
_linalg.py statements over kernels that ask Blas first) until something else is
assigned.
public LinalgEngine Linalg { get; set; }
Property Value
- LinalgEngine
The assigned engine, or the shared DefaultLinalgEngine; never null. Assigning null restores the default.
Remarks
You rarely need this. A LAPACK backend reaches the factorisations through Blas already
(the Try* members of IBlasBackend), which is how NumSharp.Interop.OpenBLAS serves
them. Assign a DefaultLinalgEngine subclass to compute a factorisation another way while NumPy's
argument checks, dtype rules and result layouts stay (override its protected virtual kernels), or a
LinalgEngine of your own to replace whole functions.
The property belongs to this engine instance, which every array bound to it shares, so an assignment reaches
every array bound to the engine, existing ones included, from the next np.linalg call on: each call
reads the property once, so one already running finishes with the engine it read. Do not assign it while
another thread runs np.linalg functions whose results you compare: they may straddle the change. An engine
assigned to Default later starts with the shared default here.
Methods
ACos(NDArray, DType, NDArray, NDArray)
public abstract NDArray ACos(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
ACosh(NDArray, DType, NDArray, NDArray)
public abstract NDArray ACosh(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
AMax(NDArray, int?, DType, bool)
public abstract NDArray AMax(NDArray nd, int? axis = null, DType dtype = null, bool keepdims = false)
Parameters
Returns
AMin(NDArray, int?, DType, bool)
public abstract NDArray AMin(NDArray nd, int? axis = null, DType dtype = null, bool keepdims = false)
Parameters
Returns
ASin(NDArray, DType, NDArray, NDArray)
public abstract NDArray ASin(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
ASinh(NDArray, DType, NDArray, NDArray)
public abstract NDArray ASinh(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
ATan(NDArray, DType, NDArray, NDArray)
public abstract NDArray ATan(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
ATan2(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray ATan2(NDArray y, NDArray x, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
ATanh(NDArray, DType, NDArray, NDArray)
public abstract NDArray ATanh(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Abs(NDArray, DType, NDArray, NDArray)
public abstract NDArray Abs(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Add(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray Add(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
All(NDArray)
NumPy's np.all(a) over every element: logical_and.reduce of the elements' truth values (a text
element reads true when non-empty), True for an empty array (the identity).
public abstract bool All(NDArray nd)
Parameters
ndNDArrayThe array (any dtype, any layout).
Returns
- bool
Whether every element is true.
Exceptions
- SystemError
A
Uarray holding a unit above U+10FFFF (NumPy's bool cast of the text).
All(NDArray, int[], NDArray, bool, NDArray)
NumPy's np.all with a tuple axis, the whole call: the reduce prologue (every axis,
then a repeat), the text truth route, the masked reduction and the out= store.
public abstract NDArray All(NDArray a, int[] axis, NDArray @out, bool keepdims = false, NDArray where = null)
Parameters
aNDArrayThe array (any dtype, any layout).
axisint[]The reduced axes (an empty tuple reduces nothing).
outNDArrayNumPy's
out=, or null for a fresh result.keepdimsboolWhether the reduced axes stay with length one.
whereNDArrayNumPy's
where=bool mask, or null.
Returns
- NDArray
outitself when given; otherwise the fresh bool array, read-only when 0-d.
Remarks
New in 0.80.0 (the np-layer dtype plan, P1b).
Exceptions
- ArgumentNullException
aoraxisis null.- ValueError
A read-only or misshapen
out, a mask with more axes thana, or an axis that appears twice (duplicate value in 'axis').- ArgumentException
whereis not a bool array, oroutdoes not have the result's shape.- AxisError
An axis is out of range.
- IncorrectShapeException
whereoroutdoes not broadcast againsta.- SystemError
A
Uarray holding a unit above U+10FFFF.
All(NDArray, int[], bool)
np.all over a tuple of axes: every axis checked, then a repeat refused, then the boolean reduction
(an EMPTY tuple reduces nothing and returns the truth values in the input's shape).
public abstract NDArray<bool> All(NDArray nd, int[] axis, bool keepdims = false)
Parameters
ndNDArrayThe array (any dtype, any layout).
axisint[]The reduced axes (negative values count from the end).
keepdimsboolWhether the reduced axes stay with length one.
Returns
Remarks
Abstract since 0.80.0 (the np-layer dtype plan's P1b): DefaultEngine had it as its own
member, which the public np.all reached by a type test.
Exceptions
- ArgumentNullException
ndoraxisis null.- AxisError
An axis is out of range (the first one, in the tuple's order).
- ValueError
An axis appears twice (
duplicate value in 'axis').- SystemError
A
Uarray holding a unit above U+10FFFF.
All(NDArray, int?, NDArray, bool, NDArray)
NumPy's np.all(a, axis, out, keepdims, *, where), the whole call: logical_and.reduce(a, axis, bool,
out, keepdims=keepdims, where=where) — the reduce prologue in NumPy's order, the text truth route, the masked
reduction and the out= store.
public abstract NDArray All(NDArray a, int? axis, NDArray @out, bool keepdims = false, NDArray where = null)
Parameters
aNDArrayThe array (any dtype, any layout).
axisint?The reduced axis, or null for every axis (NumPy's
axis=None).outNDArrayNumPy's
out=: an array of the result's shape and any dtype that receives the bool result with unsafe casting, or null for a fresh result.keepdimsboolWhether the reduced axes stay with length one.
whereNDArrayNumPy's
where=: a bool mask that broadcasts toa's shape (masked-off elements count as True, the identity), or null for no mask.
Returns
- NDArray
outitself when given; otherwise a fresh bool array, read-only when 0-d (NumPy's scalar).
Remarks
The engine owns NumPy's whole call, dtype decisions included (the np-layer dtype plan, P1b): the public
np.all only calls this (the declaration below dispatches a subclass operand to its method). New in
0.80.0. A bare null axis is
ambiguous with the tuple member below: pass a typed int?.
Exceptions
- ArgumentNullException
ais null.- ValueError
outis read-only (output array is read-only, checked first), has the wrong rank, or cannot hold the result; orwherehas more axes thanaor would make it stretch (NumPy's reduction-iterator texts).- ArgumentException
whereis not a bool array (NumPy's TypeError text: the mask must cast to bool under thesaferule); oroutdoes not have the result's shape.- AxisError
axisis out of range.- IncorrectShapeException
whereoroutdoes not broadcast againsta.- SystemError
A
Uarray holding a unit above U+10FFFF.
All(NDArray, int?, bool)
np.all along one axis, or over every axis when axis is null: the boolean reduction
without out= or where=, a fresh array the caller may wrap as NumPy's scalar.
public abstract NDArray<bool> All(NDArray nd, int? axis, bool keepdims = false)
Parameters
ndNDArrayThe array (any dtype, any layout).
axisint?The reduced axis (negative counts from the end; a 0-d array accepts 0 and -1), or null for every axis.
keepdimsboolWhether the reduced axes stay with length one.
Returns
- NDArray<bool>
The bool result, laid out as NumPy's reduction allocates it. Over every axis it is a fresh, writeable owner (a 0-d array without
keepdims); the publicnp.alloverloads decide whether a 0-d result becomes NumPy's read-only scalar.
Remarks
keepdims and the null axis were added to the contract in 0.80.0 (the np-layer dtype
plan's P1b, decision D2: widened in place; the member took one int axis before).
Exceptions
- ArgumentNullException
ndis null.- AxisError
axisis out of range.- SystemError
A
Uarray holding a unit above U+10FFFF.
AllClose(NDArray, NDArray, double, double, bool)
public abstract bool AllClose(NDArray a, NDArray b, double rtol = 1E-05, double atol = 1E-08, bool equal_nan = false)
Parameters
Returns
Angle(NDArray, bool)
NumPy's np.angle: the counterclockwise angle of each element from the positive real axis, in
radians in (-pi, pi], or in degrees when deg is set. A complex element gives
arctan2(z.imag, z.real); a real one gives NumPy's arctan2(0, z): 0 for a positive value or
+0, pi for a negative value or -0, NaN for NaN.
public abstract NDArray Angle(NDArray z, bool deg = false)
Parameters
zNDArrayThe input, a plain array:
np.angledecides thenumpy.matrixclass before it calls this member, so an override never sees a matrix operand.degboolReturn degrees (the radians multiplied by
180 / piin the result's own dtype).
Returns
- NDArray
A new array of
z's shape: float64 for complex128; for a real input the float tier of NumPy'sarctan2(0, z)with a weak 0 (float16 for int8 / uint8 / float16, float32 for int16 / uint16 / char / float32, float64 for bool, the wider integers, float64 and decimal).
Remarks
NumPy writes angle in Python (numpy/lib/_function_base_impl.py); DefaultEngine's
override runs those statements. An override replaces np.angle for every array whose engine it is,
so it must keep NumPy's dtype tiers and the real-input values above.
Exceptions
- TypeError
zholds text (S,UorStringDType): NumPy'sarctan2has no string loop, and the text namesarctan2as NumPy's does.
Any(NDArray)
NumPy's np.any(a) over every element: logical_or.reduce of the elements' truth values (a text
element reads true when non-empty), False for an empty array (the identity).
public abstract bool Any(NDArray nd)
Parameters
ndNDArrayThe array (any dtype, any layout).
Returns
- bool
Whether any element is true.
Exceptions
- SystemError
A
Uarray holding a unit above U+10FFFF (NumPy's bool cast of the text).
Any(NDArray, int[], NDArray, bool, NDArray)
NumPy's np.any with a tuple axis, the whole call: the reduce prologue (every axis,
then a repeat), the text truth route, the masked reduction and the out= store.
public abstract NDArray Any(NDArray a, int[] axis, NDArray @out, bool keepdims = false, NDArray where = null)
Parameters
aNDArrayThe array (any dtype, any layout).
axisint[]The reduced axes (an empty tuple reduces nothing).
outNDArrayNumPy's
out=, or null for a fresh result.keepdimsboolWhether the reduced axes stay with length one.
whereNDArrayNumPy's
where=bool mask, or null.
Returns
- NDArray
outitself when given; otherwise the fresh bool array, read-only when 0-d.
Remarks
New in 0.80.0 (the np-layer dtype plan, P1b).
Exceptions
- ArgumentNullException
aoraxisis null.- ValueError
A read-only or misshapen
out, a mask with more axes thana, or an axis that appears twice (duplicate value in 'axis').- ArgumentException
whereis not a bool array, oroutdoes not have the result's shape.- AxisError
An axis is out of range.
- IncorrectShapeException
whereoroutdoes not broadcast againsta.- SystemError
A
Uarray holding a unit above U+10FFFF.
Any(NDArray, int[], bool)
np.any over a tuple of axes: every axis checked, then a repeat refused, then the boolean reduction
(an EMPTY tuple reduces nothing and returns the truth values in the input's shape).
public abstract NDArray<bool> Any(NDArray nd, int[] axis, bool keepdims = false)
Parameters
ndNDArrayThe array (any dtype, any layout).
axisint[]The reduced axes (negative values count from the end).
keepdimsboolWhether the reduced axes stay with length one.
Returns
Remarks
Abstract since 0.80.0 (the np-layer dtype plan's P1b): DefaultEngine had it as its own
member, which the public np.any reached by a type test.
Exceptions
- ArgumentNullException
ndoraxisis null.- AxisError
An axis is out of range (the first one, in the tuple's order).
- ValueError
An axis appears twice (
duplicate value in 'axis').- SystemError
A
Uarray holding a unit above U+10FFFF.
Any(NDArray, int?, NDArray, bool, NDArray)
NumPy's np.any(a, axis, out, keepdims, *, where), the whole call: logical_or.reduce(a, axis, bool,
out, keepdims=keepdims, where=where) — the reduce prologue in NumPy's order, the text truth route, the masked
reduction and the out= store.
public abstract NDArray Any(NDArray a, int? axis, NDArray @out, bool keepdims = false, NDArray where = null)
Parameters
aNDArrayThe array (any dtype, any layout).
axisint?The reduced axis, or null for every axis (NumPy's
axis=None).outNDArrayNumPy's
out=: an array of the result's shape and any dtype that receives the bool result with unsafe casting, or null for a fresh result.keepdimsboolWhether the reduced axes stay with length one.
whereNDArrayNumPy's
where=: a bool mask that broadcasts toa's shape (masked-off elements count as False, the identity), or null for no mask.
Returns
- NDArray
outitself when given; otherwise a fresh bool array, read-only when 0-d (NumPy's scalar).
Remarks
The engine owns NumPy's whole call, dtype decisions included (the np-layer dtype plan, P1b): the public
np.any only calls this (the declaration below dispatches a subclass operand to its method). New in
0.80.0. A bare null axis is
ambiguous with the tuple member below: pass a typed int?.
Exceptions
- ArgumentNullException
ais null.- ValueError
outis read-only (output array is read-only, checked first), has the wrong rank, or cannot hold the result; orwherehas more axes thanaor would make it stretch (NumPy's reduction-iterator texts).- ArgumentException
whereis not a bool array (NumPy's TypeError text: the mask must cast to bool under thesaferule); oroutdoes not have the result's shape.- AxisError
axisis out of range.- IncorrectShapeException
whereoroutdoes not broadcast againsta.- SystemError
A
Uarray holding a unit above U+10FFFF.
Any(NDArray, int?, bool)
np.any along one axis, or over every axis when axis is null: the boolean reduction
without out= or where=, a fresh array the caller may wrap as NumPy's scalar.
public abstract NDArray<bool> Any(NDArray nd, int? axis, bool keepdims = false)
Parameters
ndNDArrayThe array (any dtype, any layout).
axisint?The reduced axis (negative counts from the end; a 0-d array accepts 0 and -1), or null for every axis.
keepdimsboolWhether the reduced axes stay with length one.
Returns
- NDArray<bool>
The bool result, laid out as NumPy's reduction allocates it. Over every axis it is a fresh, writeable owner (a 0-d array without
keepdims); the publicnp.anyoverloads decide whether a 0-d result becomes NumPy's read-only scalar.
Remarks
keepdims and the null axis were added to the contract in 0.80.0 (the np-layer dtype
plan's P1b, decision D2: widened in place; the member took one int axis before).
Exceptions
- ArgumentNullException
ndis null.- AxisError
axisis out of range.- SystemError
A
Uarray holding a unit above U+10FFFF.
ArgMax(NDArray)
public abstract NDArray ArgMax(NDArray a)
Parameters
aNDArray
Returns
ArgMax(NDArray, int, bool)
public abstract NDArray ArgMax(NDArray a, int axis, bool keepdims = false)
Parameters
Returns
ArgMin(NDArray)
public abstract NDArray ArgMin(NDArray a)
Parameters
aNDArray
Returns
ArgMin(NDArray, int, bool)
public abstract NDArray ArgMin(NDArray a, int axis, bool keepdims = false)
Parameters
Returns
ArgPartition(NDArray, object, int?, string, string)
NumPy's np.argpartition(a, kth, axis, kind, order) and ndarray.argpartition
(PyArray_ArgPartition), the whole call: the int64 indices that partition a along the
axis (see Partition(NDArray, object, int?, string, string)).
public abstract NDArray ArgPartition(NDArray a, object kth, int? axis = -1, string kind = "introselect", string order = null)
Parameters
aNDArrayThe array (only read). A 0-d array ravels to one element first, as NumPy's
PyArray_CheckAxisdoes.kthobjectNumPy's array_like of positions along the axis: a C# int, an int[], an integer index array, or any other object, converted with
np.asanyarray. A negative position counts from the end; every listed position ends where a sorted copy holds its element.axisint?The axis (negative counts from the end), or null for the flattened array.
kindstringNumPy's
kind=: only"introselect"(the default) or null.orderstringNumPy's
order=, a field name, or null: every NumSharp dtype has no fields, so any value is refused.
Returns
- NDArray
A fresh, C-contiguous int64 array of
a's shape (one-dimensional for a null axis): the element at each listed position is where a sorted copy holds it. Text answers with the default argsort (NumPy's generic introsort fallback).
Remarks
New in 0.80.0 (the np-layer dtype plan, phase PE, E5): np.argpartition and
NDArray.argpartition call this.
Exceptions
- ValueError
A
kindother than"introselect"(select kind must be 'introselect' (got 'x')) or anorder, before the array is read; a kth index array of more than one dimension (object too deep for desired array, before the axis) or of bool dtype (Booleans unacceptable as partition index); a position out of bounds (kth(=5) out of bounds (5), skipped for an empty array).- TypeError
A kth index array of a non-integer dtype (
Partition index must be integer).- AxisError
The axis is out of range.
- ArgumentNullException
kthis null, at NumPy's kth stage (after the axis: NumPy's kth=None raises its TypeError there).
ArgSort(NDArray, int?, string, object, bool?, bool?)
NumPy's np.argsort(a, axis, kind, order, stable, descending) and ndarray.argsort (PyArray_ArgSort),
the whole call: the int64 indices that sort a along the axis.
public abstract NDArray ArgSort(NDArray a, int? axis = -1, string kind = null, object order = null, bool? stable = null, bool? descending = null)
Parameters
aNDArrayThe array (only read). A 0-d array ravels to one element first, as NumPy's
PyArray_CheckAxisdoes: its answer is[0], and an axis other than 0 / -1 reports dimension 1.axisint?The sorted axis (negative counts from the end), or null for the C-order flattening.
kindstringNumPy's
kind=, read from its first character (quicksort,heapsort,mergesort orstable, any case), or null for the default. It changes the answer only where NumPy's does: the heapsort kind is the default kind, the default kind's float value sort leaves the NaNs in the order NumPy's x86-simd-sort moves them to the end (the stable kind's in input order, every NaN's bits kept either way), and the default kind's descending sorts follow NumPy's introsort.orderobjectNumPy's
order=, a field name or a list of them, or null: every NumSharp dtype has no fields, so any value is refused.stablebool?NumPy's keyword-only
stable=: true asks for the stable kind; any non-null value is refused together withkind.descendingbool?NumPy 2.5's keyword-only
descending=: true sorts the largest value first, NaN still last (complex: the NaN classes last, each in descending order); any non-null value is refused together withkind.StringDTyperefuses it.
Returns
- NDArray
A fresh, C-contiguous int64 array of
a's shape (one-dimensional for a null axis). Ascending ties keep their order for every numeric kind (NumSharp's numeric ascending argsort is one stable order); text, and every descending default-kind argsort, follow NumPy's introsort.
Remarks
New in 0.80.0 (the np-layer dtype plan, phase PE, E5): np.argsort and NDArray.argsort
call this.
Exceptions
- ValueError
An unknown
kind(sort kind must be one of 'quick', 'heap', or 'stable' (got 'x')),kindtogether withstableordescending, or anorder, all before the array is read; aStringDTypeline of two or more elements holding an NA whose NA object is neither NaN-like nor a string.- RuntimeError
A
StringDTypearray sorted descending (unsupported sort kind), before the axis: NumPy resolves the argsort loop first.- AxisError
The axis is out of range.
Argwhere(NDArray)
public abstract NDArray Argwhere(NDArray a)
Parameters
aNDArray
Returns
ArrayEqual(NDArray, NDArray, bool)
NumPy's np.array_equal(a1, a2, equal_nan=False): whether two arrays have the same shape and equal
elements. No broadcasting (that is ArrayEquiv(NDArray, NDArray)).
public abstract bool ArrayEqual(NDArray a1, NDArray a2, bool equal_nan = false)
Parameters
a1NDArrayThe first array, or null (NumSharp's null convention: two nulls are equal, a null and an array are not).
a2NDArrayThe second array, or null.
equal_nanboolCount NaNs at the same places as equal (a complex value is NaN when either part is; a
StringDTypeNaN-like NA is a NaN). Without it NaN equals nothing, so an array holding a NaN is not equal to itself.
Returns
- bool
True when the shapes are equal and every element compares equal.
Remarks
NumPy writes array_equal in Python (numpy/_core/numeric.py); DefaultEngine's override runs those
statements for every dtype, text included, with a fused early-exiting equality scan for two dense operands of
one dtype. np.array_equal and the member array_equal(NDArray, bool) call it with
plain views of subclass operands, on the engine of the first operand that is not null; an override replaces
both for every array whose engine it is. New in 0.80.0 (the np-layer dtype plan, phase PE); it was the internal
class ArrayEqualEngine.
Exceptions
- TypeError
With
equal_nan, a fixed-width string operand and two different arrays of one shape (NumPy'sisnanhas no string loop); twoStringDTypeoperands whose NA objects differ (their comparison refuses the pair).
ArrayEquiv(NDArray, NDArray)
NumPy's np.array_equiv(a1, a2): whether two arrays broadcast together and every element of the
broadcast comparison is equal.
public abstract bool ArrayEquiv(NDArray a1, NDArray a2)
Parameters
a1NDArrayThe first array, or null (two nulls are equivalent, a null and an array are not).
a2NDArrayThe second array, or null.
Returns
- bool
True when the shapes broadcast and every element compares equal (NaN never does: there is no
equal_nan). An empty broadcast is equivalent.
Remarks
NumPy writes array_equiv in Python (numpy/_core/numeric.py). np.array_equiv calls this
with plain
views of subclass operands, on the engine of the first operand that is not null; an override replaces it
for every array whose engine it is. New in 0.80.0 (the np-layer dtype plan, phase PE); it was the internal
class ArrayEqualEngine.
Exceptions
- TypeError
Two
StringDTypeoperands whose NA objects differ.
Average(NDArray, int[], NDArray, bool, bool)
NumPy's np.average(a, axis=None, weights=None, returned=False, *, keepdims=False): the (weighted) average
over the given axes, and with returned the sum of the weights in the average's shape.
public abstract (NDArray avg, NDArray sumOfWeights) Average(NDArray a, int[] axis = null, NDArray weights = null, bool returned = false, bool keepdims = false)
Parameters
aNDArrayThe operand, a plain array (not null): any dtype and layout; text takes NumPy's text statements.
axisint[]The reduced axes (a negative axis counts from the end), or null for every axis. A one-axis call passes a one-element array.
weightsNDArrayThe weights, or null for the plain mean: of
a's shape, or of the reduced axes' extents in the order ofaxis.returnedboolAlso compute the sum of weights (NumPy's
returned=True); false leaves the pair's second element null.keepdimsboolKeep the reduced axes with length 1.
Returns
- (NDArray Lhs, NDArray Rhs)
The average and the sum of weights (null unless
returned): arrays the caller owns, 0-d for a reduction over every axis withoutkeepdims. The pair stands for NumPy's return, which is the average alone or the tuple.
Remarks
NumPy writes average in Python; DefaultEngine's override runs its statements in NumPy's order.
np.average (both of its return shapes, returned or not) calls it after the numpy.matrix rule and
the null check; an override replaces it for every array whose engine it is. New in 0.80.0 (the np-layer dtype plan, phase PE);
it was the internal class AverageEngine.
Exceptions
- AxisError
An axis out of bounds (
axis: axis 9 is out of bounds for array of dimension 2: NumPy names the argument).- ValueError
An axis that appears twice (
repeated axis in); weights not of the reduced axes' shape.axisargument- ZeroDivisionError
Weights that sum to zero (
Weights sum to zero, can't be normalized), or a mean without weights whose result is empty (division by zero).- TypeError
Weights of another shape without an axis (
Axis must be specified when shapes of a and weights differ.); the weight sum's refusal of a text result dtype; a text operand without weights (the mean's add.reduce refusal).- DTypePromotionError
Weights and an operand with no common DType (StringDType beside a number or beside S).
- InvalidOperationException
Not reached: a weight sum in a text result dtype that NumPy refuses but that computed (a wiring error inside NumSharp).
Bartlett(double)
NumPy's np.bartlett(M): the triangular window of M points,
where(n <= 0, 1 + n/(M-1), 1 - n/(M-1)) over n = arange(1-M, M, 2) - zero at both ends, one at
the centre only when the count is odd.
public abstract NDArray Bartlett(double M)
Parameters
MdoubleThe number of points, NumPy's
_FloatLike_co: a fractional count gives NumPy's lengthlen(arange(1 - M, M, 2)); below one gives an empty array, exactly one givesones(1).
Returns
- NDArray
A new 1-D float64 array.
Remarks
NumPy writes the window in Python; DefaultEngine fuses its ufunc chain into one np.evaluate pass in
NumPy's operation order, so the values are NumPy's bit for bit (float64 add, subtract and divide are
IEEE-exact). The window has no operand to choose an engine by: np.bartlett calls the default engine's
member, so an override is reached through that engine (or called directly).
Exceptions
- ValueError
Mis NaN (arange'sarange: cannot compute length), +infinity or too large for arange to size (Maximum allowed size exceeded).- OutOfMemoryException
A finite count whose window does not fit in memory.
Bincount(NDArray, NDArray, int)
NumPy's np.bincount(x, weights=None, minlength=0) (arr_bincount,
numpy/_core/src/multiarray/compiled_base.c), the whole call: the number of occurrences of each
non-negative integer in x, or with weights the sum of the weights at
the positions of each value. The result has max(x.max() + 1, minlength) bins.
public abstract NDArray Bincount(NDArray x, NDArray weights = null, int minlength = 0)
Parameters
xNDArrayA 1-D array of non-negative integers: an integer, bool or char dtype, cast to int64 (a uint64 value at or past 2^63 wraps negative and is refused, as NumPy's cast makes it).
weightsNDArrayNull, or a 1-D array of
x's length, cast to float64.minlengthintThe smallest number of bins (non-negative).
Returns
- NDArray
A new 1-D array: int64 counts without
weights, float64 sums with them. An emptyxgivesminlengthint64 zeros, whatever the weights.
Remarks
New in 0.80.0 (the np-layer dtype plan): the public np.bincount computes a numpy.matrix
operand as a plain array and calls this.
Exceptions
- ArgumentNullException
xis null.- IncorrectShapeException
x, or with values the weights, is not 1-D (NumPy'sobject of too small depth for desired array/object too deep for desired arrayValueError texts).- InvalidCastException
xis not an integer, bool or char array, or the weights are complex or text (NumPy's safe-cast TypeError text).- ValueError
In NumPy's order: a negative
minlength, a negative value, weights of another length.
BitwiseAnd(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray BitwiseAnd(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
BitwiseCount(NDArray, DType, NDArray, NDArray)
public abstract NDArray BitwiseCount(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
BitwiseOr(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray BitwiseOr(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
BitwiseXor(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray BitwiseXor(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Blackman(double)
NumPy's np.blackman(M): the Blackman window of M points, the first three terms of a
cosine sum, 0.42 + 0.5cos(pin/(M-1)) + 0.08cos(2.0pi*n/(M-1)) over n = arange(1-M, M, 2).
public abstract NDArray Blackman(double M)
Parameters
MdoubleThe number of points, NumPy's
_FloatLike_co(the length and the guards of Bartlett(double)).
Returns
- NDArray
A new 1-D float64 array (its end points are a tiny negative number, -1.3877787807814457e-17, as in NumPy).
Remarks
DefaultEngine's fused pass keeps NumPy's evaluation order ((pi * n) / (M - 1) and
((2.0 * pi) * n) / (M - 1) round in two steps each), and float64 cos is the host CRT's, NumPy's
own on win-amd64; elsewhere a libm can differ in the last bit. np.blackman calls the default engine's
member.
Exceptions
- ValueError
Mis NaN, +infinity or too large for arange to size.- OutOfMemoryException
A finite count whose window does not fit in memory.
BooleanMask(NDArray, NDArray)
public abstract NDArray BooleanMask(NDArray arr, NDArray mask)
Parameters
Returns
BooleanMaskSet(NDArray, NDArray, NDArray)
public abstract void BooleanMaskSet(NDArray arr, NDArray mask, NDArray value)
Parameters
Cast(NDArray, Type, bool)
public abstract NDArray Cast(NDArray x, Type dtype, bool copy)
Parameters
Returns
Cbrt(NDArray, DType, NDArray, NDArray)
public abstract NDArray Cbrt(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Ceil(NDArray, DType, NDArray, NDArray)
public abstract NDArray Ceil(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
ClipNDArray(NDArray, NDArray, NDArray, DType, NDArray, NDArray)
np.clip's engine entry (NumPy's _methods._clip plus the routed ufunc): drops an unclipping
Python-int bound, routes to positive / minimum / maximum / clip, and broadcasts the array, the bounds,
out and where together.
public abstract NDArray ClipNDArray(NDArray lhs, NDArray min, NDArray max, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
lhsNDArrayThe array to clip.
minNDArrayThe lower bound, or null for none (a 0-d bound is a scalar; a 0-d integer bound is a Python int).
maxNDArrayThe upper bound, or null for none.
dtypeDTypeThe loop dtype (NumPy's
dtype=), or null for the promoted one.outNDArrayThe out= array, or null for a fresh result.
whereNDArrayThe bool where= mask, or null for everywhere.
Returns
- NDArray
out, or a fresh array in NumPy's ufunc output layout.
Exceptions
- ValueError
A read-only out, or operands that do not broadcast / an out that would be stretched.
- TypeError
A dtype= / out= cast NumPy's same_kind rule refuses.
- ArgumentException
A non-bool where.
- OverflowError
A kept Python-int bound does not fit an integer loop dtype.
- TypeError
No bound is left and the loop would be bool (positive has no bool loop).
Compare(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray Compare(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Conjugate(NDArray, DType, NDArray, NDArray)
NumPy 'conjugate' / 'conj' — the complex conjugate, element-wise. Identity at every real dtype with a loop (values unchanged, dtype preserved); bool has none and resolves to the int8 loop when no dtype is given (an int8 result of 0 / 1); for Complex it flips the sign of the imaginary part. dtype selects the loop; out=/where= follow the ufunc contract.
public abstract NDArray Conjugate(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
ndNDArrayThe input.
dtypeDTypeThe loop dtype, or null for the input's (int8 for bool).
outNDArrayAn array to write the result into and return, or null.
whereNDArrayA bool mask of the elements to compute, or null for all.
Returns
- NDArray
The conjugate, or
out.
Exceptions
- TypeError
A text input, or a
dtype/outthe loop cannot reach (NumPy's ufunc texts).
Convolve(NDArray, NDArray, string)
NumPy's np.convolve(a, v, mode='full'): the discrete linear convolution of two one-dimensional
sequences, multiarray.correlate(a, v[::-1], mode) after NumPy's Python statements.
public abstract NDArray Convolve(NDArray a, NDArray v, string mode = "full")
Parameters
aNDArrayThe first sequence (any dtype, any layout; a 0-d one is one element, NumPy's
ndmin=1).vNDArrayThe second sequence (likewise). The longer of the two is the data, the other is reversed.
modestringfull(the default),sameorvalid, matched exactly.
Returns
- NDArray
A fresh 1-D array of the operands' common dtype.
Remarks
NumPy writes convolve in Python (numpy/_core/numeric.py); its last statement is the C function behind
Correlate(NDArray, NDArray, string), whose kernels reproduce NumPy's dot products bit for bit, except long float products
without the OpenBLAS backend (a bounded ULP difference). Unlike Correlate2(NDArray, NDArray, string)
a complex kernel is not conjugated. np.convolve and the member convolve(NDArray, string) call it;
an override replaces both for every array whose engine it is (the engine of a). New in
0.80.0 (the np-layer dtype plan, phase PE); it was the internal class ConvolveEngine.
Exceptions
- ValueError
a cannot be empty/v cannot be empty(on the operands as given, before the swap), then Correlate(NDArray, NDArray, string)'s errors in its order: an unknownmode, an operand of two or more dimensions, a fixed-width string operand.- UnicodeEncodeError
A
modeholding a lone surrogate (after the emptiness checks).- TypeError
A null
mode(after the emptiness checks), or aStringDTypeoperand's refusal or first-product error.- NotSupportedException
A
StringDTypeoperand whose OBJECT product NumPy computes.
CopySign(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray CopySign(NDArray x1, NDArray x2, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Corrcoef(NDArray, NDArray, bool, DType)
NumPy's np.corrcoef(x, y=None, rowvar=True, *, dtype=None): the Pearson correlation coefficients
R_ij = C_ij / sqrt(C_ii * C_jj) of C = cov(x, y, rowvar, dtype=dtype), the two divisions made in
place, then the result clipped to [-1, 1] in place (the real and the imaginary lanes of a complex result), which
rounding can push a coefficient past.
public abstract NDArray Corrcoef(NDArray x, NDArray y = null, bool rowvar = true, DType dtype = null)
Parameters
xNDArrayThe variables, a plain array (not null): 1-D or 2-D, a variable per row unless
rowvaris false.yNDArrayAn additional set of variables, or null.
rowvarboolWhether rows are variables (columns observations).
dtypeDTypeThe result dtype, or null for Cov(NDArray, NDArray, bool, bool, int?, NDArray, NDArray, DType)'s
result_type(x, y, float64).
Returns
- NDArray
The correlation matrix, a fresh array the caller owns (cov's own matrix, divided and clipped in place). For one variable cov's result is 0-d, which has no diagonal: NumPy's
c / cthen, 1 or NaN (a NaN, infinite or zero variance). No variables give cov's empty(0, 0)float64 array.
Remarks
NumPy writes corrcoef in Python over cov (NumPy 2.x dropped its bias / ddof); DefaultEngine runs
its statements over the operand engine's Cov(NDArray, NDArray, bool, bool, int?, NDArray, NDArray, DType), Sqrt(NDArray, DType, NDArray, NDArray), Divide(NDArray, NDArray, DType, NDArray, NDArray) and
ClipNDArray(NDArray, NDArray, NDArray, DType, NDArray, NDArray) and the array object's diagonal and real / imaginary lanes. np.corrcoef calls
it after the null check, a subclass operand handed in as its plain view; an override replaces it for every
array whose engine it is.
Exceptions
- ValueError
More than 2 dimensions; text variables whose
xandyhave different observation counts; text that does not parse into a numericdtype; aStringDTyperequest over no observations (Cov(NDArray, NDArray, bool, bool, int?, NDArray, NDArray, DType)'s).- IncorrectShapeException
Numeric variables with different observation counts (cov's concatenate).
- TypeError
Text that cov's mean refuses.
- DTypePromotionError
StringDTypevariables withoutdtype.- ArgumentException
An integer or bool
dtype(cov's in-place centring refuses the cast).- OverflowError
An integer text outside an integer
dtype.- OverflowException
Decimal arithmetic out of range (.NET's own, decimal has no NumPy dtype).
- UnicodeEncodeError
A U → S conversion of non-ASCII text.
- UnicodeDecodeError
An S → U conversion of non-ASCII bytes.
Correlate(NDArray, NDArray, string)
NumPy's multiarray.correlate(a, v, mode) — PyArray_Correlate, the correlation np.convolve
ends with (multiarray.correlate(a, v[::-1], mode)) — the whole call: the mode, the operands'
descriptor lookup (a StringDType operand's answers), their one-dimension check,
_pyarray_correlate's emptiness checks, the result allocation (a fixed-width string type number has no
item size) and the sliding product c_k = Σ_n a[n + k] · v[n] in the operands' common dtype. Unlike
Correlate2(NDArray, NDArray, string) it neither conjugates v nor reverses the result when the operands
are swapped (the longer one is always the data).
public abstract NDArray Correlate(NDArray a, NDArray v, string mode = "valid")
Parameters
aNDArrayThe first one-dimensional sequence (any dtype, any layout).
vNDArrayThe second one-dimensional sequence, read forward: np.convolve passes its kernel reversed.
modestringvalid(the default),sameorfull, matched exactly.
Returns
- NDArray
A fresh 1-D array of the operands' common dtype, of
max(n1, n2) - min(n1, n2) + 1,max(n1, n2)orn1 + n2 - 1elements.
Remarks
NumPy's function is C (multiarraymodule.c), so the call is an engine member; np.convolve's Python
statements (the 0-d promotion, its own emptiness checks, the swap by length, the reversal) run before it in
Convolve(NDArray, NDArray, string).
Exceptions
- ValueError
First an unknown
mode, with NumPy's two texts:Use one of 'valid', 'same', or 'full' for convolve/correlate modefor a text whose first letter names a mode,mode must be one of 'valid', 'same', or 'full' (got 'x')with the argument in Python'sreprfor any other. Then an operand that is not one-dimensional (object of too small depth for desired arrayfor a 0-d one,object too deep for desired arrayfor two or more dimensions, the first operand first), an empty one (first array argument cannot be empty/second array argument cannot be empty), or a text operand after those checks (function not available for this data type).- UnicodeEncodeError
A
modeholding a lone surrogate: CPython's UTF-8 encoding error, raised before the mode is read.- TypeError
A null
mode(NumPy'sNone):convolve/correlate mode not understood. AStringDTypeoperand: NumPy's legacy-only descriptor refusal, or Python's error from the first product of its OBJECT fallback.- NotSupportedException
A
StringDTypeoperand whose OBJECT product NumPy computes (an object array, which NumSharp does not have).
Correlate2(NDArray, NDArray, string)
NumPy's multiarray.correlate2(a, v, mode) — PyArray_Correlate2, the whole body of
np.correlate — the whole call: Correlate(NDArray, NDArray, string)'s statements, with the second operand conjugated
for a complex common dtype before the product (c_k = Σ_n a[n + k] · conj(v[n])) and, when the operands
are swapped because a is the shorter, the result reversed (_pyarray_revert), so
correlate2(v, a) is the reversed conjugate of correlate2(a, v).
public abstract NDArray Correlate2(NDArray a, NDArray v, string mode = "valid")
Parameters
aNDArrayThe first one-dimensional sequence (any dtype, any layout).
vNDArrayThe second one-dimensional sequence (conjugated for a complex common dtype).
modestringvalid(the default),sameorfull, matched exactly.
Returns
- NDArray
A fresh 1-D array of the operands' common dtype (lengths as for Correlate(NDArray, NDArray, string)).
Remarks
NumPy's function is C, so the call is an engine member; the subclass answer stays with
np.correlate's woven subclass path.
Exceptions
- ValueError
An unknown
mode, then an operand that is not one-dimensional, an empty one, or a fixed-width string one (the texts and order of Correlate(NDArray, NDArray, string)).- UnicodeEncodeError
A
modeholding a lone surrogate.- TypeError
A null
mode(convolve/correlate mode not understood), or aStringDTypeoperand's refusal or first-product error.- NotSupportedException
A
StringDTypeoperand whose OBJECT product NumPy computes.
Cos(NDArray, DType, NDArray, NDArray)
public abstract NDArray Cos(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Cosh(NDArray, DType, NDArray, NDArray)
public abstract NDArray Cosh(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
CountNonZero(NDArray)
NumPy's np.count_nonzero(a) (multiarray.count_nonzero), the whole call: the number of elements
whose truth value is True (a text element counts when non-empty), 0 for an array with no element.
public abstract long CountNonZero(NDArray a)
Parameters
aNDArrayThe array (any dtype, any layout).
Returns
- long
The count.
Remarks
The public np.count_nonzero only calls this, a subclass operand handed in as its plain view (the
np-layer dtype plan, P1b).
Exceptions
- NullReferenceException
ais null.
CountNonZero(NDArray, NDAxis?, bool)
NumPy's np.count_nonzero(a, axis=None, *, keepdims=False), the whole call: without an axis and without
keepdims the flat count (multiarray.count_nonzero(a)) as NumPy's scalar, otherwise
a_bool.sum(axis=axis, dtype=intp, keepdims=keepdims) over the truth values (text through
a != ''), int64 zeros of the reduced shape for an array with no element.
public abstract NDArray CountNonZero(NDArray a, NDAxis? axis, bool keepdims = false)
Parameters
aNDArrayThe array (any dtype, any layout).
axisNDAxis?NumPy's
axis: null (None) counts every element; one axis (negative counts from the end; a 0-d array accepts 0 and -1, the sum's rule) or a tuple of axes (each range-checked, then a repeat refused; the empty tuple counts each element on its own).keepdimsboolWhether the counted axes stay with length one.
Returns
- NDArray
The int64 counts, laid out as NumPy's sum allocates them; a read-only 0-d array (NumPy's scalar) when every axis is counted without
keepdims(and for any count of a 0-d array).
Remarks
The public np.count_nonzero only calls this, a subclass operand handed in as its plain view (the
np-layer dtype plan, P1b). The axis is an NDAxis since API-parity batch 4 (2026-11-12): the
member took one int axis, so a tuple and axis=None with keepdims had no route; an
int argument converts.
Exceptions
- AxisError
An axis is out of range (the first one, as given).
- ValueError
A tuple names an axis twice (
duplicate value in 'axis').
Cov(NDArray, NDArray, bool, bool, int?, NDArray, NDArray, DType)
NumPy's np.cov(m, y=None, rowvar=True, bias=False, ddof=None, fweights=None, aweights=None, *,
dtype=None): the covariance matrix of the variables (rows of m unless
rowvar is false, plus those of y).
public abstract NDArray Cov(NDArray m, NDArray y = null, bool rowvar = true, bool bias = false, int? ddof = null, NDArray fweights = null, NDArray aweights = null, DType dtype = null)
Parameters
mNDArrayThe variables, a plain array (not null): 1-D or 2-D.
yNDArrayAn additional set of variables, or null.
rowvarboolWhether rows are variables (columns observations).
biasboolNormalize by N instead of N - 1 (overridden by
ddof).ddofint?The delta degrees of freedom, or null for
bias's default.fweightsNDArrayThe integer frequency weights, or null.
aweightsNDArrayThe analytic weights, or null.
dtypeDTypeThe result dtype, or null for
result_type(m, y, float64).
Returns
- NDArray
The covariance matrix (squeezed: a 0-d array for one variable), a fresh array the caller owns; an empty
(0, 0)float64 array for no variables.
Remarks
NumPy writes cov in Python; DefaultEngine's override runs its statements (its product goes through
np.dot, so the OpenBLAS backend computes it when installed). np.cov (and np.corrcoef
through it) calls this after the null check, a subclass operand handed in as its plain view; an override
replaces it for every array whose engine it is. New in 0.80.0 (the np-layer dtype plan, phase PE); it
was the internal
class CovEngine.
Exceptions
- ValueError
More than 2 dimensions; text variables whose
mandyhave different observation counts; a negative weight; text that does not parse into a numericdtype; aStringDTyperequest over no observations.- IncorrectShapeException
Numeric variables with different observation counts (concatenate).
- TypeError
A non-integral frequency weight; text the mean refuses.
- RuntimeError
A malformed weight array.
- DTypePromotionError
StringDTypevariables withoutdtype, or aStringDTyperequest with weights.- TypeError
An integer or bool
dtype(the in-place centring's cast refusal).- ZeroDivisionError
Weights that sum to zero.
- OverflowError
An integer text outside an integer
dtype.- OverflowException
Decimal arithmetic out of range (.NET's own, decimal has no NumPy dtype).
- UnicodeEncodeError
A U → S conversion of non-ASCII text.
- UnicodeDecodeError
An S → U conversion of non-ASCII bytes.
CreateNDArray(Shape, DType, IArraySlice, char)
public abstract NDArray CreateNDArray(Shape shape, DType dtype = null, IArraySlice buffer = null, char order = 'C')
Parameters
shapeShapedtypeDTypebufferIArraySliceorderchar
Returns
CreateNDArray(Shape, DType, Array, char)
public abstract NDArray CreateNDArray(Shape shape, DType dtype = null, Array buffer = null, char order = 'C')
Parameters
Returns
Cross(NDArray, NDArray, int, int, int, int?)
NumPy's np.cross(a, b, axisa=-1, axisb=-1, axisc=-1, axis=None): the cross product of (arrays of)
2- or 3-vectors taken along axisa / axisb, the other axes broadcast; a
2-vector's missing third component is zero, and two 2-vectors give only the z-component.
public abstract NDArray Cross(NDArray a, NDArray b, int axisa = -1, int axisb = -1, int axisc = -1, int? axis = null)
Parameters
aNDArrayThe first vector(s), at least 1-D.
bNDArrayThe second vector(s), at least 1-D.
axisaintThe axis of
athat holds the vectors (negative counts from the end).axisbintThe axis of
bthat holds the vectors.axiscintThe axis of the result that holds the 3-vectors; ignored when both inputs are 2-vectors.
axisint?When given, the one axis of both inputs and the result; it overrides the other three.
Returns
- NDArray
A new array in
promote_types(a.dtype, b.dtype)over the broadcast leading axes, plus the 3-vector axis ataxiscunless both inputs are 2-vectors.
Remarks
DefaultEngine composes NumPy's statements over multiply, negative, subtract and moveaxis (no kernel of its own). The 2-vector forms are deprecated in NumPy 2.0; the warning is not modelled.
Exceptions
- NullReferenceException
aorbis null.- ValueError
A 0-D input (
At least one array has zero dimension), or a vector length other than 2 or 3 (incompatible dimensions for cross product).- AxisError
An axis out of range for its operand, reported with its
axisa/axisb/axiscprefix;axiscis checked against the result's rank right after the broadcast.- IncorrectShapeException
Leading axes that do not broadcast (
np.broadcast's text), raised before the dtype promotion.- TypeError
A text operand: multiply has no string loop (raised after the shape checks).
Deg2Rad(NDArray, DType, NDArray, NDArray)
public abstract NDArray Deg2Rad(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Degrees(NDArray, DType, NDArray, NDArray)
NumPy's np.degrees ufunc: the same conversion as Rad2Deg(NDArray, DType, NDArray, NDArray) (radians to degrees), but a ufunc of its
own, so a refusal (text, an operand type with no loop) names degrees.
public abstract NDArray Degrees(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
ndNDArrayThe angles.
dtypeDTypeThe loop dtype (
dtype=), or null for the operand's float tier.outNDArrayThe array to write into (
out=), or null.whereNDArrayThe bool mask of the positions to compute (
where=), or null for all.
Returns
- NDArray
The converted angles:
outwhen given, else a new array of the float tier (float16 for bool / int8 / uint8, float32 for int16 / uint16, float64 for wider integers; floats keep theirs).
Exceptions
- TypeError
A text or complex operand (no degrees loop), with NumPy's texts.
- ValueError
A read-only
out.- ArgumentException
A non-bool
where, or adtypethe operand cannot reach.
Diff(NDArray, int, int, object, object)
NumPy's np.diff(a, n=1, axis=-1, prepend=<no value>, append=<no value>): the n-th
discrete difference along an axis, a = op(a[1:], a[:-1]) repeated n times after concatenating
prepend / append along the axis, where op is != for bool and - otherwise.
public abstract NDArray Diff(NDArray a, int n = 1, int axis = -1, object prepend = null, object append = null)
Parameters
aNDArrayThe input, at least 1-D (not null).
nintHow many times to difference; 0 returns
aitself.axisintThe axis to difference along (negative counts from the end).
prependobjectValues to put before
aalong the axis (a scalar is broadcast to length 1), or null for none.appendobjectValues to put after
aalong the axis, or null for none.
Returns
- NDArray
aitself forn0; otherwise a new array, the axis shorter byn, in the subtraction's dtype (bool for a bool input).
Exceptions
- ArgumentNullException
ais null.- ArgumentException
A negative
n(order must be non-negative but got -1).- ValueError
A 0-D
a(diff requires input that is at least one dimensional).- AxisError
axisout of range.- TypeError
Text with
nabove 0: subtract has no string loop.
Digitize(NDArray, NDArray, bool)
NumPy's np.digitize(x, bins, right=False): the index of the bin each value of x
falls in, searchsorted on the bins (reversed for decreasing bins) with the side right
selects.
public abstract NDArray Digitize(NDArray x, NDArray bins, bool right = false)
Parameters
xNDArrayThe values to bin, any shape (not null).
binsNDArrayThe 1-D monotonic bin edges (not null).
rightboolWhether an interval includes its right edge instead of its left one.
Returns
- NDArray
The int64 bin indices, of
x's shape.
Exceptions
- ArgumentNullException
xorbinsis null.- IncorrectTypeException
A complex
x(x may not be complex, checked first).- ValueError
binsnot 1-D, or not monotonic (bins must be monotonically increasing or decreasing).- InvalidCastException
binsthat do not cast 'safely' to float64 (NumPy's TypeError text).- TypeError
A StringDType
xagainst numeric bins: Python cannot order the pair.
DivMod(NDArray, NDArray, DType, (NDArray Quotient, NDArray Remainder), NDArray)
np.divmod — the fused two-output ufunc returning
(floor_divide(lhs, rhs), remainder(lhs, rhs)) element-wise in a single pass.
Item1 is the floored quotient, Item2 the floored remainder (divisor's sign). Same NEP50
promotion as Mod(NDArray, NDArray, DType, NDArray, NDArray)/FloorDivide(NDArray, NDArray, DType, NDArray, NDArray). When out
(a 2-tuple) or where is supplied the op composes the two validated
single-output ufuncs; otherwise it runs the fused kernel.
public abstract (NDArray Quotient, NDArray Remainder) DivMod(NDArray lhs, NDArray rhs, DType dtype = null, (NDArray Quotient, NDArray Remainder) @out = default, NDArray where = null)
Parameters
Returns
Divide(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray Divide(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Dot(NDArray, NDArray, NDArray)
NumPy's np.dot(a, b, out=None) — PyArray_MatrixProduct2 — the whole call: the text operands'
answers in NumPy's order, the product (an inner product, a matrix product, a multiply with a 0-d operand, or a
sum product over the last axis of x and the second-to-last of y), and
new_array_for_sum's strict out=.
public abstract NDArray Dot(NDArray x, NDArray y, NDArray @out = null)
Parameters
xNDArrayThe first operand.
yNDArrayThe second operand.
outNDArrayThe out array, or null for a fresh result. It must have the product's exact dtype and rank, be C-contiguous and writeable; no cast, no broadcast.
Returns
- NDArray
The product, or
outafter the product was copied into it.
Remarks
Widened in place with out (the np-layer dtype plan, P2): a call without it is the
product alone, as before, and an engine deriving from TensorEngine implements the three-parameter member.
Exceptions
- ValueError
An out array the check refuses:
output array is not acceptable (must have the right datatype, number of dimensions, and be a C-Array), or, of the right rank,output array has wrong dimensions.- IncorrectShapeException
Misaligned operands (NumPy's
shapes (…) and (…) not alignedValueError text).
DotFunction1D(NDArray, NDArray)
The dtype's dot function over two 1-D operands of one length: np.vdot's last step (NumPy's
array_vdot calls PyArray_ArrFuncs.dotfunc directly). The default computes np.dot of the two
vectors; DefaultEngine runs the dot function itself, which differs from np.dot's 1-D route for
a length-1 pair (summed from +0, not the plain product) and a reversed or broadcast operand (its own loop,
not a copy).
public virtual NDArray DotFunction1D(NDArray left, NDArray right)
Parameters
leftNDArrayThe first vector (conjugated by np.vdot when complex).
rightNDArrayThe second vector, the same length.
Returns
- NDArray
A fresh 0-d result.
Remarks
An engine overrides it to run its own 1-D dot (a BLAS dot); the default's np.dot route stays correct
for every dtype, so overriding is only for speed or NumPy's exact summation order.
Exceptions
- IncorrectShapeException
The vectors' lengths differ (NumPy's
shapes (…) and (…) not alignedtext).- DTypePromotionError
The operands have no common dtype.
Ediff1d(NDArray, object, object)
NumPy's np.ediff1d(ary, to_end=None, to_begin=None): the differences between consecutive elements
of the flattened array, with to_begin / to_end (each cast to ary's dtype under
same_kind) put before and after.
public abstract NDArray Ediff1d(NDArray ary, object to_end = null, object to_begin = null)
Parameters
aryNDArrayThe input, flattened (not null).
to_endobjectValues to append, or null for none.
to_beginobjectValues to prepend, or null for none.
Returns
- NDArray
A new 1-D array in
ary's dtype.
Exceptions
- ArgumentNullException
aryis null.- TypeError
to_begin / to_end that cannot reach
ary's dtype undersame_kind(NumPy's TypeError and text:dtype of).to_beginmust be compatible with inputaryunder thesame_kindrule.- TypeError
Text or bool, which subtract has no loop for (NumPy's texts).
Einsum(string, NDArray[], NDArray, DType, char, string, object)
NumPy's np.einsum(subscripts, *operands, out=None, dtype=None, order='K', casting='safe',
optimize=False): the Einstein summation convention over operands, the whole call
from the argument checks to the copy into out.
public abstract NDArray Einsum(string subscripts, NDArray[] operands, NDArray @out = null, DType dtype = null, char order = 'K', string casting = "safe", object optimize = null)
Parameters
subscriptsstringComma-separated subscript labels, optionally followed by
->and the output labels ("ij,jk->ik"); spaces are ignored and...broadcasts. Without->the output is every label used once, in ASCII order, after the broadcast dimensions.operandsNDArray[]The arrays the subscripts label, in order (the facade turns NumPy's sublist spelling into a subscripts string first).
outNDArrayAn array to receive the result, or null for a new array. Its rank is checked with the subscripts, its shape and dtype after the contraction.
dtypeDTypeThe loop dtype, or null for the operands' promoted dtype (NEP 50
result_type, not Sum(NDArray, int?, DType, bool)'s widened accumulator:'ij->i'over int32 is int32).ordercharThe result's memory layout:
'C','F','A'or'K', in either case.'A'and'K'give F order when every operand is F-contiguous;'A'gives C order otherwise and'K'keeps the computed layout.castingstringThe rule every operand must meet to reach the loop dtype, and the result to reach
out's dtype:"no","equiv","safe","same_kind"or"unsafe", spelled exactly.optimizeobjectNumPy's
optimize=: null orfalse,true, any string ("greedy","optimal"; NumPy reads another string as greedy), a path fromnp.einsum_path(an EinsumPath or NumPy's raw['einsum_path', ...]list), or a(string, number)tuple. It is checked like NumPy checks it and does not change the result: the contraction always runs left to right.
Returns
- NDArray
One operand, no
outand no label summed: a VIEW of the operand (diagonals and a transpose), writeable when the operand is, never the operand itself;orderanddtypeare ignored there, as NumPy ignores them.Otherwise a new array in the loop dtype, or
outitself holding the result cast to its dtype. A full contraction gives a 0-d array.
Remarks
The contraction is NumPy's optimize= path (bmm_einsum): a left-to-right pairwise
fold, each step one Matmul(NDArray, NDArray) (batched when labels are shared and kept)
after diagonals, sums and a transpose of each term, or one broadcast Multiply(NDArray, NDArray, DType, NDArray, NDArray) when nothing
is contracted. The products dispatch on Blas, so float32 / float64 / complex128
contractions match NumPy's optimize=True byte for byte when the OpenBLAS backend is installed.
Integer and boolean contractions are exact; a float sum outside a product ('ij->i', three or
more operands) follows NumSharp's sum order and can differ from NumPy's default (C) einsum in the last
ULP.
An override replaces the whole call, the checks included; the facade only applies the numpy.matrix and numpy.char.chararray boundaries and converts the sublist spelling before it calls this member.
Exceptions
- ArgumentNullException
subscriptsis null.- ValueError
No operand (
must specify the einstein sum subscripts string and at least one operand); anorderletter or acastingname NumPy refuses, with its texts; subscripts NumPy refuses (malformed labels, a wrong operand count, a bad ellipsis, an output label absent from the inputs, an impossible diagonal, label extents that disagree, anoutof the wrong rank), with its parser's texts; anoutwhose extents differ from the result's; a read-onlyout.- TypeError
castingis null; anoptimizeNumPy does not understand (Did not understand the path: ...); an operand that cannot reach the loop dtype undercasting, or a result that cannot reachout's dtype, with NumPy's iterator texts; a text operand or a textdtypeoutside the view path, which have no sum of products (NumPy's cast, zero-fill and loop refusals, in its order).
EinsumPath(string, NDArray[], object)
NumPy's np.einsum_path(subscripts, *operands, optimize='greedy'): the order in which to contract the
operands pairwise and NumPy's printed cost report, computed from the subscripts and the operands' SHAPES
(no element is read): _parse_einsum_input, then the _greedy_path / _optimal_path
search with the _flop_count cost model, then the info string.
public abstract (EinsumPath path, string repr) EinsumPath(string subscripts, NDArray[] operands, object optimize)
Parameters
subscriptsstringThe einsum subscripts, as Einsum(string, NDArray[], NDArray, DType, char, string, object) reads them (the facade turns NumPy's sublist spelling into this string first).
operandsNDArray[]The operands the subscripts label; null reads as none. Only their shapes are read.
optimizeobjectNumPy's
optimize=, required here (NumPy's default,'greedy', is the facades': a C# object parameter cannot default to a string), in its decision order:false/ null (no optimization: the operands in order),true,"greedy"or"optimal", a precomputed EinsumPath (an explicit path, checked for completeness), or a("greedy" | "optimal", memory)tuple capping the largest intermediate.
Returns
- (EinsumPath path, string repr)
The path (NumPy's
['einsum_path', (i, j), ...]list as an EinsumPath) and the report; both byte-identical to NumPy's except the placeholder letters an ellipsis expands to in the report, which NumPy draws from a hash-randomized set and NumSharp deterministically.
Remarks
The cost model is BigInteger arithmetic, as NumPy's Python ints are, so products
past 64 bits still compare correctly. An override replaces the plan of np.einsum_path (whose facade
dispatches on the first operand's engine, the default one with none); Einsum(string, NDArray[], NDArray, DType, char, string, object) resolves its own
optimize= separately and contracts left to right whatever the plan.
Exceptions
- ArgumentNullException
subscriptsis null.- ValueError
A null operand (
einsum_path operand {i} is null); subscripts NumPy's Python parser refuses, with its texts (an operand count that differs from the terms', a second->, an invalid symbol, an output label no input has, a term of the wrong rank, extents that disagree).- KeyError
An unknown path name (NumPy's
('Path name %s not found', ...)).- RuntimeError
An explicit path that does not contract every operand.
- TypeError
An
optimizeNumPy does not understand (Did not understand the path: ...,object of type 'int' has no len()).- IndexOutOfRangeException
An ellipsis with no operand to read its rank from (where NumPy fails indexing its operand list).
EmathArccos(NDArray)
NumPy's np.emath.arccos(x): _fix_real_abs_gt_1(x), then arccos. A real element with
|x| > 1 (an infinity included) makes the whole result complex where ACos(NDArray, DType, NDArray, NDArray) returns
NaN.
public abstract NDArray EmathArccos(NDArray x)
Parameters
xNDArrayThe input, any dtype and layout.
Returns
- NDArray
The inverse cosine: real in
[0, pi]while every real element has|x| <= 1(NaN does not trigger the conversion), complex128 otherwise or for a complex input.
Exceptions
- TypeError
A text operand: the scan's
abs(x)has no text loop, NumPy'sufunc 'absolute' did not contain a loop with signature matching types ... -> None, even for an empty array.
EmathArcsin(NDArray)
NumPy's np.emath.arcsin(x): _fix_real_abs_gt_1(x), then arcsin; a real element with
|x| > 1 makes the whole result complex.
public abstract NDArray EmathArcsin(NDArray x)
Parameters
xNDArrayThe input, any dtype and layout.
Returns
- NDArray
The inverse sine: real in
[-pi/2, pi/2]while every real element has|x| <= 1, complex128 otherwise or for a complex input.
Exceptions
- TypeError
A text operand, with EmathArccos(NDArray)'s text.
EmathArctanh(NDArray)
NumPy's np.emath.arctanh(x): _fix_real_abs_gt_1(x), then arctanh; a real element with
|x| > 1 makes the whole result complex. |x| == 1 stays real and gives ±inf.
public abstract NDArray EmathArctanh(NDArray x)
Parameters
xNDArrayThe input, any dtype and layout.
Returns
- NDArray
The inverse hyperbolic tangent: real while every real element has
|x| <= 1, complex128 otherwise or for a complex input.
Exceptions
- TypeError
A text operand, with EmathArccos(NDArray)'s text.
EmathLog(NDArray)
NumPy's np.emath.log(x): _fix_real_lt_zero(x), then log. A negative real element makes
the whole result complex (log(-e) == 1 + pi i) where Log(NDArray, DType, NDArray, NDArray) returns NaN.
public abstract NDArray EmathLog(NDArray x)
Parameters
xNDArrayThe input, any dtype and layout.
Returns
- NDArray
The natural logarithm: complex128 when
xis complex or a real element is negative (complex64 in NumPy for the narrow dtypes listed on EmathSqrt(NDArray)), else real;log(0)is-infandlog(inf)inf, both real.
Exceptions
- TypeError
A text operand, with EmathSqrt(NDArray)'s text.
EmathLog10(NDArray)
NumPy's np.emath.log10(x): _fix_real_lt_zero(x), then log10; a negative real element
makes the whole result complex.
public abstract NDArray EmathLog10(NDArray x)
Parameters
xNDArrayThe input, any dtype and layout.
Returns
- NDArray
The base-10 logarithm, complex under EmathLog(NDArray)'s conditions, else real.
Exceptions
- TypeError
A text operand, with EmathSqrt(NDArray)'s text.
EmathLog2(NDArray)
NumPy's np.emath.log2(x): _fix_real_lt_zero(x), then log2; a negative real element
makes the whole result complex.
public abstract NDArray EmathLog2(NDArray x)
Parameters
xNDArrayThe input, any dtype and layout.
Returns
- NDArray
The base-2 logarithm, complex under EmathLog(NDArray)'s conditions, else real.
Exceptions
- TypeError
A text operand, with EmathSqrt(NDArray)'s text.
EmathLogn(NDArray, NDArray)
NumPy's np.emath.logn(n, x): _fix_real_lt_zero(x), _fix_real_lt_zero(n), then
log(x) / log(n). Each operand is converted on its own, so a negative base alone (logn(-2, 8))
makes log(n) and with it the quotient complex.
public abstract NDArray EmathLogn(NDArray n, NDArray x)
Parameters
nNDArrayThe base(s), any dtype and layout. NumPy's argument order: the base comes first.
xNDArrayThe value(s), broadcast against
nby the division.
Returns
- NDArray
The quotient of the two logarithms, in the division's promoted dtype. A 0-d log result is read as a weak scalar by the division (the ufuncs' rule on this branch), where NumPy reads it as strong: a 0-d
xbeside a float16ngives float16 here and float64 in NumPy.
Exceptions
- TypeError
A text operand, with EmathSqrt(NDArray)'s text;
xis scanned first, as in NumPy.- IncorrectShapeException
Operands that do not broadcast together (NumPy's ValueError
operands could not be broadcast together with shapes ...), raised by the division after both logarithms.
EmathPower(NDArray, NDArray)
NumPy's np.emath.power(x, p): _fix_real_lt_zero(x), _fix_int_lt_zero(p), then
power(x, p). A negative real base makes the computation complex; a negative real exponent turns
p into a float (p * 1.0), so an integer base with a negative integer exponent
does not hit Power(NDArray, NDArray, DType, NDArray, NDArray)'s "Integers to negative integer powers" error.
public abstract NDArray EmathPower(NDArray x, NDArray p)
Parameters
xNDArrayThe base(s), any dtype and layout.
pNDArrayThe exponent(s), broadcast against
xby the power ufunc.
Returns
- NDArray
The power ufunc's result in its promoted dtype (complex128 after a negative real base). A 0-d operand is read as a weak scalar by the power ufunc (the ufuncs' rule on this branch), where NumPy reads a 0-d array as strong: a uint16 base with a 0-d int64 exponent gives uint16 here and int64 in NumPy.
Remarks
A negative base with a non-integer exponent takes the complex power, which is allclose to
NumPy's but not bit-exact (the F5 complex-power divergence); integer exponents are exact.
Exceptions
- TypeError
A text operand, with EmathSqrt(NDArray)'s text;
xis scanned first.- IncorrectShapeException
Operands that do not broadcast together, raised by the power ufunc.
EmathSqrt(NDArray)
NumPy's np.emath.sqrt(x): _fix_real_lt_zero(x), then sqrt. A real input with any element
below zero is converted to complex as a whole before the square root, so a negative element gets its
principal complex root where Sqrt(NDArray, DType, NDArray, NDArray) returns NaN.
public abstract NDArray EmathSqrt(NDArray x)
Parameters
xNDArrayThe input, any dtype and layout (a C# scalar or array converts at the facade).
Returns
- NDArray
The ufunc's result: complex128 when
xis complex or a real element is negative (NumPy picks complex64 for a float32, int8, int16, uint8 or uint16 input; NumSharp has one complex type), else the ordinary real result (integers and bool promote as Sqrt(NDArray, DType, NDArray, NDArray) does).-0.0and NaN never trigger the conversion. A 0-d input gives a 0-d array.
Remarks
The scan reads every element of a real operand once (an early exit at the first negative one); a complex operand skips it, because NumPy's conversion of a complex array is value-identical.
Exceptions
- TypeError
A text operand (S, U or StringDType): the domain scan's
x < 0has no loop for text and a Python int, NumPy'sufunc 'less' did not contain a loop ..., even for an empty array.
Evaluate(NDExpr, NDArray[], NDArray, NDArray, DType, string, char)
Fused evaluation of an NDExpr tree in one iterator pass: np.evaluate's whole call, its
keywords as the caller passed them (the np-layer dtype plan's D11). Virtual with a
NotSupportedException default, so an alternative engine opts in explicitly.
public virtual NDArray Evaluate(NDExpr expr, NDArray[] operands = null, NDArray @out = null, NDArray where = null, DType dtype = null, string casting = null, char order = 'K')
Parameters
exprNDExprThe tree; its array leaves are embedded NDArrays, or Input(int) leaves naming
operandsby position.operandsNDArray[]The positional operands for a tree of Input(int) leaves, or null for a tree whose leaves embed their arrays.
outNDArrayA pre-allocated result (ufunc
out=rules), or null.whereNDArrayA boolean write mask (ufunc
where=), or null.dtypeDTypeThe result dtype (a root cast), or null for the tree's own.
castingstringThe
out=cast rule name, or null forsame_kind.ordercharThe layout of a fresh result:
'K','C','F'or'A'(either case).
Returns
- NDArray
The evaluated array, or
outholding it.
Remarks
An implementation checks the arguments in np.evaluate's order: a read-only out,
then the keywords (dtype with out, the order letter, the casting name),
then the tree when its program is built (a node over a text operand that it does not compute among them) -
DefaultEngine's does.
Exceptions
- NotSupportedException
This engine has no fused evaluation (the default).
Evaluate(NDExprProgram, NDArray[], NDArray, in NDEvaluateOptions)
Fused evaluation of an already-compiled program (CompiledExpression):
the per-call work only — iteration shape, result allocation, iterator. The public
Evaluate(NDExpr, …) member above resolves the program from the tree's cache and
lands here.
public virtual NDArray Evaluate(NDExprProgram program, NDArray[] operands, NDArray @out, in NDEvaluateOptions options = default)
Parameters
programNDExprProgramThe compiled program: the bound tree, its input signature and kernel(s).
operandsNDArray[]The arrays bound to the program's inputs, in the program's order.
outNDArrayNumPy's
out=: the array that receives the result, ornullfor a fresh one.optionsNDEvaluateOptionsResolved
dtype=/casting=/order=keywords (plan P4.5);default= no override.
Returns
- NDArray
The result:
outwhen given, else a fresh array bound to this engine.
Remarks
Public so an engine can intercept every compiled evaluation (profiling, routing to another engine) and hand it on
to base. Footgun: NDExprProgram and NDEvaluateOptions are opaque outside
NumSharp.dll - an engine NOT derived from DefaultEngine can forward them but cannot run
them itself, so it keeps this base behaviour (the throw).
Exceptions
- NotSupportedException
This engine does not evaluate expressions (the base behaviour; an engine derived from DefaultEngine inherits its implementation).
Exp(NDArray, DType, NDArray, NDArray)
public abstract NDArray Exp(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Exp2(NDArray, DType, NDArray, NDArray)
public abstract NDArray Exp2(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Expm1(NDArray, DType, NDArray, NDArray)
public abstract NDArray Expm1(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
FMax(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray FMax(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
FMin(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray FMin(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Fabs(NDArray, DType, NDArray, NDArray)
public abstract NDArray Fabs(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Fix(NDArray, NDArray)
NumPy's np.fix(x, out=None): rounds toward zero, element-wise. In NumPy 2.4.2 its body is the one
statement return nx.trunc(x, out=out), so the dtype is kept (integers and bool unchanged, floats
truncated), NaN and the infinities pass through, the sign of -0.0 survives, and every error is trunc's.
public abstract NDArray Fix(NDArray x, NDArray @out = null)
Parameters
xNDArrayThe input (not null).
outNDArrayAn array to write the result into and return, or null: it joins the ufunc's broadcast and takes a same_kind cast from the loop dtype.
Returns
- NDArray
A new array of
x's shape and dtype, orout.
Remarks
DefaultEngine's member is that statement over Truncate(NDArray, DType, NDArray, NDArray), so trunc's error texts (they name
trunc, as NumPy's fix leaks them) are fix's. np.fix calls it after its matrix rule; an override
replaces it for every array whose engine it is. Unlike a ufunc it has no where= / dtype=.
Exceptions
- TypeError
An input trunc has no loop for: text (NumPy's no-loop texts), or complex (
ufunc 'trunc' not supported for the input types).- ValueError
A read-only
out(output array is read-only).- TypeError
An
outthe result does not reach under same_kind (Cannot cast ufunc 'trunc' output from ...).- ArgumentException
An
outthe result does not broadcast into.- NullReferenceException
xis null.
FlatNonZero(NDArray)
public abstract NDArray<long> FlatNonZero(NDArray a)
Parameters
aNDArray
Returns
FloatPower(NDArray, NDArray, DType, NDArray, NDArray)
Element-wise power with a MINIMUM precision of float64 (np.float_power). Unlike
Power(NDArray, NDArray, DType, NDArray, NDArray), float_power has ONLY the float64 (dd->d) and complex128
(DD->D) loops, so every real input (bool/int/float16/float32/decimal/char)
promotes to float64 and a complex operand promotes to complex128 — the result is
therefore always an inexact float. That absence of an integer loop is exactly why
float_power does NOT raise Power's "Integers to negative integer powers are not
allowed" (float_power(2, -1) == 0.5). The computation itself is bit-identical
to Power(NDArray, NDArray, DType, NDArray, NDArray) on those two loops.
public abstract NDArray FloatPower(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
lhsNDArrayThe bases (any dtype; promoted to the float loop).
rhsNDArrayThe exponents (any dtype; promoted to the float loop).
dtypeDTypeExplicit loop dtype (NumPy ufunc
dtype=). Only float64 or complex128 select a loop; any other request raises NumPy's "No loop matching the specified signature and casting was found for ufunc float_power".outNDArrayDestination (NumPy ufunc
out=): joins the broadcast without being stretched, must be same_kind-castable from the float loop dtype; returned as-is.whereNDArrayBoolean write-mask (NumPy ufunc
where=): only mask-true slots are computed/written; false slots keep the prioroutcontents.
Returns
- NDArray
The bases raised to the exponents at float64/complex128 precision (or
outwhen supplied).
Exceptions
- IncorrectTypeException
A
dtypeother than float64 or complex128 was requested (no such loop exists).- TypeError
A complex input cannot same_kind-cast to a requested float64 loop, or the loop dtype cannot same_kind-cast into
out.- ArgumentException
whereis non-bool;outis read-only; or the shapes do not broadcast.
Floor(NDArray, DType, NDArray, NDArray)
public abstract NDArray Floor(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
FloorDivide(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray FloorDivide(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Fmod(NDArray, NDArray, DType, NDArray, NDArray)
np.fmod — C-style truncated remainder (result takes the DIVIDEND's sign), the complement of Mod(NDArray, NDArray, DType, NDArray, NDArray) (floored, divisor's sign). Same NEP50 promotion as Mod (integer stays integer, bool -> int8) and the same (inputs, dtype, out, where) house order.
public abstract NDArray Fmod(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Frexp(NDArray, NDArray, NDArray, NDArray, DType)
NumPy's np.frexp: the (mantissa, int32 exponent) decomposition.
public abstract (NDArray Mantissa, NDArray Exponent) Frexp(NDArray x, NDArray out1 = null, NDArray out2 = null, NDArray where = null, DType dtype = null)
Parameters
xNDArrayThe input.
out1NDArrayThe mantissa output, or null.
out2NDArrayThe exponent output, or null.
whereNDArrayThe bool write mask, or null.
dtypeDTypeNumPy's
dtype=: frexp has no loop for any explicit dtype (it would apply to both outputs, and the exponent is int32), so anything but null raises.
Returns
Exceptions
- IncorrectTypeException
A complex input, or any
dtype.
Gcd(NDArray, NDArray, DType, NDArray, NDArray)
np.gcd — element-wise greatest common divisor of |lhs| and |lhs|. INTEGER-ONLY: a bool/float/complex/decimal operand (or a uint64+signed pair promoting to float64) has no loop and raises NumPy's no-loop TypeError. Uniform NEP50 promotion (both operands + output share one integer dtype); a negative result is possible only where the magnitude wraps the signed range (gcd(-128,-128)==-128). Same (inputs, dtype, out, where) house order as the rest of the binary ufunc surface.
public abstract NDArray Gcd(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
lhsNDArrayFirst input array.
rhsNDArraySecond input array.
dtypeDTypeExplicit loop dtype (NumPy ufunc dtype=); must name an integer loop.
outNDArrayOutput location (NumPy ufunc out=); returned as-is when supplied.
whereNDArrayBoolean mask (NumPy ufunc where=); masked-off elements keep their prior value.
Returns
- NDArray
The element-wise gcd, in the promoted integer dtype.
Geomspace(NDArray, NDArray, long, bool, DType, int)
NumPy's np.geomspace(start, stop, num=50, endpoint=True, dtype=None, axis=0): numbers spaced evenly on a
log scale, each end pair its own geometric progression - computed as NumPy computes it: both ends divided by
sign(start), logspace(log10(start), log10(stop)), the ends written back exactly, the whole
multiplied by the sign, the sample axis moved to axis - so ends of opposite signs give NaN
between them (the log of a negative value) and complex ends a logarithmic spiral.
public abstract NDArray Geomspace(NDArray start, NDArray stop, long num = 50, bool endpoint = true, DType dtype = null, int axis = 0)
Parameters
startNDArrayThe first sample(s): a 0-d array (a C# number converts to one, read as NumPy reads a Python number) or any array that broadcasts with
stop; no element may be zero.stopNDArrayThe last sample(s) when
endpointis true; no element may be zero.numlongThe number of samples.
endpointboolWhether
stopis the last sample.dtypeDTypeThe result dtype, or null for the computation dtype
dt = result_type(start, stop, float(num), zeros((), dtype))(float64 for real ends unless they are a narrower float array AND the dtype asks for it, complex128 for complex ends or a complex dtype); the samples are computed indtand cast at the end (an integer dtype truncates toward zero); a text dtype is refused, as NumPy refuses it (below).axisintThe axis of the result that holds the samples (NumPy's trailing
moveaxis(result, 0, axis)): in range for the result's rank, one more than the broadcast ends'.
Returns
- NDArray
A new array of shape
(num, *broadcast(start, stop).shape)with the sample axis moved toaxis; a moved axis is NumPy'smoveaxisview, which does not own its buffer unless the final cast todtypecopies it.
Remarks
np.geomspace calls this member of the start operand's engine. DefaultEngine follows NumPy's
statements over arrays (sign, true_divide, log10, linspace, power, the end writes, multiply, moveaxis), so an
override must keep that arithmetic in dt: float32 ends with a float32 dtype round in float32, as
NumPy's do. Two 0-d ends that compute in float64 are NumPy's float64 result byte for byte (the sign is exactly
1 or -1, and the interior is Pow(double, double) and
Log10(double), the routines NumPy calls on win-amd64); complex ends are within the
complex-unary envelope of NumPy's values (about 3 ULP), not its bits. A NaN start makes every sample of its
progression NaN, as NumPy's result *= out_sign does.
API-parity batch 10: this one member replaces the scalar Geomspace(double, ...) and
Geomspace(Complex, ...) members; a C# number or Complex converts to a 0-d array.
Exceptions
- ArgumentNullException
startorstopis null.- ValueError
A zero element in either end (
Geometric sequence cannot include zero, NumPy's first check), then (after the text dtypes) a negativenum(Number of samples, -1, must be non-negative.).- DTypePromotionError
A
StringDTypedtype: NumPy'sresult_type(start, stop, float(num), zeros((), dtype))finds no common DType (its text lists the four DType classes), right after the zero check.- TypeError
An
SorUdtype: the ends promote to text and NumPy'ssign(start)has no string loop (ufunc 'sign' did not contain a loop with signature matching types <class 'numpy.dtypes.StrDType'> -> None), right after the zero check.- IncorrectShapeException
Ends that do not broadcast (the division by the start's sign).
- AxisError
axisout of range for the result (destination: axis 1 is out of bounds for array of dimension 1), checked afternum.- NotSupportedException
dtypehas no storage lane (a datetime descriptor): the final cast refuses it.
GetStorage(DType)
Get storage described by the dtype DESCRIPTOR descr (NumPy's PyArray_NewFromDescr
entry — the descriptor becomes the array's dtype, its class supplies the storage lane). The default
routes through GetStorage(Type), which is exact for every builtin (one canonical descriptor
per lane); an engine that carries parametric descriptors overrides it.
public virtual UnmanagedStorage GetStorage(DType descr)
Parameters
descrDType
Returns
GetStorage(Type)
Get storage for given dtype.
public abstract UnmanagedStorage GetStorage(Type dtype)
Parameters
dtypeType
Returns
Gradient(NDArray, object[], int[], int)
NumPy's np.gradient(f, *varargs, axis=None, edge_order=1): one fresh array per requested axis, with
second-order central differences inside and first- or second-order one-sided differences at both ends; each
component has f's shape.
public abstract np.GradientResult Gradient(NDArray f, object[] varargs, int[] axis = null, int edge_order = 1)
Parameters
fNDArrayThe sampled values, a plain array (null is refused by the body's first statement).
varargsobject[]NumPy's
*varargs: no entry (unit steps), one scalar for every axis, or one entry per requested axis, each a scalar step (a C# number is a Python number, weak) or a 1-D coordinate array as long as its axis.axisint[]The axes to differentiate along (negative values count from the end), or null for every axis. A one-axis call passes a one-element array. (DefaultEngine's override names it
axisArg: its loop rebinds NumPy'saxis.)edge_orderintThe boundary order: 1 gives first-order ends; any other value up to 2 (0 and negative values included, as NumPy reads them) gives second-order ends.
Returns
- np.GradientResult
One component per requested axis, a single array when exactly one axis was requested (NumPy's bare ndarray), none for a 0-d
fwithout an axis.
Remarks
NumPy writes gradient in Python; DefaultEngine's override runs its statements, each in NumPy's dtype, so the
components are bit-identical to NumPy's. np.gradient's overloads spread their spacings into one list
and call this, a subclass operand handed in as its plain view; an override replaces it for every array whose
engine it is. NumPy creates every component with np.empty_like(f, dtype=otype), so each is
f's class (Gradient(GradientResult, NDArray)). New in 0.80.0 (the np-layer dtype plan,
phase PE); it was the internal class GradientEngine.
Exceptions
- ArgumentNullException
fis null.- AxisError
An axis outside
[-f.ndim, f.ndim).- ValueError
A repeated axis; a ragged list spacing; a coordinate array of another rank than 1 or another length than its axis;
edge_orderabove 2; an axis shorter thanedge_order + 1.- NotSupportedException
A list spacing holding None or another object, or a Python int past uint64 (NumPy's object array).
- TypeError
A spacing count other than 0, 1 or the number of axes; a bool
fwith a scalar step or first-order edges (NumPy's boolean subtract); a textf; bool coordinates; a str or None step.- IndexError
The coordinates of an empty axis.
- ZeroDivisionError
A zero step that is a Python number with second-order edges (CPython's ZeroDivisionError).
- DivideByZeroException
A decimal input or step divided by zero (.NET's own: decimal has no inf).
- OverflowError
A Python int step past the float range.
- OverflowException
A decimal result past decimal's range.
Greater(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray Greater(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
GreaterEqual(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray GreaterEqual(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Hamming(double)
NumPy's np.hamming(M): the Hamming window of M points, the raised cosine
0.54 + 0.46cos(pin/(M-1)) over n = arange(1-M, M, 2) - its ends stay at 0.08, not zero.
public abstract NDArray Hamming(double M)
Parameters
MdoubleThe number of points, NumPy's
_FloatLike_co(the length and the guards of Bartlett(double)).
Returns
- NDArray
A new 1-D float64 array.
Remarks
DefaultEngine's fused pass keeps NumPy's evaluation order; np.hamming calls the default engine's
member.
Exceptions
- ValueError
Mis NaN, +infinity or too large for arange to size.- OutOfMemoryException
A finite count whose window does not fit in memory.
Hanning(double)
NumPy's np.hanning(M): the Hann window of M points, the raised cosine
0.5 + 0.5cos(pin/(M-1)) over n = arange(1-M, M, 2) - zero at both ends.
public abstract NDArray Hanning(double M)
Parameters
MdoubleThe number of points, NumPy's
_FloatLike_co(the length and the guards of Bartlett(double)).
Returns
- NDArray
A new 1-D float64 array.
Remarks
DefaultEngine's fused pass keeps NumPy's evaluation order; np.hanning calls the default engine's
member.
Exceptions
- ValueError
Mis NaN, +infinity or too large for arange to size.- OutOfMemoryException
A finite count whose window does not fit in memory.
Heaviside(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray Heaviside(NDArray x1, NDArray x2, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Histogram(NDArray, object, (double, double)?, bool, NDArray)
NumPy's np.histogram(a, bins=10, range=None, density=None, weights=None): the counts (or summed
weights, or density) of the data in each bin, and the bin edges.
public abstract np.HistogramResult Histogram(NDArray a, object bins, (double, double)? range = null, bool density = false, NDArray weights = null)
Parameters
aNDArrayThe data, a plain array (flattened).
binsobjectAn int count (NumPy's default is 10; the facades pass it), an estimator name, or an NDArray (a 0-d count or 1-D monotonic edges).
range(double, double)?The outer edges, or null for the data's minimum and maximum.
densityboolReturn the probability density instead of the counts.
weightsNDArrayWeights of
a's shape, or null.
Returns
- np.HistogramResult
The histogram and the edges (NumPy's tuple).
Remarks
NumPy writes histogram in Python; DefaultEngine's override runs its statements, the weighted float sums in
NumPy's blocks of 65,536 samples (which keeps them bit-identical to NumPy's). The facades hand a subclass
operand in as its plain view; an override replaces it for every array whose engine it is. New in 0.80.0
(the np-layer dtype plan, phase PE); it was the internal class HistogramEngine.
Exceptions
- ValueError
A weights shape that differs from
a's, and the edge errors of HistogramBinEdges(NDArray, object, (double, double)?, NDArray).- TypeError
The edge errors of HistogramBinEdges(NDArray, object, (double, double)?, NDArray); text data that NumPy's counting step refuses (its no-loop texts).
- UnicodeDecodeError
A text search converts
Stext holding a byte that is not ASCII to aUcommon descriptor.- ArgumentException
Bool weights over data on explicit edges (the in-place update of the bool total).
Histogram2d(NDArray, NDArray, object, (double, double)?[], bool, NDArray)
NumPy's np.histogram2d(x, y, bins=10, range=None, density=None, weights=None): the bidimensional
histogram of two samples, NumPy's wrapper of histogramdd (numpy/lib/_twodim_base_impl.py).
public abstract np.Histogram2dResult Histogram2d(NDArray x, NDArray y, object bins, (double, double)?[] range = null, bool density = false, NDArray weights = null)
Parameters
xNDArrayThe x coordinates, a plain array (not null).
yNDArrayThe y coordinates, a plain array of
x's length (not null).binsobjectThe bin spec: an int or NDArray for both dimensions (NumPy's default is 10; the facades pass it), or a 1- or 2-element sequence of per-dimension specs.
range(double, double)?[]Per-dimension outer edges, or null.
densityboolReturn the probability density instead of the counts.
weightsNDArrayPer-point weights, or null.
Returns
- np.Histogram2dResult
The histogram
Hand the two edge arrays (NumPy's tuple).
Remarks
NumPy writes histogram2d in Python; DefaultEngine's override runs its statements (the length check, the bins
dispatch, then histogramdd's statements). An override replaces np.histogram2d for every array whose
engine it is (the engine of x). New in 0.80.0 (the np-layer dtype plan, phase PE); it was
the internal class HistogramEngine.
Exceptions
- ArgumentNullException
xoryis null.- TypeError
xoryis 0-d (len() of unsized object), and the TypeErrors of Histogramdd(NDArray[], object, (double, double)?[], bool, NDArray).- ValueError
xandydiffer in length (x and y must have the same length.); arrays of one length but different shapes; two 2-D arrays of one shape (too many values to unpack (expected 2)); and the ValueErrors of Histogramdd(NDArray[], object, (double, double)?[], bool, NDArray).
HistogramBinEdges(NDArray, object, (double, double)?, NDArray)
NumPy's np.histogram_bin_edges(a, bins=10, range=None, weights=None): the bin edges
Histogram(NDArray, object, (double, double)?, bool, NDArray) would use, from _ravel_and_check_weights and _get_bin_edges.
public abstract NDArray HistogramBinEdges(NDArray a, object bins, (double, double)? range = null, NDArray weights = null)
Parameters
aNDArrayThe data, a plain array (flattened).
binsobjectAn int count (NumPy's default is 10; the facades pass it), an estimator name (
auto,fd,doane,scott,stone,rice,sturges,sqrt), or an NDArray (a 0-d count or 1-D monotonic edges, returned as given).range(double, double)?The outer edges, or null for the data's minimum and maximum.
weightsNDArrayWeights of
a's shape (shape-checked only), or null.
Returns
- NDArray
The bin edges (
nbins + 1of them); an explicit edge array comes back as that array.
Remarks
NumPy writes histogram_bin_edges in Python; DefaultEngine's override runs its statements. The facades hand
a subclass operand in as its plain view and convert their C# bins form first; an override
replaces it for
every array whose engine it is (the engine of a). New in 0.80.0 (the np-layer dtype plan,
phase PE); it was the internal class HistogramEngine.
Exceptions
- ValueError
A weights shape that differs from
a's; an unknown estimator; a count below 1; edges that are not 1-D or decrease (text edges by the string comparison); an invalid range; too many bins for the range.- TypeError
Weights with an estimator; a non-integer scalar
bins; text data without a range (itsa.min()), with a range and an estimator (the in-range mask's comparison), or against the edges' dtype (DTypePromotionError: no common DType for text and Python numbers).
Histogramdd(NDArray[], object, (double, double)?[], bool, NDArray)
NumPy's np.histogramdd(sample, bins=10, range=None, density=None, weights=None): the D-dimensional
histogram of N points.
public abstract np.HistogramddResult Histogramdd(NDArray[] sample, object bins, (double, double)?[] range = null, bool density = false, NDArray weights = null)
Parameters
sampleNDArray[]The points as D coordinate columns, each 1-D of length N: the normalized form of NumPy's
(N, D)array or sequence of D arrays (the facades build it).binsobjectThe bin spec: an int for every dimension (NumPy's default is 10; the facades pass it), an int array, an NDArray, an NDArray array, or an object array of per-dimension specs.
range(double, double)?[]Per-dimension outer edges, or null.
densityboolReturn the probability density instead of the counts.
weightsNDArrayPer-point weights: a 1-D array of N values, read as given, or null.
Returns
- np.HistogramddResult
The histogram and its per-dimension edges (NumPy's tuple). Without density the histogram is NumPy's VIEW of the padded counts; a 1-D edges array the caller passed is returned as that same array.
Remarks
NumPy writes histogramdd in Python; DefaultEngine's override runs its statements one dimension at a time, in
NumPy's order. An override replaces np.histogramdd for every array whose engine it is (the engine of
the sample's first column); np.histogram2d reaches DefaultEngine's histogramdd statements through
Histogram2d(NDArray, NDArray, object, (double, double)?[], bool, NDArray). New in 0.80.0 (the np-layer dtype plan, phase PE); it was the internal class
HistogramEngine.
Exceptions
- ValueError
A dimension mismatch, a non-positive scalar bin, edges that are not a scalar or 1-D, or non-monotonic edges; with points, 1-D weights of another length than the points.
- IncorrectShapeException
With points, weights that are not 1-D (bincount's depth check).
- InvalidCastException
With points, complex weights (bincount's safe cast to float64).
- IndexError
An empty edge array in any dimension (NumPy's
edges[i][-1]).- TypeError
A scalar bin that is not an integer, or that does not compare with 1; text samples with a scalar bin spec and no range; text edges; 1-D text weights with points.
- UnicodeDecodeError
An
Scolumn beside aUcolumn holding a byte that is not ASCII (NumPy's stacking decodes it before any bin is read).
Hypot(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray Hypot(NDArray x1, NDArray x2, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
I0(NDArray)
NumPy's np.i0(x), the modified Bessel function of the first kind, order 0: astype(float) for a
dtype that is not float, abs, then the cephes Chebyshev series (|x| <= 8 and above), each
float width computed in its own precision as NumPy's ufunc chain computes it.
public abstract NDArray I0(NDArray x)
Parameters
xNDArrayThe input, any dtype but complex, any layout (not null).
Returns
- NDArray
The values: float16 / float32 / float64 kept, float64 for bool, integers, char and parsed text, decimal for decimal (the double bridge).
Remarks
DefaultEngine runs the series per element in one fused np.evaluate pass.
Exceptions
- ArgumentNullException
xis null.- IncorrectTypeException
A complex operand (NumPy's
i0 not supported for complex values).- ValueError
Text that does not parse as a float (NumPy's
astype(float)).- OverflowException
A decimal result past the decimal range (
|x|above about 72).
Inner(NDArray, NDArray)
np.inner — a sum product over the LAST axis of both operands.
public virtual NDArray Inner(NDArray a, NDArray b)
Parameters
aNDArrayThe first operand.
bNDArrayThe second operand; its last two axes are swapped (a view) before the product.
Returns
- NDArray
The inner product, shape
a.shape[:-1] + b.shape[:-1].
Remarks
NumPy's PyArray_InnerProduct swaps the last two axes of b
(when a.ndim >= 1 and b.ndim >= 2) and hands the pair to the very same
PyArray_MatrixProduct2 that backs np.dot — which is why an unaligned
inner reports b's shape ALREADY TRANSPOSED.
NDAnchoredAttribute: the managed product reads both operands' raw addresses in
Dot, an engine method that opens no scope, so the weaver roots a and
b here until the product returns — a caller's temporary operand
(np.inner(a, np.arange(n))) cannot be collected under the kernel. An override does not inherit
the mark.
Exceptions
- IncorrectShapeException
The last axes do not align (NumPy's "shapes ... not aligned" text, with
b's shape transposed).- ArgumentException
The same misalignment on the vector-times-matrix path of
Dot, which raises the house type of that path with the same NumPy text.- TypeError
A fixed-width string operand beside a 0-d one: NumPy's no-loop refusal of the
multiplyit computes.- ValueError
A text operand otherwise: "dot not available for this type" (the string product has no item size to allocate).
Interp(NDArray, NDArray, NDArray, NDArray, NDArray, double?)
NumPy's np.interp(x, xp, fp, left=None, right=None, period=None): the piecewise-linear interpolant
through the points (xp, fp), evaluated at x. NumPy picks the loop from fp alone (complex128 for a complex fp,
float64 otherwise); with a period, x and xp are taken modulo it and the fill values are ignored.
public abstract NDArray Interp(NDArray x, NDArray xp, NDArray fp, NDArray left = null, NDArray right = null, double? period = null)
Parameters
xNDArrayThe coordinates to evaluate at, any shape.
xpNDArrayThe sample points, 1-D, increasing unless a period is given (not checked: NumPy's loop answers other points deterministically).
fpNDArrayThe sample values, 1-D, as many as xp.
leftNDArrayThe value below
xp[0]as NumPy's Python object, or null (None, meaningfp[0]). A C# literal is a Python number / bool / str (a double or an int converts implicitly, a Complex is a Python complex), a 0-d array that is not an explicit array a NumPy scalar, anything else an ndarray; the loop converts it as NumPy's does (PyFloat_AsDouble, or for the complex loopPyComplex_RealAsDouble/ImagAsDouble) after the operand and length checks.rightNDArrayThe value above
xp[-1], asleft(null meansfp[-1]), converted after it.perioddouble?The period of the x-coordinates, or null; it must not be zero.
Returns
- NDArray
A new array of x's shape (0-d for a 0-d x): complex128 for a complex fp, float64 otherwise.
Remarks
API-parity batch 12: the fill values were an object that took only a double or a Complex; they
are now typed, and every Python object NumPy converts converts here too.
Exceptions
- NullReferenceException
An operand is null.
- ValueError
fp or xp not 1-D (
object too deep for desired array/object of too small depth for desired array), empty sample points, lengths that differ, a zero period; with a period, points that are not 1-D (Data points must be 1-D sequences) or text that does not parse as a float; a 0-d text array fill that spells no float (could not convert string to float).- InvalidCastException
Without a period, an operand that does not cast 'safely' to the loop's dtype (NumPy's TypeError text).
- TypeError
Without a period, a fill value the loop's conversion refuses, raised after the operand and length checks: a Python complex in the real loop (
must be real number, not complex), a Python str (must be real number, not str), an array of one or more dimensions (only 0-dimensional arrays can be converted to Python scalars), a 0-d complex array (float() argument must be a string or a real number, not 'complex').
Invert(NDArray, DType, NDArray, NDArray)
public abstract NDArray Invert(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
IsClose(NDArray, NDArray, double, double, bool)
public abstract NDArray<bool> IsClose(NDArray a, NDArray b, double rtol = 1E-05, double atol = 1E-08, bool equal_nan = false)
Parameters
Returns
IsFinite(NDArray, DType, NDArray, NDArray)
public abstract NDArray IsFinite(NDArray a, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
IsInf(NDArray, DType, NDArray, NDArray)
public abstract NDArray IsInf(NDArray a, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
IsNan(NDArray, DType, NDArray, NDArray)
public abstract NDArray IsNan(NDArray a, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
IsNegInf(NDArray, DType, NDArray, NDArray)
NumPy's np.isneginf(x, out=None), isinf(x) & signbit(x): True where an element is -inf.
Integers and bool are never infinite.
public abstract NDArray IsNegInf(NDArray a, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
aNDArrayThe input.
dtypeDTypeUnused by the NumPy function (it has no dtype=); NumSharp's facade passes bool.
outNDArrayAn array to write the result into and return, or null.
whereNDArrayUnused by the NumPy function (null).
Returns
- NDArray
A bool array of
a's shape, orout.
Exceptions
- TypeError
A complex input (NumPy's signbit refusal, raised first), or text (isinf's refusal).
IsPosInf(NDArray, DType, NDArray, NDArray)
NumPy's np.isposinf(x, out=None), isinf(x) & ~signbit(x): True where an element is +inf.
Integers and bool are never infinite.
public abstract NDArray IsPosInf(NDArray a, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
aNDArrayThe input.
dtypeDTypeUnused by the NumPy function (it has no dtype=); NumSharp's facade passes bool.
outNDArrayAn array to write the result into and return, or null.
whereNDArrayUnused by the NumPy function (null).
Returns
- NDArray
A bool array of
a's shape, orout.
Exceptions
- TypeError
A complex input (
This operation is not supported for complex128 values because it would be ambiguous., NumPy's signbit refusal, raised first), or text (isinf's refusal).
Iscomplex(NDArray)
NumPy's np.iscomplex(x): for a complex input imag(x) != 0 (True where an element's imaginary
part is not zero: NaN and inf count, -0.0 does not), for any other dtype all False.
public abstract NDArray Iscomplex(NDArray a)
Parameters
aNDArrayThe input.
Returns
- NDArray
A bool array of
a's shape: for a dtype that is not complex, NumPy'szeros(shape, bool)[()], a view of a fresh buffer (OWNDATA false; the 0-d array itself for a 0-d input).
Exceptions
- ArgumentNullException
ais null.
Isin(NDArray, NDArray, bool, bool, string)
NumPy's np.isin: whether each element of element is in
test_elements (or, with invert, is not), as a bool array of
element's shape. NaN is never a member; text compares as text, a StringDType NA by
its descriptor's rules.
public abstract NDArray Isin(NDArray element, NDArray test_elements, bool assume_unique = false, bool invert = false, string kind = null)
Parameters
elementNDArrayThe tested values, a plain array (
np.isincomputes anumpy.matrixoperand as a plain one).test_elementsNDArrayThe set, flattened before use.
assume_uniqueboolNumPy's speed hint. Where NumPy takes its sort path, repeated values then get NumPy's answer for them (an element is flagged when an equal value follows it in
elementor lies in the set); the table method and the loop path ignore it.invertboolAnswer
element not in test_elements(NumPy's AND of!=).kindstringThe algorithm: null (automatic),
"sort"or"table". Every path gives the same membership, except underassume_uniquewith repeated values;"table"is only valid for bool and integer arrays.
Returns
- NDArray
A bool array of
element's shape: a view of a fresh 1-D answer, as NumPy's reshape returns it.
Remarks
NumPy writes isin in Python (_isin); DefaultEngine's override runs NumPy's path decision (table, loop
or sort) and answers each path with NumPy's membership. An override replaces np.isin for every array
whose engine it is (the engine of element). New in 0.80.0 (the np-layer dtype plan, phase
PE); it was the internal class IsinEngine.
Exceptions
- ValueError
An unknown
kind(Invalid kind: 'x'. Please use None, 'sort' or 'table'.),kind='table'for an array that is not bool or integer, orkind='table'over a set whose range is2**63 - 1or more (Maximum allowed dimension exceeded).- InvalidOperationException
kind='table'with a set whose range exceeds its dtype's maximum (NumPy's RuntimeError text).- UnicodeDecodeError
The text route's sort path decodes
Stext holding a byte that is not ASCII besideUtext.- NotSupportedException
A
StringDTypeset whose NA object is a sequence, held by an NA cell (NumPy broadcasts the comparison against it).
Isreal(NDArray)
NumPy's np.isreal(x), imag(x) == 0: True where an element's imaginary part is zero (a -0.0
too); every element of a dtype that is not complex is real, and no element of text is (NumPy's
'' == 0 has no loop and answers False).
public abstract NDArray Isreal(NDArray a)
Parameters
aNDArrayThe input.
Returns
- NDArray
A new bool array of
a's shape (C order whatever its layout).
Exceptions
- ArgumentNullException
ais null.
Kaiser(double, double)
NumPy's np.kaiser(M, beta): the Kaiser window of M points,
i0(beta * sqrt(1 - ((n - alpha)/alpha)**2)) / i0(beta) over n = arange(0, M) with
alpha = (M - 1)/2.
public abstract NDArray Kaiser(double M, double beta)
Parameters
MdoubleThe number of points, NumPy's
_FloatLike_co. Unlike the cosine windows kaiser has noM < 1guard:arange(0, M)is empty forM <= 0but one point for0 < M < 1, and onlyM == 1is special-cased (ones(1), which avoidsalpha == 0). A fractional count past a whole one leaves a trailing NaN where|(n - alpha)/alpha| > 1, as in NumPy.betadoubleThe shape parameter: 0 is a rectangular window and a larger value a narrower one (5 is close to a Hamming window, 6 to a Hann window, 8.6 to a Blackman window). Any double is taken; past about 709.78, where the series'
expoverflows,i0(beta)is infinite, so the window is NaN where its numerator overflows too (inf / inf) and zero elsewhere.
Returns
- NDArray
A new 1-D float64 array.
Remarks
DefaultEngine runs the cephes i0 series NumPy's np.i0 runs once per element of a fused pass, and takes
i0(beta) from its own I0(NDArray) (NumPy's i0(float(beta))), so the values are NumPy's bit for
bit where the host's exp and sqrt are. np.kaiser calls the default engine's member.
Exceptions
- ValueError
Mis NaN, or an infinity or too large for arange to size.- OutOfMemoryException
A finite count whose window does not fit in memory.
Kron(NDArray, NDArray)
NumPy's np.kron(a, b), the whole call: the Kronecker product, a composite array of blocks of
b scaled by the elements of a. For a.shape = (r0, ..., rN) and
b.shape = (s0, ..., sN) the result has shape (r0s0, ..., rNsN) and
kron(a, b)[k0, ..., kN] = a[i0, ..., iN] * b[j0, ..., jN] with kt = it*st + jt.
public abstract NDArray Kron(NDArray a, NDArray b)
Parameters
aNDArrayThe first operand.
bNDArrayThe second operand. The operand of smaller rank is read as if prepended with length-1 axes (NumPy's
ndmin).
Returns
- NDArray
A fresh, writeable, C-contiguous array in np.multiply's result dtype (NEP 50); with a 0-d operand the element-wise product, the degenerate Kronecker product.
Remarks
New in 0.80.0 (the np-layer dtype plan): the public np.kron applies the numpy.matrix and
numpy.char.chararray rules and calls this.
Exceptions
- NullReferenceException
aorbis null.- TypeError
Operands np.multiply refuses (text has no multiply loop: NumPy's ufunc refusal).
Lcm(NDArray, NDArray, DType, NDArray, NDArray)
np.lcm — element-wise lowest common multiple of |lhs| and |rhs| (0 when either is 0). Shares every rule with Gcd(NDArray, NDArray, DType, NDArray, NDArray) (integer-only loops, uniform NEP50 promotion, same house order); the product |lhs|/gcd*|rhs| WRAPS the dtype on overflow, matching NumPy.
public abstract NDArray Lcm(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
lhsNDArrayFirst input array.
rhsNDArraySecond input array.
dtypeDTypeExplicit loop dtype (NumPy ufunc dtype=); must name an integer loop.
outNDArrayOutput location (NumPy ufunc out=); returned as-is when supplied.
whereNDArrayBoolean mask (NumPy ufunc where=); masked-off elements keep their prior value.
Returns
- NDArray
The element-wise lcm, in the promoted integer dtype.
Ldexp(NDArray, NDArray, DType, NDArray, NDArray)
NumPy's np.ldexp: x1 * 2^x2, the inverse of Frexp(NDArray, NDArray, NDArray, NDArray, DType). x1 is the float mantissa
(int / bool promote to a float tier), x2 an INTEGER exponent that does NOT widen x1's dtype; the result is
x1's float tier, or dtype.
public abstract NDArray Ldexp(NDArray x1, NDArray x2, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
x1NDArrayThe mantissas.
x2NDArrayThe integer exponents.
dtypeDTypeThe loop's float dtype (NumPy's
dtype=: float16 / float32 / float64), or null for x1's tier. NumPy's loops pair a float with an int exponent and cast the operands 'safe', so x1 must cast safely to it and x2 to int64; anything else has no loop.outNDArrayThe output (same_kind cast from the loop dtype), or null.
whereNDArrayThe bool write mask, or null.
Returns
- NDArray
The result, or
out.
Remarks
The parameter order is the ufunc shape (inputs, dtype, out, where last), which
NumSharp.Build reads to give np.ldexp NumPy's array_wrap for a matrix operand: with
dtype anywhere else the function would return a plain array. np.ldexp keeps NumPy's keyword
order.
Exceptions
- IncorrectTypeException
No loop: a complex mantissa, a non-integer exponent, or a
dtypethe operands do not reach (NumPy's "No loop matching ..." text).
LeftShift(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray LeftShift(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Less(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray Less(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
LessEqual(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray LessEqual(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
LexSort(NDArray[], int)
NumPy's np.lexsort(keys, axis) (PyArray_LexSort), the whole call: the int64 indices that sort
by several keys at once, the LAST key primary and each earlier one breaking the ties of the keys after it
(a stable sort per key).
public abstract NDArray LexSort(NDArray[] keys, int axis = -1)
Parameters
keysNDArray[]The keys, every one of the same shape (any dtype; text sorts by code points). The public
np.lexsort(NDArray, int)splits an array along its first axis into this list.axisintThe axis sorted along (negative counts from the end). Keys of rank 0 accept 0 and -1 (NumPy's backwards compatibility) and answer the 0-d
0.
Returns
- NDArray
A fresh int64 array of the keys' shape (zeros for keys of at most one element).
Remarks
New in 0.80.0 (the np-layer dtype plan, phase PE, E5): the public np.lexsort applies its class
boundaries and calls this.
Exceptions
- TypeError
keysis null or empty (need sequence of keys with len > 0 in lexsort).- ArgumentNullException
A key is null.
- ValueError
The keys differ in shape (
all keys need to be the same shape).- AxisError
The axis is out of range.
Linspace(NDArray, NDArray, long, bool, DType, int, string)
NumPy's np.linspace(start, stop, num, endpoint, dtype=dtype, axis=axis, device=device) over array_like
ends, statement for statement: the samples are computed in result_type(start, stop, ensure_inexact=True)
(float32 ends stay float32, integer ends compute in float64, complex ends in complex), along a new axis of
length num in front of the ends' broadcast shape, which axis then moves.
public abstract NDArray Linspace(NDArray start, NDArray stop, long num, bool endpoint, DType dtype, int axis, string device)
Parameters
startNDArrayThe first sample (a 0-d array for a scalar end). A C# number that reached the NDArray parameter through its implicit conversion is a WEAK Python number (NEP 50): it takes the other end's dtype, so
(0, float32 1.5)computes in float32 and two C# numbers in float64.stopNDArrayThe last sample when
endpointis true; otherwise the bound the samples approach. Broadcast againststart.numlongThe number of samples.
endpointboolWhether
stopis the last sample (it is then written exactly:y[-1, ...] = stop).dtypeDTypeThe result dtype, or null for the computation dtype. An integer dtype FLOORS the samples before the cast (NumPy 1.20+), bool casts (nonzero is True), a text dtype formats them as
astypedoes.axisintWhere the sample axis goes in the result (NumPy's
moveaxis(y, 0, axis)); 0 keeps it first, -1 makes it last.devicestringNumPy's Array-API
device=: only"cpu"and null are accepted, checked where NumPy's rampnp.arangechecks it (after the count, the promotion and the broadcast).
Returns
- NDArray
The samples:
(num, *broadcast(start, stop).shape)with the sample axis moved toaxis. Ownership follows NumPy's statements: a moved axis or two scalar ends computed in float64 give a view whose buffer the array does not own; array ends give a fresh array.
Remarks
np.linspace calls this member of the start operand's engine. An override must keep NumPy's arithmetic,
which ported code reads bit for bit: arange(num) * step + start in the computation dtype (float32 ends
round in float32), the exact last sample, y * delta + start for one sample with the endpoint, and NumPy's
gh-5437 order arange(num) / div * delta + start when ANY step is zero. A subclass operand
(numpy.matrix) arrives as a plain view and the result is wrapped by its class, as NumPy's
_array_converter.wrap does.
Exceptions
- ValueError
A negative
num(Number of samples, -1, must be non-negative.), checked first; adeviceother than"cpu".- DTypePromotionError
Ends with no common inexact dtype (text ends: NumPy's text naming the DType classes and
_PyFloatDType).- IncorrectShapeException
Ends that do not broadcast (NumPy's ValueError text,
operands could not be broadcast together with shapes ...).- AxisError
axisout of range for the result's rank (NumPy'sdestination: axis 3 is out of bounds for array of dimension 2).- TypeError
An integer
dtypeover complex ends: NumPy'sfloorhas no complex loop.
Linspace(double, double, long, bool, DType, string)
NumPy's np.linspace(start, stop, num, endpoint=True, dtype=None, *, device=None) over scalar ends:
num evenly spaced samples from start to stop. With
endpoint the step is (stop - start) / (num - 1) and the last sample is
stop itself (NumPy overwrites y[-1], so no rounding of start + i * step
reaches it); without it the step is (stop - start) / num and stop is not a sample.
public abstract NDArray Linspace(double start, double stop, long num, bool endpoint = true, DType dtype = null, string device = null)
Parameters
startdoubleThe first sample.
stopdoubleThe last sample when
endpointis true; otherwise the bound the samples approach.numlongThe number of samples.
endpointboolWhether
stopis the last sample.dtypeDTypeThe result dtype, or null for float64. The samples are computed in float64 and then converted: an integer dtype FLOORS them (NumPy 1.20+'s
_nx.floor(y, out=y)before the cast, not a truncation toward zero; char follows uint16), bool issample != 0, complex128 takes the sample as its real part, and a text dtype (S,U,StringDType) formats them as NumPy'sastypedoes ('0.25', cut to the width of a fixed-width dtype).devicestringNumPy's Array-API
device=: only"cpu"and null are accepted. NumPy reads it after the sample count (it is the ramp's np.arange that checks it), so a negative count is reported first.
Returns
- NDArray
A new 1-D array of
numsamples. A float64 result of two or more samples, or of one sample withendpointfalse, does not own its buffer (OWNDATAfalse: NumPy returns its in-place ramp throughastype(copy=False), which is a view); every other result owns its buffer.
Remarks
np.linspace reaches this member through the array-ends member, which hands it two 0-d ends that compute
in float64 (two C# numbers, NumPy float64 / integer / bool scalars) with the sample axis first: the same
samples, without the ramp arrays. An override must keep NumPy's arithmetic, which
code ported from NumPy reads: the floor of the integer dtypes, the exact last sample, one sample as
0 * (stop - start) + start (a NaN when an end is infinite or NaN, +0.0 for a start of -0.0), and a
step that underflows to zero replaced by (i / div) * (stop - start) + start (NumPy's gh-5437 branch,
which keeps a subnormal range spread out).
Exceptions
- ValueError
A negative
num(Number of samples, -1, must be non-negative.), NumPy's first check: before the device and before anything is allocated.- ValueError
deviceis neither null nor"cpu"(NumPy'sDevice not understood. Only "cpu" is allowed, but received: ...).- NotSupportedException
dtypehas no storage lane (a datetime descriptor).
Log(NDArray, DType, NDArray, NDArray)
public abstract NDArray Log(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Log10(NDArray, DType, NDArray, NDArray)
public abstract NDArray Log10(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Log1p(NDArray, DType, NDArray, NDArray)
public abstract NDArray Log1p(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Log2(NDArray, DType, NDArray, NDArray)
public abstract NDArray Log2(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
LogAddExp(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray LogAddExp(NDArray x1, NDArray x2, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
LogAddExp2(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray LogAddExp2(NDArray x1, NDArray x2, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
LogicalAnd(NDArray, NDArray, DType, NDArray, NDArray)
NumPy's logical_and ufunc, the whole call: the element-wise AND of the operands' truth values, NumPy's
logical_and(x1, x2, /, out=None, *, where=True, dtype=None). A text operand reads true when
non-empty (NumPy's string loop computes over the operands' truth arrays).
public abstract NDArray LogicalAnd(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
lhsNDArrayThe first operand (any dtype, text included; any layout).
rhsNDArrayThe second operand; broadcasts against
lhs.dtypeDTypeThe
dtype=loop request: the logical loops are bool-output only, so it validates and selects nothing; a non-bool request raises NumPy's no-loop error.outNDArrayA location into which the result is stored (any numeric dtype: bool casts same_kind to all, True to 1), or null; returned itself when given.
whereNDArrayA bool mask: only its true elements are computed; masked-off slots of
outkeep their contents (of a fresh result they are unspecified, as in NumPy).
Returns
- NDArray
A bool array of the broadcast shape, or
out.
Remarks
NumPy's loop is C (@TYPE@_logical_and), so the call is an engine member, as every ufunc's is; the
numpy.matrix and numpy.char.chararray answers stay with np.logical_and's woven subclass path.
Exceptions
- IncorrectTypeException
A non-bool
dtype(No loop matching the specified signature and casting was found for ufunc logical_and).- TypeError
A detailed or non-legacy
dtypedescriptor, or a text call NumPy's string loop refuses.- SystemError
A
Uoperand holding a unit above U+10FFFF (NumPy's bool cast of the text).- ValueError
A read-only
out.- TypeError
An
outthe bool result cannot be cast into.- ArgumentException
A
wherethat is not bool, or a mask oroutthat does not broadcast with the operands (NumPy's ValueError text).- IncorrectShapeException
Operands that do not broadcast together.
LogicalNot(NDArray, DType, NDArray, NDArray)
NumPy's logical_not ufunc, the whole call: the element-wise NOT of the operand's truth value (zero is
True, nonzero False; a NaN is truthy), NumPy's logical_not(x, /, out=None, *, where=True, dtype=None).
Unlike the binary three it has no string loop in NumPy, so a text operand is refused.
public abstract NDArray LogicalNot(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
ndNDArrayThe operand (any numeric dtype; any layout).
dtypeDTypeThe
dtype=loop request: validate-only (bool loops); a non-bool request raises NumPy's no-loop error.outNDArrayA location into which the result is stored (any numeric dtype), or null; returned itself when given.
whereNDArrayA bool mask: only its true elements are computed; masked-off slots of
outkeep their contents.
Returns
- NDArray
A bool array of the operand's shape (broadcast with the mask and
out), orout.
Exceptions
- IncorrectTypeException
A non-bool
dtype(No loop matching the specified signature and casting was found for ufunc logical_not), for a text operand too: the loops are bool-output only.- TypeError
A text operand without
dtype(NumPy's no-loop refusal; a StringDType operand's text names the requested output class), or a detailed or non-legacydtypedescriptor.- ValueError
A read-only
out.- TypeError
An
outthe bool result cannot be cast into, or a fixed-width text operand underdtype=bool(the input cast NumPy refuses, its UFuncTypeError text).- ArgumentException
A
wherethat is not bool, or a mask oroutthat does not broadcast with the operand (NumPy's ValueError text).
LogicalOr(NDArray, NDArray, DType, NDArray, NDArray)
NumPy's logical_or ufunc, the whole call: the element-wise OR of the operands' truth values, NumPy's
logical_or(x1, x2, /, out=None, *, where=True, dtype=None). A text operand reads true when non-empty.
public abstract NDArray LogicalOr(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
lhsNDArrayThe first operand (any dtype, text included; any layout).
rhsNDArrayThe second operand; broadcasts against
lhs.dtypeDTypeThe
dtype=loop request: validate-only (bool loops); a non-bool request raises NumPy's no-loop error.outNDArrayA location into which the result is stored (any numeric dtype), or null; returned itself when given.
whereNDArrayA bool mask: only its true elements are computed; masked-off slots of
outkeep their contents.
Returns
- NDArray
A bool array of the broadcast shape, or
out.
Exceptions
- IncorrectTypeException
A non-bool
dtype(No loop matching the specified signature and casting was found for ufunc logical_or).- TypeError
A detailed or non-legacy
dtypedescriptor, or a text call NumPy's string loop refuses.- SystemError
A
Uoperand holding a unit above U+10FFFF.- ValueError
A read-only
out.- TypeError
An
outthe bool result cannot be cast into.- ArgumentException
A
wherethat is not bool, or a mask oroutthat does not broadcast with the operands (NumPy's ValueError text).- IncorrectShapeException
Operands that do not broadcast together.
LogicalXor(NDArray, NDArray, DType, NDArray, NDArray)
NumPy's logical_xor ufunc, the whole call: the element-wise XOR of the operands' truth values, NumPy's
logical_xor(x1, x2, /, out=None, *, where=True, dtype=None). A text operand reads true when non-empty.
public abstract NDArray LogicalXor(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
lhsNDArrayThe first operand (any dtype, text included; any layout).
rhsNDArrayThe second operand; broadcasts against
lhs.dtypeDTypeThe
dtype=loop request: validate-only (bool loops); a non-bool request raises NumPy's no-loop error.outNDArrayA location into which the result is stored (any numeric dtype), or null; returned itself when given.
whereNDArrayA bool mask: only its true elements are computed; masked-off slots of
outkeep their contents.
Returns
- NDArray
A bool array of the broadcast shape, or
out.
Exceptions
- IncorrectTypeException
A non-bool
dtype(No loop matching the specified signature and casting was found for ufunc logical_xor).- TypeError
A detailed or non-legacy
dtypedescriptor, or a text call NumPy's string loop refuses.- SystemError
A
Uoperand holding a unit above U+10FFFF.- ValueError
A read-only
out.- TypeError
An
outthe bool result cannot be cast into.- ArgumentException
A
wherethat is not bool, or a mask oroutthat does not broadcast with the operands (NumPy's ValueError text).- IncorrectShapeException
Operands that do not broadcast together.
Logspace(double, double, long, bool, double, DType, int)
NumPy's np.logspace(start, stop, num=50, endpoint=True, base=10.0, dtype=None, axis=0) over scalar
ends: base ** linspace(start, stop, num, endpoint), computed in float64 and only then cast to
dtype (computing in a narrower dtype would round differently).
public abstract NDArray Logspace(double start, double stop, long num = 50, bool endpoint = true, double @base = 10, DType dtype = null, int axis = 0)
Parameters
startdoublebase ** startis the first sample.stopdoublebase ** stopis the last sample whenendpointis true.numlongThe number of samples.
endpointboolWhether
base ** stopis the last sample (its exponent isstopitself, as NumPy's linspace writesy[-1] = stop).basedoubleThe base of the log space. A negative base with a fractional exponent gives NaN, as NumPy's real power does.
dtypeDTypeThe result dtype, or null for float64. The float64 powers are cast, so an integer dtype TRUNCATES toward zero (unlike Linspace(double, double, long, bool, DType, string), which floors) and a text dtype formats them.
axisintThe destination of NumPy's trailing
moveaxis(y, 0, axis): a no-op for the 1-D result of scalar ends, but only 0 and -1 are in range.
Returns
- NDArray
A new 1-D array of
numsamples that owns its buffer.
Remarks
np.logspace calls this member of the default engine. DefaultEngine fills the powers in one pass with
Pow(double, double), the CRT routine NumPy's npy_pow calls on win-amd64, so
its float64 result is NumPy's byte for byte; an override that computes the powers otherwise loses that.
Exceptions
- ValueError
A negative
num(Number of samples, -1, must be non-negative.), checked beforeaxis.- AxisError
An
axisother than 0 or -1 (destination: axis 1 is out of bounds for array of dimension 1).- NotSupportedException
dtypehas no storage lane (a datetime descriptor): the final cast refuses it.
Matmul(NDArray, NDArray)
public abstract NDArray Matmul(NDArray lhs, NDArray rhs)
Parameters
Returns
Matmul(NDArray, NDArray, NDArray, int[][], int?, bool?, DType, string, char)
NumPy's np.matmul(x1, x2, out, axes, axis, keepdims, dtype, casting, order) — the gufunc
(n?,k),(k,m?)->(n?,m?) — the whole call: the argument checks (the order and casting names,
axis with axes, the dtype= class, the loop refusal of text, keepdims /
axis, a read-only out=), the core axes axes= names, the loop dtype= selects (each
input's cast checked under casting), the product (Matmul(NDArray, NDArray)),
the result's core axes placed, the layout order asks for, and the delivery into
out (its cast and its core dimensions checked first).
public abstract NDArray Matmul(NDArray x1, NDArray x2, NDArray @out, int[][] axes, int? axis, bool? keepdims, DType dtype, string casting, char order)
Parameters
x1NDArrayThe left operand, at least 1-D: a 1-D operand drops its optional core dimension
n?.x2NDArrayThe right operand, at least 1-D: a 1-D operand drops
m?.outNDArrayWhere the product is delivered, or null. Any layout; takes a cast of the product under
casting; its extra leading loop axes receive copies of the product.axesint[][]The axes carrying each operand's core dimensions (
{x1, x2, out}: two for an operand of two or more dimensions, one for a 1-D one; all three entries are required), or null.axisint?Refused for any value (matmul's three core dimensions are distinct), or null.
keepdimsbool?Refused for any value, false included (the output has core dimensions); null when the caller did not pass it.
dtypeDTypeThe loop dtype, or null (the product's own).
castingstringThe rule the input-to-loop and product-to-out casts are checked under:
no,equiv,safe,same_kindorunsafe.ordercharThe result's layout:
'C','F','A'(F when both inputs are F-contiguous, else C) or'K'(the product's own).
Returns
- NDArray
The product, or
outitself holding it.
Remarks
New in 0.80.0 (the np-layer dtype plan, P2): the public np.matmul calls this (the ufunc
mechanism answers for a subclass operand); Matmul(NDArray, NDArray) stays the product kernel
the call ends in.
Exceptions
- ValueError
An order or casting name NumPy refuses; an
axes=list without three entries, or with a repeated axis; a read-onlyout; anoutwhose core dimension differs from the product's, or whose loop axes the product does not broadcast into.- TypeError
axiswithaxes; adtypewith details beyond its class; text operands or a textdtype(no matmul loop);keepdimsoraxisgiven.- AxisError
An
axes=entry whose length is not its operand's core rank, or an axis out of range.- TypeError
A cast
castingrefuses (NumPy's UFuncTypeError text).- IncorrectShapeException
Core dimensions that do not match, or loop axes that do not broadcast (the product's texts).
- InvalidOperationException
A 0-d operand.
- NotSupportedException
dtypeis a class without storage yet.- NullReferenceException
x2is null.
Matvec(NDArray, NDArray)
The np.matvec gufunc (m,n),(n)->(m) — NumPy's gemv route.
public virtual NDArray Matvec(NDArray x1, NDArray x2)
Parameters
Returns
Matvec(NDArray, NDArray, NDArray, int[][], int?, bool, DType, string, char)
NumPy's np.matvec(x1, x2, out, axes, axis, keepdims, dtype, casting, order) — the gufunc (m,n),(n)->(m) —
the whole call: the argument checks, the core axes axes= names, the core sizes, the loop
dtype selects, the product (Matvec(NDArray, NDArray)), the result's core axis
placed, and the delivery into out.
public abstract NDArray Matvec(NDArray x1, NDArray x2, NDArray @out, int[][] axes, int? axis, bool keepdims, DType dtype, string casting, char order)
Parameters
x1NDArrayThe matrix operand, at least 2-D.
x2NDArrayThe vector operand, at least 1-D; not conjugated.
outNDArrayWhere the answer is delivered (its cast checked under
casting), or null.axesint[][]The core axes per operand (
{(m,n), (n), (m)}, all three entries), or null.axisint?Refused for any value (the two core dimensions are distinct), or null.
keepdimsboolRefused when true.
dtypeDTypeThe loop dtype, or null.
castingstringThe rule the input-to-loop and answer-to-out casts are checked under:
no,equiv,safe,same_kind(NumPy's default) orunsafe.ordercharThe layout of an allocated answer:
'K'(NumPy's default: the loop axes in the inputs' memory order),'C','F', or'A'(F when both inputs are F-contiguous, else C); ignored without. Lowercase letters are accepted.
Returns
- NDArray
The matrix-vector products, or
outitself holding them.
Remarks
New in 0.80.0 (the np-layer dtype plan, P2): the public np.matvec calls this (the ufunc
mechanism answers for a subclass operand).
Exceptions
- TypeError
axiswithaxes, or either given; adtypewith details beyond its class; text operands or a textdtype;keepdims.- ValueError
An operand with too few dimensions; core axes of different lengths; an
axes=list without three entries; a read-onlyout, or one the answer does not broadcast into.- AxisError
An
axes=entry of the wrong length, or an axis out of range.- TypeError
An input cannot be cast to the loop, or the answer into
out, undercasting(NumPy's UFuncTypeError text).- ValueError
A
castingorordername NumPy refuses (casting must be one of 'no', 'equiv', 'safe', 'same_kind', 'unsafe' (got '…'),order must be one of 'C', 'F', 'A', or 'K' (got '…')), checked casting first.- TypeError
A null
casting(casting must be str, not NoneType).- IncorrectShapeException
Loop axes that do not broadcast (the product's text).
- NotSupportedException
dtypeis a class without storage yet.- NullReferenceException
x2is null.
Maximum(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray Maximum(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Mean(NDArray, int?, DType, bool)
The mean without out= / where=: ReduceMean(NDArray, NDAxis?, bool, DType, NDArray, NDArray) under its shipped (0.70.0) signature, kept
for callers and subclasses of that member.
public abstract NDArray Mean(NDArray nd, int? axis = null, DType dtype = null, bool keepdims = false)
Parameters
ndNDArrayThe array to average.
axisint?The reduced axis, or null for every axis.
dtypeDTypeThe sum's loop dtype, or null for
_mean's default.keepdimsboolWhether the reduced axes stay with length 1.
Returns
- NDArray
The mean (see ReduceMean(NDArray, NDAxis?, bool, DType, NDArray, NDArray)).
Remarks
Footgun: np.mean and ndarray.mean call ReduceMean(NDArray, NDAxis?, bool, DType, NDArray, NDArray) since 0.80.0, so an override
of this member no longer intercepts them; override ReduceMean(NDArray, NDAxis?, bool, DType, NDArray, NDArray).
Exceptions
- AxisError
axisis out of range.
Median(NDArray, int[], NDArray, bool, bool)
NumPy's np.median(a, axis=None, out=None, overwrite_input=False, keepdims=False): the median of the data,
flattened or along the given axes; an even-sized slice gives the MEAN of its two central values.
public abstract NDArray Median(NDArray a, int[] axis = null, NDArray @out = null, bool overwrite_input = false, bool keepdims = false)
Parameters
aNDArrayThe data, a plain array (bool computes as its 0 / 1 values; text is refused as NumPy refuses it, a
StringDTypearray is sorted first).axisint[]The reduced axes (negative counts from the end), or null for the flattened data; an EMPTY array reduces nothing. A one-axis call passes a one-element array (NumPy turns an int axis into a 1-tuple).
outNDArrayAn optional output array of the result's shape, written and returned itself.
overwrite_inputboolWhether the data may be partitioned in place.
keepdimsboolWhether the reduced axes are kept with length one.
Returns
- NDArray
The median (NaN for an empty slice);
outitself when one is given.
Remarks
NumPy writes median in Python (_ureduce over _median); np.median calls this after its
class rules. An override replaces it for every array whose engine it is. New in 0.80.0 (the np-layer dtype
plan, phase PE); it was the internal class QuantileEngine.
Exceptions
- ArgumentNullException
ais null.- ValueError
An axis repeats; or, for a
StringDTypearray, a None-like NA in a sorted line, an empty reduced axis or a read-only out.- AxisError
An axis is out of range.
- ValueError
outthat np.median's closingmean(part[indexer], out=out)refuses in its add.reduce prologue, before anything is computed: read-only (output array is read-only), of the wrong rank (output parameter for reduction operation add has the wrong number of dimensions: Found 2 but expected 1) or with a length-1 axis where the result is longer (parity QA-31).- IncorrectShapeException
An
outwhose axes do not broadcast with the result's: the prologue's iterator text over the partition's middle slice (operands could not be broadcast together with remapped shapes [original->remapped]: (3,)->(3) (1,4)), NumPy's ValueError.- TypeError
Text data or a text out that NumPy's closing mean refuses (its verbatim text).
- IncorrectShapeException
Several reduced axes beside a kept axis of length 0.
- IndexError
keepdims with an out NumPy cannot index, before the text refusals.
Minimum(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray Minimum(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Mod(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray Mod(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
ModF(NDArray, DType, NDArray, NDArray, NDArray)
public abstract (NDArray Fractional, NDArray Integral) ModF(NDArray nd, DType dtype = null, NDArray outFrac = null, NDArray outIntegral = null, NDArray where = null)
Parameters
Returns
MoveAxis(NDArray, int[], int[])
NumPy's np.moveaxis: the axes of source moved to the positions of
destination, the other axes keeping their order (a view).
public abstract NDArray MoveAxis(NDArray nd, int[] source, int[] destination)
Parameters
ndNDArrayThe array.
sourceint[]The axes to move (negative values count from the end).
destinationint[]Their new positions.
Returns
- NDArray
A view with the permuted axes.
Exceptions
- AxisError
An axis is out of range ("source: …" / "destination: …").
- ValueError
An argument repeats an axis, or the two have different lengths.
Multiply(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray Multiply(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
NanArgMax(NDArray, int?, NDArray, bool)
NumPy's np.nanargmax(a, axis=None, out=None, *, keepdims=<no value>): argmax of the
array with every NaN replaced by -inf, after NumPy's all-NaN slice guard. Only an inexact array (float16,
float32, float64, complex) has NaNs to replace: NumPy's _replace_nan leaves integers, bool and text
alone (NumSharp's char and decimal too), so theirs is argmax itself.
public abstract NDArray NanArgMax(NDArray a, int? axis = null, NDArray @out = null, bool keepdims = false)
Parameters
aNDArrayThe input.
axisint?The axis to reduce, or null for the flattened array; a 0-d array takes 0 and -1.
outNDArrayAn array to write the indices into and return, or null: its shape must equal the result's, its dtype must reach int64 by a safe cast (bool through uint32, and char); the indices are cast unsafely into it.
keepdimsboolWhether the reduced axes stay with length one (every axis for the flattened form).
Returns
- NDArray
The int64 indices (0-d for the flattened form without keepdims), or
out.
Remarks
The result cannot be trusted when a slice holds only NaNs and infinities of the losing sign (NumPy's caveat).
Exceptions
- NullReferenceException
ais null.- AxisError
axisout of range, naming the input's rank for an inexact dtype and the ravelled rank otherwise (the NumPy statement that raises differs).- ValueError
An all-NaN slice (
All-NaN slice encountered); an empty reduced length (attempt to get argmax of an empty sequence); an out of another shape (output array does not match result of np.argmax.); aStringDTypeline of two or more elements holding an NA that is neither a string nor NaN-like.- TypeError
An out whose dtype does not cast safely to int64.
- MemoryError
A corrupt
StringDTypecell (NumPy'sMemoryErrortext).
NanArgMin(NDArray, int?, NDArray, bool)
NumPy's np.nanargmin(a, axis=None, out=None, *, keepdims=<no value>): argmin of the
array with every NaN replaced by +inf, after NumPy's all-NaN slice guard. Only an inexact array (float16,
float32, float64, complex) has NaNs to replace: NumPy's _replace_nan leaves integers, bool and text
alone (NumSharp's char and decimal too), so theirs is argmin itself.
public abstract NDArray NanArgMin(NDArray a, int? axis = null, NDArray @out = null, bool keepdims = false)
Parameters
aNDArrayThe input.
axisint?The axis to reduce, or null for the flattened array; a 0-d array takes 0 and -1.
outNDArrayAn array to write the indices into and return, or null: its shape must equal the result's, its dtype must reach int64 by a safe cast (bool through uint32, and char); the indices are cast unsafely into it.
keepdimsboolWhether the reduced axes stay with length one (every axis for the flattened form).
Returns
- NDArray
The int64 indices (0-d for the flattened form without keepdims), or
out.
Remarks
The result cannot be trusted when a slice holds only NaNs and infinities of the losing sign (NumPy's caveat).
Exceptions
- NullReferenceException
ais null.- AxisError
axisout of range, naming the input's rank for an inexact dtype and the ravelled rank otherwise (the NumPy statement that raises differs).- ValueError
An all-NaN slice (
All-NaN slice encountered); an empty reduced length (attempt to get argmin of an empty sequence); an out of another shape (output array does not match result of np.argmin.); aStringDTypeline of two or more elements holding an NA that is neither a string nor NaN-like.- TypeError
An out whose dtype does not cast safely to int64.
- MemoryError
A corrupt
StringDTypecell (NumPy'sMemoryErrortext).
NanCumProd(NDArray, int?, DType, NDArray)
NumPy's np.nancumprod: the running product with every NaN counted as one (_replace_nan(a, 1),
then np.cumprod).
public abstract NDArray NanCumProd(NDArray a, int? axis = null, DType dtype = null, NDArray @out = null)
Parameters
aNDArrayThe array, a plain one (the facade decides the
numpy.matrixclass first). Text is not inexact: a numericdtypeparses it, and a parsed'nan'is multiplied, not replaced by one.axisint?The accumulated axis (negative counts from the end), or null for the flattened array.
dtypeDTypeThe loop and result dtype, or null for NEP 50's accumulator of the input.
outNDArrayNumPy's
out=: an array of the result's shape that receives it and is returned, or null.
Returns
- NDArray
outitself when given, else a fresh array.
Remarks
DefaultEngine's override runs NumPy's statements over ReduceCumMul(NDArray, int?, DType, NDArray). An override replaces
np.nancumprod for every array whose engine it is. New in 0.80.0 (the np-layer dtype plan, phase PE).
Exceptions
- AxisError
axisis out of range.- TypeError
A text operand or request NumPy's loop resolution refuses.
- ValueError
A read-only
out, or text a numeric dtype cannot parse.- IncorrectShapeException
outdoes not have the result's shape.
NanCumSum(NDArray, int?, DType, NDArray)
NumPy's np.nancumsum: the running sum with every NaN counted as zero (_replace_nan(a, 0), then
np.cumsum). A leading run of NaNs therefore gives zeros, never NaN.
public abstract NDArray NanCumSum(NDArray a, int? axis = null, DType dtype = null, NDArray @out = null)
Parameters
aNDArrayThe array, a plain one (the facade decides the
numpy.matrixclass first). Text is not inexact, so it isnp.cumsum's text: StringDType concatenates, fixed-width text is refused or parsed under a numericdtype.axisint?The accumulated axis (negative counts from the end), or null for the flattened array.
dtypeDTypeThe loop and result dtype, or null for NEP 50's accumulator of the input.
outNDArrayNumPy's
out=: an array of the result's shape that receives it and is returned, or null.
Returns
- NDArray
outitself when given, else a fresh array.
Remarks
NumPy writes nancumsum in Python (numpy/lib/_nanfunctions_impl.py); DefaultEngine's override runs
those statements over ReduceCumAdd(NDArray, int?, DType, NDArray). An override replaces np.nancumsum for every array
whose engine it is. New in 0.80.0 (the np-layer dtype plan, phase PE).
Exceptions
- AxisError
axisis out of range.- TypeError
A text operand or request NumPy's loop resolution refuses.
- ValueError
A read-only
out, or text a numeric loop cannot parse.- IncorrectShapeException
outdoes not have the result's shape.
NanMax(NDArray, NDAxis?, bool, NDArray, object, NDArray)
NumPy's np.nanmax, the whole call: the maximum ignoring NaNs, which on an ndarray IS
np.fmax.reduce (NumPy's "All-NaN slice" RuntimeWarning is not modeled), with NumPy's out=,
initial= and where=.
public abstract NDArray NanMax(NDArray a, NDAxis? axis = null, bool keepdims = false, NDArray @out = null, object initial = null, NDArray where = null)
Parameters
aNDArrayThe array (integer, bool, char and decimal arrays hold no NaN: the plain
np.max).axisNDAxis?The reduced axis (negative counts from the end), or null for every axis.
keepdimsboolWhether the reduced axes stay with length one.
outNDArrayNumPy's
out=: the array that receives the result (the loop ispromote_types(out, a)), or null for a fresh result.initialobjectNumPy's
initial=: the value every output starts from, packed into the loop dtype as NumPy'sPyArray_Packdoes, or null for none.whereNDArrayNumPy's
where=: a bool mask, only the selected elements reduce; it needsinitial.
Returns
- NDArray
outitself when given; otherwise a fresh array, a read-only 0-d one for a full reduction without keepdims. An all-NaN slice gives its first NaN, bits intact.
Remarks
Widened with out, initial and where in 0.80.0
(the np-layer dtype plan, phase PE, E5). This is NumPy's branch for a BASE ndarray: np.nanmax asks the
operand's class first (NanMax(NDAxis?, NDArray, bool, object, NDArray), virtual), which calls this member for an ndarray and
takes NumPy's branch for subclasses in a matrix's or chararray's override.
Exceptions
- AxisError
axisis out of range.- ArgumentException
An empty reduction without
initial(zero-size array to reduction operation fmax which has no identity, NumPy's ValueError); a non-bool mask.- ValueError
A read-only or misshapen
out, a mask withoutinitial, aninitialthe loop cannot hold.- OverflowError
An integer
initialpast the loop's range.- TypeError
Text, or a complex
initialfor a real loop.- IncorrectShapeException
The mask or
outdoes not broadcast.
NanMean(NDArray, NDAxis?, DType, bool, NDArray, NDArray)
NumPy's np.nanmean: the mean of the non-NaN elements, the NaN-free sum divided by their count. A
slice without one gives NaN (the division's 0 / 0). An input that cannot hold NaN (integer, bool, char,
decimal, text) is np.mean's, keywords included.
public abstract NDArray NanMean(NDArray a, NDAxis? axis = null, DType dtype = null, bool keepdims = false, NDArray @out = null, NDArray where = null)
Parameters
aNDArrayThe array, a plain one (the facade decides the
numpy.matrixclass first).axisNDAxis?The reduced axis (negative counts from the end), or null for a flat reduction.
dtypeDTypeThe loop of the sum (NumPy's
dtype=), or null for the input's dtype. Must be inexact for an inexact input.keepdimsboolKeep the reduced axis as a length-1 dimension.
outNDArrayNumPy's
out=: the sum and the division land in it (returned), or null.whereNDArrayNumPy's
where=: the bool mask of the elements that take part (both the count and the sum read it), or null.
Returns
- NDArray
The mean in the sum's dtype (
outitself when given); 0-d (NumPy's scalar) for a flat reduction withoutkeepdims.
Remarks
NumPy writes nanmean in Python (numpy/lib/_nanfunctions_impl.py); DefaultEngine's override runs those
statements: the sum over NumPy's K-order copy in its own schedule (a float16 or float32 input sums in its own
dtype), then the division by the int64 count in the float64 loop, or Smith's complex loop for complex. An
override replaces np.nanmean for every array whose engine it is. New in 0.80.0 (the np-layer dtype
plan, phase PE).
Exceptions
- TypeError
An inexact input with a non-inexact
dtype: "If a is inexact, then dtype must be inexact" (raised before the axis is checked, as in NumPy); or with a non-inexactout: "If a is inexact, then out must be inexact".- AxisError
axisoutside the operand, except 0 and -1 on a 0-d inexact operand, which reduce flat (ufunc.reduce's rule: nanmean's first axis consumer is np.sum).
NanMedian(NDArray, int[], NDArray, bool, bool)
NumPy's np.nanmedian(a, axis=None, out=None, overwrite_input=False, keepdims=False): the median of the
values that are not NaN (the mean of the two central values of an even count); a slice that is entirely NaN,
or empty, gives NaN.
public abstract NDArray NanMedian(NDArray a, int[] axis = null, NDArray @out = null, bool overwrite_input = false, bool keepdims = false)
Parameters
aNDArrayThe data, a plain array (bool computes as its 0 / 1 values; text is refused as NumPy refuses it, a
StringDTypearray drops its NaN-like NAs and takes the median of the rest).axisint[]The reduced axes, or null for the flattened data; an EMPTY array reduces nothing. A one-axis call passes a one-element array.
outNDArrayAn optional output array of the result's shape, written and returned itself.
overwrite_inputboolWhether the data may be partitioned in place.
keepdimsboolWhether the reduced axes are kept with length one.
Returns
- NDArray
The NaN-ignoring median;
outitself when one is given.
Remarks
NumPy writes nanmedian in Python; np.nanmedian calls this after its class rule. An override replaces it
for every array whose engine it is. New in 0.80.0 (the np-layer dtype plan, phase PE); it was the internal
class QuantileEngine.
Exceptions
- ArgumentNullException
ais null.- ValueError
An axis repeats; a
StringDTypearray's errors (a None-like NA in a sorted line, an empty input's mean, the store into out).- AxisError
An axis is out of range.
- ValueError
The store
out[...] = result(np.nanmedian's, after the computation): anoutthe result does not broadcast to (could not broadcast input array from shape (4,) into shape (3,)) or a read-only one (assignment destination is read-only); for empty data, np.nanmean's add.reduce prologue texts (parity QA-31).- TypeError
Text data that NumPy's NaN test (or, for empty data, its
nanmean) refuses.- NotSupportedException
A
StringDTyperow result NumPy stores in an OBJECT array.- IndexError
Data that is not empty, under keepdims, with an out NumPy cannot index.
NanMin(NDArray, NDAxis?, bool, NDArray, object, NDArray)
NumPy's np.nanmin, the whole call: the minimum ignoring NaNs, which on an ndarray IS
np.fmin.reduce (NumPy's "All-NaN slice" RuntimeWarning is not modeled), with NumPy's out=,
initial= and where=.
public abstract NDArray NanMin(NDArray a, NDAxis? axis = null, bool keepdims = false, NDArray @out = null, object initial = null, NDArray where = null)
Parameters
aNDArrayThe array (integer, bool, char and decimal arrays hold no NaN: the plain
np.min).axisNDAxis?The reduced axis (negative counts from the end), or null for every axis.
keepdimsboolWhether the reduced axes stay with length one.
outNDArrayNumPy's
out=: the array that receives the result (the loop ispromote_types(out, a)), or null for a fresh result.initialobjectNumPy's
initial=: the value every output starts from, packed into the loop dtype as NumPy'sPyArray_Packdoes, or null for none.whereNDArrayNumPy's
where=: a bool mask, only the selected elements reduce; it needsinitial.
Returns
- NDArray
outitself when given; otherwise a fresh array, a read-only 0-d one for a full reduction without keepdims. An all-NaN slice gives its first NaN, bits intact.
Remarks
Widened with out, initial and where in 0.80.0
(the np-layer dtype plan, phase PE, E5). This is NumPy's branch for a BASE ndarray: np.nanmin asks the
operand's class first (NanMin(NDAxis?, NDArray, bool, object, NDArray), virtual), which calls this member for an ndarray and
takes NumPy's branch for subclasses in a matrix's or chararray's override.
Exceptions
- AxisError
axisis out of range.- ArgumentException
An empty reduction without
initial(zero-size array to reduction operation fmin which has no identity, NumPy's ValueError); a non-bool mask.- ValueError
A read-only or misshapen
out, a mask withoutinitial, aninitialthe loop cannot hold.- OverflowError
An integer
initialpast the loop's range.- TypeError
Text, or a complex
initialfor a real loop.- IncorrectShapeException
The mask or
outdoes not broadcast.
NanPercentile(NDArray, object, int[], NDArray, bool, string, bool, NDArray)
NumPy's np.nanpercentile(a, q, axis=None, out=None, overwrite_input=False, method='linear',
keepdims=False, *, weights=None): NanQuantile(NDArray, object, int[], NDArray, bool, string, bool, NDArray) with q given in percent,
q = np.true_divide(q, 100) first.
public abstract NDArray NanPercentile(NDArray a, object q, int[] axis = null, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false, NDArray weights = null)
Parameters
aNDArrayThe data, a plain array.
qobjectThe percentiles in [0, 100], NumPy's array_like (the forms of Quantile(NDArray, object, int[], NDArray, bool, string, bool, NDArray)'s q).
axisint[]The reduced axes, or null for the flattened data; an EMPTY array reduces nothing.
outNDArrayAn optional output array, written and returned itself.
overwrite_inputboolWhether the data may be partitioned in place.
methodstringOne of NumPy's thirteen estimation methods, matched exactly.
keepdimsboolWhether the reduced axes are kept with length one.
weightsNDArrayNumPy's
weights=(only withinverted_cdf), or null.
Returns
- NDArray
The percentiles of the non-NaN values (NaN for an all-NaN slice);
outitself when one is given.
Remarks
NumPy writes nanpercentile in Python; np.nanpercentile calls this after its class rule. An override
replaces it for every array whose engine it is. New in 0.80.0 (the np-layer dtype plan, phase PE); it was the
internal class QuantileEngine.
Exceptions
- ValueError
A percentile outside [0, 100] (on the quotient), and the other ValueErrors of NanQuantile(NDArray, object, int[], NDArray, bool, string, bool, NDArray).
- TypeError
The TypeErrors of NanQuantile(NDArray, object, int[], NDArray, bool, string, bool, NDArray).
- AxisError
An axis is out of range.
- ArgumentNullException
a, a null q, ormethodis null.- ArgumentException
An unknown method name, or an out of another shape.
- IndexError
Data that is not empty, under keepdims, with an out NumPy cannot index.
- InvalidCastException
A q array of a complex dtype.
NanProd(NDArray, NDAxis?, bool, DType, NDArray, object, NDArray)
NumPy's np.nanprod: a, mask = _replace_nan(a, 1); return np.prod(a, axis, dtype, out, keepdims,
initial, where) - the product with every NaN counted as one; an input that cannot hold NaN is
np.prod's, keywords included.
public abstract NDArray NanProd(NDArray a, NDAxis? axis = null, bool keepdims = false, DType dtype = null, NDArray @out = null, object initial = null, NDArray where = null)
Parameters
aNDArrayThe array, a plain one (the facade decides the
numpy.matrixclass first).axisNDAxis?The reduced axis (negative counts from the end), or null for every axis.
keepdimsboolKeep the reduced axes as length-1 dimensions.
dtypeDTypenp.prod's
dtype=, or null.outNDArraynp.prod's
out=(returned), or null.initialobjectnp.prod's
initial=, or null for none.whereNDArraynp.prod's
where=mask, or null.
Returns
- NDArray
The product;
outitself when given; 0-d for a flat reduction withoutkeepdims.
Remarks
The engine order is ReduceProduct(NDArray, NDAxis?, bool, DType, NDArray, object, NDArray)'s; np.nanprod takes NumPy's. The keywords beyond axis / keepdims arrived with API-parity batch 3 (2026-11-11).
Exceptions
- AxisError
axisoutside the operand.
NanQuantile(NDArray, object, int[], NDArray, bool, string, bool, NDArray)
NumPy's np.nanquantile(a, q, axis=None, out=None, overwrite_input=False, method='linear', keepdims=False, *,
weights=None): Quantile(NDArray, object, int[], NDArray, bool, string, bool, NDArray) of the values that are not NaN; a slice holding nothing but NaN
gives NaN.
public abstract NDArray NanQuantile(NDArray a, object q, int[] axis = null, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false, NDArray weights = null)
Parameters
aNDArrayThe data, a plain array (a
StringDTypearray computes the quantile of what its NaN-like NAs leave; fixed-width text meetsisnan's refusal).qobjectThe quantiles in [0, 1], NumPy's array_like (the forms of Quantile(NDArray, object, int[], NDArray, bool, string, bool, NDArray)'s q).
axisint[]The reduced axes, or null for the flattened data; an EMPTY array reduces nothing.
outNDArrayAn optional output array, written and returned itself.
overwrite_inputboolWhether the data may be partitioned in place.
methodstringOne of NumPy's thirteen estimation methods, matched exactly.
keepdimsboolWhether the reduced axes are kept with length one.
weightsNDArrayNumPy's
weights=(only withinverted_cdf), or null. With weights, empty data answersnp.nanmean; other data runs the weighted branch over each line's non-NaN values.
Returns
- NDArray
The quantiles of the non-NaN values (NaN for an all-NaN slice; for q of two or more dimensions over merged axes, q's axes are moved as NumPy's
_nanquantile_ureduce_funcmoves them);outitself when one is given.
Remarks
NumPy writes nanquantile in Python; DefaultEngine's override runs its statements in NumPy's order.
np.nanquantile calls it after its class rule; an override replaces it for every array whose engine it
is. New in 0.80.0 (the np-layer dtype plan, phase PE); it was the internal class QuantileEngine.
Exceptions
- TypeError
ais complex; a text q; fixed-width text data (isnanhas no text loop, ornp.nanmean's add.reduce refuses empty text); bool data with an interpolating method; weights of another shape without an axis, or text weights.- ValueError
A quantile out of range; an empty q of rank other than 1; a repeated axis; a q of rank above 2 (except over data that is NaN everywhere); the weights' checks.
- AxisError
An axis is out of range.
- ArgumentNullException
a, a null q, ormethodis null.- ArgumentException
An unknown method name (except over data that is NaN everywhere), or an out of another shape.
- IndexError
Data that is not empty, under keepdims, with an out NumPy cannot index (
_ureduce's prologue), before the text refusals.- InvalidCastException
A q array of a complex dtype.
- OverflowError
An integer q array whose virtual indexes leave its dtype.
NanStd(NDArray, NDAxis?, DType, int, bool, NDArray, NDArray, NDArray, int?)
NumPy's np.nanstd: the square root of NanVar(NDArray, NDAxis?, DType, int, bool, NDArray, NDArray, NDArray, int?), in the variance's dtype.
public abstract NDArray NanStd(NDArray a, NDAxis? axis = null, DType dtype = null, int ddof = 0, bool keepdims = false, NDArray @out = null, NDArray where = null, NDArray mean = null, int? correction = null)
Parameters
aNDArrayThe array, a plain one (the facade decides the
numpy.matrixclass first).axisNDAxis?The reduced axis (negative counts from the end), or null for a flat reduction.
dtypeDTypeThe loop of both sums (NumPy's
dtype=), or null for the input's dtype. Must be inexact for an inexact input.ddofintDelta degrees of freedom: the divisor is the non-NaN count minus
ddof.keepdimsboolKeep the reduced axis as a length-1 dimension.
outNDArrayNumPy's
out=: the variance's sum and division land in it (returned), or null.whereNDArrayNumPy's
where=: the bool mask of the elements that take part, or null.meanNDArrayNumPy's
mean=: the mean to subtract (shaped as withkeepdims=True) instead of the computed one, or null.correctionint?NumPy's
correction=, the Array-API name ofddof; giving both (a non-zero ddof) raises.
Returns
- NDArray
The standard deviation: the loop dtype, float64 for a complex input without
dtype(outitself when given, its variance square-rooted in place); 0-d for a flat reduction withoutkeepdims.
Remarks
An input that cannot hold NaN is np.std's, keywords included. New in 0.80.0 (the np-layer dtype plan,
phase PE).
Exceptions
- TypeError
An inexact input with a non-inexact
dtype: "If a is inexact, then dtype must be inexact"; with a non-inexactout: "If a is inexact, then out must be inexact".- ValueError
A non-zero
ddofwithcorrection.- AxisError
axisoutside the operand.
NanSum(NDArray, NDAxis?, bool, DType, NDArray, object, NDArray)
NumPy's np.nansum: a, mask = _replace_nan(a, 0); return np.sum(a, axis, dtype, out, keepdims, initial,
where) - the sum with every NaN counted as zero (a complex element with a NaN in either part included); an
input that cannot hold NaN is np.sum's, keywords included.
public abstract NDArray NanSum(NDArray a, NDAxis? axis = null, bool keepdims = false, DType dtype = null, NDArray @out = null, object initial = null, NDArray where = null)
Parameters
aNDArrayThe array, a plain one (the facade decides the
numpy.matrixclass first).axisNDAxis?The reduced axis (negative counts from the end), or null for every axis.
keepdimsboolKeep the reduced axes as length-1 dimensions.
dtypeDTypenp.sum's
dtype=: the accumulator / result dtype, or null.outNDArraynp.sum's
out=: the destination (returned), or null.initialobjectnp.sum's
initial=: the start value (a Python scalar), or null for none.whereNDArraynp.sum's
where=: the bool mask of the elements that take part, or null.
Returns
- NDArray
The sum;
outitself when given; 0-d for a flat reduction withoutkeepdims.
Remarks
The engine order (axis, keepdims, dtype, out, initial, where) is ReduceAdd(NDArray, NDAxis?, bool, DType, NDArray, object, NDArray)'s; np.nansum takes NumPy's. The keywords beyond axis / keepdims arrived with API-parity batch 3 (2026-11-11).
Exceptions
- AxisError
axisoutside the operand.
NanToNum(NDArray, bool, object, object, object)
NumPy's np.nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None): NaN replaced with
nan, +inf with posinf and -inf with neginf, in
the real and imaginary parts of a complex input alike. An input that is not inexact (bool, integers, char,
decimal, text) holds no NaN or inf and comes back as it is.
public abstract NDArray NanToNum(NDArray x, bool copy = true, object nan = null, object posinf = null, object neginf = null)
Parameters
xNDArrayThe input.
copyboolWhether to work on a copy (true) or in place on
x(false: the result isxitself, its memory written).nanobjectThe fill for NaN: null for NumPy's 0.0, a real scalar (a C# number, bool, char or float16), or an array_like (an NDArray or a C# array) broadcast against
x; cast same_kind to x's real dtype, as NumPy'scopytocasts it, so text and complex fills are refused.posinfobjectThe fill for +inf, as
nan; null for the largest finite value of x's real dtype (float16, float32, or float64 for float64 and complex128).neginfobjectThe fill for -inf, as
nan; null for the smallest finite value.
Returns
- NDArray
The array with its non-finite values replaced: a copy, or
xwhencopyis false.
Remarks
DefaultEngine fills scalar fills into a contiguous target in one fused pass (the
DirectILKernelGenerator.NanToNum kernel); array fills and other layouts run NumPy's three
copyto(where=) statements.
Exceptions
- ArgumentNullException
xis null.- ValueError
An array fill that does not broadcast into
x(np.copyto's text).- InvalidCastException
On an inexact input, a fill NumPy's
copytorefuses to cast same_kind into x's real dtype: text (NumPy's TypeError text,Cannot cast scalar from dtype('<U1') to dtype('float64') according to the rule 'same_kind', np.copyto's house type for it; the text is never parsed), a complex number, a complex or text array. It is raised by thecopytostatement that meets the fill (NaN, then +inf, then -inf; for a complex input the real part's three, then the imaginary part's), as in NumPy, so withcopyfalse the earlier fills are already written. Also a scalar fill of a type that does not convert to a number.
NanVar(NDArray, NDAxis?, DType, int, bool, NDArray, NDArray, NDArray, int?)
NumPy's np.nanvar: the variance of the non-NaN elements. It differs from np.var in three
observable ways: the deviations are rounded into the input's dtype before they are squared, a complex square
is the real part of x * conj(x), and a slice without degrees of freedom is NaN (np.var gives +inf).
public abstract NDArray NanVar(NDArray a, NDAxis? axis = null, DType dtype = null, int ddof = 0, bool keepdims = false, NDArray @out = null, NDArray where = null, NDArray mean = null, int? correction = null)
Parameters
aNDArrayThe array, a plain one (the facade decides the
numpy.matrixclass first).axisNDAxis?The reduced axis (negative counts from the end), or null for a flat reduction.
dtypeDTypeThe loop of both sums (NumPy's
dtype=), or null for the input's dtype. Must be inexact for an inexact input.ddofintDelta degrees of freedom: the divisor is the non-NaN count minus
ddof.keepdimsboolKeep the reduced axis as a length-1 dimension.
outNDArrayNumPy's
out=: the variance's sum and division land in it (returned), or null.whereNDArrayNumPy's
where=: the bool mask of the elements that take part, or null.meanNDArrayNumPy's
mean=: the mean to subtract (shaped as withkeepdims=True) instead of the computed one, or null.correctionint?NumPy's
correction=, the Array-API name ofddof; giving both (a non-zero ddof) raises.
Returns
- NDArray
The variance: the loop dtype, float64 for a complex input without
dtype(outitself when given); 0-d (NumPy's scalar) for a flat reduction withoutkeepdims.
Remarks
An input that cannot hold NaN (integer, bool, char, decimal, text) is np.var's, keywords included.
DefaultEngine's override runs NumPy's _nanfunctions_impl.nanvar statements. An override replaces
np.nanvar for every array whose engine it is; NanStd(NDArray, NDAxis?, DType, int, bool, NDArray, NDArray, NDArray, int?) is a separate member, so an engine
that changes one should change both. New in 0.80.0 (the np-layer dtype plan, phase PE).
Exceptions
- TypeError
An inexact input with a non-inexact
dtype: "If a is inexact, then dtype must be inexact"; with a non-inexactout: "If a is inexact, then out must be inexact".- ValueError
A non-zero
ddofwithcorrection: "ddof and correction can't be provided simultaneously.".- AxisError
axisoutside the operand.
Negate(NDArray, DType, NDArray, NDArray)
public abstract NDArray Negate(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
NewArray(DType, Shape, bool)
A new array of dtype and shape bound to this engine: the one allocation
an engine makes its results with, so the result of a computation stays on the engine that computed it (and
the next operation on that result computes there too).
protected NDArray NewArray(DType dtype, Shape shape, bool fillZeros)
Parameters
dtypeDTypeThe dtype descriptor of the elements (a Type, an NPTypeCode or a NumPy dtype string converts implicitly).
shapeShapeThe dimensions. A view's layout (strides, offset, broadcast) is laid out again in C order and a fresh dense or KEEPORDER layout is kept, as for every allocation (NumSharp.Shape.ForFreshAllocation()).
fillZerosboolTrue to zero the buffer; false leaves pool noise the caller must overwrite completely before anyone reads it (a fixed-width
Uarray is zeroed either way, NumPy'sNPY_NEEDS_INIT).
Returns
- NDArray
The new array, owning its buffer, bound to this engine (TensorEngine is
this).
Remarks
The storage comes from this engine's GetStorage(DType), so an engine that overrides it
allocates its results through its own override. A result built any other way (new NDArray(dtype,
shape), NDArray.Scalar, np.zeros) binds Default instead: an engine member that
builds its result so moves it off the engine that computed it whenever that engine is not the default (a
wrap of a buffer the engine filled names the engine in its initializer: { TensorEngine = this }).
Exceptions
- ValueError
A dimension is negative, or the byte count overflows.
NewArray<T>(Shape, bool)
The typed form of NewArray(DType, Shape, bool): a new NDArray<TDType> of
shape bound to this engine.
protected NDArray<T> NewArray<T>(Shape shape, bool fillZeros) where T : unmanaged
Parameters
shapeShapeThe dimensions (a view's layout is laid out again in C order, as for every allocation).
fillZerosboolTrue to zero the buffer; false leaves pool noise the caller must overwrite completely.
Returns
- NDArray<T>
The new typed array, owning its buffer, bound to this engine.
Type Parameters
TThe element type; its NPTypeCode is the dtype.
Exceptions
- ValueError
A dimension is negative, or the byte count overflows.
NewScalar(object)
WritableScalar(object) bound to this engine: the dtype is the value's own (its C# type).
protected NDArray NewScalar(object value)
Parameters
valueobjectThe value.
Returns
- NDArray
A new writeable 0-d array, bound to this engine.
Exceptions
- NotSupportedException
value's type is no NumSharp dtype.
NewScalar(object, DType)
WritableScalar(object, DType) bound to this engine: value stored as
dtype.
protected NDArray NewScalar(object value, DType dtype)
Parameters
Returns
- NDArray
A new writeable 0-d array, bound to this engine.
Exceptions
- ArgumentNullException
dtypeis null.- ValueError
A non-text value into a
coerce=FalseStringDType.
NewScalar<T>(object)
WritableScalar<T>(object) bound to this engine: value converted to
T first.
protected NDArray NewScalar<T>(object value) where T : unmanaged
Parameters
valueobjectThe value, converted with
Converts.ChangeTypeunless it already is aT.
Returns
- NDArray
A new writeable 0-d array, bound to this engine.
Type Parameters
TThe element type.
Exceptions
- InvalidCastException
valuedoes not convert toT.
NewScalar<T>(T)
NumSharp.NDArray.WritableScalar<T>(T) bound to this engine: the 0-d value an engine member returns (a flat reduction, a 0-d operation) or computes with stays on the engine that made it.
protected NDArray NewScalar<T>(T value) where T : unmanaged
Parameters
valueTThe value.
Returns
- NDArray
A new writeable 0-d array holding
value, bound to this engine: an engine exit that hands it out as NumPy's scalar calls NumSharp.NDArray.PyArray_Return() (a keepdims exit reshapes it into an array first, which must stay writeable).
Type Parameters
TThe element type; its NPTypeCode is the dtype.
NextAfter(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray NextAfter(NDArray x1, NDArray x2, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
NonZero(NDArray)
public abstract NDArray<long>[] NonZero(NDArray a)
Parameters
aNDArray
Returns
NotEqual(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray NotEqual(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Outer(NDArray, NDArray, NDArray)
NumPy's np.outer(a, b, out=None): multiply(a.ravel()[:, newaxis], b.ravel()[newaxis, :], out),
every product a[i] * b[j] of the two inputs flattened - one multiply ufunc call, so its loops, its
promotion and its out= rules are outer's.
public abstract NDArray Outer(NDArray a, NDArray b, NDArray @out = null)
Parameters
aNDArrayThe first input, any shape (flattened; not null).
bNDArrayThe second input, any shape (flattened; not null).
outNDArrayAn array to write the products into, or null: it joins the multiply's broadcast (never stretched) and takes a same_kind cast from the product dtype; it is returned itself.
Returns
- NDArray
A new
(a.size, b.size)array in the multiply's promoted dtype, orout.
Remarks
NumPy writes outer in Python (numpy/_core/numeric.py); DefaultEngine runs its one statement over the
array object's ravel and expand_dims and a's engine's Multiply(NDArray, NDArray, DType, NDArray, NDArray).
np.outer calls it with plain views of subclass operands, and numpy.linalg's Array-API
outer after its one-dimensional check; an override replaces both for every array whose engine it is.
Exceptions
- NullReferenceException
aorbis null.- TypeError
Operands the multiply has no loop for (text with numbers, two texts; NumPy's no-loop texts), or a text product without
out's string multiply.- ValueError
A read-only
out(output array is read-only).- TypeError
An
outthe product dtype does not reach under same_kind (Cannot cast ufunc 'multiply' output from ...).- ArgumentException
An
outthe products do not broadcast into (operands could not be broadcast together with shapes ...).
Packbits(NDArray, int?, string)
NumPy's np.packbits(a, axis=None, bitorder='big') (io_pack / pack_bits,
numpy/_core/src/multiarray/compiled_base.c), the whole call: the elements packed into the bits of a
uint8 array, one bit per element (1 iff it is nonzero), the axis shortened to ceil(len / 8) and the
last byte zero-padded.
public abstract NDArray Packbits(NDArray a, int? axis = null, string bitorder = "big")
Parameters
aNDArrayA bool or integer array (NumSharp's char included), read in logical order for any layout.
axisint?The axis to pack along, or null to pack the C-order flattened array into a 1-D result. A 0-d input is promoted to
(1,)and accepts only 0 and -1.bitorderstring"big"puts the first element in the most significant bit,"little"in the least; NumPy's prefix rule: a value beginning with"little"is little, one beginning with"big"big, null is big.
Returns
- NDArray
A new uint8 array of
a's rank (1-D for a null axis), F-contiguous when the input is.
Remarks
New in 0.80.0 (the np-layer dtype plan): the public np.packbits applies the numpy.matrix
rule and calls this.
Exceptions
- ArgumentNullException
ais null.- ValueError
bitorderbegins with neither ('order' must be either 'little' or 'big'), checked first.- TypeError
ais neither bool nor integer (Expected an input array of integer or boolean data type).- AxisError
axisis out of bounds fora's rank.
Partition(NDArray, object, int?, string, string)
NumPy's np.partition(a, kth, axis, kind, order) (fromnumeric.partition over
PyArray_Partition), the whole call: a copy of a in which every
kth element is where a sorted copy holds it, with no larger element before it and no
smaller one after it along the axis (introselect). Use PartitionInPlace(NDArray, object, int?, string, string) for
ndarray.partition.
public abstract NDArray Partition(NDArray a, object kth, int? axis = -1, string kind = "introselect", string order = null)
Parameters
aNDArrayThe array (only read). Text has no partition function, so NumPy sorts each line.
kthobjectNumPy's array_like of positions along the axis: a C# int, an int[], an integer index array, or any other object, converted with
np.asanyarray. A negative position counts from the end; every listed position ends where a sorted copy holds its element.axisint?The axis (negative counts from the end), or null for the flattened array.
kindstringNumPy's
kind=: only"introselect"(the default) or null.orderstringNumPy's
order=, a field name, or null: every NumSharp dtype has no fields, so any value is refused.
Returns
- NDArray
A fresh array of
a's dtype laid out ascopy(order='K')lays outa, or the partitioned flattening for a null axis. Float NaNs end each line with their own bits; the arrangement between the listed positions is the introselect's own.
Remarks
New in 0.80.0 (the np-layer dtype plan, phase PE, E5): the public np.partition applies its class
boundaries and calls this; DefaultEngine partitions with its AxisPartition kernels.
Exceptions
- ValueError
A
kindother than"introselect"(select kind must be 'introselect' (got 'x')) or anorder, before the array is read; a kth index array of more than one dimension (object too deep for desired array, before the axis) or of bool dtype (Booleans unacceptable as partition index); a position out of bounds (kth(=5) out of bounds (5), skipped for an empty array).- TypeError
A kth index array of a non-integer dtype (
Partition index must be integer).- AxisError
The axis is out of range.
- ArgumentNullException
kthis null, at NumPy's kth stage (after the axis: NumPy's kth=None raises its TypeError there).
PartitionInPlace(NDArray, object, int?, string, string)
NumPy's ndarray.partition(kth, axis, kind, order) (array_partition over PyArray_Partition),
the whole call: partitions a IN PLACE along the axis (see Partition(NDArray, object, int?, string, string)), in
NumPy's order of checks (the kind, the order, the axis, writeability, then the positions).
public abstract void PartitionInPlace(NDArray a, object kth, int? axis = -1, string kind = "introselect", string order = null)
Parameters
aNDArrayThe array partitioned in place.
kthobjectNumPy's array_like of positions along the axis: a C# int, an int[], an integer index array, or any other object, converted with
np.asanyarray. A negative position counts from the end; every listed position ends where a sorted copy holds its element.axisint?The axis (negative counts from the end), or null: NumSharp's extension that partitions a contiguous array's flattening in place.
kindstringNumPy's
kind=: only"introselect"(the default) or null.orderstringNumPy's
order=, a field name, or null: every NumSharp dtype has no fields, so any value is refused.
Remarks
New in 0.80.0 (the np-layer dtype plan, phase PE, E5): NDArray.partition calls this.
Exceptions
- ValueError
A
kindother than"introselect"(select kind must be 'introselect' (got 'x')) or anorder, before the array is read; a kth index array of more than one dimension (object too deep for desired array, before the axis) or of bool dtype (Booleans unacceptable as partition index); a read-only array (partition array is read-only); a position out of bounds (kth(=5) out of bounds (5), skipped for an empty array).- TypeError
A kth index array of a non-integer dtype (
Partition index must be integer).- AxisError
The axis is out of range.
- ArgumentNullException
kthis null, at NumPy's kth stage (after the axis: NumPy's kth=None raises its TypeError there).
Percentile(NDArray, object, int[], NDArray, bool, string, bool, NDArray)
NumPy's np.percentile(a, q, axis=None, out=None, overwrite_input=False, method='linear', keepdims=False, *,
weights=None): Quantile(NDArray, object, int[], NDArray, bool, string, bool, NDArray) with q given in percent, q = np.true_divide(q, 100) first.
public abstract NDArray Percentile(NDArray a, object q, int[] axis = null, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false, NDArray weights = null)
Parameters
aNDArrayThe data, a plain array.
qobjectThe percentiles in [0, 100], NumPy's array_like (the forms of Quantile(NDArray, object, int[], NDArray, bool, string, bool, NDArray)'s q; the division by 100 is float64 for a number, q's own dtype for an array, so an integer index is never taken).
axisint[]The reduced axes, or null for the flattened data; an EMPTY array reduces nothing.
outNDArrayAn optional output array, written and returned itself.
overwrite_inputboolWhether the data may be partitioned in place.
methodstringOne of NumPy's thirteen estimation methods, matched exactly.
keepdimsboolWhether the reduced axes are kept with length one.
weightsNDArrayNumPy's
weights=(only withinverted_cdf), or null.
Returns
- NDArray
The percentiles (q's axes first);
outitself when one is given.
Remarks
NumPy writes percentile in Python; np.percentile calls this after its class rules. An override
replaces it for every array whose engine it is. New in 0.80.0 (the np-layer dtype plan, phase PE); it was the
internal class QuantileEngine.
Exceptions
- ValueError
A percentile outside [0, 100] (
Percentiles must be in the range [0, 100], on the quotient), and the other ValueErrors of Quantile(NDArray, object, int[], NDArray, bool, string, bool, NDArray).- TypeError
The TypeErrors of Quantile(NDArray, object, int[], NDArray, bool, string, bool, NDArray) (a text q is refused by the division).
- AxisError
An axis is out of range.
- ArgumentNullException
a, a null q, ormethodis null.- ArgumentException
An unknown method name, or an out of another shape.
- IndexError
keepdims with an out NumPy cannot index; text data with an empty reduced axis.
- IndexOutOfRangeException
Numeric data whose reduced axes hold no element.
- IncorrectShapeException
Several reduced axes beside a kept axis of length 0.
- InvalidCastException
A q array of a complex dtype.
Poly(NDArray)
NumPy's np.poly(seq_of_zeros): the coefficients (highest degree first, leading 1) of the
polynomial with the given roots, or of a square matrix's characteristic polynomial (its eigenvalues are
the roots).
public abstract NDArray Poly(NDArray seq_of_zeros)
Parameters
seq_of_zerosNDArrayA 1-D sequence of roots, or a non-empty square 2-D array. A 0-d input is one root (atleast_1d): this is poly's body, which NumPy's np.poly reaches only through its dispatcher, and that refuses a 0-d input first (the np.poly facade raises its TypeError).
Returns
- NDArray
The coefficients, 1-D: float64 for real roots of any dtype but float32 (kept) and complex (kept; the real part when the roots come in conjugate pairs); the 0-d float64
1.0for no roots.
Exceptions
- ValueError
Neither 1-D nor a non-empty square 2-D array (
input must be 1d or non-empty square 2d array.); a 1-D text root that does not parse as a float (NumPy's mintypecode cast to'd').- TypeError
A square text matrix: its eigenvalues' finiteness check has no text loop.
- NotSupportedException
A square matrix with no LAPACK backend (the eigenvalues).
Polyadd(NDArray, NDArray)
NumPy's np.polyadd(a1, a2): the shorter coefficient array (by len(), the first axis)
zero-extended on the high-degree side with zeros of its own dtype, then added.
public abstract NDArray Polyadd(NDArray a1, NDArray a2)
Parameters
a1NDArrayThe first polynomial's coefficients (a scalar is a constant).
a2NDArrayThe second polynomial's coefficients.
Returns
- NDArray
The sum's coefficients, in the addition's promoted dtype.
Exceptions
- TypeError
Coefficients the addition has no loop for (text with numbers).
- IncorrectShapeException
An N-D operand: the 1-D pad meets np.concatenate's rank error, and equal first axes the addition's broadcast error (NumPy's ValueError texts).
Polyder(NDArray, int)
NumPy's np.polyder(p, m=1): the m-th derivative, each order
p[:-1] * arange(n, 0, -1) with n = len(p) - 1.
public abstract NDArray Polyder(NDArray p, int m = 1)
Parameters
pNDArrayThe coefficients, highest degree first (null is NumPy's None:
asarray(None)'s refusal). Each order slices the FIRST axis (len(p)) and multiplies by an int64 ramp oflen(p) - 1terms, which broadcasts against the LAST axis ofp[:-1]: a 2-D p is differentiated along its rows, as NumPy's statement does (np.polyder(np.ones((3, 2)))is[[2, 1], [2, 1]]).mintThe order of differentiation: 0 returns
asarray(p)itself, after NumPy's discardedm == 0product has had its chance to raise.
Returns
- NDArray
The derivative's coefficients (int32 coefficients become int64 through the int64 ramp); for
mpast the degree, an empty array.
Remarks
NumPy writes polyder in Python (numpy/lib/_polynomial_impl.py, which also handles a poly1d - NumSharp's
poly1d calls its own derivative); DefaultEngine runs its loop over the array object's slice and multiply.
np.polyder calls it with plain views of subclass operands, on p's engine (the
default one for null); an override replaces it for every array whose engine it is.
Exceptions
- ValueError
A negative
m(Order of derivative must be positive (see polyint)), checked beforepis read.- NotSupportedException
pis null (NumPy's object array of None).- IncorrectShapeException
An N-D p whose
p[:-1]does not broadcast with the ramp at some level, them == 0one included (the multiply'soperands could not be broadcast together with shapes (2,4) (2,), NumPy's ValueError):np.polyder(np.ones((3, 4)), 0)raises.- TypeError
A 0-d p, at every order, 0 included (
len() of unsized object); text coefficients the multiply has no loop for (a fixed-width one; aStringDTypep repeats its strings, as NumPy's string multiply does).
Polydiv(NDArray, NDArray)
NumPy's np.polydiv(u, v): long division of the floated coefficients (u + 0.0, v +
0.0), the scalar quotient coefficients computed with NumPy's scalar arithmetic, the remainder's
leading near-zero coefficients dropped (rtol=1e-14, at least one kept).
public abstract (NDArray q, NDArray r) Polydiv(NDArray u, NDArray v)
Parameters
uNDArrayThe dividend's coefficients, measured by
len()(its first axis).vNDArrayThe divisor's coefficients, measured by
len().
Returns
- (NDArray Lhs, NDArray Rhs)
The quotient and the remainder, floating or complex; for an N-D u shorter than v, NumPy's
(zeros(1), u)with u's leading near-zero rows dropped.
Exceptions
- TypeError
Coefficients the float conversion has no loop for (text); or a complex quotient coefficient with dimensions (u or v N-D), which NumPy's
q[k] = drefuses through complex() (only 0-dimensional arrays can be converted to Python scalars).- ValueError
A real quotient coefficient with dimensions (
setting an array element with a sequence.).- IncorrectShapeException
Rows of an N-D u and v that do not broadcast: NumPy's first statement
w = u[0] + v[0]raises the add's error, u's row first.- IndexError
An empty u or v (
u[0]/v[0]).
Polyfit(NDArray, NDArray, int, double?, bool, NDArray, object)
NumPy's np.polyfit(x, y, deg, rcond=None, full=False, w=None, cov=False): the least-squares polynomial
of degree deg through the points, from the Vandermonde matrix of x with
its columns scaled to unit norm, one np.linalg.lstsq solve, and the scale taken back out of the
coefficients.
public abstract PolyfitResult Polyfit(NDArray x, NDArray y, int deg, double? rcond = null, bool full = false, NDArray w = null, object cov = null)
Parameters
xNDArrayThe sample points, 1-D (null is NumPy's None:
asarray(None)'s refusal);x + 0.0makes them float (float32 stays float32).yNDArrayThe sample values: 1-D, or 2-D with one data set per column, as long as
x.degintThe degree of the polynomial.
rconddouble?The relative condition number of the fit, or null for
len(x) * epsof x's float dtype.fullboolAlso return lstsq's residuals, rank and singular values (NumPy's five-tuple).
wNDArrayWeights applied to the unsquared residuals, one per sample point, or null.
covobjectNumPy's
cov=: null /false(no covariance),true(scaled by the residuals),"unscaled", or any other object, read as Python's truth value (the empty string is false). Ignored withfull.
Returns
- PolyfitResult
The PolyfitResult carrying exactly the arrays NumPy returns: the coefficients (highest degree first, one column per data set); with
full, the residuals, rank and singular values; with a truthycov, the covariance. Every other slot is null.
Remarks
NumPy writes polyfit in Python; DefaultEngine runs its statements over the operand engines' Vander(NDArray, int?, bool),
Sum(NDArray, int?, DType, bool), Sqrt(NDArray, DType, NDArray, NDArray), Dot(NDArray, NDArray, NDArray), Outer(NDArray, NDArray, NDArray) and the
Linalg sub-engine's lstsq and inv. NumPy's RankWarning for a rank-deficient fit is not modelled.
np.polyfit calls it with plain views of subclass operands, on x's engine (the
default one for null); an override replaces it for every array whose engine it is.
Exceptions
- ValueError
A negative
deg(expected deg >= 0); a scaled covariance with no more points than coefficients (the number of data points must exceed order to scale the covariance matrix).- TypeError
NumPy's shape refusals in its order (
expected 1D vector for x,expected non-empty vector for x,expected 1D or 2D array for y,expected x and y to have same length,expected a 1-d array for weights,expected w and y to have the same length); text the float conversion+ 0.0has no loop for; a float16 or decimal x that numpy.linalg refuses (array type float16 is unsupported in linalg).- NotSupportedException
xoryis null (NumPy's object array of None).- OpenBlasMissingBackendException
No LAPACK backend is installed: lstsq needs one.
- LinAlgError
lstsq's SVD does not converge (a NaN or an infinity in the data), or the covariance's inverse meets a singular matrix.
- IncorrectShapeException
Weights that do not broadcast against a 2-D y's columns.
Polyint(NDArray, int, NDArray)
NumPy's np.polyint(p, m=1, k=None): the m-th antiderivative, each integration
dividing the coefficients by their exponents and appending a constant.
public abstract NDArray Polyint(NDArray p, int m = 1, NDArray k = null)
Parameters
pNDArrayThe coefficients, highest degree first, measured by
len()(its first axis: an N-D p meets the division's broadcast or the concatenation's rank error, as in NumPy).mintThe order of the antiderivative.
kNDArrayThe integration constants, highest order first, measured by
len(): null for zeros, one value for every order, or at leastmvalues.
Returns
- NDArray
The antiderivative's coefficients (floating or complex: the division by the exponents); for
m0,pas an array.
Exceptions
- ValueError
A negative
m, or fewer constants thanm.- TypeError
With
mabove 0: a 0-dp(len() of unsized object), or text, whose division by the exponents has no loop.- IncorrectShapeException
An N-D p or k whose shapes the division, the constants' broadcast or the concatenation refuses (NumPy's ValueError texts).
Polymul(NDArray, NDArray)
NumPy's np.polymul(a1, a2): each input's leading zeros dropped (NumPy wraps it in poly1d),
then the full convolution of the coefficients.
public abstract NDArray Polymul(NDArray a1, NDArray a2)
Parameters
Returns
- NDArray
The product's coefficients.
Exceptions
- ValueError
An input of rank above 1 (
Polynomial must be 1d only., the first input's first); fixed-width text otherwise (function not available for this data type, np.convolve's refusal).
Polysub(NDArray, NDArray)
NumPy's np.polysub(a1, a2): the shorter coefficient array (by len(), the first axis)
zero-extended on the high-degree side with zeros of its own dtype, then a1 - a2.
public abstract NDArray Polysub(NDArray a1, NDArray a2)
Parameters
Returns
- NDArray
The difference's coefficients, in the subtraction's promoted dtype.
Exceptions
- TypeError
Coefficients the subtraction has no loop for (text, bool).
- IncorrectShapeException
An N-D operand: the 1-D pad meets np.concatenate's rank error, and equal first axes the subtraction's broadcast error (NumPy's ValueError texts).
Polyval(NDArray, NDArray)
NumPy's np.polyval(p, x): Horner's scheme, y = y * x + pv for each pv in
p, from y = zeros_like(x).
public abstract NDArray Polyval(NDArray p, NDArray x)
Parameters
pNDArrayThe coefficients, highest degree first. NumPy iterates its first axis (
len(p)coefficients): an N-D p's coefficients are its rows, each broadcast against x.xNDArrayThe points, any shape.
Returns
- NDArray
The values, of dtype
result_type(p, x); ofx's shape for a 1-D p, of the broadcast of x's shape and a row's for an N-D p; with no coefficient,zeros_like(x).
Exceptions
- TypeError
A 0-d
p(iteration over a 0-d array), or text, which has no multiply (inx) or add (inp) loop.- IncorrectShapeException
An N-D p whose rows do not broadcast with x (the add's
operands could not be broadcast togethertext, NumPy's ValueError).
Positive(NDArray, DType, NDArray, NDArray)
NumPy 'positive' — identity at every numeric dtype (no bool loop). dtype selects the loop (positive(i32, dtype=f64) widens; a bool loop request raises NumPy's did-not-contain-a-loop TypeError).
public abstract NDArray Positive(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Power(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray Power(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Ptp(NDArray, int[], NDArray, bool)
NumPy's np.ptp(a, axis=(...)): the range over the axes of a tuple, with maximum.reduce's tuple
checks first (every axis in range, then no axis twice).
public abstract NDArray Ptp(NDArray a, int[] axis, NDArray @out = null, bool keepdims = false)
Parameters
aNDArrayThe array, a plain one (the facade decides the
numpy.matrixclass first).axisint[]The reduced axes (negative values count from the end), or null for every axis. An empty tuple reduces nothing: the result is
a - a.outNDArrayNumPy's
out=, or null for a fresh result.keepdimsboolWhether the reduced axes stay with length one.
Returns
- NDArray
outitself when given; otherwise the range, dtype preserved.
Remarks
A tuple of one axis, or of every axis, re-enters Ptp(NDArray, int?, NDArray, bool) through virtual dispatch, so an override of that member sees those calls too. New in 0.80.0 (the np-layer dtype plan, phase PE).
Exceptions
- ArgumentNullException
ais null.- AxisError
An axis is out of range (a 0-d input has no axis for a tuple to name).
- ValueError
An axis appears twice (
duplicate value in 'axis').- TypeError
Fixed-width text, or a text out (NumPy's loop refusal).
- ValueError
An
outthat _ptp'smaximum.reduce(a, axis, out=out)refuses in its prologue, before anything is computed: of the wrong rank (output parameter for reduction operation maximum has the wrong number of dimensions: Found 2 but expected 1) or with a length-1 axis where the result is longer (parity QA-31).- IncorrectShapeException
An
outwhose axes do not broadcast with the result's (operands could not be broadcast together with remapped shapes [original->remapped]: (3,)->(3) (3,4)), NumPy's ValueError under the house type of a broadcast failure.
Ptp(NDArray, int?, NDArray, bool)
NumPy's np.ptp (_methods._ptp): the range, maximum.reduce(a, axis) -
minimum.reduce(a, axis), in a's own dtype, so an integer range wraps exactly as NumPy's
does (ptp(int8 [-128, 127]) is -1).
public abstract NDArray Ptp(NDArray a, int? axis = null, NDArray @out = null, bool keepdims = false)
Parameters
aNDArrayThe array, a plain one (
np.ptpdecides thenumpy.matrixclass first). Numbers and StringDType; fixed-width text is refused as NumPy'smaximum.reducerefuses it.axisint?The reduced axis (negative counts from the end; a 0-d array accepts 0 and -1), or null for every axis.
outNDArrayNumPy's
out=: an array of the result's shape that receives the range and is returned, or null for a fresh result. NumPy parses it before anything else, so a read-only out fails first.keepdimsboolWhether the reduced axis stays with length one.
Returns
- NDArray
outitself when given; otherwise a fresh array, read-only when 0-d (NumPy's scalar).
Remarks
NumPy writes ptp in Python (numpy/_core/_methods.py); DefaultEngine's override runs those statements
over ReduceAMax(NDArray, NDAxis?, bool, DType, NDArray, object, NDArray) and ReduceAMin(NDArray, NDAxis?, bool, DType, NDArray, object, NDArray). An override replaces np.ptp for every
array whose engine it is, and the tuple-axis overload re-enters this one for a single axis or for every
axis. New in 0.80.0 (the np-layer dtype plan, phase PE); it was an internal static of DefaultEngine.
Exceptions
- ArgumentNullException
ais null.- AxisError
axisis out of range.- TypeError
Fixed-width text, or a text out: NumPy's maximum.reduce has no such loop.
- ValueError
A read-only out, an empty reduction (NumPy's maximum has no identity), or a StringDType subtraction NumPy refuses.
- ValueError
An
outthat _ptp'smaximum.reduce(a, axis, out=out)refuses in its prologue, before anything is computed: of the wrong rank (output parameter for reduction operation maximum has the wrong number of dimensions: Found 2 but expected 1) or with a length-1 axis where the result is longer (parity QA-31).- IncorrectShapeException
An
outwhose axes do not broadcast with the result's (operands could not be broadcast together with remapped shapes [original->remapped]: (3,)->(3) (3,4)), NumPy's ValueError under the house type of a broadcast failure.
Quantile(NDArray, object, int[], NDArray, bool, string, bool, NDArray)
NumPy's np.quantile(a, q, axis=None, out=None, overwrite_input=False, method='linear', keepdims=False, *,
weights=None): the q-th quantiles of the data, flattened or along the given axes.
public abstract NDArray Quantile(NDArray a, object q, int[] axis = null, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false, NDArray weights = null)
Parameters
aNDArrayThe data, a plain array (any real dtype; text takes NumPy's take path or its refusal).
qobjectThe quantiles in [0, 1], NumPy's array_like: a double or float is a Python float (the result keeps a float data's dtype), a C# integer a Python int (an integer virtual index is TAKEN, not interpolated), a double array a list, an NDArray an ndarray (q's axes lead the result); anything else is converted with
np.asanyarray.axisint[]The reduced axes (negative counts from the end), or null for the flattened data; an EMPTY array reduces nothing. A one-axis call passes a one-element array.
outNDArrayAn optional output array, written and returned itself.
overwrite_inputboolWhether the data may be partitioned in place (DefaultEngine stages a copy anyway).
methodstringOne of NumPy's thirteen estimation methods (
linear,lower,higher,nearest,midpoint,inverted_cdf, ...), matched exactly.keepdimsboolWhether the reduced axes are kept with length one.
weightsNDArrayNumPy's
weights=(only withinverted_cdf), or null for equal weights.
Returns
- NDArray
The quantiles (q's axes first);
outitself when one is given.
Remarks
NumPy writes quantile in Python; DefaultEngine's override runs its statements in NumPy's order (the complex
check, q's checks, the weighted branch, the text routes, then _ureduce and the numeric quantile).
np.quantile calls it with plain views of subclass operands (a numpy.char.chararray
operand's view remembers the class, which DefaultEngine reads for NumPy's text route); an override replaces
it for every array whose engine it is. New in 0.80.0 (the np-layer dtype plan, phase PE); it was the
internal class QuantileEngine.
Exceptions
- TypeError
ais complex (a must be an array of real numbers, NumPy's first statement); a text q; text data with an interpolating method, an out that does not cast safely, or keepdims over a 0-d result; bool data with an interpolating method; weights of another shape without an axis, or text weights.- ValueError
A quantile outside [0, 1] (
Quantiles must be in the range [0, 1]); an empty q of rank other than 1; a repeated axis; a q of rank above 2; aStringDTypeline holding a None-like NA; the weights' checks (another method, a wrong shape, a negative weight, a sum that is NaN, inf or zero).- AxisError
An axis is out of range for
a.- ArgumentNullException
a, a null q, ormethodis null.- ArgumentException
An unknown method name, or an
outof another shape than the result.- IndexError
keepdims with an
outNumPy cannot index (_ureduce's prologue); text data with an empty reduced axis.- IndexOutOfRangeException
Numeric data whose reduced axes hold no element (NumPy's IndexError texts).
- InvalidCastException
A q array of a complex dtype.
- OverflowError
An integer q array whose virtual indexes leave its dtype.
Rad2Deg(NDArray, DType, NDArray, NDArray)
public abstract NDArray Rad2Deg(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Radians(NDArray, DType, NDArray, NDArray)
NumPy's np.radians ufunc: the same conversion as Deg2Rad(NDArray, DType, NDArray, NDArray) (degrees to radians), but a ufunc of its
own, so a refusal (text, an operand type with no loop) names radians.
public abstract NDArray Radians(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
ndNDArrayThe angles.
dtypeDTypeThe loop dtype (
dtype=), or null for the operand's float tier.outNDArrayThe array to write into (
out=), or null.whereNDArrayThe bool mask of the positions to compute (
where=), or null for all.
Returns
- NDArray
The converted angles:
outwhen given, else a new array of the float tier (float16 for bool / int8 / uint8, float32 for int16 / uint16, float64 for wider integers; floats keep theirs).
Exceptions
- TypeError
A text or complex operand (no radians loop), with NumPy's texts.
- ValueError
A read-only
out.- ArgumentException
A non-bool
where, or adtypethe operand cannot reach.
RavelMultiIndex(NDArray[], long[], object, char)
NumPy's np.ravel_multi_index(multi_index, dims, mode='raise', order='C') (arr_ravel_multi_index,
numpy/_core/src/multiarray/compiled_base.c), the whole call: the flat index each coordinate tuple has in
an array of dimensions dims, the inverse of UnravelIndex(NDArray, long[], char).
public abstract NDArray<long> RavelMultiIndex(NDArray[] multi_index, long[] dims, object mode = null, char order = 'C')
Parameters
multi_indexNDArray[]The coordinate arrays, one per dimension of
dims: integer or bool, any layout; they broadcast against each other, and the broadcast shape is the result's. A null entry is NumPy'sNone, refused.dimslong[]The shape the coordinates index (NumPy's intp sequence, read only). An empty shape (NumPy's
()) takes no coordinate array and gives the flat index 0.modeobjectNumPy's mode argument: a string for every axis -
"raise"(an out-of-range coordinate raises),"wrap"(modulo, with sign correction) or"clip"(saturate) -, a sequence of such strings other than a string (NumPy's tuple or list: one mode per axis, a null entry raising on its axis), or null (NumPy'sNone: raise on every axis).orderchar'C'(row-major, the default) or'F'(column-major), in either case: the stride order the coordinates fold with.
Returns
- NDArray<long>
The int64 flat indices in the coordinates' broadcast shape, laid out as NumPy's iterator allocates them (KEEPORDER over the coordinate arrays: F-ordered coordinates give an F-ordered result, a transposed set the same permutation, mixed or broadcast ones C order). Coordinates that are all 0-d give NumPy's scalar: a fresh read-only 0-d array.
Remarks
New in 0.80.0 (the np-layer dtype plan): the public np.ravel_multi_index array overloads compute
a numpy.matrix operand as a plain array and call this; the scalar overload
np.ravel_multi_index(long[], Shape, string, char) computes its one index itself. The dimensions are
long[] (NumPy's intp) since API-parity batch 13; they were int[].
Exceptions
- ArgumentNullException
multi_indexordimsis null.- ValueError
In NumPy's order: an order letter that is not C / F / A / K in either case; a mode sequence of another length (
list of clipmodes has wrong length (1 instead of 2)) or a mode string NumPy's clipmode parser refuses; an'A'or'K'order (only 'C' or 'F' order is permitted); a dims product that overflows int64 (invalid dims: array size defined by dims is larger than the maximum possible size.); a coordinate count that differs fromdims' length (parameter multi_index must be a sequence of length N); a zero dimension while there is a coordinate to fold (cannot unravel if shape has zero entries (is empty)., whatever the mode); and (moderaise) a coordinate out of range (invalid entry in coordinates array).- TypeError
A mode that is neither a string, null nor a sequence of strings and nulls (
clipmode not understood; NumPy's integer modes have no C# spelling here), checked with the modes; a coordinate array that is neither integer nor bool, or a null entry (only int indices permitted), checked in order after the count.- IncorrectShapeException
The coordinate arrays do not broadcast together (NumPy's
ValueErrortext from its iterator, every coordinate shape listed).- NotSupportedException
Runtime code generation is unavailable (the IL kernel cannot be emitted).
RealIfClose(NDArray, double)
NumPy's np.real_if_close(a, tol=100): a complex input whose every imaginary part is strictly within
tol of zero becomes its real part; anything else is returned as it is.
public abstract NDArray RealIfClose(NDArray a, double tol = 100)
Parameters
aNDArrayThe input.
toldoubleAbove 1, a multiple of the complex dtype's machine epsilon (float64's, 2^-52); at most 1, an absolute bound. At 0 or below nothing collapses: a magnitude is never strictly below it.
Returns
- NDArray
A float64 view of the real parts (sharing
a's memory, as NumPy'sa.real) when every imaginary part is within the bound (an empty complex array always is); otherwiseaitself.
Remarks
DefaultEngine decides in one early-exit pass over the imaginary parts (NaN and inf never collapse).
Exceptions
- NullReferenceException
ais null.
Reciprocal(NDArray, DType, NDArray, NDArray)
public abstract NDArray Reciprocal(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
ReduceAMax(NDArray, NDAxis?, bool, DType, NDArray, object, NDArray)
NumPy's np.max / np.amax (np.maximum.reduce) over axis, or over every
axis when it is null, with ufunc.reduce's dtype= and NumPy's out=, initial= and
where=: the whole call of np.max and ndarray.max.
public abstract NDArray ReduceAMax(NDArray arr, NDAxis? axis, bool keepdims = false, DType dtype = null, NDArray @out = null, object initial = null, NDArray where = null)
Parameters
arrNDArrayThe array (any dtype;
StringDTypecomputes, fixed-width text is refused).axisNDAxis?The reduced axis (negative counts from the end), or null for every axis. A 0-d array accepts 0 and -1 and nothing else.
keepdimsboolWhether the reduced axes stay with length one.
dtypeDTypeThe loop dtype (
dtype=, NumPy'snp.maximum.reducekeyword), or null for the input's.np.maxitself has none.outNDArrayNumPy's
out=: the array that receives the result (any dtype: the loop ispromote_types(out, arr)and its result is cast in), or null for a fresh result.initialobjectNumPy's
initial=: the value every output starts from, packed into the loop dtype as NumPy'sPyArray_Packdoes (a C# integer or float is a Python int or float, range-checked, never wrapped), or null for none.whereNDArrayNumPy's
where=: a bool mask broadcast againstarr, only the selected elements reduce; it needsinitial. Null, or a 0-d true mask, is no mask.
Returns
- NDArray
outitself when given; otherwise a fresh array, a read-only 0-d one (NumPy's scalar) for a full reduction without keepdims.
Remarks
Widened with out, initial and where in 0.80.0
(the np-layer dtype plan, phase PE, E5: D2): the keyword path was the static
DefaultEngine.MaxMinNumPy, which the public functions called past the engine.
Exceptions
- AxisError
axisis out of range.- ArgumentException
An empty reduction without
initial(zero-size array to reduction operation maximum which has no identity, NumPy's ValueError); a non-bool mask (NumPy's TypeError text).- TypeError
Fixed-width text, a string
dtype, or a complexinitialfor a real loop.- NotSupportedException
dtypetogether without,initialorwhere(NumPy'sufunc.reducetakes them together; NumSharp's keyword path computes inpromote_types(out, arr)only).- ValueError
With a keyword: a read-only or misshapen
out, a mask with more axes thanarr, a mask withoutinitialor an empty reduced axis without it (NumPy's no-identity texts), aninitialthe loop cannot hold (a NaN into an integer loop, a sequence).- OverflowError
An integer
initialpast the loop's range.- IncorrectShapeException
The mask or
outdoes not broadcast.
ReduceAMin(NDArray, NDAxis?, bool, DType, NDArray, object, NDArray)
NumPy's np.min / np.amin (np.minimum.reduce) over axis, or over every
axis when it is null, with ufunc.reduce's dtype= and NumPy's out=, initial= and
where=: the whole call of np.min and ndarray.min.
public abstract NDArray ReduceAMin(NDArray arr, NDAxis? axis, bool keepdims = false, DType dtype = null, NDArray @out = null, object initial = null, NDArray where = null)
Parameters
arrNDArrayThe array (any dtype;
StringDTypecomputes, fixed-width text is refused).axisNDAxis?The reduced axis (negative counts from the end), or null for every axis. A 0-d array accepts 0 and -1 and nothing else.
keepdimsboolWhether the reduced axes stay with length one.
dtypeDTypeThe loop dtype (
dtype=, NumPy'snp.minimum.reducekeyword), or null for the input's.np.minitself has none.outNDArrayNumPy's
out=: the array that receives the result (any dtype: the loop ispromote_types(out, arr)and its result is cast in), or null for a fresh result.initialobjectNumPy's
initial=: the value every output starts from, packed into the loop dtype as NumPy'sPyArray_Packdoes (a C# integer or float is a Python int or float, range-checked, never wrapped), or null for none.whereNDArrayNumPy's
where=: a bool mask broadcast againstarr, only the selected elements reduce; it needsinitial. Null, or a 0-d true mask, is no mask.
Returns
- NDArray
outitself when given; otherwise a fresh array, a read-only 0-d one (NumPy's scalar) for a full reduction without keepdims.
Remarks
Widened with out, initial and where in 0.80.0
(the np-layer dtype plan, phase PE, E5: D2): the keyword path was the static
DefaultEngine.MaxMinNumPy, which the public functions called past the engine.
Exceptions
- AxisError
axisis out of range.- ArgumentException
An empty reduction without
initial(zero-size array to reduction operation minimum which has no identity, NumPy's ValueError); a non-bool mask (NumPy's TypeError text).- TypeError
Fixed-width text, a string
dtype, or a complexinitialfor a real loop.- NotSupportedException
dtypetogether without,initialorwhere(NumPy'sufunc.reducetakes them together; NumSharp's keyword path computes inpromote_types(out, arr)only).- ValueError
With a keyword: a read-only or misshapen
out, a mask with more axes thanarr, a mask withoutinitialor an empty reduced axis without it (NumPy's no-identity texts), aninitialthe loop cannot hold (a NaN into an integer loop, a sequence).- OverflowError
An integer
initialpast the loop's range.- IncorrectShapeException
The mask or
outdoes not broadcast.
ReduceAdd(NDArray, NDAxis?, bool, DType, NDArray, object, NDArray)
NumPy's np.sum (np.add.reduce), the whole call: the add reduction over axis
(every axis when null), started from the add identity or initial, over the elements
where selects, stored into out when given. np.sum and
ndarray.sum are this member, a subclass operand handed in as its plain view (the declaration below
answers for the class).
public abstract NDArray ReduceAdd(NDArray arr, NDAxis? axis, bool keepdims = false, DType dtype = null, NDArray @out = null, object initial = null, NDArray where = null)
Parameters
arrNDArrayThe array (any dtype, any layout;
StringDTypeconcatenates, fixed-width text is refused).axisNDAxis?The reduced axis (negative counts from the end), or null for every axis. A 0-d input accepts 0 and -1 as every axis (ufunc.reduce's backward-compatibility rule).
keepdimsboolWhether the reduced axes stay in the result with length 1.
dtypeDTypeThe loop dtype (
dtype=), or null: NEP 50's accumulator of the input withoutout(int64 for bool and the signed integers, uint64 for the unsigned ones),promote_types(out, arr)with it (no small-integer widening).outNDArrayNumPy's
out=, an array of the result's shape that receives the sum with an unsafe cast and is returned, or null for a fresh result.initialobjectNumPy's
initial=: the value every output starts from instead of the identity, packed into the loop dtype asPyArray_Packpacks it (a C# integer is a Python int, range-checked and never wrapped; adoublea Python float, truncated into an integer loop; a 0-d array is cast), or null for the identity (C# cannot pass NumPy'sinitial=None, which copies each output's first element instead).whereNDArrayNumPy's
where=: a bool mask broadcast againstarr; only the selected elements are added, an output with none selected keeps the start value. Null, or a 0-d true mask, is no mask.
Returns
- NDArray
outitself when given; otherwise a fresh array, NumPy's read-only scalar for a full reduction without keepdims.
Remarks
out joined the contract in 0.80.0 (the np-layer dtype plan's P1d), initial
and where in its P10 (decision D10): a breaking change for a subclass, which must add the
parameters. Sum(NDArray, int?, DType, bool) stays for callers of the shipped member; np.sum calls this one.
Exceptions
- TypeError
A C# scalar passed as
out(return arrays must be of ArrayType), NumPy's text refusals, or aninitialthe loop cannot take (a complex into a real loop).- ValueError
A read-only or misshapen
out, a mask with more axes thanarr(the reduce prologue's texts), or aninitialthe loop cannot hold (a NaN into an integer loop, a sequence).- ArgumentException
whereis not a bool array (NumPy's TypeError text).- AxisError
axisis out of range.- IncorrectShapeException
outorwheredoes not broadcast againstarr.- OverflowError
An integer
initialpast the loop's range.
ReduceArgMax(NDArray, int?, bool, NDArray)
NumPy's np.argmax(a, axis=None, out=None, *, keepdims=False) (PyArray_ArgMaxWithKeepdims), the
whole call: the int64 index of the largest element along axis_ (its first occurrence), or
of the C-order flattened array, written into out when one is given.
public abstract NDArray ReduceArgMax(NDArray arr, int? axis_, bool keepdims = false, NDArray @out = null)
Parameters
arrNDArrayThe array (any dtype: fixed-width text is compared as NumPy's
STRING_argmax/UNICODE_argmaxcompare it, aStringDTypearray by its dtype's compare, a NaN-like NA greater than any text).axis_int?The reduced axis (negative counts from the end), or null for the flattened array (a 0-d input ravels first, so it accepts 0 and -1).
keepdimsboolWhether the reduced axis stays with length one (with
axis_null, every axis: the shape(1,) * arr.ndim).outNDArrayNumPy's
out=: an array of exactly the result's shape whose dtype casts safely to int64 (bool through uint32, and NumSharp's char); the int64 indices are cast into it unsafely (an int8 out wraps an index of 200 to -56, a bool out reads index != 0) and it is returned itself. Null for a fresh result.
Returns
- NDArray
outitself when given; otherwise the int64 indices, a read-only 0-d array (NumPy's scalar) for the flattened form without keepdims.
Remarks
Widened with out in 0.80.0 (the np-layer dtype plan): NumPy's out= contract
was np's NanArgWriteOut, which np.argmax and np.nanargmax called around this member. Its two checks run
in NumPy's order, the shape before the dtype, and both before an element is compared
(_PyArray_ArgMinMaxCommon): an out error comes before a StringDType comparison's
refusal.
Exceptions
- AxisError
axis_is outside the input's rank (rank 1 for a 0-d input), checked before anything else, for every dtype.- ValueError
An empty reduced line (
attempt to get argmax of an empty sequence); anoutof another shape (output array does not match result of np.argmax.); aStringDTypecomparison that meets a None-like NA (Cannot compare null that is not a nan-like value).- TypeError
out's dtype does not cast safely to int64 (uint64, the floats, complex, text: NumPy'sCannot cast array data from dtype('uint64') to dtype('int64') according to the rule 'safe', which names a 0-d out ascalar).- MemoryError
A corrupt
StringDTypecell (NumPy'sMemoryErrortext).
ReduceArgMin(NDArray, int?, bool, NDArray)
NumPy's np.argmin(a, axis=None, out=None, *, keepdims=False) (PyArray_ArgMinWithKeepdims), the
whole call: the int64 index of the smallest element along axis_ (its first occurrence), or
of the C-order flattened array, written into out when one is given.
public abstract NDArray ReduceArgMin(NDArray arr, int? axis_, bool keepdims = false, NDArray @out = null)
Parameters
arrNDArrayThe array (any dtype: fixed-width text is compared as NumPy's
STRING_argmin/UNICODE_argmincompare it, aStringDTypearray by its dtype's compare, a NaN-like NA greater than any text).axis_int?The reduced axis (negative counts from the end), or null for the flattened array (a 0-d input ravels first, so it accepts 0 and -1).
keepdimsboolWhether the reduced axis stays with length one (with
axis_null, every axis: the shape(1,) * arr.ndim).outNDArrayNumPy's
out=: an array of exactly the result's shape whose dtype casts safely to int64 (bool through uint32, and NumSharp's char); the int64 indices are cast into it unsafely (an int8 out wraps an index of 200 to -56, a bool out reads index != 0) and it is returned itself. Null for a fresh result.
Returns
- NDArray
outitself when given; otherwise the int64 indices, a read-only 0-d array (NumPy's scalar) for the flattened form without keepdims.
Remarks
Widened with out in 0.80.0 (the np-layer dtype plan): NumPy's out= contract
was np's NanArgWriteOut, which np.argmin and np.nanargmin called around this member. Its two checks run
in NumPy's order, the shape before the dtype, and both before an element is compared
(_PyArray_ArgMinMaxCommon): an out error comes before a StringDType comparison's
refusal.
Exceptions
- AxisError
axis_is outside the input's rank (rank 1 for a 0-d input), checked before anything else, for every dtype.- ValueError
An empty reduced line (
attempt to get argmin of an empty sequence); anoutof another shape (output array does not match result of np.argmin.); aStringDTypecomparison that meets a None-like NA (Cannot compare null that is not a nan-like value).- TypeError
out's dtype does not cast safely to int64 (uint64, the floats, complex, text: NumPy'sCannot cast array data from dtype('uint64') to dtype('int64') according to the rule 'safe', which names a 0-d out ascalar).- MemoryError
A corrupt
StringDTypecell (NumPy'sMemoryErrortext).
ReduceCumAdd(NDArray, int?, DType, NDArray)
NumPy's np.cumsum (np.add.accumulate), the whole call: the running sums along
axis_ (the flattened array when null), stored into out when given.
public abstract NDArray ReduceCumAdd(NDArray arr, int? axis_, DType dtype = null, NDArray @out = null)
Parameters
arrNDArrayThe array.
axis_int?The accumulated axis (negative counts from the end), or null for the flattened array.
dtypeDTypeThe loop / result dtype (
dtype=), or null: then the loop ispromote_types(out.dtype, arr.dtype)whenoutis given (no NEP 50 widening), NEP 50's accumulator of the input otherwise.outNDArrayNumPy's
out=, an array of the result's shape that receives it with unsafe casting, or null for a fresh result.
Returns
- NDArray
outitself when given, else a fresh array.
Remarks
The engine owns NumPy's whole call, dtype decisions included (the np-layer dtype plan): the public
np.cumsum only calls this (a subclass operand arrives as its plain view; the declaration below answers
for the class). out was added to the contract in 0.80.0 (a breaking change for a
subclass, decision D2 of that plan).
Exceptions
- AxisError
axis_is out of range.- TypeError
A text operand or request NumPy's loop resolution refuses.
- ValueError
A read-only
out, or text a numeric loop cannot parse.- IncorrectShapeException
outdoes not have the result's shape.
ReduceCumMul(NDArray, int?, DType, NDArray)
NumPy's np.cumprod (np.multiply.accumulate), the whole call: the running products along
axis_ (the flattened array when null), stored into out when given.
public abstract NDArray ReduceCumMul(NDArray arr, int? axis_, DType dtype = null, NDArray @out = null)
Parameters
arrNDArrayThe array.
axis_int?The accumulated axis (negative counts from the end), or null for the flattened array.
dtypeDTypeThe loop / result dtype (
dtype=), or null: then the loop ispromote_types(out.dtype, arr.dtype)whenoutis given (no NEP 50 widening), NEP 50's accumulator of the input otherwise.outNDArrayNumPy's
out=, an array of the result's shape that receives it with unsafe casting, or null for a fresh result.
Returns
- NDArray
outitself when given, else a fresh array.
Remarks
The engine owns NumPy's whole call, dtype decisions included (the np-layer dtype plan): the public
np.cumprod only calls this (a subclass operand arrives as its plain view; the declaration below
answers for the class). out was added to the contract in 0.80.0 (a breaking change for a
subclass, decision D2 of that plan).
Exceptions
- AxisError
axis_is out of range.- TypeError
A text operand or request NumPy's loop resolution refuses.
- ValueError
A read-only
out, or text a numeric dtype cannot parse.- IncorrectShapeException
outdoes not have the result's shape.
ReduceMean(NDArray, NDAxis?, bool, DType, NDArray, NDArray)
NumPy's np.mean (_methods._mean), the whole call: the add reduction divided by the count of the
reduced elements, stored into out when given.
public abstract NDArray ReduceMean(NDArray arr, NDAxis? axis, bool keepdims = false, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
arrNDArrayThe array to average (any dtype, any layout).
axisNDAxis?The reduced axis (negative counts from the end), or null for every axis. Unlike a ufunc reduction, a 0-d array takes no axis.
keepdimsboolWhether the reduced axes stay in the result with length 1.
dtypeDTypeThe loop of the sum (
dtype=), or null: float64 for a bool or integer input, float32 for float16 (with a float16 result), the input's own dtype otherwise.outNDArrayNumPy's
out=, an array of the result's shape, or null for a fresh result. NumPy stores the SUM into it (inpromote_types(out, arr)whendtypeis null and the input is not a bool, integer or float16 one) and then divides it in place, both with an unsafe cast: an integer out holds truncated values.whereNDArrayNumPy's keyword-only
where=: a bool mask broadcast againstarr; the mean of each output is the sum of its selected elements divided by their count (_count_reduce_items: the mask broadcast to the array's shape and summed), so an output with none selected is0 / 0(NaN in a float loop, NumPy's unsafe cast of it in an integer one). Null, or a 0-d true mask, is no mask.
Returns
- NDArray
outitself when given; otherwise a fresh array, NumPy's read-only scalar for a full reduction.
Remarks
The engine owns NumPy's whole call, dtype decisions included (the np-layer dtype plan). out
was added to the contract in 0.80.0 (P1d, decision D2: a breaking change for a subclass), and
where in its P10 (D10); numpy.matrix's mean(out=) runs through it. Mean(NDArray, int?, DType, bool)
stays for callers of the shipped member; np.mean calls this one.
Exceptions
- AxisError
axisis out of range (every axis is, for a 0-d input without a mask; with one, ufunc.reduce's rule reads axis 0 / -1 of a 0-d input as every axis).- ValueError
outis read-only or does not have the result's shape (NumPy's reduce prologue texts), or text a numeric loop must parse does not parse.- IncorrectShapeException
outdoes not broadcast against the input, orwheredoes not broadcast to its shape.- ArgumentException
whereis not a bool array (NumPy's TypeError text), raised by the sum after the count.- TypeError
A text operand, out or request NumPy's loop resolution refuses.
ReduceProduct(NDArray, NDAxis?, bool, DType, NDArray, object, NDArray)
NumPy's np.prod (np.multiply.reduce), the whole call: the product over axis
(every axis when null), stored into out when given.
public abstract NDArray ReduceProduct(NDArray arr, NDAxis? axis, bool keepdims = false, DType dtype = null, NDArray @out = null, object initial = null, NDArray where = null)
Parameters
arrNDArrayThe array (any dtype, any layout).
axisNDAxis?The reduced axis (negative counts from the end), or null for every axis. A 0-d input accepts 0 and -1 (ufunc.reduce's backward-compatibility rule).
keepdimsboolWhether the reduced axes stay in the result with length 1.
dtypeDTypeThe loop dtype (
dtype=), or null: NEP 50's accumulator of the input withoutout,promote_types(out, arr)with it (no small-integer widening then).outNDArrayNumPy's
out=, an array of the result's shape that receives it with unsafe casting, or null for a fresh result.initialobjectNumPy's
initial=: the value every output starts from instead of the identity 1, packed into the loop dtype asPyArray_Packpacks it (see ReduceAdd(NDArray, NDAxis?, bool, DType, NDArray, object, NDArray)), or null for the identity.whereNDArrayNumPy's
where=: a bool mask broadcast againstarr; only the selected elements are multiplied in, an output with none selected keeps the start value. Null, or a 0-d true mask, is no mask.
Returns
- NDArray
outitself when given; otherwise a fresh array, NumPy's read-only scalar for a full reduction.
Remarks
out was added to the contract in 0.80.0 (the np-layer dtype plan's P1d, decision D2: a
breaking change for a subclass), initial and where in its P10 (D10);
numpy.matrix's prod(out=) runs through it. With either keyword the product is NumPy's sequential
multiply.reduce loop through its reduction iterator; without them a float product is NumPy's sequential
order too (the SIMD lanes of NL3 were removed on 2026-11-12), so the keywords change no bits.
Exceptions
- AxisError
axisis out of range.- ValueError
outis read-only or does not have the result's shape (NumPy's reduce prologue texts), text a numeric loop must parse does not parse, or aninitialthe loop cannot hold.- ArgumentException
whereis not a bool array (NumPy's TypeError text).- IncorrectShapeException
outorwheredoes not broadcast against the input.- OverflowError
An integer
initialpast the loop's range.- TypeError
Text, or a string request: NumPy's refusal (no multiply loop reduces text into itself; integer counts into a text out repeat); a C# scalar as
out; a complexinitialfor a real loop.
ReduceStd(NDArray, NDAxis?, bool, int?, DType, NDArray, NDArray, NDArray, int?)
NumPy's np.std (_methods._std), the whole call: the square root of ReduceVar(NDArray, NDAxis?, bool, int?, DType, NDArray, NDArray, NDArray, int?), stored
into out when given.
public abstract NDArray ReduceStd(NDArray arr, NDAxis? axis, bool keepdims = false, int? ddof = null, DType dtype = null, NDArray @out = null, NDArray where = null, NDArray mean = null, int? correction = null)
Parameters
arrNDArrayThe operand (any dtype, any layout).
axisNDAxis?The reduced axis (negative counts from the end), or null for every axis.
keepdimsboolWhether the reduced axes stay in the result with length 1.
ddofint?Delta degrees of freedom (null is 0): the divisor is
max(n - ddof, 0).dtypeDTypeThe loop of both sums (an integer or bool input defaults to float64, every other input to its own dtype).
outNDArrayNumPy's
out=: a FLOAT or complex array of the result's shape, or null. NumPy hands it to the variance's last sum (whose loop it joins), divides it in place and takes the square root in place.whereNDArrayNumPy's keyword-only
where=(see ReduceVar(NDArray, NDAxis?, bool, int?, DType, NDArray, NDArray, NDArray, int?)), or null.meanNDArrayNumPy's keyword-only
mean=(see ReduceVar(NDArray, NDAxis?, bool, int?, DType, NDArray, NDArray, NDArray, int?)), or null to compute it.correctionint?NumPy's keyword-only
correction=, the Array API's name ofddof(see ReduceVar(NDArray, NDAxis?, bool, int?, DType, NDArray, NDArray, NDArray, int?)), or null.
Returns
- NDArray
outitself when given; otherwise a fresh array, a read-only 0-d scalar when the result has no dimensions.
Remarks
out was added to the contract in 0.80.0 (the np-layer dtype plan's P1d, decision D2),
where, mean and correction in its P10 (D10);
numpy.matrix's std(out=) runs through it.
Exceptions
- AxisError
axisis outside the operand (a 0-d operand included, without a mask).- TypeError
A bool input with
dtype=boolor a boolmeanagainst a bool input (NumPy's boolean-subtract refusal), or text NumPy's loop resolution refuses.- ValueError
outis read-only or does not have the result's shape; bothddof(nonzero) andcorrectiongiven (ddof and correction can't be provided simultaneously.).- TypeError
An integer or bool
dtype(with a result that has dimensions) orout: NumPy'ssqrtoutput-cast error undersame_kind.- ArgumentException
A non-bool
where.- IncorrectShapeException
whereormeandoes not broadcast with the operand.
ReduceVar(NDArray, NDAxis?, bool, int?, DType, NDArray, NDArray, NDArray, int?)
NumPy's np.var (_methods._var), the whole call: the mean of the squared deviations from the mean,
divided by max(n - ddof, 0), stored into out when given.
public abstract NDArray ReduceVar(NDArray arr, NDAxis? axis, bool keepdims = false, int? ddof = null, DType dtype = null, NDArray @out = null, NDArray where = null, NDArray mean = null, int? correction = null)
Parameters
arrNDArrayThe operand (any dtype, any layout).
axisNDAxis?The reduced axis (negative counts from the end), or null for every axis.
keepdimsboolWhether the reduced axes stay in the result with length 1.
ddofint?Delta degrees of freedom (null is 0).
dtypeDTypeThe loop of both sums (an integer or bool input defaults to float64, every other input to its own dtype); it decides the result dtype.
outNDArrayNumPy's
out=, an array of the result's shape, or null. NumPy hands it to its LAST sum only (the squared deviations', whose loop ispromote_types(out, x)withoutdtype), then divides it in place.whereNDArrayNumPy's keyword-only
where=: a bool mask broadcast againstarr. Each output's count, mean and sum of squared deviations take only its selected elements, and the divisor ismax(count - ddof, 0)per output. Null, or a 0-d true mask, is no mask.meanNDArrayNumPy's keyword-only
mean=: the mean to subtract instead of computing it, an array that broadcasts againstarr(the keepdims meannp.mean(arr, axis, keepdims=True)gives), or a C# number standing for a Python scalar; null computes it. Footgun: NumPy does not divide or cast it, so the deviations takearr - mean's own dtype (an int32 array with an integer mean subtracts and squares in int32, wrapping), and a mean that broadcasts to a LARGER shape makes the result larger.correctionint?NumPy's keyword-only
correction=, the Array API's name ofddof: it replacesddofwhen that is null or 0, or null for none.
Returns
- NDArray
outitself when given; otherwise a fresh array, a read-only 0-d scalar when the result has no dimensions.
Remarks
out was added to the contract in 0.80.0 (the np-layer dtype plan's P1d, decision D2),
where, mean and correction in its P10 (D10);
numpy.matrix's var(out=) runs through it. ndarray.var has no correction= in NumPy 2.4.2
(its _var refuses the keyword), so var(NDAxis?, DType, NDArray, int, bool, NDArray, NDArray) passes null.
Exceptions
- AxisError
axisis outside the operand (a 0-d operand included, without a mask).- TypeError
A bool input with
dtype=boolor a boolmeanagainst a bool input (NumPy's boolean-subtract refusal), a text out for a float or complex input, or text NumPy's loop resolution refuses.- ValueError
outis read-only or does not have the result's shape; bothddof(nonzero) andcorrectiongiven (ddof and correction can't be provided simultaneously., raised before anything else, as NumPy'snp.varraises it).- ArgumentException
A non-bool
where(NumPy's TypeError text).- IncorrectShapeException
whereormeandoes not broadcast with the operand.
RightShift(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray RightShift(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Rint(NDArray, DType, NDArray, NDArray)
public abstract NDArray Rint(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
RollAxis(NDArray, int, int)
public abstract NDArray RollAxis(NDArray nd, int axis, int start = 0)
Parameters
Returns
Roots(NDArray)
NumPy's np.roots(p): the roots of the polynomial with coefficients p (highest
degree first), the eigenvalues of its companion matrix after the leading and trailing zeros are stripped
(each trailing zero a root at 0).
public abstract NDArray Roots(NDArray p)
Parameters
pNDArrayThe coefficients, 1-D after
atleast_1d. This is roots' body: a 0-d input is one coefficient here, while the np.roots facade refuses it first with NumPy's dispatcher TypeError.
Returns
- NDArray
The roots: complex128 or float64 (LAPACK's eigenvalues), with the zero roots appended; an empty float64 array for no non-zero coefficient or a single one.
Exceptions
- ValueError
p is not rank 1 (
Input must be a rank-1 array.), or a text coefficient between the first and last non-empty one does not parse as a float.- NotSupportedException
Two or more non-zero coefficients and no LAPACK backend.
Round(NDArray, DType, NDArray, NDArray)
public abstract NDArray Round(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Round(NDArray, int, DType, NDArray)
public abstract NDArray Round(NDArray nd, int decimals, DType dtype = null, NDArray @out = null)
Parameters
Returns
SearchSorted(NDArray, NDArray, string, NDArray)
NumPy's np.searchsorted(a, v, side, sorter) (PyArray_SearchSorted): the indices at which the
elements of v would be inserted into the sorted 1-D a to keep it sorted,
the whole call — the descriptor both operands are converted to (numbers: their common dtype; text: the common
string dtype, a number formatted; StringDType without a common descriptor: Python objects), NumPy's checks in
its order, and its binary search, its monotonic carry and its sorter checks included.
public abstract NDArray SearchSorted(NDArray a, NDArray v, string side = "left", NDArray sorter = null)
Parameters
aNDArrayThe haystack: 1-D, sorted ascending unless
sorteris given. Any dtype, text included; any layout.vNDArrayThe keys: any dtype, shape and layout (a 0-d array for one key).
sidestring"left"(the first suitable index) or"right"(the last).sorterNDArrayIndices that sort
a, or null: 1-D, integer, ofa's size.
Returns
- NDArray
A fresh int64 array of
v's shape (0-d for a 0-d key).
Remarks
New in 0.80.0 (the np-layer dtype plan, P2): the public np.searchsorted calls this, a subclass
operand handed in as its plain view.
Exceptions
- ArgumentException
sideis not"left"/"right".- ValueError
See SearchSorted(NDArray, int, string, NDArray); or a StringDType comparison that touched a None-like NA.
- TypeError
A sorter refusal; a U array converted to StringDType (NumPy's 'safe' cast refusal); the first comparison Python refuses on the object path (
'<' not supported between instances of 'str' and 'int').- UnicodeDecodeError
A text search converts bytes that are not ASCII to the common
Udtype.- DTypePromotionError
Text with an operand that has no common dtype with it.
- NullReferenceException
aorvis null.
SearchSorted(NDArray, double, string, NDArray)
NumPy's np.searchsorted(a, v, side, sorter) (PyArray_SearchSorted) for a Python float key: the
index at which v would be inserted into the sorted 1-D a to keep it
sorted, the whole call.
public abstract long SearchSorted(NDArray a, double v, string side = "left", NDArray sorter = null)
Parameters
aNDArrayThe haystack: 1-D, sorted ascending unless
sorteris given. Any dtype, text included; any layout.vdoubleThe key, read as NumPy's Python float (the search runs in
promote_types(a, float64): a float32 haystack is searched in float64, as NumPy does).sidestring"left"(the first suitable index) or"right"(the last).sorterNDArrayIndices that sort
a, or null: 1-D, integer, ofa's size.
Returns
- long
The insertion index (0 to
a.size).
Remarks
New in 0.80.0 (the np-layer dtype plan, P2): the public np.searchsorted calls this, a subclass
operand handed in as its plain view.
Exceptions
- ArgumentException
sideis not"left"/"right".- ValueError
- TypeError
A sorter refusal (see the int member), or a StringDType haystack whose first comparison with the float Python refuses (
'<' not supported between instances of 'str' and 'float').- NullReferenceException
ais null.
SearchSorted(NDArray, int, string, NDArray)
NumPy's np.searchsorted(a, v, side, sorter) (PyArray_SearchSorted) for a Python int key: the
index at which v would be inserted into the sorted 1-D a to keep it
sorted, the whole call (NumPy's argument checks in its order, then the search in the operands' common dtype).
public abstract long SearchSorted(NDArray a, int v, string side = "left", NDArray sorter = null)
Parameters
aNDArrayThe haystack: 1-D, sorted ascending unless
sorteris given (an unsorted one gets NumPy's bisection's answer, not an error). Any dtype, text included; any layout.vintThe key, read as NumPy's Python int (a strong int32 descriptor: the search runs in
promote_types(a, int32), never casting the key down toa's dtype).sidestring"left"(the first suitable index) or"right"(the last).sorterNDArrayIndices that sort
a(typically its argsort), or null: 1-D, integer, ofa's size.
Returns
- long
The insertion index (0 to
a.size).
Remarks
New in 0.80.0 (the np-layer dtype plan, P2): the public np.searchsorted calls this, a subclass
operand handed in as its plain view. A member of its own, not the array form over a 0-d key: the key stays on
the stack, about 15x cheaper per call.
Exceptions
- ArgumentException
sideis not"left"/"right"(NumPy's two ValueError texts).- ValueError
ais not 1-D, a sorter of uint64, a sorter whose size differs froma's, or a sorter index outsideathat the search reaches.- TypeError
A sorter that is not 1-D (
could not parse sorter argument) or not integer (sorter must only contain integers), or a StringDType haystack whose first comparison with the int Python refuses ('<' not supported between instances of 'str' and 'int').- NullReferenceException
ais null.
Setdiff1d(NDArray, NDArray, bool)
NumPy's np.setdiff1d(ar1, ar2, assume_unique=False): the values of ar1 not in
ar2, ar1[isin(ar1, ar2, assume_unique=True, invert=True)] after making both
unique (or only flattening ar1 when assume_unique).
public abstract NDArray Setdiff1d(NDArray ar1, NDArray ar2, bool assume_unique = false)
Parameters
ar1NDArrayThe values to keep or drop.
ar2NDArrayThe values to drop.
assume_uniqueboolWhether both operands are already unique (the result is then in ar1's order, its duplicates kept).
Returns
- NDArray
A new 1-D array in
ar1's dtype, sorted unlessassume_unique; a surviving float32 / float64 NaN is NumPy's canonical positive quiet NaN.
Exceptions
- UnicodeDecodeError
The membership test's sort path decodes
Stext holding a byte that is not ASCII.- ValueError
A
StringDTypearray whose sort compares a None-like NA.
Setxor1d(NDArray, NDArray, bool)
NumPy's np.setxor1d(ar1, ar2, assume_unique=False): the sorted values found in exactly one of the
operands (each made unique first unless assume_unique).
public abstract NDArray Setxor1d(NDArray ar1, NDArray ar2, bool assume_unique = false)
Parameters
ar1NDArrayThe first operand.
ar2NDArrayThe second operand.
assume_uniqueboolWhether both operands are already unique (their values then are not made unique; a repeated value is then not exclusive).
Returns
- NDArray
A new 1-D array; a surviving float32 / float64 NaN is NumPy's canonical positive quiet NaN.
Exceptions
- UnicodeDecodeError
A
Uresult overStext holding a byte that is not ASCII.- DTypePromotionError
A
StringDTypeoperand beside a class the concatenation finds no common DType with.- ValueError
A
StringDTypearray whose sort compares a None-like NA.
Sign(NDArray, DType, NDArray, NDArray)
public abstract NDArray Sign(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
SignBit(NDArray, DType, NDArray, NDArray)
public abstract NDArray SignBit(NDArray a, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Sin(NDArray, DType, NDArray, NDArray)
public abstract NDArray Sin(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Sinc(NDArray)
NumPy's np.sinc(x), the normalized sinc sin(pix) / (pix): y = pi * x, every exact
zero of y replaced by the machine epsilon of y's dtype (1e-20 for a dtype that is not float),
then sin(y) / y, so the removable singularity gives its limit 1.
public abstract NDArray Sinc(NDArray x)
Parameters
xNDArrayThe input, any dtype and layout (not null).
Returns
- NDArray
The values, of
pi * x's dtype: float64 for bool, integers and char; float16 / float32 / float64 kept; complex128 for complex; decimal for decimal (the double bridge).
Remarks
DefaultEngine runs the four statements as one fused np.evaluate pass.
Exceptions
- ArgumentNullException
xis null.- TypeError
A text operand:
pi * xhas no loop (NumPy's no-loop texts).- OverflowException
A decimal
xwhosepi * xleaves the decimal range.
Sinh(NDArray, DType, NDArray, NDArray)
public abstract NDArray Sinh(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Sort(NDArray, int?, string, object, bool?, bool?)
NumPy's np.sort(a, axis, kind, order, stable, descending) (fromnumeric.sort over
PyArray_Sort), the whole call: a sorted copy of a, which is only read. Use
SortInPlace(NDArray, int?, string, object, bool?, bool?) for ndarray.sort.
public abstract NDArray Sort(NDArray a, int? axis = -1, string kind = null, object order = null, bool? stable = null, bool? descending = null)
Parameters
aNDArrayThe array (any dtype: text sorts by code points,
StringDTypein NumPy's NA order).axisint?The sorted axis (negative counts from the end), or null for the C-order flattening.
kindstringNumPy's
kind=, read from its first character (quicksort,heapsort,mergesort orstable, any case), or null for the default. It changes the answer only where NumPy's does: the heapsort kind is the default kind, the default kind's float value sort leaves the NaNs in the order NumPy's x86-simd-sort moves them to the end (the stable kind's in input order, every NaN's bits kept either way), and the default kind's descending sorts follow NumPy's introsort.orderobjectNumPy's
order=, a field name or a list of them, or null: every NumSharp dtype has no fields, so any value is refused.stablebool?NumPy's keyword-only
stable=: true asks for the stable kind; any non-null value is refused together withkind.descendingbool?NumPy 2.5's keyword-only
descending=: true sorts the largest value first, NaN still last (complex: the NaN classes last, each in descending order); any non-null value is refused together withkind.StringDTyperefuses it.
Returns
- NDArray
A fresh array of
a's dtype laid out ascopy(order='K')lays outa(an F input stays F), or the sorted flattening for a null axis.
Remarks
New in 0.80.0 (the np-layer dtype plan, phase PE, E5): the public np.sort applies its class
boundaries and calls this; DefaultEngine sorts with its AxisSort kernels.
Exceptions
- ValueError
An unknown
kind(sort kind must be one of 'quick', 'heap', or 'stable' (got 'x')),kindtogether withstableordescending, or anorder, all before the array is read; aStringDTypeline of two or more elements holding an NA whose NA object is neither NaN-like nor a string.- RuntimeError
A
StringDTypearray sorted descending (unsupported sort kind), after the axis check.- AxisError
The axis is out of range (a 0-d array refuses every axis: NumPy's sort does not ravel it first).
SortComplex(NDArray)
NumPy's np.sort_complex(a): a sorted copy along the last axis (b = array(a, copy=True);
b.sort()), in the input's own dtype, then converted to complex (astype('D')) unless it is.
public abstract NDArray SortComplex(NDArray a)
Parameters
aNDArrayThe input (not null).
Returns
- NDArray
A new complex128 array of
a's shape, sorted along its last axis (complex values lexicographically: real part, then imaginary part).
Remarks
The sort runs in the original dtype, so an int64 past 2^53 orders by its exact value, not by its double image; only the sorted result is widened.
Exceptions
- AxisError
A 0-d array (
axis -1 is out of bounds for array of dimension 0, which NumPy'sb.sort()raises).- ValueError
Text that is not a complex number (
complex() arg is a malformed string).
SortInPlace(NDArray, int?, string, object, bool?, bool?)
NumPy's ndarray.sort(axis, kind, order, stable, descending) (array_sort over PyArray_Sort), the whole
call: sorts a IN PLACE along the axis, in NumPy's order of checks (the arguments, the axis,
writeability, then the sort). Use Sort(NDArray, int?, string, object, bool?, bool?) for a sorted copy.
public abstract void SortInPlace(NDArray a, int? axis = -1, string kind = null, object order = null, bool? stable = null, bool? descending = null)
Parameters
aNDArrayThe array sorted in place (any dtype).
axisint?The sorted axis (negative counts from the end), or null: NumSharp's extension that sorts a contiguous array's flattening in place.
kindstringNumPy's
kind=, read from its first character (quicksort,heapsort,mergesort orstable, any case), or null for the default. It changes the answer only where NumPy's does: the heapsort kind is the default kind, the default kind's float value sort leaves the NaNs in the order NumPy's x86-simd-sort moves them to the end (the stable kind's in input order, every NaN's bits kept either way), and the default kind's descending sorts follow NumPy's introsort.orderobjectNumPy's
order=, a field name or a list of them, or null: every NumSharp dtype has no fields, so any value is refused.stablebool?NumPy's keyword-only
stable=: true asks for the stable kind; any non-null value is refused together withkind.descendingbool?NumPy 2.5's keyword-only
descending=: true sorts the largest value first, NaN still last (complex: the NaN classes last, each in descending order); any non-null value is refused together withkind.StringDTyperefuses it.
Remarks
New in 0.80.0 (the np-layer dtype plan, phase PE, E5): NDArray.sort calls this.
Exceptions
- ValueError
An unknown
kind(sort kind must be one of 'quick', 'heap', or 'stable' (got 'x')),kindtogether withstableordescending, or anorder, all before the array is read; a read-only array (sort array is read-only); aStringDTypeline of two or more elements holding an NA whose NA object is neither NaN-like nor a string.- RuntimeError
A
StringDTypearray sorted descending (unsupported sort kind), after the axis and writeability checks.- AxisError
The axis is out of range.
Spacing(NDArray, DType, NDArray, NDArray)
public abstract NDArray Spacing(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Sqrt(NDArray, DType, NDArray, NDArray)
public abstract NDArray Sqrt(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Square(NDArray, DType, NDArray, NDArray)
public abstract NDArray Square(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Subtract(NDArray, NDArray, DType, NDArray, NDArray)
public abstract NDArray Subtract(NDArray lhs, NDArray rhs, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Sum(NDArray, int?, DType, bool)
The sum without out= / initial= / where=: ReduceAdd(NDArray, NDAxis?, bool, DType, NDArray, object, NDArray) under its shipped (0.70.0)
signature, kept for callers and subclasses of that member.
public abstract NDArray Sum(NDArray nd, int? axis = null, DType dtype = null, bool keepdims = false)
Parameters
ndNDArrayThe array to sum.
axisint?The reduced axis, or null for every axis.
dtypeDTypeThe loop dtype, or null for NEP 50's accumulator.
keepdimsboolWhether the reduced axes stay with length 1.
Returns
Remarks
Footgun: np.sum and ndarray.sum call ReduceAdd(NDArray, NDAxis?, bool, DType, NDArray, object, NDArray) since 0.80.0, so an override of
this member no longer intercepts them; override ReduceAdd(NDArray, NDAxis?, bool, DType, NDArray, object, NDArray).
Exceptions
- AxisError
axisis out of range.
SwapAxes(NDArray, int, int)
public abstract NDArray SwapAxes(NDArray nd, int axis1, int axis2)
Parameters
Returns
Tan(NDArray, DType, NDArray, NDArray)
public abstract NDArray Tan(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Tanh(NDArray, DType, NDArray, NDArray)
public abstract NDArray Tanh(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Tensordot(NDArray, NDArray, int)
NumPy's np.tensordot(a, b, axes=2) with an integer axes: the sum of products over the
last axes axes of a and the first axes axes of
b - NumPy's axes_a = list(range(-axes, 0)), axes_b = list(range(0, axes)),
then the statements of Tensordot(NDArray, NDArray, int[], int[]).
public abstract NDArray Tensordot(NDArray a, NDArray b, int axes = 2)
Parameters
aNDArrayThe first tensor (not null).
bNDArrayThe second tensor (not null).
axesintThe number of axes to contract: 0 is the outer (tensor) product, 1 the matrix product, 2 the double contraction. A negative count contracts nothing (NumPy's
range(-axes, 0)is empty).
Returns
- NDArray
A new array of
a's kept axes followed byb's, the dot product's dtype.
Remarks
NumPy writes tensordot in Python (numpy/_core/numeric.py); DefaultEngine builds the two axis lists and
runs the list form. np.tensordot calls it after the matrix and chararray boundaries, and numpy.linalg's
Array-API tensordot directly; an override replaces both for every array whose engine it is.
Exceptions
- IndexError
More axes than an operand has (
tuple index out of range).- ValueError
Contracted extents that differ (
shape-mismatch for sum), and the final dot's refusals of text (dot not available for this type).- TypeError
The final dot's refusals of text operands (NumPy's texts).
- NotSupportedException
A
StringDTypeoperand beside a number, which NumPy computes as Python objects (an object array NumSharp does not have).- NullReferenceException
aorbis null.
Tensordot(NDArray, NDArray, int[], int[])
NumPy's np.tensordot(a, b, axes=(axes_a, axes_b)): the sum of products pairing axis
axesA[k] of a with axis axesB[k] of b - each operand
transposed so its contracted axes meet, reshaped to a matrix, one dot product, and the result reshaped to the
kept axes.
public abstract NDArray Tensordot(NDArray a, NDArray b, int[] axesA, int[] axesB)
Parameters
aNDArrayThe first tensor (not null).
bNDArrayThe second tensor (not null).
axesAint[]The axes of
ato contract, in pairing order (negative counts from the end).axesBint[]The axes of
bto contract, paired element by element withaxesA.
Returns
- NDArray
A new array of
a's kept axes followed byb's, the dot product's dtype.
Remarks
DefaultEngine runs NumPy's statements over the operand engines' Transpose(NDArray, int[]) and
Dot(NDArray, NDArray, NDArray) and the array object's reshape, so the product takes the OpenBLAS backend when one is
installed. np.tensordot's list and (int, int) forms call it (the pair as two one-element lists,
NumPy's [axes_a] / [axes_b]), and numpy.linalg's Array-API tensordot directly.
Exceptions
- ValueError
A list that repeats a RAW axis value (
duplicate axes are not allowed in tensordot, checked first); lists of different lengths or contracted extents that differ (shape-mismatch for sum); the final dot's refusals of text.- IndexError
An axis out of range (
tuple index out of range: NumPy indexes the shape tuple with the raw axis). A mismatched extent earlier in the lists settles as the shape mismatch first, hiding a later out-of-range axis.- TypeError
The final dot's refusals of text operands (NumPy's texts).
- NotSupportedException
A
StringDTypeoperand beside a number, which NumPy computes as Python objects.- NullReferenceException
a,bor an axis list is null.
Trace(NDArray, int, int, int, DType, NDArray)
NumPy's np.trace(a, offset, axis1, axis2, dtype, out) (PyArray_Trace), the whole call: the sums
along the diagonals diagonal(NDArray, int, int, int) returns, add.reduce over its
last axis with
dtype and out.
public abstract NDArray Trace(NDArray a, int offset = 0, int axis1 = 0, int axis2 = 1, DType dtype = null, NDArray @out = null)
Parameters
aNDArrayThe array (at least 2-D; any dtype, text included).
offsetintThe diagonal's offset from the main one.
axis1intThe first axis of the 2-D sub-arrays.
axis2intThe second axis of the 2-D sub-arrays.
dtypeDTypeThe sum's dtype (
dtype=), or null: then the loop ispromote_types(out.dtype, a.dtype)whenoutis given (no NEP 50 widening), NEP 50's accumulator ofaotherwise (signed integers and bool to int64, unsigned integers to uint64).outNDArrayNumPy's
out=, an array of the result's shape that receives it with unsafe casting, or null for a fresh result: the add reduction's out operand, checked by the reduce prologue (read-only first, then its rank, then its length).
Returns
- NDArray
outitself when given; otherwise the sums: a read-only 0-d result (NumPy's scalar) for 2-Da,a's shape without the two axes otherwise.
Remarks
New in 0.80.0 (the np-layer dtype plan, P1b): the public np.trace calls this, a subclass operand
handed in as its plain view.
Exceptions
- ArgumentNullException
ais null.- ValueError
diagonal(NDArray, int, int, int)'s refusals; a StringDType diagonal that cannot be reduced (empty: no identity; an NA under the None-like rule); a read-only
out("output array is read-only") or one of the wrong rank ("output parameter for reduction operation add has the wrong number of dimensions: ...").- AxisError
An axis is out of range.
- TypeError
NumPy's loop resolution refuses text: a text operand with another out class, a text out for numbers, a string
dtype.- IncorrectShapeException
out's length does not broadcast against the diagonal (NumPy's "operands could not be broadcast together with remapped shapes" text).
Transpose(NDArray, int[])
public abstract NDArray Transpose(NDArray nd, int[] premute = null)
Parameters
Returns
Trapezoid(NDArray, NDArray, double, int)
NumPy's np.trapezoid(y, x=None, dx=1.0, axis=-1): the integral of y along the axis
by the composite trapezoidal rule, sum(d * (y[1:] + y[:-1]) / 2.0, axis) with d the spacing.
public abstract NDArray Trapezoid(NDArray y, NDArray x = null, double dx = 1, int axis = -1)
Parameters
yNDArrayThe integrand, a plain array (not null).
xNDArrayThe sample points (1-D along the axis, or of
y's rank), or null for evenly spaced samples.dxdoubleThe spacing when
xis null.axisintThe integration axis, read against each statement's array as NumPy reads it.
Returns
- NDArray
The integral: a fresh array the caller owns, of
y's shape without the axis (0-d for a 1-Dy), its dtype NumPy's arithmetic result.
Remarks
NumPy writes trapezoid in Python; DefaultEngine's override runs its statements, the half and its sum fused
into one pass where that gives NumPy's bits. np.trapezoid calls this after the null check, a
subclass operand handed in as its plain view; an override replaces it for every array whose engine it is.
New in 0.80.0 (the np-layer dtype plan, phase PE); it was the internal class TrapezoidEngine.
Exceptions
- IndexError
The axis is outside
y's rank.- AxisError
An N-D
xhas no axisaxis(np.diff'snormalize_axis_index).- ValueError
A 0-D
x(np.diff's "at least one dimensional"), or a StringDTypeywhose concatenation meets an NA it cannot add.- IncorrectShapeException
The spacing does not broadcast against
y[1:] + y[:-1].- TypeError
A text
yorx: the refusal of the first NumPy statement that has no loop for it.
TrimZeros(NDArray, string, int[])
NumPy's np.trim_zeros(filt, trim='fb', axis=None): filt cut to the bounding box of
its nonzero elements along the trimmed axes - the leading ('f') and / or trailing ('b')
hyperplanes that hold only zeros removed. The values decide which view comes back, so it is a computation
(the plan's borderline decision), though nothing is computed into a new buffer.
public abstract NDArray TrimZeros(NDArray filt, string trim = "fb", int[] axis = null)
Parameters
filtNDArrayThe input, a plain array:
np.trim_zerosdecides thenumpy.matrixandnumpy.char.chararrayclasses before it calls this member. A text array is trimmed by its truth values (an empty string is a zero), as NumPy'sargwherereads them through the dtype'snonzero.trimstringThe sides to trim:
"f"(front),"b"(back),"fb"or"bf"(both), in any case; null reads as the empty string, which is refused.axisint[]The axes to trim (a negative axis counts from the end), or null for every axis; an empty array trims nothing.
Returns
- NDArray
A view of
filtwith the zero hyperplanes cut from the sidestrimnames (an axis without a nonzero element is cut to length 0, whatevertrimsays), orfiltitself when no axis is trimmed (an emptyaxis, or a 0-dfiltwithaxisnull). The dtype and the number of dimensions arefilt's.
Remarks
NumPy's _arg_trim_zeros takes the edges from argwhere(filt)'s minimum and maximum. The
bounding box is separable, so DefaultEngine takes each trimmed axis' first and last index from
nonzero(any(filt, other axes)) instead: the same view, without every nonzero coordinate.
Exceptions
- ValueError
trimholds another spelling (unexpected character(s) in, checked first), or an axis is repeated (trim: 'fx'repeated axis in).axisargument- AxisError
An axis is out of range for
filt(axis: axis 3 is out of bounds for array of dimension 2), checked for every axis before the repeat.- NullReferenceException
filtis null (read after the trim check).
Truncate(NDArray, DType, NDArray, NDArray)
public abstract NDArray Truncate(NDArray nd, DType dtype = null, NDArray @out = null, NDArray where = null)
Parameters
Returns
Union1d(NDArray, NDArray)
NumPy's np.union1d(ar1, ar2), unique(concatenate((ar1, ar2), axis=None)): the sorted unique
values found in either flattened operand.
public abstract NDArray Union1d(NDArray ar1, NDArray ar2)
Parameters
Returns
- NDArray
A new 1-D array in the concatenation's promoted dtype; a surviving float32 / float64 NaN is NumPy's canonical positive quiet NaN, as NumPy's sort leaves it.
Exceptions
- UnicodeDecodeError
A
Uunion overStext holding a byte that is not ASCII.- DTypePromotionError
A
StringDTypeoperand beside a class the concatenation finds no common DType with.- ValueError
A
StringDTypearray whose sort compares a None-like NA.
Unique(NDArray, bool, bool, bool, int?, bool, bool)
NumPy's np.unique: the sorted unique elements of ar (flattened, or its sub-arrays
along axis), with the optional first-occurrence indices, reconstruction indices and counts.
public abstract NDArray[] Unique(NDArray ar, bool return_index = false, bool return_inverse = false, bool return_counts = false, int? axis = null, bool equal_nan = true, bool sorted = true)
Parameters
arNDArrayThe operand, a plain array (only read;
np.uniquehands anumpy.matrixornumpy.char.chararrayoperand in as its plain view).return_indexboolAlso return the index of each value's first occurrence (along the axis, if given).
return_inverseboolAlso return the indices that rebuild
arfrom the values.return_countsboolAlso return how many times each value occurs.
axisint?The axis whose sub-arrays are compared, or null to flatten first. A 1-D operand's axis is checked, then the flat path runs (NumPy's rule). Along an axis every NaN sub-array is distinct and
-0.0equals+0.0(NumPy compares rows as structured scalars).equal_nanboolCollapse every NaN into one value on the flat numeric path (NumPy's default); the axis path and fixed-width text ignore it.
sortedboolNumPy's
sorted(NumPy 2.3), accepted for parity: the values always come back sorted. NumPy'ssorted=Falsereturns its hash set's iteration order, which is platform-specific (identical as a set).
Returns
- NDArray[]
The present outputs in NumPy's order,
[values, index?, inverse?, counts?]: the values in the operand's dtype, the index outputs int64. Without an axis the inverse has the operand's shape (a view); with one it is 1-D.
Remarks
np.unique wraps the result in np.UniqueResult; both NDArray.unique members call this
member too (the bare one takes element 0). An override replaces all three for every array whose engine it
is (the engine of ar). New in 0.80.0 (the np-layer dtype plan, phase PE); it was the
internal class UniqueEngine.
Exceptions
- AxisError
axisis out of range.- TypeError
A
StringDTypeoperand with an axis over two or more dimensions.- ValueError
A
StringDTypeoperand whose sort compares a None-like NA.
UniqueAll(NDArray)
NumPy's np.unique_all (the Array API): the unique values of the flattened operand, the index of each
value's first occurrence, the indices that rebuild the operand and the counts, every NaN distinct
(equal_nan=False).
public abstract NDArray[] UniqueAll(NDArray x)
Parameters
xNDArrayThe operand, a plain array (only read).
Returns
- NDArray[]
[values, indices, inverse_indices, counts]: the values sorted, the other three int64; the inverse hasx's shape (a view;()for a 0-d operand).
Remarks
np.unique_all wraps the result in np.UniqueAllResult. An override replaces it for every array
whose engine it is. New in 0.80.0 (the np-layer dtype plan, phase PE); it was the internal class
UniqueEngine.
Exceptions
- ValueError
A
StringDTypeoperand whose sort compares a None-like NA.- MemoryError
A corrupt
StringDTypecell (NumPy'sMemoryErrortext).
UniqueCounts(NDArray)
NumPy's np.unique_counts (the Array API): the unique values of the flattened operand and how often
each occurs, every NaN distinct (equal_nan=False).
public abstract NDArray[] UniqueCounts(NDArray x)
Parameters
xNDArrayThe operand, a plain array (only read).
Returns
- NDArray[]
[values, counts]: the values sorted, the counts int64.
Remarks
np.unique_counts wraps the result in np.UniqueCountsResult. An override replaces it for every
array whose engine it is. New in 0.80.0 (the np-layer dtype plan, phase PE); it was the internal class
UniqueEngine.
Exceptions
- ValueError
A
StringDTypeoperand whose sort compares a None-like NA.- MemoryError
A corrupt
StringDTypecell (NumPy'sMemoryErrortext).
UniqueInverse(NDArray)
NumPy's np.unique_inverse (the Array API): the unique values of the flattened operand and the indices
that rebuild it, every NaN distinct (equal_nan=False).
public abstract NDArray[] UniqueInverse(NDArray x)
Parameters
xNDArrayThe operand, a plain array (only read).
Returns
- NDArray[]
[values, inverse_indices]: the values sorted; the inverse int64 withx's shape (a view;()for a 0-d operand), sonp.take(values, inverse_indices)rebuilds the operand.
Remarks
np.unique_inverse wraps the result in np.UniqueInverseResult. An override replaces it for every
array whose engine it is. New in 0.80.0 (the np-layer dtype plan, phase PE); it was the internal class
UniqueEngine.
Exceptions
- ValueError
A
StringDTypeoperand whose sort compares a None-like NA.- MemoryError
A corrupt
StringDTypecell (NumPy'sMemoryErrortext).
UniqueValues(NDArray)
NumPy's np.unique_values (the Array API): the unique values of the flattened operand, every NaN
distinct (equal_nan=False).
public abstract NDArray UniqueValues(NDArray x)
Parameters
xNDArrayThe operand, a plain array (only read).
Returns
- NDArray
The unique values, sorted. NumPy returns its hash set's order for integer, complex and text values (a platform-specific order; the same set).
Remarks
An override replaces np.unique_values for every array whose engine it is. New in 0.80.0 (the np-layer
dtype plan, phase PE); it was the internal class UniqueEngine.
Exceptions
- MemoryError
A corrupt
StringDTypecell (NumPy'sMemoryErrortext).
Unpackbits(NDArray, int?, long?, string)
NumPy's np.unpackbits(a, axis=None, count=None, bitorder='big') (io_unpack /
unpack_bits), the whole call: each uint8 element unpacked into eight 0 / 1 uint8 elements along the
axis, the inverse of Packbits(NDArray, int?, string).
public abstract NDArray Unpackbits(NDArray a, int? axis = null, long? count = null, string bitorder = "big")
Parameters
aNDArrayA uint8 array, read in logical order for any layout.
axisint?The axis to unpack along, or null to unpack the C-order flattened array into a 1-D result. A 0-d input is promoted to
(1,)and accepts only 0 and -1.countlong?The number of output elements along the axis: null unpacks every bit (
8 * len); a non-negative count takes that many bits (truncating, or zero-padding past the available bits); a negative count trims that many bits off the end.bitorderstring"big"or"little"; NumPy's unpack rule reads only the first character ('l'is little,'b'big), null is big.
Returns
- NDArray
A new uint8 array of 0 / 1 values of
a's rank (1-D for a null axis), F-contiguous when the input is.
Remarks
New in 0.80.0 (the np-layer dtype plan): the public np.unpackbits applies the numpy.matrix
rule and calls this. An empty input with a count that asks for elements gives zeros, where NumPy leaks
uninitialised memory.
Exceptions
- ArgumentNullException
ais null.- ValueError
bitorderis empty or begins with neither ('order' must begin with 'l' or 'b'), checked first; or-countexceeds the available bits (-count larger than number of elements).- TypeError
ais not uint8 (Expected an input array of unsigned byte data type).- AxisError
axisis out of bounds fora's rank.
UnravelIndex(NDArray, long[], char)
NumPy's np.unravel_index(indices, shape, order='C') (arr_unravel_index,
numpy/_core/src/multiarray/compiled_base.c), the whole call: the coordinates of each flat index in an
array of dimensions shape.
public abstract NDArray<long>[] UnravelIndex(NDArray indices, long[] shape, char order = 'C')
Parameters
indicesNDArrayAn integer (or bool) array of flat indices, of any rank and layout. Read as int64: a uint64 index at or past 2^63 wraps negative and is out of bounds, as NumPy's same_kind cast to intp makes it.
shapelong[]The dimensions to unravel into (NumPy's intp sequence; negative dimensions multiply in). An empty shape (NumPy's
()) is legal: its one valid index is 0, and only a 0-d index array may use it. Read only: the facade passes a Shape's own array.orderchar'C'(row-major, the default) or'F'(column-major), in either case.
Returns
- NDArray<long>[]
One int64 array per dimension of
shape, each ofindices' shape: the columns of one interleaved buffer of shapeindices.shape + (len(shape),)laid out along the indices' iteration order, so every array is a strided view of that shared buffer. A 0-dindicesgives NumPy's scalars instead (fresh read-only 0-d arrays); an emptyshapewith a 0-d index gives an empty array.
Remarks
New in 0.80.0 (the np-layer dtype plan): the public np.unravel_index(NDArray, Shape, char)
computes a numpy.matrix operand as a plain array and calls this. The dimensions are long[] (NumPy's
intp) since API-parity batch 13; they were int[].
Exceptions
- ArgumentNullException
indicesorshapeis null.- ValueError
In NumPy's order: an order letter that is not C / F / A / K in either case; a product of the dimensions that overflows int64 or is exactly -1 (
dimensions are too large; ...); then, after the TypeError, an'A'or'K'order (only 'C' or 'F' order is permitted); the first index outside[0, prod(shape))in the iteration order (index N is out of bounds for array with size M); and, for an emptyshape, an index array of rank 1 or more (multiple indices are not supported for 0d arrays, after the indices).- TypeError
indicesis neither integer nor bool (only int indices permitted).- NotSupportedException
Runtime code generation is unavailable (the IL kernel cannot be emitted).
Unwrap(NDArray, double?, int, object)
NumPy's np.unwrap(p, discont=None, axis=-1, *, period=6.283185307179586): along the axis, every jump
between neighbours larger than max(discont, period / 2) is corrected by multiples of the period
(the cumulative correction added to p[1:]).
public abstract NDArray Unwrap(NDArray p, double? discont = null, int axis = -1, object period = null)
Parameters
pNDArrayThe input, at least 1-D, not complex (not null).
discontdouble?The largest jump left alone, or null for
period / 2(a smaller one acts asperiod / 2).axisintThe axis to unwrap along (negative counts from the end).
periodobjectNumPy's period, a Python float or int: a boxed double (or null for
2 pi) takes the float path, a boxed long or int NumPy's integer path for an integer or bool input.
Returns
- NDArray
A new array of
p's shape: float64 (or the input's float dtype) on the float path, the integer dtype on the integer path.
Exceptions
- ArgumentNullException
pis null.- ArgumentException
periodis neither null, a double, a long nor an int.- ValueError
A 0-D
p.- AxisError
axisout of range.- TypeError
A complex
p.- OverflowError
On the integer path, a bound or the period that does not fit the input dtype (NumPy's OverflowError).
Vander(NDArray, int?, bool)
NumPy's np.vander(x, N=None, increasing=False): the Vandermonde matrix of a 1-D x,
whose columns are powers of x - x^(N-1) down to x^0, or x^0 up to
x^(N-1) when increasing is set. NumPy makes the powers with
multiply.accumulate in promote_types(x.dtype, int), so an integer matrix wraps where NumPy's
does and every float power is the product NumPy rounds, not x ** k.
public abstract NDArray Vander(NDArray x, int? N = null, bool increasing = false)
Parameters
xNDArrayThe 1-D input, a plain array:
np.vandercomputes anumpy.matrixoperand as a plain array before it calls this member. A 0-d or N-D array is refused.Nint?The number of columns, or null for a square matrix (
len(x)columns).increasingboolWhether the powers increase from left to right.
Returns
- NDArray
A new C-contiguous matrix of shape
(len(x), N)that owns its buffer, inpromote_types(x.dtype, int64): int64 for bool, char and the integers up to int64, float64 for uint64 and every float dtype, decimal and complex128 as they are. A fixed-width textxgives a 21-character text matrix (NumPy promotes int64 to text): the text'1'in every row for one column, an empty matrix for no column.
Remarks
NumPy's statements: v = empty((len(x), N), dtype=promote_types(x.dtype, int)); the first column
(or the last, decreasing) is 1; the others start as x and multiply.accumulate along the
columns turns column k into x^(k+1). An override must keep that product order: a float
power computed another way rounds differently.
Exceptions
- ValueError
xis not one-dimensional (x must be a one-dimensional array or sequence.), orNis negative (the allocation'snegative dimensions are not allowed).- TypeError
A fixed-width text
x(SorU) with two or more columns: the powers come frommultiply, which has no string loop (NumPy's no-loop text).- DTypePromotionError
A
StringDTypex, whateverN:promote_types(StringDType, int64)finds no common DType, before the allocation.- OverflowException
Nis null andxhas more than MaxValue elements (the column count is an int).
Vdot(NDArray, NDArray)
np.vdot — both operands flattened to 1-D, a conjugated when
complex, then a vector dot product. Always 0-d.
public virtual NDArray Vdot(NDArray a, NDArray b)
Parameters
Returns
VdotFunction1D(NDArray, NDArray)
np.vdot's last step over its two flattened operands of one length: NumPy's array_vdot runs
CDOUBLE_vdot (cblas_zdotc_sub / its conjugating own loop) for a complex128 common dtype and the
dtype's dot function for every other. The default conjugates left and runs
DotFunction1D(NDArray, NDArray): the same values, but the copy flips the sign of a NaN imaginary part and costs a
pass and an allocation; DefaultEngine runs zdotc itself.
public virtual NDArray VdotFunction1D(NDArray left, NDArray right)
Parameters
leftNDArrayThe first vector (
ip1), the one np.vdot conjugates, as the caller flattened it.rightNDArrayThe second vector (
ip2), the same length.
Returns
- NDArray
A fresh 0-d result of the operands' common dtype.
Remarks
An engine overrides it to run its own conjugating dot (NumPy's zdotc) instead of the conjugated
copy; np.vdot reaches it after flattening and checking its operands.
Exceptions
- IncorrectShapeException
The vectors' lengths differ (np.vdot's reshape has already refused that: a direct call only).
- DTypePromotionError
The operands have no common dtype.
VdotReadsFirstInPlace(NPTypeCode, long, long)
Whether np.vdot reads its first operand in place when NumPy's flattening keeps it a view at a stride other than 1 (a reversed, broadcast or stepped run), as NumPy does: true by default, NumPy's arithmetic. An engine whose dot function is slower over such a run than over a contiguous copy may answer false: the operand is then copied (C order) and the result is the dot function's over the copy, within the usual reordering bound of NumPy's.
public virtual bool VdotReadsFirstInPlace(NPTypeCode dtype, long stride, long n)
Parameters
dtypeNPTypeCodeThe first operand's dtype (the dot function's when it is the operands' common dtype).
stridelongThe flattened view's element stride (not 1).
nlongThe number of elements.
Returns
- bool
True to read the view in place (NumPy's bits), false to copy it first.
Remarks
Footgun: answering false gives up NumPy's exact bits for that operand - the result is the dot function's over the copy, which can differ from NumPy's in the last bits.
Vecdot(NDArray, NDArray)
The np.vecdot gufunc (n),(n)->() — x1 conjugated when
complex. Operands arrive validated; leading axes broadcast.
public virtual NDArray Vecdot(NDArray x1, NDArray x2)
Parameters
Returns
Vecdot(NDArray, NDArray, NDArray, int[][], int?, bool, DType, string, char)
NumPy's np.vecdot(x1, x2, out, axes, axis, keepdims, dtype, casting, order) — the gufunc (n),(n)->(),
x1 conjugated — the whole call: the argument checks, the core axis (axes= or
axis=, both operands' moved last), the core sizes, the loop dtype selects, the
product (Vecdot(NDArray, NDArray)), the kept axis under keepdims, and the
delivery into out.
public abstract NDArray Vecdot(NDArray x1, NDArray x2, NDArray @out, int[][] axes, int? axis, bool keepdims, DType dtype, string casting, char order)
Parameters
x1NDArrayThe first operand, at least 1-D; conjugated when complex.
x2NDArrayThe second operand, at least 1-D.
outNDArrayWhere the answer is delivered (its cast checked under
casting), or null.axesint[][]The core axis of each operand (
{x1, x2}, or{x1, x2, out}where the output entry is empty, or holds the kept axis underkeepdims), or null.axisint?The core axis of both operands, or null (the last).
keepdimsboolWhether the contracted axis stays in the result with length 1.
dtypeDTypeThe loop dtype, or null.
castingstringThe rule the input-to-loop and answer-to-out casts are checked under:
no,equiv,safe,same_kind(NumPy's default) orunsafe.ordercharThe layout of an allocated answer:
'K'(NumPy's default: the loop axes in the inputs' memory order),'C','F', or'A'(F when both inputs are F-contiguous, else C); ignored without. Lowercase letters are accepted.
Returns
- NDArray
The vector dot products, or
outitself holding them.
Remarks
New in 0.80.0 (the np-layer dtype plan, P2): the public np.vecdot calls this (the ufunc
mechanism answers for a subclass operand).
Exceptions
- TypeError
axiswithaxes; adtypewith details beyond its class; text operands or a textdtype(no vecdot loop).- ValueError
A 0-d operand; core axes of different lengths; an
axes=list of the wrong length; a read-onlyout, or one the answer does not broadcast into.- AxisError
An
axes=entry of the wrong length, or an axis out of range.- TypeError
An input cannot be cast to the loop, or the answer into
out, undercasting(NumPy's UFuncTypeError text).- ValueError
A
castingorordername NumPy refuses (casting must be one of 'no', 'equiv', 'safe', 'same_kind', 'unsafe' (got '…'),order must be one of 'C', 'F', 'A', or 'K' (got '…')), checked casting first.- TypeError
A null
casting(casting must be str, not NoneType).- IncorrectShapeException
Loop axes that do not broadcast.
- NotSupportedException
dtypeis a class without storage yet.- NullReferenceException
x2is null.
Vecmat(NDArray, NDArray)
The np.vecmat gufunc (n),(n,m)->(m) — x1 conjugated
when complex.
public virtual NDArray Vecmat(NDArray x1, NDArray x2)
Parameters
Returns
Vecmat(NDArray, NDArray, NDArray, int[][], int?, bool, DType, string, char)
NumPy's np.vecmat(x1, x2, out, axes, axis, keepdims, dtype, casting, order) — the gufunc (n),(n,m)->(m),
x1 conjugated — the whole call: the argument checks, the core axes axes= names,
the core sizes, the loop dtype selects, the product
(Vecmat(NDArray, NDArray)), the result's core axis placed, and the delivery into
out.
public abstract NDArray Vecmat(NDArray x1, NDArray x2, NDArray @out, int[][] axes, int? axis, bool keepdims, DType dtype, string casting, char order)
Parameters
x1NDArrayThe vector operand, at least 1-D; conjugated when complex.
x2NDArrayThe matrix operand, at least 2-D.
outNDArrayWhere the answer is delivered (its cast checked under
casting), or null.axesint[][]The core axes per operand (
{(n), (n,m), (m)}, all three entries), or null.axisint?Refused for any value (the two core dimensions are distinct), or null.
keepdimsboolRefused when true.
dtypeDTypeThe loop dtype, or null.
castingstringThe rule the input-to-loop and answer-to-out casts are checked under:
no,equiv,safe,same_kind(NumPy's default) orunsafe.ordercharThe layout of an allocated answer:
'K'(NumPy's default: the loop axes in the inputs' memory order),'C','F', or'A'(F when both inputs are F-contiguous, else C); ignored without. Lowercase letters are accepted.
Returns
- NDArray
The vector-matrix products, or
outitself holding them.
Remarks
New in 0.80.0 (the np-layer dtype plan, P2): the public np.vecmat calls this (the ufunc
mechanism answers for a subclass operand).
Exceptions
- TypeError
axiswithaxes, or either given; adtypewith details beyond its class; text operands or a textdtype;keepdims.- ValueError
An operand with too few dimensions; core axes of different lengths; an
axes=list without three entries; a read-onlyout, or one the answer does not broadcast into.- AxisError
An
axes=entry of the wrong length, or an axis out of range.- TypeError
An input cannot be cast to the loop, or the answer into
out, undercasting(NumPy's UFuncTypeError text).- ValueError
A
castingorordername NumPy refuses (casting must be one of 'no', 'equiv', 'safe', 'same_kind', 'unsafe' (got '…'),order must be one of 'C', 'F', 'A', or 'K' (got '…')), checked casting first.- TypeError
A null
casting(casting must be str, not NoneType).- IncorrectShapeException
Loop axes that do not broadcast (the product's text).
- NotSupportedException
dtypeis a class without storage yet.- NullReferenceException
x2is null.