Class np
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
API bridge between NumSharp and Python NumPy
[SuppressMessage("ReSharper", "StaticMemberInitializerReferesToMemberBelow")]
public static class np
- Inheritance
-
np
- Inherited Members
Fields
bool
public static readonly Type @bool
Field Value
bool8
public static readonly Type bool8
Field Value
bool_
public static readonly Type bool_
Field Value
byte
public static readonly Type @byte
Field Value
cdouble
public static readonly Type cdouble
Field Value
char
public static readonly Type @char
Field Value
clongdouble
public static readonly Type clongdouble
Field Value
complex128
public static readonly Type complex128
Field Value
complex_
public static readonly Type complex_
Field Value
decimal
public static readonly Type @decimal
Field Value
double
public static readonly Type @double
Field Value
float16
public static readonly Type float16
Field Value
float32
public static readonly Type float32
Field Value
float64
public static readonly Type float64
Field Value
float_
public static readonly Type float_
Field Value
half
public static readonly Type half
Field Value
int0
public static readonly Type int0
Field Value
int16
public static readonly Type int16
Field Value
int32
public static readonly Type int32
Field Value
int64
public static readonly Type int64
Field Value
int8
public static readonly Type int8
Field Value
int_
public static readonly Type int_
Field Value
intc
public static readonly Type intc
Field Value
intp
public static readonly Type intp
Field Value
long
public static readonly Type @long
Field Value
longlong
public static readonly Type longlong
Field Value
newaxis
A convenient alias for None, useful for indexing arrays.
public static readonly Slice newaxis
Field Value
Remarks
https://numpy.org/doc/stable/user/basics.indexing.html
https://stackoverflow.com/questions/42190783/what-does-three-dots-in-python-mean-when-indexing-what-looks-like-a-number
sbyte
public static readonly Type @sbyte
Field Value
short
public static readonly Type @short
Field Value
single
public static readonly Type single
Field Value
ubyte
public static readonly Type ubyte
Field Value
uint
public static readonly Type @uint
Field Value
uint0
public static readonly Type uint0
Field Value
uint16
public static readonly Type uint16
Field Value
uint32
public static readonly Type uint32
Field Value
uint64
public static readonly Type uint64
Field Value
uint8
public static readonly Type uint8
Field Value
uintc
public static readonly Type uintc
Field Value
uintp
public static readonly Type uintp
Field Value
ulong
public static readonly Type @ulong
Field Value
ulonglong
public static readonly Type ulonglong
Field Value
ushort
public static readonly Type @ushort
Field Value
Properties
BackendEngine
public static BackendType BackendEngine { get; set; }
Property Value
Inf
public static double Inf { get; }
Property Value
Infinity
public static double Infinity { get; }
Property Value
NAN
public static double NAN { get; }
Property Value
NINF
public static double NINF { get; }
Property Value
NaN
public static double NaN { get; }
Property Value
PINF
public static double PINF { get; }
Property Value
chars
public static Type chars { get; }
Property Value
complex64
NumSharp does not support complex64 (two 32-bit floats). The only complex
type available is complex128 (two 64-bit floats, backed by
Complex). Accessing this property throws
NotSupportedException; use complex128 or
complex_ instead.
public static Type complex64 { get; }
Property Value
csingle
NumPy alias for complex64. Same as complex64 — throws because NumSharp does not support complex64.
public static Type csingle { get; }
Property Value
e
public static double e { get; }
Property Value
euler_gamma
public static double euler_gamma { get; }
Property Value
inf
public static double inf { get; }
Property Value
infinity
public static double infinity { get; }
Property Value
infty
public static double infty { get; }
Property Value
nan
public static double nan { get; }
Property Value
pi
public static double pi { get; }
Property Value
random
public static NumPyRandom random { get; }
Property Value
Methods
LoadJagged(byte[])
public static Array LoadJagged(byte[] bytes)
Parameters
bytesbyte[]
Returns
LoadJagged(Stream, bool)
public static Array LoadJagged(Stream stream, bool trim = true)
Parameters
Returns
LoadJagged(string)
public static Array LoadJagged(string path)
Parameters
pathstring
Returns
LoadJagged_Npz(byte[])
public static NpzDictionary<Array> LoadJagged_Npz(byte[] bytes)
Parameters
bytesbyte[]
Returns
LoadJagged_Npz(Stream, bool)
public static NpzDictionary<Array> LoadJagged_Npz(Stream stream, bool trim = true)
Parameters
Returns
LoadJagged_Npz(string)
public static NpzDictionary<Array> LoadJagged_Npz(string path)
Parameters
pathstring
Returns
LoadMatrix(byte[])
public static Array LoadMatrix(byte[] bytes)
Parameters
bytesbyte[]
Returns
LoadMatrix(Stream)
public static Array LoadMatrix(Stream stream)
Parameters
streamStream
Returns
LoadMatrix(string)
public static Array LoadMatrix(string path)
Parameters
pathstring
Returns
LoadMatrix_Npz(byte[])
public static NpzDictionary<Array> LoadMatrix_Npz(byte[] bytes)
Parameters
bytesbyte[]
Returns
LoadMatrix_Npz(Stream)
public static NpzDictionary<Array> LoadMatrix_Npz(Stream stream)
Parameters
streamStream
Returns
LoadMatrix_Npz(string)
public static NpzDictionary<Array> LoadMatrix_Npz(string path)
Parameters
pathstring
Returns
Load_Npz<T>(byte[])
public static NpzDictionary<T> Load_Npz<T>(byte[] bytes) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
bytesbyte[]
Returns
Type Parameters
T
Load_Npz<T>(byte[], out T)
public static void Load_Npz<T>(byte[] bytes, out T value) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
bytesbyte[]valueT
Type Parameters
T
Load_Npz<T>(Stream)
public static NpzDictionary<T> Load_Npz<T>(Stream stream) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
streamStream
Returns
Type Parameters
T
Load_Npz<T>(Stream, out NpzDictionary<T>)
public static NpzDictionary<T> Load_Npz<T>(Stream stream, out NpzDictionary<T> value) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
streamStreamvalueNpzDictionary<T>
Returns
Type Parameters
T
Load_Npz<T>(Stream, out T)
public static void Load_Npz<T>(Stream stream, out T value) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
streamStreamvalueT
Type Parameters
T
Load_Npz<T>(string)
public static NpzDictionary<T> Load_Npz<T>(string path) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
pathstring
Returns
Type Parameters
T
Load_Npz<T>(string, out NpzDictionary<T>)
public static NpzDictionary<T> Load_Npz<T>(string path, out NpzDictionary<T> value) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
pathstringvalueNpzDictionary<T>
Returns
Type Parameters
T
Load_Npz<T>(string, out T)
public static void Load_Npz<T>(string path, out T value) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
pathstringvalueT
Type Parameters
T
Load<T>(byte[])
public static T Load<T>(byte[] bytes) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
bytesbyte[]
Returns
- T
Type Parameters
T
Load<T>(byte[], out T)
public static T Load<T>(byte[] bytes, out T value) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
bytesbyte[]valueT
Returns
- T
Type Parameters
T
Load<T>(Stream)
public static T Load<T>(Stream stream) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
streamStream
Returns
- T
Type Parameters
T
Load<T>(Stream, out T)
public static T Load<T>(Stream stream, out T value) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
streamStreamvalueT
Returns
- T
Type Parameters
T
Load<T>(string)
public static T Load<T>(string path) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
pathstring
Returns
- T
Type Parameters
T
Load<T>(string, out T)
public static T Load<T>(string path, out T value) where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
Parameters
pathstringvalueT
Returns
- T
Type Parameters
T
Save(Array)
public static byte[] Save(Array array)
Parameters
arrayArray
Returns
- byte[]
Save(Array, Stream)
public static ulong Save(Array array, Stream stream)
Parameters
Returns
Save(Array, string)
public static ulong Save(Array array, string path)
Parameters
Returns
Save_Npz(Array, CompressionLevel)
public static byte[] Save_Npz(Array array, CompressionLevel compression = CompressionLevel.Fastest)
Parameters
arrayArraycompressionCompressionLevel
Returns
- byte[]
Save_Npz(Array, Stream, CompressionLevel, bool)
public static void Save_Npz(Array array, Stream stream, CompressionLevel compression = CompressionLevel.Fastest, bool leaveOpen = false)
Parameters
arrayArraystreamStreamcompressionCompressionLevelleaveOpenbool
Save_Npz(Array, string, CompressionLevel)
public static void Save_Npz(Array array, string path, CompressionLevel compression = CompressionLevel.Fastest)
Parameters
arrayArraypathstringcompressionCompressionLevel
Save_Npz(Dictionary<string, Array>, CompressionLevel)
public static byte[] Save_Npz(Dictionary<string, Array> arrays, CompressionLevel compression = CompressionLevel.Fastest)
Parameters
arraysDictionary<string, Array>compressionCompressionLevel
Returns
- byte[]
Save_Npz(Dictionary<string, Array>, Stream, CompressionLevel, bool)
public static void Save_Npz(Dictionary<string, Array> arrays, Stream stream, CompressionLevel compression = CompressionLevel.Fastest, bool leaveOpen = false)
Parameters
arraysDictionary<string, Array>streamStreamcompressionCompressionLevelleaveOpenbool
Save_Npz(Dictionary<string, Array>, string, CompressionLevel)
public static void Save_Npz(Dictionary<string, Array> arrays, string path, CompressionLevel compression = CompressionLevel.Fastest)
Parameters
arraysDictionary<string, Array>pathstringcompressionCompressionLevel
abs(NDArray)
Calculate the absolute value element-wise.
np.abs is a shorthand for this function.
public static NDArray abs(NDArray a)
Parameters
aNDArrayInput value.
Returns
- NDArray
An ndarray containing the absolute value of each element in x.
Remarks
abs(NDArray, NDArray, NDArray, NPTypeCode?)
Calculate the absolute value element-wise (alias of absolute(NDArray, NDArray, NDArray, NPTypeCode?)).
Mirrors NumPy's ufunc signature: absolute(x, /, out=None, *, where=True, dtype=None).
public static NDArray abs(NDArray a, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
aNDArrayInput value.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?Explicit loop dtype (NumPy ufunc dtype=): the input must be same_kind-castable to it; for complex input it selects the magnitude dtype (float kinds only).
Returns
Remarks
abs(NDArray, NPTypeCode?)
Calculate the absolute value element-wise.
np.abs is a shorthand for this function.
public static NDArray abs(NDArray a, NPTypeCode? dtype)
Parameters
aNDArrayInput value.
dtypeNPTypeCode?The dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
An ndarray containing the absolute value of each element in x.
Remarks
abs(NDArray, Type)
Calculate the absolute value element-wise.
np.abs is a shorthand for this function.
public static NDArray abs(NDArray a, Type dtype)
Parameters
aNDArrayInput value.
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
An ndarray containing the absolute value of each element in x.
Remarks
absolute(NDArray)
Calculate the absolute value element-wise.
np.abs is a shorthand for this function.
public static NDArray absolute(NDArray a)
Parameters
aNDArrayInput value.
Returns
- NDArray
An ndarray containing the absolute value of each element in x.
Remarks
absolute(NDArray, NDArray, NDArray, NPTypeCode?)
Calculate the absolute value element-wise.
Mirrors NumPy's ufunc signature: absolute(x, /, out=None, *, where=True, dtype=None).
public static NDArray absolute(NDArray a, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
aNDArrayInput value.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?Explicit loop dtype (NumPy ufunc dtype=): the input must be same_kind-castable to it; for complex input it selects the magnitude dtype (float kinds only).
Returns
Remarks
absolute(NDArray, NPTypeCode?)
Calculate the absolute value element-wise.
np.abs is a shorthand for this function.
public static NDArray absolute(NDArray a, NPTypeCode? dtype)
Parameters
aNDArrayInput value.
dtypeNPTypeCode?The dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
An ndarray containing the absolute value of each element in x.
Remarks
absolute(NDArray, Type)
Calculate the absolute value element-wise.
np.abs is a shorthand for this function.
public static NDArray absolute(NDArray a, Type dtype)
Parameters
aNDArrayInput value.
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
An ndarray containing the absolute value of each element in x.
Remarks
add(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
public static NDArray add(NDArray x1, NDArray x2, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
x1NDArrayx2NDArrayoutNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?
Returns
Remarks
all(NDArray)
Test whether all array elements evaluate to True.
public static bool all(NDArray a)
Parameters
aNDArrayInput array or object that can be converted to an array.
Returns
- bool
True if all elements evaluate to True (non-zero).
Remarks
all(NDArray, bool)
Test whether all array elements evaluate to True, optionally keeping reduced dimensions. Reduces over all axes (axis = None semantics).
public static NDArray<bool> all(NDArray nd, bool keepdims)
Parameters
ndNDArrayInput array.
keepdimsboolIf True, the result is broadcast-compatible with the input (every dimension becomes size 1). Otherwise the result is a 0-d array.
Returns
Remarks
all(NDArray, int, bool)
Test whether all array elements along a given axis evaluate to True.
public static NDArray<bool> all(NDArray nd, int axis, bool keepdims = false)
Parameters
ndNDArrayInput array or object that can be converted to an array.
axisintAxis along which a logical AND reduction is performed.
keepdimsboolIf True, the reduced axes are left in the result as dimensions with size one.
Returns
Remarks
all(NDArray, int[], NDArray, bool, NDArray)
Tuple-axis variant of the full np.all overload (with out and where).
public static NDArray all(NDArray a, int[] axis, NDArray @out, bool keepdims = false, NDArray where = null)
Parameters
aNDArrayInput array.
axisint[]Axes along which to reduce.
outNDArrayDestination array. Its dtype is preserved.
keepdimsboolIf True, reduced axes are left as size-one dimensions.
whereNDArrayBoolean mask, broadcastable against
a.
Returns
- NDArray
The reduced array, or
outwhen supplied.
Remarks
all(NDArray, int[], bool)
Test whether all array elements along the given axes evaluate to True. Multiple axes can be specified by passing an array of ints.
public static NDArray<bool> all(NDArray nd, int[] axis, bool keepdims = false)
Parameters
ndNDArrayInput array.
axisint[]Tuple of axes along which a logical AND reduction is performed. An empty array returns the input cast to bool (no reduction).
keepdimsboolIf True, the reduced axes are left in the result as dimensions with size one.
Returns
Remarks
all(NDArray, int?, NDArray, bool, NDArray)
Test whether all array elements along the given axis evaluate to True, with optional
out= destination and where= mask. Matches NumPy 2.x:
all(a, axis=None, out=None, keepdims=False, *, where=True).
public static NDArray all(NDArray a, int? axis = null, NDArray @out = null, bool keepdims = false, NDArray where = null)
Parameters
aNDArrayInput array.
axisint?Axis along which to reduce. Pass
nullfor axis=None (all axes).outNDArrayDestination array. Its dtype is preserved (e.g. an int
outstores 0/1 instead of bool). Passnullto allocate a fresh boolean array.keepdimsboolIf True, the reduced axes are left as dimensions with size one.
whereNDArrayBoolean (or numeric-treated-as-bool) mask, broadcastable against
a. Elements wherewhere=Falseare excluded from the reduction and contribute the identity value (True forall). Passnullfor no mask.
Returns
- NDArray
The reduced array, or
outwhen supplied.
Remarks
allclose(NDArray, NDArray, double, double, bool)
Returns True if two arrays are element-wise equal within a tolerance. The tolerance values are positive, typically very small numbers.The
relative difference (rtol * abs(b)) and the absolute difference
atol are added together to compare against the absolute difference
between a and b.
If either array contains one or more NaNs, False is returned.
Infs are treated as equal if they are in the same place and of the same
sign in both arrays.
public static bool allclose(NDArray a, NDArray b, double rtol = 1E-05, double atol = 1E-08, bool equal_nan = false)
Parameters
aNDArrayInput array to compare with b
bNDArrayInput array to compare with a.
rtoldoubleThe relative tolerance parameter(see Notes)
atoldoubleThe absolute tolerance parameter(see Notes)
equal_nanboolWhether to compare NaN's as equal. If True, NaN's in
awill be considered equal to NaN's inbin the output array.
Returns
amax(NDArray, int?, bool, Type)
Return the maximum of an array or maximum along an axis.
public static NDArray amax(NDArray a, int? axis = null, bool keepdims = false, Type dtype = null)
Parameters
aNDArrayaxisint?Axis or axes along which to operate.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
dtypeTypethe type expected as a return, null will remain the same dtype.
Returns
- NDArray
Maximum of a. If axis is None, the result is a scalar value. If axis is given, the result is an array of dimension a.ndim - 1.
Remarks
amax<T>(NDArray)
Return the maximum of an array or maximum along an axis.
public static T amax<T>(NDArray a) where T : unmanaged
Parameters
aNDArray
Returns
- T
Maximum of a. If axis is None, the result is a scalar value. If axis is given, the result is an array of dimension a.ndim - 1.
Type Parameters
Tthe type expected as a return, cast is performed if necessary.
Remarks
amin(NDArray, int?, bool, Type)
Return the minimum of an array or minimum along an axis.
public static NDArray amin(NDArray a, int? axis = null, bool keepdims = false, Type dtype = null)
Parameters
aNDArrayInput data.
axisint?Axis or axes along which to operate.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
dtypeTypethe type expected as a return, null will remain the same dtype.
Returns
- NDArray
Minimum of a. If axis is None, the result is a scalar value. If axis is given, the result is an array of dimension a.ndim - 1.
Remarks
amin<T>(NDArray)
Return the minimum of an array or minimum along an axis.
public static T amin<T>(NDArray a) where T : unmanaged
Parameters
aNDArrayInput data.
Returns
- T
Minimum of a. If axis is None, the result is a scalar value. If axis is given, the result is an array of dimension a.ndim - 1.
Type Parameters
Tthe type expected as a return, cast is performed if necessary.
Remarks
any(NDArray)
Test whether any array element evaluates to True.
public static bool any(NDArray a)
Parameters
aNDArrayInput array or object that can be converted to an array.
Returns
- bool
True if any element evaluates to True (non-zero).
Remarks
any(NDArray, bool)
Test whether any array element evaluates to True, optionally keeping reduced dimensions. Reduces over all axes (axis = None semantics).
public static NDArray<bool> any(NDArray nd, bool keepdims)
Parameters
ndNDArrayInput array.
keepdimsboolIf True, the result has all dimensions as size 1 (broadcast-compatible with the input). Otherwise the result is a 0-d array.
Returns
Remarks
any(NDArray, int, bool)
Test whether any array element along a given axis evaluates to True.
public static NDArray<bool> any(NDArray nd, int axis, bool keepdims = false)
Parameters
ndNDArrayInput array.
axisintAxis along which a logical OR reduction is performed.
keepdimsboolIf True, the reduced axes are left in the result as dimensions with size one.
Returns
Remarks
any(NDArray, int[], NDArray, bool, NDArray)
Tuple-axis variant of the full np.any overload (with out and where).
public static NDArray any(NDArray a, int[] axis, NDArray @out, bool keepdims = false, NDArray where = null)
Parameters
aNDArrayInput array.
axisint[]Axes along which to reduce.
outNDArrayDestination array. Its dtype is preserved.
keepdimsboolIf True, reduced axes are left as size-one dimensions.
whereNDArrayBoolean mask, broadcastable against
a.
Returns
- NDArray
The reduced array, or
outwhen supplied.
Remarks
any(NDArray, int[], bool)
Test whether any array element along the given axes evaluates to True. Multiple axes can be specified by passing an array of ints.
public static NDArray<bool> any(NDArray nd, int[] axis, bool keepdims = false)
Parameters
ndNDArrayInput array.
axisint[]Tuple of axes along which a logical OR reduction is performed. An empty array returns the input cast to bool (no reduction).
keepdimsboolIf True, the reduced axes are left in the result as dimensions with size one.
Returns
Remarks
any(NDArray, int?, NDArray, bool, NDArray)
Test whether any array element along the given axis evaluates to True, with optional
out= destination and where= mask. Matches NumPy 2.x:
any(a, axis=None, out=None, keepdims=False, *, where=True).
public static NDArray any(NDArray a, int? axis = null, NDArray @out = null, bool keepdims = false, NDArray where = null)
Parameters
aNDArrayInput array.
axisint?Axis along which to reduce. Pass
nullfor axis=None (all axes).outNDArrayDestination array. Its dtype is preserved. Pass
nullto allocate fresh.keepdimsboolIf True, the reduced axes are left as size-one dimensions.
whereNDArrayBoolean (or numeric-treated-as-bool) mask, broadcastable against
a. Elements wherewhere=Falseare excluded from the reduction and contribute the identity value (False forany). Passnullfor no mask.
Returns
- NDArray
The reduced array, or
outwhen supplied.
Remarks
append(NDArray, NDArray, int?)
Append values to the end of arr.
public static NDArray append(NDArray arr, NDArray values, int? axis = null)
Parameters
arrNDArrayInput array.
valuesNDArrayValues to append. Shape must match
arron all dimensions exceptaxiswhenaxisis given; otherwise it is flattened.axisint?Axis along which to append.
null(default) flattens botharrandvaluesto 1-D before concatenation.
Returns
- NDArray
A new array with
valuesappended toarralongaxis.
Remarks
append(NDArray, object, int?)
Scalar / generic-value overload that wraps the value via
asanyarray(in object, Type) before delegating. Matches NumPy's
np.append([1,2,3], 4) idiom — the scalar is auto-coerced
to a 0-D ndarray (whose ravel is shape (1,)).
public static NDArray append(NDArray arr, object values, int? axis = null)
Parameters
Returns
arange(double)
Return evenly spaced values within a given interval.
public static NDArray arange(double stop)
Parameters
stopdoubleEnd of interval (exclusive).
Returns
- NDArray
Array of evenly spaced double values.
arange(double, NPTypeCode)
Return evenly spaced values within a given interval.
public static NDArray arange(double stop, NPTypeCode dtype)
Parameters
stopdoubleEnd of interval (exclusive).
dtypeNPTypeCodeThe type of the output array.
Returns
- NDArray
Array of evenly spaced values from 0 to stop-1.
Remarks
arange(double, double, NPTypeCode)
Return evenly spaced values within a given interval.
public static NDArray arange(double start, double stop, NPTypeCode dtype)
Parameters
startdoubleStart of interval (inclusive).
stopdoubleEnd of interval (exclusive).
dtypeNPTypeCodeThe type of the output array.
Returns
- NDArray
Array of evenly spaced values.
Remarks
arange(double, double, double)
Return evenly spaced values within a given interval.
public static NDArray arange(double start, double stop, double step = 1)
Parameters
startdoubleStart of interval (inclusive).
stopdoubleEnd of interval (exclusive).
stepdoubleSpacing between values. Default is 1.
Returns
- NDArray
Array of evenly spaced double values.
arange(double, double, double, NPTypeCode)
Return evenly spaced values within a given interval.
Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop).
public static NDArray arange(double start, double stop, double step, NPTypeCode dtype)
Parameters
startdoubleStart of interval. The interval includes this value.
stopdoubleEnd of interval. The interval does not include this value.
stepdoubleSpacing between values. Default is 1.
dtypeNPTypeCodeThe type of the output array. If Empty, infers from inputs (int64 for integers, float64 for floats).
Returns
- NDArray
Array of evenly spaced values.
Remarks
arange(double, double, double, Type)
Return evenly spaced values within a given interval.
Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop).
public static NDArray arange(double start, double stop, double step, Type dtype)
Parameters
startdoubleStart of interval. The interval includes this value.
stopdoubleEnd of interval. The interval does not include this value.
stepdoubleSpacing between values. Default is 1.
dtypeTypeThe type of the output array. If null, infers from inputs (int64 for integers, float64 for floats).
Returns
- NDArray
Array of evenly spaced values.
Remarks
arange(double, double, Type)
Return evenly spaced values within a given interval.
public static NDArray arange(double start, double stop, Type dtype)
Parameters
startdoubleStart of interval (inclusive).
stopdoubleEnd of interval (exclusive).
dtypeTypeThe type of the output array.
Returns
- NDArray
Array of evenly spaced values.
Remarks
arange(double, Type)
Return evenly spaced values within a given interval.
public static NDArray arange(double stop, Type dtype)
Parameters
Returns
- NDArray
Array of evenly spaced values from 0 to stop-1.
Remarks
arange(int)
Return evenly spaced values within a given interval.
public static NDArray arange(int stop)
Parameters
stopintEnd of interval (exclusive).
Returns
- NDArray
Array of evenly spaced int64 values.
Remarks
NumPy 2.x returns int64 for integer arange.
arange(int, int, int)
Return evenly spaced values within a given interval.
public static NDArray arange(int start, int stop, int step = 1)
Parameters
startintStart of interval (inclusive).
stopintEnd of interval (exclusive).
stepintSpacing between values. Default is 1.
Returns
- NDArray
Array of evenly spaced int64 values.
Remarks
NumPy 2.x returns int64 for integer arange.
arange(long)
Return evenly spaced values within a given interval.
public static NDArray arange(long stop)
Parameters
stoplongEnd of interval (exclusive).
Returns
- NDArray
Array of evenly spaced int64 values.
Remarks
NumPy 2.x returns int64 for integer arange.
arange(long, long, long)
Return evenly spaced values within a given interval.
public static NDArray arange(long start, long stop, long step = 1)
Parameters
startlongStart of interval (inclusive).
stoplongEnd of interval (exclusive).
steplongSpacing between values. Default is 1.
Returns
- NDArray
Array of evenly spaced int64 values.
Remarks
NumPy 2.x returns int64 for integer arange.
arange(float)
Return evenly spaced values within a given interval.
public static NDArray arange(float stop)
Parameters
stopfloatEnd of interval (exclusive).
Returns
- NDArray
Array of evenly spaced float values.
arange(float, float, float)
Return evenly spaced values within a given interval.
public static NDArray arange(float start, float stop, float step = 1)
Parameters
startfloatStart of interval (inclusive).
stopfloatEnd of interval (exclusive).
stepfloatSpacing between values. Default is 1.
Returns
- NDArray
Array of evenly spaced float values.
arccos(NDArray, NDArray, NDArray, NPTypeCode?)
Trigonometric inverse cosine, element-wise.
The inverse of cos so that, if y = cos(x), then x = arccos(y).
public static NDArray arccos(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array.
outNDArraywhereNDArraydtypeNPTypeCode?The dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
The angle of the ray intersecting the unit circle at the given x-coordinate in radians [0, pi]. This is a scalar if x is a scalar.
Remarks
arccos(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray arccos(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayInput array.
dtypeNPTypeCodeThe loop dtype the computation should run in.
Returns
Remarks
arccos(NDArray, Type)
Trigonometric inverse cosine, element-wise.
The inverse of cos so that, if y = cos(x), then x = arccos(y).
public static NDArray arccos(NDArray x, Type dtype)
Parameters
xNDArrayInput array.
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
The angle of the ray intersecting the unit circle at the given x-coordinate in radians [0, pi]. This is a scalar if x is a scalar.
Remarks
arcsin(NDArray, NDArray, NDArray, NPTypeCode?)
Inverse sine, element-wise.
The convention is to return the angle z whose real part lies in [-pi/2, pi/2].
public static NDArray arcsin(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array.
outNDArraywhereNDArraydtypeNPTypeCode?The dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
The inverse sine of each element in x, in radians and in the closed interval [-pi/2, pi/2]. This is a scalar if x is a scalar.
Remarks
arcsin(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray arcsin(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayInput array.
dtypeNPTypeCodeThe loop dtype the computation should run in.
Returns
Remarks
arcsin(NDArray, Type)
Inverse sine, element-wise.
The convention is to return the angle z whose real part lies in [-pi/2, pi/2].
public static NDArray arcsin(NDArray x, Type dtype)
Parameters
xNDArrayInput array.
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
The inverse sine of each element in x, in radians and in the closed interval [-pi/2, pi/2]. This is a scalar if x is a scalar.
Remarks
arctan(NDArray, NDArray, NDArray, NPTypeCode?)
Compute trigonometric inverse tangent, element-wise.
The inverse of tan, so that if y = tan(x) then x = arctan(y).
public static NDArray arctan(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array.
outNDArraywhereNDArraydtypeNPTypeCode?The dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
Return has the same shape as x. Its real part is in [-pi/2, pi/2] (arctan(+/-inf) returns +/-pi/2). This is a scalar if x is a scalar.
Remarks
arctan(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray arctan(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayInput array.
dtypeNPTypeCodeThe loop dtype the computation should run in.
Returns
Remarks
arctan(NDArray, Type)
Compute trigonometric inverse tangent, element-wise.
The inverse of tan, so that if y = tan(x) then x = arctan(y).
public static NDArray arctan(NDArray x, Type dtype)
Parameters
xNDArrayInput array.
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
Return has the same shape as x. Its real part is in [-pi/2, pi/2] (arctan(+/-inf) returns +/-pi/2). This is a scalar if x is a scalar.
Remarks
arctan2(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
Compute Element-wise arc tangent of x1/x2 choosing the quadrant correctly.
By IEEE convention, this function is defined for x2 = +/-0 and for either or both of x1 and x2 = +/-inf
public static NDArray arctan2(NDArray y, NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
yNDArrayxNDArrayInput array y-coordinates.
outNDArraywhereNDArraydtypeNPTypeCode?The dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
The Array of angles in radians, in the range [-pi, pi]. This is a scalar if both x1 and x2 are scalars.
Remarks
arctan2(NDArray, NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray arctan2(NDArray y, NDArray x, NPTypeCode dtype)
Parameters
yNDArrayxNDArraydtypeNPTypeCode
Returns
Remarks
arctan2(NDArray, NDArray, Type)
Compute Element-wise arc tangent of x1/x2 choosing the quadrant correctly.
By IEEE convention, this function is defined for x2 = +/-0 and for either or both of x1 and x2 = +/-inf
public static NDArray arctan2(NDArray y, NDArray x, Type dtype)
Parameters
yNDArrayxNDArrayInput array y-coordinates.
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
The Array of angles in radians, in the range [-pi, pi]. This is a scalar if both x1 and x2 are scalars.
Remarks
are_broadcastable(NDArray, NDArray)
Tests if these two two arrays are broadcastable against each other.
public static bool are_broadcastable(NDArray lhs, NDArray rhs)
Parameters
Returns
- bool
True if these can be broadcasted against each other.
Remarks
are_broadcastable(params NDArray[])
Tests if these two two arrays are broadcastable against each other.
public static bool are_broadcastable(params NDArray[] ndArrays)
Parameters
ndArraysNDArray[]The arrays to test for broadcasting.
Returns
- bool
True if these can be broadcasted against each other.
Remarks
are_broadcastable(params Shape[])
Tests if these two two arrays are broadcastable against each other.
public static bool are_broadcastable(params Shape[] shapes)
Parameters
shapesShape[]The shapes to test for broadcasting.
Returns
- bool
True if these can be broadcasted against each other.
Remarks
are_broadcastable(params int[][])
Tests if these two two arrays are broadcastable against each other.
public static bool are_broadcastable(params int[][] shapes)
Parameters
shapesint[][]The shapes to test for broadcasting.
Returns
- bool
True if these can be broadcasted against each other.
Remarks
are_broadcastable(long[], long[])
Tests if these two shapes are broadcastable against each other.
public static bool are_broadcastable(long[] shape1, long[] shape2)
Parameters
Returns
- bool
True if these can be broadcasted against each other.
Remarks
argmax(NDArray)
Returns the index of the maximum value.
public static long argmax(NDArray a)
Parameters
aNDArrayInput array.
Returns
- long
Index of the maximum value in the flattened array.
Remarks
argmax(NDArray, int, bool)
Returns the indices of the maximum values along an axis.
public static NDArray argmax(NDArray a, int axis, bool keepdims = false)
Parameters
aNDArrayInput array.
axisintBy default, the index is into the flattened array, otherwise along the specified axis.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one.
Returns
- NDArray
Array of indices into the array. It has the same shape as a.shape with the dimension along axis removed (unless keepdims is True).
Remarks
argmin(NDArray)
Returns the index of the minimum value.
public static long argmin(NDArray a)
Parameters
aNDArrayInput array.
Returns
- long
Index of the minimum value in the flattened array.
Remarks
argmin(NDArray, int, bool)
Returns the indices of the minimum values along an axis.
public static NDArray argmin(NDArray a, int axis, bool keepdims = false)
Parameters
aNDArrayInput array.
axisintBy default, the index is into the flattened array, otherwise along the specified axis.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one.
Returns
- NDArray
Array of indices into the array. It has the same shape as a.shape with the dimension along axis removed (unless keepdims is True).
Remarks
argsort(NDArray, int?)
Returns the indices that would sort nd along axis
(default last; null flattens). Returns int64 indices. NumPy np.argsort.
public static NDArray argsort(NDArray nd, int? axis = -1)
Parameters
Returns
argsort<T>(NDArray, int)
Returns the indices that would sort an array.
Perform an indirect sort along the given axis using the algorithm specified by the kind keyword.It returns an array of indices of the same shape as a that index data along the given axis in sorted order.
public static NDArray argsort<T>(NDArray nd, int axis = -1) where T : unmanaged
Parameters
Returns
Type Parameters
T
argwhere(NDArray)
Find the indices of array elements that are non-zero, grouped by element.
public static NDArray argwhere(NDArray a)
Parameters
aNDArrayInput array.
Returns
- NDArray
Indices of elements that are non-zero, grouped per element. The result is a 2-D array of shape
(N, a.ndim)whereNis the number of non-zero elements. Each row contains the coordinates of one non-zero element. Result dtype isint64. For 0-d input, returns shape(1, 0)when the value is truthy and(0, 0)otherwise. For empty input of shape(0, d1, ..., dn), returns shape(0, ndim).
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.argwhere.html
Equivalent to np.transpose(np.nonzero(a)) with a special case for 0-d input.
Distinct from nonzero(NDArray) which returns a tuple of column arrays.
around(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload. NumPy's np.round/np.around accept out= only (they are
functions, not ufuncs — no where=/dtype= kwargs; probed 2.4.2).
public static NDArray around(NDArray x, NPTypeCode dtype)
Parameters
xNDArraydtypeNPTypeCode
Returns
Remarks
around(NDArray, int, NDArray)
Evenly round to the given number of decimals.
public static NDArray around(NDArray x, int decimals = 0, NDArray @out = null)
Parameters
Returns
- NDArray
An array of the same type as a, containing the rounded values. Unless out was specified, a new array is created. A reference to the result is returned. The real and imaginary parts of complex numbers are rounded separately.The result of rounding a float is a float.
Remarks
around(NDArray, int, NPTypeCode)
Evenly round to the given number of decimals.
public static NDArray around(NDArray x, int decimals, NPTypeCode dtype)
Parameters
xNDArrayInput array
decimalsintNumber of decimal places to round to
dtypeNPTypeCodeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
An array of the same type as a, containing the rounded values. Unless out was specified, a new array is created. A reference to the result is returned. The real and imaginary parts of complex numbers are rounded separately.The result of rounding a float is a float.
Remarks
around(NDArray, int, Type)
Evenly round to the given number of decimals.
public static NDArray around(NDArray x, int decimals, Type dtype)
Parameters
xNDArrayInput array
decimalsintNumber of decimal places to round to
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
An array of the same type as a, containing the rounded values. Unless out was specified, a new array is created. A reference to the result is returned. The real and imaginary parts of complex numbers are rounded separately.The result of rounding a float is a float.
Remarks
around(NDArray, Type)
Evenly round to the given number of decimals.
public static NDArray around(NDArray x, Type dtype)
Parameters
xNDArrayInput array
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
An array of the same type as a, containing the rounded values. Unless out was specified, a new array is created. A reference to the result is returned. The real and imaginary parts of complex numbers are rounded separately.The result of rounding a float is a float.
Remarks
array(NDArray, bool)
Create an array from an existing NDArray. Matches NumPy's default
np.array(a) which always copies (NumPy 2.x: copy=True by default).
public static NDArray array(NDArray nd, bool copy = true)
Parameters
ndNDArraySource array.
copyboolWhen
true(default) the source storage is cloned; whenfalsethe storage is shared (alias). For "copy only if needed" semantics use asarray(NDArray, Type, char, bool?, NDArray, string).
Returns
Remarks
array(Array, Type, int, bool, char)
Creates an NDArray from an array with an unknown size or dtype.
[SuppressMessage("ReSharper", "InvalidXmlDocComment")]
public static NDArray array(Array array, Type dtype = null, int ndmin = 1, bool copy = true, char order = 'C')
Parameters
arrayArraydtypeTypendminintSpecifies the minimum number of dimensions that the resulting array should have. Ones will be pre-pended to the shape as needed to meet this requirement.
copyboolAlways copies if the array is larger than 1-d.
ordercharMemory layout: 'C' (row-major, default), 'F' (column-major), 'A'/'K' (resolved from source).
Returns
Remarks
array(string)
public static NDArray array(string chars)
Parameters
charsstring
Returns
array(string[])
Create a vector ndarray of type <xref href="System.String" data-throw-if-not-resolved="false"></xref>.
Encode string array. format: [numOfRow lenOfRow1 lenOfRow2 contents] sample: [2 2 4 aacccc]
public static NDArray array(string[] strArray)
Parameters
strArraystring[]
Returns
array2string(NDArray, int?, int?, bool?, string, string, int?, int?, char?, string, string)
Return a string representation of an array (NumPy's np.array2string).
public static string array2string(NDArray a, int? max_line_width = null, int? precision = null, bool? suppress_small = null, string separator = " ", string prefix = "", int? threshold = null, int? edgeitems = null, char? sign = null, string floatmode = null, string suffix = "")
Parameters
aNDArrayInput array.
max_line_widthint?Inserts newlines if text is longer than this. Defaults to the current linewidth.
precisionint?Floating point precision. Defaults to the current precision.
suppress_smallbool?Represent numbers very close to zero as zero. Defaults to the current option.
separatorstringInserted between elements (default " ").
prefixstringUsed to align/wrap the output; its content is not included.
thresholdint?Total number of elements which trigger summarization.
edgeitemsint?Number of items at the beginning and end of each dimension in summary.
signchar?'-', '+', or ' '.
floatmodestringOne of "fixed", "unique", "maxprec", "maxprec_equal".
suffixstringUsed to wrap the output; its content is not included.
Returns
Remarks
array_equal(NDArray, NDArray)
True if two arrays have the same shape and elements, False otherwise.
public static bool array_equal(NDArray a, NDArray b)
Parameters
Returns
- bool
Returns True if the arrays are equal.
Remarks
array_repr(NDArray, int?, int?, bool?)
Return the string representation of an array (NumPy's np.array_repr).
public static string array_repr(NDArray a, int? max_line_width = null, int? precision = null, bool? suppress_small = null)
Parameters
Returns
Remarks
array_split(NDArray, int, int)
Split an array into multiple sub-arrays.
public static NDArray[] array_split(NDArray ary, int indices_or_sections, int axis = 0)
Parameters
Returns
- NDArray[]
Remarks
The only difference between split and array_split is that array_split allows indices_or_sections to be an integer that does not equally divide the axis. https://numpy.org/doc/stable/reference/generated/numpy.array_split.html
array_split(NDArray, int[], int)
Split an array into multiple sub-arrays.
public static NDArray[] array_split(NDArray ary, int[] indices, int axis = 0)
Parameters
Returns
- NDArray[]
array_split(NDArray, long[], int)
Split an array into multiple sub-arrays.
public static NDArray[] array_split(NDArray ary, long[] indices, int axis = 0)
Parameters
Returns
- NDArray[]
array_str(NDArray, int?, int?, bool?)
Return a string representation of the data in an array (NumPy's np.array_str).
public static string array_str(NDArray a, int? max_line_width = null, int? precision = null, bool? suppress_small = null)
Parameters
Returns
Remarks
array<T>(IEnumerable<T>)
Creates a Vector NDArray from given data.
public static NDArray array<T>(IEnumerable<T> data) where T : unmanaged
Parameters
dataIEnumerable<T>The enumeration of data to create NDArray from.
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.array.html
Always performs a copy.
array<T>(IEnumerable<T>, int)
Creates a Vector NDArray from given data.
public static NDArray array<T>(IEnumerable<T> data, int size) where T : unmanaged
Parameters
dataIEnumerable<T>The enumeration of data to create NDArray from.
sizeintMaximum number of items to read from
data.
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.array.html
Always performs a copy.
size can be used to limit the amount of items to read form data. Reading stops on either size or data ends.
array<T>(IEnumerable<T>, long)
Creates a Vector NDArray from given data.
public static NDArray array<T>(IEnumerable<T> data, long size) where T : unmanaged
Parameters
dataIEnumerable<T>The enumeration of data to create NDArray from.
sizelongMaximum number of items to read from
data.
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.array.html
Always performs a copy.
size can be used to limit the amount of items to read form data. Reading stops on either size or data ends.
array<T>(T)
Creates a scalar (0-dimensional) NDArray from a single value.
public static NDArray array<T>(T scalar) where T : unmanaged
Parameters
scalarTThe scalar value.
Returns
Type Parameters
TThe type of the value, must be compliant to numpy's supported dtypes.
Remarks
NumPy: np.array(42) creates a 0-dimensional array with shape (). https://numpy.org/doc/stable/reference/generated/numpy.array.html
array<T>(T[,,,,,,,,,,,,,,,], bool)
Creates an NDArray from given data.
public static NDArray array<T>(T[,,,,,,,,,,,,,,,] data, bool copy = true) where T : unmanaged
Parameters
dataT[,,,,,,,,,,,,,,,]The array to create NDArray from.
copyboolIf true then the array will be copied to a newly allocated memory.
If false then the array will be pinned by calling Alloc(object).
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[,,,,,,,,,,,,,,], bool)
Creates an NDArray from given data.
public static NDArray array<T>(T[,,,,,,,,,,,,,,] data, bool copy = true) where T : unmanaged
Parameters
dataT[,,,,,,,,,,,,,,]The array to create NDArray from.
copyboolIf true then the array will be copied to a newly allocated memory.
If false then the array will be pinned by calling Alloc(object).
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[,,,,,,,,,,,,,], bool)
Creates an NDArray from given data.
public static NDArray array<T>(T[,,,,,,,,,,,,,] data, bool copy = true) where T : unmanaged
Parameters
dataT[,,,,,,,,,,,,,]The array to create NDArray from.
copyboolIf true then the array will be copied to a newly allocated memory.
If false then the array will be pinned by calling Alloc(object).
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[,,,,,,,,,,,,], bool)
Creates an NDArray from given data.
public static NDArray array<T>(T[,,,,,,,,,,,,] data, bool copy = true) where T : unmanaged
Parameters
dataT[,,,,,,,,,,,,]The array to create NDArray from.
copyboolIf true then the array will be copied to a newly allocated memory.
If false then the array will be pinned by calling Alloc(object).
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[,,,,,,,,,,,], bool)
Creates an NDArray from given data.
public static NDArray array<T>(T[,,,,,,,,,,,] data, bool copy = true) where T : unmanaged
Parameters
dataT[,,,,,,,,,,,]The array to create NDArray from.
copyboolIf true then the array will be copied to a newly allocated memory.
If false then the array will be pinned by calling Alloc(object).
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[,,,,,,,,,,], bool)
Creates an NDArray from given data.
public static NDArray array<T>(T[,,,,,,,,,,] data, bool copy = true) where T : unmanaged
Parameters
dataT[,,,,,,,,,,]The array to create NDArray from.
copyboolIf true then the array will be copied to a newly allocated memory.
If false then the array will be pinned by calling Alloc(object).
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[,,,,,,,,,], bool)
Creates an NDArray from given data.
public static NDArray array<T>(T[,,,,,,,,,] data, bool copy = true) where T : unmanaged
Parameters
dataT[,,,,,,,,,]The array to create NDArray from.
copyboolIf true then the array will be copied to a newly allocated memory.
If false then the array will be pinned by calling Alloc(object).
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[,,,,,,,,], bool)
Creates an NDArray from given data.
public static NDArray array<T>(T[,,,,,,,,] data, bool copy = true) where T : unmanaged
Parameters
dataT[,,,,,,,,]The array to create NDArray from.
copyboolIf true then the array will be copied to a newly allocated memory.
If false then the array will be pinned by calling Alloc(object).
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[,,,,,,,], bool)
Creates an NDArray from given data.
public static NDArray array<T>(T[,,,,,,,] data, bool copy = true) where T : unmanaged
Parameters
dataT[,,,,,,,]The array to create NDArray from.
copyboolIf true then the array will be copied to a newly allocated memory.
If false then the array will be pinned by calling Alloc(object).
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[,,,,,,], bool)
Creates an NDArray from given data.
public static NDArray array<T>(T[,,,,,,] data, bool copy = true) where T : unmanaged
Parameters
dataT[,,,,,,]The array to create NDArray from.
copyboolIf true then the array will be copied to a newly allocated memory.
If false then the array will be pinned by calling Alloc(object).
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[,,,,,], bool)
Creates an NDArray from given data.
public static NDArray array<T>(T[,,,,,] data, bool copy = true) where T : unmanaged
Parameters
dataT[,,,,,]The array to create NDArray from.
copyboolIf true then the array will be copied to a newly allocated memory.
If false then the array will be pinned by calling Alloc(object).
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[,,,,], bool)
Creates an NDArray from given data.
public static NDArray array<T>(T[,,,,] data, bool copy = true) where T : unmanaged
Parameters
dataT[,,,,]The array to create NDArray from.
copyboolIf true then the array will be copied to a newly allocated memory.
If false then the array will be pinned by calling Alloc(object).
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[,,,], bool)
Creates an NDArray from given data.
public static NDArray array<T>(T[,,,] data, bool copy = true) where T : unmanaged
Parameters
dataT[,,,]The array to create NDArray from.
copyboolIf true then the array will be copied to a newly allocated memory.
If false then the array will be pinned by calling Alloc(object).
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[,,], bool)
Creates an NDArray from given data.
public static NDArray array<T>(T[,,] data, bool copy = true) where T : unmanaged
Parameters
dataT[,,]The array to create NDArray from.
copyboolIf true then the array will be copied to a newly allocated memory.
If false then the array will be pinned by calling Alloc(object).
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[,], NPTypeCode)
Creates an NDArray from given data with specified dtype.
public static NDArray array<T>(T[,] data, NPTypeCode dtype) where T : unmanaged
Parameters
dataT[,]The array to create NDArray from.
dtypeNPTypeCodeThe desired data type code for the array. If different from T, the data will be cast.
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[,], bool)
Creates an NDArray from given data.
public static NDArray array<T>(T[,] data, bool copy = true) where T : unmanaged
Parameters
dataT[,]The array to create NDArray from.
copyboolIf true then the array will be copied to a newly allocated memory.
If false then the array will be pinned by calling Alloc(object).
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[,], Type)
Creates an NDArray from given data with specified dtype.
public static NDArray array<T>(T[,] data, Type dtype) where T : unmanaged
Parameters
dataT[,]The array to create NDArray from.
dtypeTypeThe desired data type for the array. If different from T, the data will be cast.
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(params T[])
Creates a Vector NDArray from given data.
public static NDArray array<T>(params T[] data) where T : unmanaged
Parameters
dataT[]The array to create NDArray from.
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.array.html
Always performs a copy.
array<T>(T[], NPTypeCode)
Creates a Vector NDArray from given data with specified dtype.
public static NDArray array<T>(T[] data, NPTypeCode dtype) where T : unmanaged
Parameters
dataT[]The array to create NDArray from.
dtypeNPTypeCodeThe desired data type code for the array. If different from T, the data will be cast.
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[], bool)
Creates an NDArray from given data.
public static NDArray array<T>(T[] data, bool copy) where T : unmanaged
Parameters
dataT[]The array to create NDArray from.
copyboolIf true then the array will be copied to a newly allocated memory.
If false then the array will be pinned by calling Alloc(object).
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[], Type)
Creates a Vector NDArray from given data with specified dtype.
public static NDArray array<T>(T[] data, Type dtype) where T : unmanaged
Parameters
dataT[]The array to create NDArray from.
dtypeTypeThe desired data type for the array. If different from T, the data will be cast.
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
array<T>(T[][])
Creates an NDArray from given data.
[SuppressMessage("ReSharper", "SuggestVarOrType_SimpleTypes")]
[SuppressMessage("ReSharper", "SuggestVarOrType_Elsewhere")]
public static NDArray array<T>(T[][] data) where T : unmanaged
Parameters
dataT[][]The array to create NDArray from. Shape is taken from the first item of each array/nested array.
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.array.html
Always performs a copy.
array<T>(T[][][])
Creates an NDArray from given data.
[SuppressMessage("ReSharper", "SuggestVarOrType_SimpleTypes")]
[SuppressMessage("ReSharper", "SuggestVarOrType_Elsewhere")]
public static NDArray array<T>(T[][][] data) where T : unmanaged
Parameters
dataT[][][]The array to create NDArray from. Shape is taken from the first item of each array/nested array.
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.array.html
Always performs a copy.
array<T>(T[][][][])
Creates an NDArray from given data.
[SuppressMessage("ReSharper", "SuggestVarOrType_SimpleTypes")]
[SuppressMessage("ReSharper", "SuggestVarOrType_Elsewhere")]
public static NDArray array<T>(T[][][][] data) where T : unmanaged
Parameters
dataT[][][][]The array to create NDArray from. Shape is taken from the first item of each array/nested array.
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.array.html
Always performs a copy.
array<T>(T[][][][][])
Creates an NDArray from given data.
[SuppressMessage("ReSharper", "SuggestVarOrType_SimpleTypes")]
[SuppressMessage("ReSharper", "SuggestVarOrType_Elsewhere")]
public static NDArray array<T>(T[][][][][] data) where T : unmanaged
Parameters
dataT[][][][][]The array to create NDArray from. Shape is taken from the first item of each array/nested array.
Returns
Type Parameters
TThe type of given array, must be compliant to numpy's supported dtypes.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.array.html
Always performs a copy.
asanyarray(in object, Type)
Convert the input to an ndarray, but pass ndarray subclasses through.
public static NDArray asanyarray(in object a, Type dtype = null)
Parameters
aobjectInput data, in any form that can be converted to an array. This includes scalars, lists, lists of tuples, tuples, tuples of tuples, tuples of lists, and ndarrays.
dtypeTypeBy default, the data-type is inferred from the input data.
Returns
- NDArray
Array interpretation of a. If a is an ndarray or a subclass of ndarray, it is returned as-is and no copy is performed.
Remarks
asanyarray(in object, Type, char)
Convert the input to an ndarray with a specified memory layout.
public static NDArray asanyarray(in object a, Type dtype, char order)
Parameters
aobjectInput data.
dtypeTypeBy default, the data-type is inferred from the input data.
orderchar'C', 'F', 'A' or 'K' (default — resolved against a).
Returns
- NDArray
Array interpretation of a in the requested layout.
Remarks
asarray(NDArray, DType, char, bool?, NDArray, string)
Convert the input to an ndarray. Convenience overload taking a DType instance.
public static NDArray asarray(NDArray a, DType dtype, char order = 'K', bool? copy = null, NDArray like = null, string device = null)
Parameters
Returns
Remarks
asarray(NDArray, NPTypeCode, char, bool?, NDArray, string)
Convert the input to an ndarray. Convenience overload taking NPTypeCode.
public static NDArray asarray(NDArray a, NPTypeCode dtype, char order = 'K', bool? copy = null, NDArray like = null, string device = null)
Parameters
Returns
Remarks
asarray(NDArray, string, char, bool?, NDArray, string)
Convert the input to an ndarray. Convenience overload taking a NumPy-style dtype string
(e.g. "float32", "<i4", "complex128").
public static NDArray asarray(NDArray a, string dtype, char order = 'K', bool? copy = null, NDArray like = null, string device = null)
Parameters
aNDArrayInput ndarray.
dtypestringNumPy-style dtype string (parsed via dtype(string)).
orderchar'C', 'F', 'A', or 'K' (default).
copybool?Tri-state copy:
null= if-needed,true= always,false= never (raises).likeNDArrayReference for array-function dispatch — accepted for parity, no effect.
devicestringOnly
"cpu"ornull.
Returns
Remarks
asarray(NDArray, Type, char, bool?, NDArray, string)
Convert the input to an ndarray, matching NumPy 2.x semantics.
If a already satisfies the requested dtype/layout, it is returned as-is — no copy.
public static NDArray asarray(NDArray a, Type dtype = null, char order = 'K', bool? copy = null, NDArray like = null, string device = null)
Parameters
aNDArrayInput ndarray.
dtypeTypeRequested dtype.
nullkeeps the input dtype.orderchar'C' (row-major), 'F' (column-major), 'A' (any contiguous), 'K' (keep — default). 'A'/'K' never force a copy on layout grounds.
copybool?Tri-state:
null= copy only if needed (default),true= always copy,false= never copy (raises if a copy would be required).likeNDArrayReference array for array-function dispatch — accepted for NumPy parity but has no observable effect in NumSharp.
devicestringTarget device. Only
"cpu"andnullare accepted.
Returns
- NDArray
NDArray with the requested dtype and memory layout. Returns
awhen no copy is needed.
Remarks
asarray(string)
public static NDArray asarray(string data)
Parameters
datastring
Returns
asarray(string[], int)
public static NDArray asarray(string[] data, int ndim = 1)
Parameters
Returns
asarray<T>(T)
public static NDArray asarray<T>(T data) where T : struct
Parameters
dataT
Returns
Type Parameters
T
asarray<T>(T[], int)
public static NDArray asarray<T>(T[] data, int ndim = 1) where T : struct
Parameters
dataT[]ndimint
Returns
Type Parameters
T
ascontiguousarray(NDArray, Type)
Return a contiguous array (ndim >= 1) in memory (C order).
public static NDArray ascontiguousarray(NDArray a, Type dtype = null)
Parameters
Returns
- NDArray
Contiguous array of same shape and content as a, with type dtype if specified.
Remarks
asfortranarray(NDArray, Type)
Return an array (ndim >= 1) laid out in Fortran order in memory.
public static NDArray asfortranarray(NDArray a, Type dtype = null)
Parameters
Returns
- NDArray
The input a in Fortran, or column-major, order.
Remarks
asscalar(NDArray)
Convert an array of size 1 to its scalar equivalent.
[Obsolete("np.asscalar is deprecated (removed in NumPy 2.0). Use NDArray.item() instead.")]
public static object asscalar(NDArray nd)
Parameters
ndNDArrayInput NDArray of size 1.
Returns
Remarks
DEPRECATED: np.asscalar was removed in NumPy 2.0.
asscalar(Array)
Convert an array of size 1 to its scalar equivalent.
[Obsolete("np.asscalar is deprecated (removed in NumPy 2.0). Use NDArray.item() instead.")]
public static object asscalar(Array arr)
Parameters
arrArrayInput array of size 1.
Returns
Remarks
DEPRECATED: np.asscalar was removed in NumPy 2.0.
asscalar<T>(ArraySlice<T>)
Convert an array of size 1 to its scalar equivalent.
[Obsolete("np.asscalar is deprecated (removed in NumPy 2.0). Use NDArray.item() instead.")]
public static T asscalar<T>(ArraySlice<T> arr) where T : unmanaged
Parameters
arrArraySlice<T>Input array of size 1.
Returns
- T
Type Parameters
T
Remarks
DEPRECATED: np.asscalar was removed in NumPy 2.0.
asscalar<T>(IArraySlice)
Convert an array of size 1 to its scalar equivalent.
[Obsolete("np.asscalar is deprecated (removed in NumPy 2.0). Use NDArray.item() instead.")]
public static T asscalar<T>(IArraySlice arr) where T : unmanaged
Parameters
arrIArraySliceInput array of size 1.
Returns
- T
Type Parameters
T
Remarks
DEPRECATED: np.asscalar was removed in NumPy 2.0.
asscalar<T>(NDArray)
Convert an array of size 1 to its scalar equivalent.
[Obsolete("np.asscalar is deprecated (removed in NumPy 2.0). Use NDArray.item() instead.")]
public static T asscalar<T>(NDArray nd) where T : unmanaged
Parameters
ndNDArrayInput NDArray of size 1.
Returns
- T
Type Parameters
T
Remarks
DEPRECATED: np.asscalar was removed in NumPy 2.0. Use NDArray.item() instead: arr.item() or arr.item<T>() https://numpy.org/doc/stable/reference/generated/numpy.ndarray.item.html
asscalar<T>(Array)
Convert an array of size 1 to its scalar equivalent.
[Obsolete("np.asscalar is deprecated (removed in NumPy 2.0). Use NDArray.item() instead.")]
public static T asscalar<T>(Array arr)
Parameters
arrArrayInput array of size 1.
Returns
- T
Type Parameters
T
Remarks
DEPRECATED: np.asscalar was removed in NumPy 2.0.
atleast_1d(NDArray)
Convert inputs to arrays with at least one dimension. Scalar inputs are converted to 1-dimensional arrays, whilst higher-dimensional inputs are preserved.
public static NDArray atleast_1d(NDArray arr)
Parameters
arrNDArray
Returns
- NDArray
An array, or list of arrays, each with a.ndim >= 1. Copies are made only if necessary.
Remarks
atleast_1d(params NDArray[])
Convert inputs to arrays with at least one dimension. Scalar inputs are converted to 1-dimensional arrays, whilst higher-dimensional inputs are preserved.
public static NDArray[] atleast_1d(params NDArray[] arys)
Parameters
arysNDArray[]One or more input arrays.
Returns
- NDArray[]
An array, or list of arrays, each with a.ndim >= 1. Copies are made only if necessary.
Remarks
atleast_1d(object)
Convert inputs to arrays with at least one dimension. Scalar inputs are converted to 1-dimensional arrays, whilst higher-dimensional inputs are preserved.
public static NDArray atleast_1d(object arys)
Parameters
arysobjectOne or more input arrays.
Returns
- NDArray
An array, or list of arrays, each with a.ndim >= 1. Copies are made only if necessary.
Remarks
atleast_1d(params object[])
Convert inputs to arrays with at least one dimension. Scalar inputs are converted to 1-dimensional arrays, whilst higher-dimensional inputs are preserved.
public static NDArray[] atleast_1d(params object[] arys)
Parameters
arysobject[]One or more input arrays.
Returns
- NDArray[]
An array, or list of arrays, each with a.ndim >= 1. Copies are made only if necessary.
Remarks
atleast_2d(NDArray)
View inputs as arrays with at least two dimensions.
public static NDArray atleast_2d(NDArray arr)
Parameters
arrNDArrayOne or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have two or more dimensions are preserved.
Returns
- NDArray
An array, or list of arrays, each with a.ndim >= 2. Copies are avoided where possible, and views with two or more dimensions are returned.
Remarks
atleast_2d(params NDArray[])
View inputs as arrays with at least two dimensions.
public static NDArray[] atleast_2d(params NDArray[] arys)
Parameters
arysNDArray[]One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have two or more dimensions are preserved.
Returns
- NDArray[]
An array, or list of arrays, each with a.ndim >= 2. Copies are avoided where possible, and views with two or more dimensions are returned.
Remarks
atleast_2d(object)
View inputs as arrays with at least two dimensions.
public static NDArray atleast_2d(object arys)
Parameters
arysobjectOne or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have two or more dimensions are preserved.
Returns
- NDArray
An array, or list of arrays, each with a.ndim >= 2. Copies are avoided where possible, and views with two or more dimensions are returned.
Remarks
atleast_2d(params object[])
View inputs as arrays with at least two dimensions.
public static NDArray[] atleast_2d(params object[] arys)
Parameters
arysobject[]One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have two or more dimensions are preserved.
Returns
- NDArray[]
An array, or list of arrays, each with a.ndim >= 2. Copies are avoided where possible, and views with two or more dimensions are returned.
Remarks
atleast_3d(NDArray)
View inputs as arrays with at least three dimensions.
public static NDArray atleast_3d(NDArray arr)
Parameters
arrNDArray
Returns
- NDArray
An array, or list of arrays, each with a.ndim >= 3. Copies are avoided where possible, and views with three or more dimensions are returned. For example, a 1-D array of shape (N,) becomes a view of shape (1, N, 1), and a 2-D array of shape (M, N) becomes a view of shape (M, N, 1).
Remarks
atleast_3d(params NDArray[])
View inputs as arrays with at least three dimensions.
public static NDArray[] atleast_3d(params NDArray[] arys)
Parameters
arysNDArray[]One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have three or more dimensions are preserved.
Returns
- NDArray[]
An array, or list of arrays, each with a.ndim >= 3. Copies are avoided where possible, and views with three or more dimensions are returned. For example, a 1-D array of shape (N,) becomes a view of shape (1, N, 1), and a 2-D array of shape (M, N) becomes a view of shape (M, N, 1).
Remarks
atleast_3d(object)
View inputs as arrays with at least three dimensions.
public static NDArray atleast_3d(object arys)
Parameters
arysobjectOne or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have three or more dimensions are preserved.
Returns
- NDArray
An array, or list of arrays, each with a.ndim >= 3. Copies are avoided where possible, and views with three or more dimensions are returned. For example, a 1-D array of shape (N,) becomes a view of shape (1, N, 1), and a 2-D array of shape (M, N) becomes a view of shape (M, N, 1).
Remarks
atleast_3d(params object[])
View inputs as arrays with at least three dimensions.
public static NDArray[] atleast_3d(params object[] arys)
Parameters
arysobject[]One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have three or more dimensions are preserved.
Returns
- NDArray[]
An array, or list of arrays, each with a.ndim >= 3. Copies are avoided where possible, and views with three or more dimensions are returned. For example, a 1-D array of shape (N,) becomes a view of shape (1, N, 1), and a 2-D array of shape (M, N) becomes a view of shape (M, N, 1).
Remarks
average(NDArray, int[], NDArray, bool)
Compute the weighted average along a tuple of axes. Equivalent to
np.average(a, axis, weights, keepdims) in NumPy with a tuple axis.
public static NDArray average(NDArray a, int[] axis, NDArray weights = null, bool keepdims = false)
Parameters
Returns
Remarks
average(NDArray, int?, NDArray, bool)
Compute the weighted average along the specified axis.
Equivalent to sum(a * weights) / sum(weights). When weights
is null this reduces to mean(NDArray) over the same axes.
public static NDArray average(NDArray a, int? axis = null, NDArray weights = null, bool keepdims = false)
Parameters
Returns
Remarks
average_returned(NDArray, int[], NDArray, bool)
Tuple-axis overload of average_returned(NDArray, int?, NDArray, bool).
public static (NDArray avg, NDArray sumOfWeights) average_returned(NDArray a, int[] axis, NDArray weights = null, bool keepdims = false)
Parameters
Returns
Remarks
average_returned(NDArray, int?, NDArray, bool)
Compute the weighted average and return a tuple (avg, sum_of_weights).
Equivalent to numpy.average(..., returned=True). When weights
is null, sum_of_weights is the number of elements per output cell
(broadcast to the average's shape).
public static (NDArray avg, NDArray sumOfWeights) average_returned(NDArray a, int? axis = null, NDArray weights = null, bool keepdims = false)
Parameters
Returns
Remarks
bitwise_and(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
Compute the bit-wise AND of two arrays element-wise. Only integer and boolean types are handled (NumPy: float/complex inputs raise the no-loop TypeError).
public static NDArray bitwise_and(NDArray x1, NDArray x2, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
x1NDArrayFirst input array.
x2NDArraySecond input array.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?
Returns
- NDArray
Result. This is a scalar if both x1 and x2 are scalars.
Remarks
bitwise_not(NDArray, NDArray, NDArray, NPTypeCode?)
Compute bit-wise inversion, or bit-wise NOT, element-wise. Alias for invert.
public static NDArray bitwise_not(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayOnly integer and boolean types are handled.
outNDArraywhereNDArraydtypeNPTypeCode?
Returns
- NDArray
Result. This is a scalar if x is a scalar.
Remarks
bitwise_not(NDArray, NPTypeCode)
Compute bit-wise inversion, or bit-wise NOT, element-wise. Alias for invert.
public static NDArray bitwise_not(NDArray x, NPTypeCode outType)
Parameters
xNDArrayoutTypeNPTypeCode
Returns
Remarks
bitwise_not(NDArray, Type)
Compute bit-wise inversion, or bit-wise NOT, element-wise. Alias for invert.
public static NDArray bitwise_not(NDArray x, Type outType)
Parameters
xNDArrayOnly integer and boolean types are handled.
outTypeTypeThe dtype the returned ndarray should be of.
Returns
- NDArray
Result. This is a scalar if x is a scalar.
Remarks
bitwise_or(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
Compute the bit-wise OR of two arrays element-wise. Only integer and boolean types are handled (NumPy: float/complex inputs raise the no-loop TypeError).
public static NDArray bitwise_or(NDArray x1, NDArray x2, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
x1NDArrayFirst input array.
x2NDArraySecond input array.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?
Returns
- NDArray
Result. This is a scalar if both x1 and x2 are scalars.
Remarks
bitwise_xor(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
Compute the bit-wise XOR of two arrays element-wise. Only integer and boolean types are handled (NumPy: float/complex inputs raise the no-loop TypeError).
public static NDArray bitwise_xor(NDArray x1, NDArray x2, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
x1NDArrayFirst input array.
x2NDArraySecond input array.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?
Returns
- NDArray
Result. This is a scalar if both x1 and x2 are scalars.
Remarks
broadcast(NDArray, NDArray)
Two-operand overload — the most common case. Retained as an explicit overload so
np.broadcast(a, b) stays binary-compatible and skips the params-array allocation.
public static np.Broadcast broadcast(NDArray nd1, NDArray nd2)
Parameters
Returns
broadcast(params NDArray[])
Produce an object that mimics broadcasting.
public static np.Broadcast broadcast(params NDArray[] arrays)
Parameters
arraysNDArray[]The arrays to broadcast against one another. NumPy caps this at 64 operands (NPY_MAXARGS); NumSharp imposes no cap, matching its unlimited-operand
NDIter.
Returns
- np.Broadcast
Broadcast the input parameters against one another, and return an object that encapsulates the result. Amongst others, it has shape and nd properties, and may be used as an iterator.
Remarks
broadcast_arrays(NDArray, NDArray)
Broadcast two arrays against each other.
public static (NDArray Lhs, NDArray Rhs) broadcast_arrays(NDArray lhs, NDArray rhs)
Parameters
Returns
- (NDArray Lhs, NDArray Rhs)
These arrays are views on the original arrays. They are typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location. If you need to write to the arrays, make copies first.
Remarks
broadcast_arrays(params NDArray[])
Broadcast any number of arrays against each other.
public static NDArray[] broadcast_arrays(params NDArray[] ndArrays)
Parameters
ndArraysNDArray[]The arrays to broadcast.
Returns
- NDArray[]
These arrays are views on the original arrays. They are typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location. If you need to write to the arrays, make copies first.
Remarks
broadcast_to(UnmanagedStorage, UnmanagedStorage)
Broadcast an array to a new shape.
public static NDArray broadcast_to(UnmanagedStorage from, UnmanagedStorage against)
Parameters
fromUnmanagedStorageThe UnmanagedStorage to broadcast.
againstUnmanagedStorageThe shape to broadcast against.
Returns
- NDArray
These arrays are views on the original arrays. They are typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location. If you need to write to the arrays, make copies first.
Remarks
broadcast_to(UnmanagedStorage, NDArray)
Broadcast an array to a new shape.
public static NDArray broadcast_to(UnmanagedStorage from, NDArray against)
Parameters
fromUnmanagedStorageThe UnmanagedStorage to broadcast.
againstNDArrayThe shape to broadcast against.
Returns
- NDArray
These arrays are views on the original arrays. They are typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location. If you need to write to the arrays, make copies first.
Remarks
broadcast_to(UnmanagedStorage, Shape)
Broadcast an array to a new shape.
public static NDArray broadcast_to(UnmanagedStorage from, Shape against)
Parameters
fromUnmanagedStorageThe NDArray to broadcast.
againstShapeThe shape to broadcast against.
Returns
- NDArray
These arrays are views on the original arrays. They are typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location. If you need to write to the arrays, make copies first.
Remarks
broadcast_to(NDArray, UnmanagedStorage)
Broadcast an array to a new shape.
public static NDArray broadcast_to(NDArray from, UnmanagedStorage against)
Parameters
fromNDArrayThe NDArray to broadcast.
againstUnmanagedStorageThe shape to broadcast against.
Returns
- NDArray
These arrays are views on the original arrays. They are typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location. If you need to write to the arrays, make copies first.
Remarks
broadcast_to(NDArray, NDArray)
Broadcast an array to a new shape.
public static NDArray broadcast_to(NDArray from, NDArray against)
Parameters
Returns
- NDArray
These arrays are views on the original arrays. They are typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location. If you need to write to the arrays, make copies first.
Remarks
broadcast_to(NDArray, Shape)
Broadcast an array to a new shape.
public static NDArray broadcast_to(NDArray from, Shape against)
Parameters
Returns
- NDArray
These arrays are views on the original arrays. They are typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location. If you need to write to the arrays, make copies first.
Remarks
broadcast_to(Shape, UnmanagedStorage)
Broadcast an shape against an other new shape.
public static Shape broadcast_to(Shape from, UnmanagedStorage against)
Parameters
fromShapeThe shape that is to be broadcasted
againstUnmanagedStorageThe shape that'll be used to broadcast
fromshape
Returns
- Shape
A readonly view on the original array with the given shape. It is typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location.
Remarks
broadcast_to(Shape, NDArray)
Broadcast an shape against an other new shape.
public static Shape broadcast_to(Shape from, NDArray against)
Parameters
fromShapeThe shape that is to be broadcasted
againstNDArrayThe shape that'll be used to broadcast
fromshape
Returns
- Shape
A readonly view on the original array with the given shape. It is typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location.
Remarks
broadcast_to(Shape, Shape)
Broadcast an shape against an other new shape.
public static Shape broadcast_to(Shape from, Shape against)
Parameters
fromShapeThe shape that is to be broadcasted
againstShapeThe shape that'll be used to broadcast
fromshape
Returns
- Shape
A readonly view on the original array with the given shape. It is typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location.
Remarks
can_cast(NDArray, NPTypeCode, string)
Returns True if cast from array dtype can occur according to the casting rule.
public static bool can_cast(NDArray from, NPTypeCode to, string casting = "safe")
Parameters
fromNDArrayArray to cast from.
toNPTypeCodeData type to cast to.
castingstringControls what kind of data casting may occur.
Returns
- bool
True if the array can be cast to the target type.
can_cast(NPTypeCode, NPTypeCode, string)
Returns True if cast between data types can occur according to the casting rule.
public static bool can_cast(NPTypeCode from, NPTypeCode to, string casting = "safe")
Parameters
fromNPTypeCodeData type to cast from.
toNPTypeCodeData type to cast to.
castingstringControls what kind of data casting may occur:
- "no" means the data types should not be cast at all.
- "equiv" means only byte-order changes are allowed.
- "safe" means only casts which can preserve values are allowed.
- "same_kind" means only safe casts or casts within a kind (int to int, float to float) are allowed.
- "unsafe" means any data conversions may be done.
Returns
- bool
True if cast can occur according to the casting rule.
Examples
np.can_cast(NPTypeCode.Int32, NPTypeCode.Int64) // True
np.can_cast(NPTypeCode.Int64, NPTypeCode.Int32) // False
np.can_cast(NPTypeCode.Int32, NPTypeCode.Single, "same_kind") // False (different kind)
np.can_cast(NPTypeCode.Int32, NPTypeCode.Int16, "unsafe") // True
Remarks
can_cast(bool, NPTypeCode, string)
Returns True if the bool value can be cast to the data type according to the casting rule.
public static bool can_cast(bool value, NPTypeCode to, string casting = "safe")
Parameters
valuebooltoNPTypeCodecastingstring
Returns
can_cast(byte, NPTypeCode, string)
Returns True if the byte value can be cast to the data type according to the casting rule.
public static bool can_cast(byte value, NPTypeCode to, string casting = "safe")
Parameters
valuebytetoNPTypeCodecastingstring
Returns
can_cast(decimal, NPTypeCode, string)
Returns True if the decimal value can be cast to the data type according to the casting rule.
public static bool can_cast(decimal value, NPTypeCode to, string casting = "safe")
Parameters
valuedecimaltoNPTypeCodecastingstring
Returns
can_cast(double, NPTypeCode, string)
Returns True if the double value can be cast to the data type according to the casting rule.
public static bool can_cast(double value, NPTypeCode to, string casting = "safe")
Parameters
valuedoubletoNPTypeCodecastingstring
Returns
can_cast(short, NPTypeCode, string)
Returns True if the short value can be cast to the data type according to the casting rule.
public static bool can_cast(short value, NPTypeCode to, string casting = "safe")
Parameters
valueshorttoNPTypeCodecastingstring
Returns
can_cast(int, NPTypeCode, string)
Returns True if the int value can be cast to the data type according to the casting rule.
public static bool can_cast(int value, NPTypeCode to, string casting = "safe")
Parameters
valueintInt value to check.
toNPTypeCodeData type to cast to.
castingstringControls what kind of data casting may occur.
Returns
- bool
True if the value can be cast to the target type.
can_cast(long, NPTypeCode, string)
Returns True if the long value can be cast to the data type according to the casting rule.
public static bool can_cast(long value, NPTypeCode to, string casting = "safe")
Parameters
valuelongtoNPTypeCodecastingstring
Returns
can_cast(object, NPTypeCode, string)
Returns True if the scalar value can be cast to the data type according to the casting rule.
public static bool can_cast(object value, NPTypeCode to, string casting = "safe")
Parameters
valueobjectScalar value to check.
toNPTypeCodeData type to cast to.
castingstringControls what kind of data casting may occur.
Returns
- bool
True if the value can be cast to the target type.
Examples
np.can_cast(100, NPTypeCode.Byte) // True (100 fits in byte)
np.can_cast(1000, NPTypeCode.Byte) // False (1000 > 255)
Remarks
Scalar values can often be cast to smaller types if the value fits.
can_cast(float, NPTypeCode, string)
Returns True if the float value can be cast to the data type according to the casting rule.
public static bool can_cast(float value, NPTypeCode to, string casting = "safe")
Parameters
valuefloattoNPTypeCodecastingstring
Returns
can_cast(Type, Type, string)
Returns True if cast between data types can occur according to the casting rule.
public static bool can_cast(Type from, Type to, string casting = "safe")
Parameters
fromTypeCLR type to cast from.
toTypeCLR type to cast to.
castingstringControls what kind of data casting may occur.
Returns
- bool
True if cast can occur according to the casting rule.
can_cast(ushort, NPTypeCode, string)
Returns True if the ushort value can be cast to the data type according to the casting rule.
public static bool can_cast(ushort value, NPTypeCode to, string casting = "safe")
Parameters
valueushorttoNPTypeCodecastingstring
Returns
can_cast(uint, NPTypeCode, string)
Returns True if the uint value can be cast to the data type according to the casting rule.
public static bool can_cast(uint value, NPTypeCode to, string casting = "safe")
Parameters
valueuinttoNPTypeCodecastingstring
Returns
can_cast(ulong, NPTypeCode, string)
Returns True if the ulong value can be cast to the data type according to the casting rule.
public static bool can_cast(ulong value, NPTypeCode to, string casting = "safe")
Parameters
valueulongtoNPTypeCodecastingstring
Returns
can_cast<TFrom, TTo>(string)
Returns True if cast between data types can occur according to the casting rule.
public static bool can_cast<TFrom, TTo>(string casting = "safe") where TFrom : struct where TTo : struct
Parameters
castingstringControls what kind of data casting may occur.
Returns
- bool
True if cast can occur according to the casting rule.
Type Parameters
TFromSource type.
TToTarget type.
Examples
np.can_cast<int, long>() // True
np.can_cast<long, int>() // False
np.can_cast<int, float>("safe") // True (int to float is safe)
cbrt(NDArray, NDArray, NDArray, NPTypeCode?)
Return the cube-root of an array, element-wise.
public static NDArray cbrt(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayThe values whose cube-roots are required.
outNDArraywhereNDArraydtypeNPTypeCode?The dtype the returned ndarray should be of.
Returns
- NDArray
An array of the same shape as x, containing the cube root of each element. If x contains negative values, the result contains the (negative) real cube root. This is a scalar if x is a scalar.
Remarks
cbrt(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray cbrt(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayInput array.
dtypeNPTypeCodeThe loop dtype the computation should run in.
Returns
Remarks
cbrt(NDArray, Type)
Return the cube-root of an array, element-wise.
public static NDArray cbrt(NDArray x, Type dtype)
Parameters
xNDArrayThe values whose cube-roots are required.
dtypeTypeThe dtype the returned ndarray should be of.
Returns
- NDArray
An array of the same shape as x, containing the cube root of each element. If x contains negative values, the result contains the (negative) real cube root. This is a scalar if x is a scalar.
Remarks
ceil(NDArray, NDArray, NDArray, NPTypeCode?)
Return the ceiling of the input, element-wise.
The ceil of the scalar x is the smallest integer i, such that i >= x. It is often denoted as \lceil x \rceil.
public static NDArray ceil(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayInput data.
outNDArraywhereNDArraydtypeNPTypeCode?The dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
The ceiling of each element in x, with float dtype. This is a scalar if x is a scalar.
Remarks
ceil(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray ceil(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayInput array.
dtypeNPTypeCodeThe loop dtype the computation should run in.
Returns
Remarks
ceil(NDArray, Type)
Return the ceiling of the input, element-wise.
The ceil of the scalar x is the smallest integer i, such that i >= x. It is often denoted as \lceil x \rceil.
public static NDArray ceil(NDArray x, Type dtype)
Parameters
xNDArrayInput data.
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
The ceiling of each element in x, with float dtype. This is a scalar if x is a scalar.
Remarks
clip(NDArray, NDArray, NDArray, NDArray, NPTypeCode?, NDArray, NDArray)
Clip (limit) the values in an array.
Given an interval, values outside the interval are clipped to the interval edges. For example, if an interval of [0, 1] is specified, values smaller than 0 become 0, and values larger than 1 become 1.
Matches NumPy 2.x signature: clip(a, a_min=None, a_max=None, out=None, *, min=None, max=None). Either or both bounds may be null. The min and max keyword aliases (added in NumPy 2.0) are accepted; mixing a_min with min (or a_max with max) throws.
public static NDArray clip(NDArray a, NDArray a_min = null, NDArray a_max = null, NDArray @out = null, NPTypeCode? dtype = null, NDArray min = null, NDArray max = null)
Parameters
aNDArrayArray containing elements to clip.
a_minNDArrayMinimum value. If null, clipping is not performed on lower interval edge.
a_maxNDArrayMaximum value. If null, clipping is not performed on upper interval edge.
outNDArrayThe results will be placed in this array. It may be the input array for in-place clipping.
outmust be of the right shape to hold the output. Its type is preserved.dtypeNPTypeCode?The dtype the returned ndarray should be of.
minNDArrayNumPy 2.x keyword alias for
a_min. Cannot be combined witha_min.maxNDArrayNumPy 2.x keyword alias for
a_max. Cannot be combined witha_max.
Returns
- NDArray
An array with the elements of a, but where values < min are replaced with min, and those > max with max.
Remarks
clip(NDArray, NDArray, NDArray, Type)
Clip (limit) the values in an array, returning a result of the requested CLR Type.
public static NDArray clip(NDArray a, NDArray a_min, NDArray a_max, Type dtype)
Parameters
aNDArrayArray containing elements to clip.
a_minNDArrayMinimum value. If null, clipping is not performed on lower interval edge.
a_maxNDArrayMaximum value. If null, clipping is not performed on upper interval edge.
dtypeTypeThe dtype the returned ndarray should be of.
Returns
- NDArray
An array with the elements of a, but where values < a_min are replaced with a_min, and those > a_max with a_max.
Remarks
common_type(params NDArray[])
Return a scalar type which is common to the input arrays.
public static Type common_type(params NDArray[] arrays)
Parameters
arraysNDArray[]Input arrays.
Returns
- Type
The common scalar type as CLR Type.
Examples
np.common_type(np.array(new int[] {1, 2})) // typeof(double)
np.common_type(a_float32, a_float64) // typeof(double)
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.common_type.html
The return type will always be a floating-point type (minimum float64 for integers). This differs from result_type which may return an integer type.
common_type_code(params NDArray[])
Return a scalar type code which is common to the input arrays.
public static NPTypeCode common_type_code(params NDArray[] arrays)
Parameters
arraysNDArray[]Input arrays.
Returns
- NPTypeCode
The common scalar type as NPTypeCode.
Remarks
The return type will always be a floating-point type (minimum Double for integers).
common_type_code(params NPTypeCode[])
Return a scalar type code which is common to the input type codes.
public static NPTypeCode common_type_code(params NPTypeCode[] types)
Parameters
typesNPTypeCode[]Input type codes.
Returns
- NPTypeCode
The common scalar type as NPTypeCode.
Remarks
NumPy common_type rules:
- Any Complex input -> Complex (complex128).
- Any Decimal input (NumSharp extension) -> Decimal.
- Any integer/bool/char input -> Double (any int presence forces float64).
- Otherwise (all float16/float32/float64): return max-precision float.
compress(NDArray, NDArray, int?, NDArray)
Return selected slices of a along the given
axis at positions where the 1-D
condition is truthy.
public static NDArray compress(NDArray condition, NDArray a, int? axis = null, NDArray @out = null)
Parameters
conditionNDArray1-D array of booleans (or any dtype interpreted as truthy). Must be 1-D — a 2-D or 0-D condition raises ArgumentException, mirroring NumPy's
ValueError("condition must be a 1-d array"). Iflen(condition) < a.shape[axis], only the firstlen(condition)positions alongaxisare considered; if longer, any True beyonda.shape[axis]raises IndexOutOfRangeException.aNDArraySource array.
axisint?Axis along which to slice.
null(default) flattensafirst.outNDArrayOptional destination. When supplied, shape must match the natural output and
out.dtypemust be safely castable toa.dtype; values are written via copyto(NDArray, NDArray, string, NDArray) with unsafe casting and the method returnsoutitself (matches NumPy's out= dispatch via PyArray_TakeFrom).
Returns
- NDArray
A copy of
awithout the slices alongaxisfor whichconditionis false. Dtype matchesa(orout's dtype when supplied).
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.compress.html
Two execution paths:
-
Fast path: bool condition, contig source, no out= or
out= matches src.dtype,
condition.size <= a.shape[axis]. Runs the fused mask-driven gather kernel (popcount → alloc → SIMD bit-scan + cpblk-per-outer-slab), skipping the flatnonzero indices NDArray. -
Generic path: mirrors NumPy's
PyArray_Compresschain — flatnonzero(cond) → take(a, indices, axis, out, "raise"). Handles non-bool conditions, out= with safe dtype cast, and OOB-True via take's RAISE mode.
When condition is 1-D extract(NDArray, NDArray) with
axis = null is equivalent.
concatenate(NDArray[], int?, NDArray, NPTypeCode?, string)
Join a sequence of arrays along an existing axis.
public static NDArray concatenate(NDArray[] arrays, int? axis = 0, NDArray @out = null, NPTypeCode? dtype = null, string casting = "same_kind")
Parameters
arraysNDArray[]The arrays must have the same shape, except in the dimension corresponding to
axis(the first, by default).axisint?The axis along which the arrays will be joined. If
null, arrays are flattened before use. Default is 0. Negative axes are normalized against the input ndim.outNDArrayIf provided, the destination to place the result. The shape must be correct, matching what would have been returned with no
outargument. Cannot be used together withdtype.dtypeNPTypeCode?If provided, the result array will have this dtype. Cannot be used together with
out.castingstringControls what kind of data casting may occur. One of
"no","equiv","safe","same_kind"(default), or"unsafe".
Returns
- NDArray
The concatenated array.
Remarks
concatenate((NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray), int)
public static NDArray concatenate((NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray) arrays, int axis = 0)
Parameters
Returns
concatenate((NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray), int)
public static NDArray concatenate((NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray) arrays, int axis = 0)
Parameters
Returns
concatenate((NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray), int)
public static NDArray concatenate((NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray) arrays, int axis = 0)
Parameters
Returns
concatenate((NDArray, NDArray, NDArray, NDArray, NDArray, NDArray), int)
public static NDArray concatenate((NDArray, NDArray, NDArray, NDArray, NDArray, NDArray) arrays, int axis = 0)
Parameters
Returns
concatenate((NDArray, NDArray, NDArray, NDArray, NDArray), int)
public static NDArray concatenate((NDArray, NDArray, NDArray, NDArray, NDArray) arrays, int axis = 0)
Parameters
Returns
concatenate((NDArray, NDArray, NDArray, NDArray), int)
public static NDArray concatenate((NDArray, NDArray, NDArray, NDArray) arrays, int axis = 0)
Parameters
Returns
concatenate((NDArray, NDArray, NDArray), int)
public static NDArray concatenate((NDArray, NDArray, NDArray) arrays, int axis = 0)
Parameters
Returns
concatenate((NDArray, NDArray), int)
public static NDArray concatenate((NDArray, NDArray) arrays, int axis = 0)
Parameters
Returns
convolve(NDArray, NDArray, string)
Returns the discrete, linear convolution of two one-dimensional sequences.
The convolution operator is often seen in signal processing, where it models the effect of a linear time-invariant system on a signal[1]. In probability theory, the sum of two independent random variables is distributed according to the convolution of their individual distributions.
If v is longer than a, the arrays are swapped before computation.
public static NDArray convolve(NDArray a, NDArray v, string mode = "full")
Parameters
Returns
copy(NDArray, char)
Return an array copy of the given object.
public static NDArray copy(NDArray a, char order = 'K')
Parameters
aNDArrayInput data.
ordercharControls the memory layout of the copy. 'C' - row-major, 'F' - column-major, 'A' - 'F' if source is F-contiguous else 'C', 'K' - match source layout as closely as possible.
Returns
- NDArray
Array interpretation of a.
Remarks
copyto(NDArray, NDArray, string, NDArray)
Copies values from one array to another, broadcasting as necessary.
public static void copyto(NDArray dst, NDArray src, string casting = "same_kind", NDArray where = null)
Parameters
dstNDArrayThe array into which values are copied.
srcNDArrayThe array from which values are copied.
castingstringControls what kind of data casting may occur when copying. Default
"same_kind". Allowed values:"no","equiv","safe","same_kind","unsafe".whereNDArrayOptional boolean mask broadcast to
dst's shape. Elements ofsrcare only written todstwhere the mask istrue.null(default) is equivalent towhere=True— every element is copied.
Remarks
Exceptions
- ArgumentException
If
dstis read-only, orcastingis not a recognised casting name, orwhereis not a boolean array.- InvalidCastException
If casting from
src's dtype todst's dtype is not allowed under the chosen rule (NumPy raisesTypeError).
cos(NDArray, NDArray, NDArray, NPTypeCode?)
Cosine element-wise.
Mirrors NumPy's ufunc signature: cos(x, /, out=None, *, where=True, dtype=None).
public static NDArray cos(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array in radians.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?Explicit loop dtype (NumPy ufunc dtype=): the computation runs at this precision; integer/bool requests raise NumPy's "No loop matching" error.
Returns
- NDArray
The cosine of each element of x. This is a scalar if x is a scalar.
Remarks
cos(NDArray, NPTypeCode)
Cosine element-wise, computed in dtype.
Positional-dtype convenience overload (NumPy accepts dtype only as a keyword).
public static NDArray cos(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayInput array in radians.
dtypeNPTypeCodeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
Remarks
cos(NDArray, Type)
Cosine element-wise.
public static NDArray cos(NDArray x, Type dtype)
Parameters
xNDArrayInput array in radians.
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
The sine of each element of x. This is a scalar if x is a scalar.
Remarks
cosh(NDArray, NDArray, NDArray, NPTypeCode?)
Hyperbolic cosine, element-wise.
Equivalent to 1/2 * (np.exp(x) + np.exp(-x)) and np.cos(1j* x).
public static NDArray cosh(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array.
outNDArraywhereNDArraydtypeNPTypeCode?The dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
Output array of same shape as x. This is a scalar if x is a scalar.
Remarks
cosh(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray cosh(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayInput array.
dtypeNPTypeCodeThe loop dtype the computation should run in.
Returns
Remarks
cosh(NDArray, Type)
Hyperbolic cosine, element-wise.
Equivalent to 1/2 * (np.exp(x) + np.exp(-x)) and np.cos(1j* x).
public static NDArray cosh(NDArray x, Type dtype)
Parameters
xNDArrayInput array.
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
Output array of same shape as x. This is a scalar if x is a scalar.
Remarks
count_nonzero(NDArray)
Counts the number of non-zero values in the array.
public static long count_nonzero(NDArray a)
Parameters
aNDArrayThe array for which to count non-zeros.
Returns
- long
Number of non-zero values in the array.
Remarks
count_nonzero(NDArray, int, bool)
Counts the number of non-zero values in the array along the given axis.
public static NDArray count_nonzero(NDArray a, int axis, bool keepdims = false)
Parameters
aNDArrayThe array for which to count non-zeros.
axisintAxis along which to count non-zeros.
keepdimsboolIf True, the axes which are reduced are left in the result as dimensions with size one.
Returns
- NDArray
Number of non-zero values along the specified axis.
Remarks
cumprod(NDArray, int?, NPTypeCode?)
Return the cumulative product of the elements along a given axis.
public static NDArray cumprod(NDArray arr, int? axis = null, NPTypeCode? typeCode = null)
Parameters
arrNDArrayInput array.
axisint?Axis along which the cumulative product is computed. The default (None) is to compute the cumprod over the flattened array.
typeCodeNPTypeCode?Type of the returned array and of the accumulator in which the elements are multiplied. If dtype is not specified, it defaults to the dtype of a, unless a has an integer dtype with a precision less than that of the default platform integer. In that case, the default platform integer is used.
Returns
- NDArray
A new array holding the result is returned unless out is specified, in which case a reference to out is returned. The result has the same size as a, and the same shape as a if axis is not None or a is a 1-d array.
Remarks
cumsum(NDArray, int?, NPTypeCode?)
Return the cumulative sum of the elements along a given axis.
public static NDArray cumsum(NDArray arr, int? axis = null, NPTypeCode? typeCode = null)
Parameters
arrNDArrayInput array.
axisint?Axis along which the cumulative sum is computed. The default (None) is to compute the cumsum over the flattened array.
typeCodeNPTypeCode?Type of the returned array and of the accumulator in which the elements are summed. If dtype is not specified, it defaults to the dtype of a, unless a has an integer dtype with a precision less than that of the default platform integer. In that case, the default platform integer is used.
Returns
- NDArray
A new array holding the result is returned unless out is specified, in which case a reference to out is returned. The result has the same size as a, and the same shape as a if axis is not None or a is a 1-d array.
Remarks
deg2rad(NDArray, NDArray, NDArray, NPTypeCode?)
Convert angles from degrees to radians.
public static NDArray deg2rad(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayAngles in degrees.
outNDArraywhereNDArraydtypeNPTypeCode?The dtype the returned ndarray should be of.
Returns
- NDArray
The corresponding angle in radians. This is a scalar if x is a scalar.
Remarks
deg2rad(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray deg2rad(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayInput array.
dtypeNPTypeCodeThe loop dtype the computation should run in.
Returns
Remarks
deg2rad(NDArray, Type)
Convert angles from degrees to radians.
public static NDArray deg2rad(NDArray x, Type dtype)
Parameters
Returns
- NDArray
The corresponding angle in radians. This is a scalar if x is a scalar.
Remarks
degrees(NDArray, NDArray, NDArray, NPTypeCode?)
Convert angles from radians to degrees. Alias for rad2deg.
public static NDArray degrees(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayAngle in radians.
outNDArraywhereNDArraydtypeNPTypeCode?The dtype the returned ndarray should be of.
Returns
- NDArray
The corresponding angle in degrees. This is a scalar if x is a scalar.
Remarks
degrees(NDArray, NPTypeCode)
Alias for rad2deg — positional-dtype convenience overload.
public static NDArray degrees(NDArray x, NPTypeCode dtype)
Parameters
xNDArraydtypeNPTypeCode
Returns
Remarks
degrees(NDArray, Type)
Convert angles from radians to degrees. Alias for rad2deg.
public static NDArray degrees(NDArray x, Type dtype)
Parameters
Returns
- NDArray
The corresponding angle in degrees. This is a scalar if x is a scalar.
Remarks
delete(NDArray, NDArray, int?)
NDArray-typed obj dispatch — selects the integer-array path or the
boolean-mask path based on obj.GetTypeCode. 0-D and 1-element
integer arrays collapse to the scalar-index fast path (matching
NumPy's obj.size == 1 and obj.dtype.kind in "ui": obj = obj.item()).
public static NDArray delete(NDArray arr, NDArray obj, int? axis = null)
Parameters
Returns
delete(NDArray, Slice, int?)
Slice-index overload. obj is interpreted via
Python slice.indices(N) against the axis length.
public static NDArray delete(NDArray arr, Slice obj, int? axis = null)
Parameters
Returns
delete(NDArray, bool[], int?)
Bool-array overload — values are interpreted as a keep-mask
inversion. Length must match the targeted axis size (NumPy raises
ValueError otherwise).
public static NDArray delete(NDArray arr, bool[] obj, int? axis = null)
Parameters
Returns
delete(NDArray, int, int?)
Return a new array with the element at obj
along axis removed.
public static NDArray delete(NDArray arr, int obj, int? axis = null)
Parameters
arrNDArrayInput array.
objintInteger index of the position to remove. Accepts negative indices (counted from the end). Raises IndexOutOfRangeException when out of bounds for the selected axis.
axisint?Axis along which to delete.
null(default) flattensarrfirst and returns a 1-D result.
Returns
- NDArray
A C-contiguous copy of
arrwith one sub-array removed alongaxis.
Remarks
delete(NDArray, int[], int?)
Array-of-indices overload. Negative indices are normalized; duplicates are silently collapsed (each axis position is removed at most once).
public static NDArray delete(NDArray arr, int[] obj, int? axis = null)
Parameters
Returns
delete(NDArray, long, int?)
Long-index overload of delete(NDArray, int, int?).
public static NDArray delete(NDArray arr, long obj, int? axis = null)
Parameters
Returns
delete(NDArray, long[], int?)
Long-array-of-indices overload.
public static NDArray delete(NDArray arr, long[] obj, int? axis = null)
Parameters
Returns
diagonal(NDArray, int, int, int)
Return specified diagonals of a. For a 2-D
array, returns the diagonal as a 1-D array. For an N-D array,
the last two axes (default axis1=0,
axis2=1) define the 2-D sub-arrays from which
diagonals are taken; the diagonal is appended as the last axis
of the returned array.
public static NDArray diagonal(NDArray a, int offset = 0, int axis1 = 0, int axis2 = 1)
Parameters
aNDArraySource array. Must have at least 2 dimensions.
offsetintOffset of the diagonal from the main diagonal. Positive values refer to diagonals above the main, negative below. Default 0.
axis1intFirst axis of the 2-D sub-array. Default 0.
axis2intSecond axis of the 2-D sub-array. Default 1.
Returns
- NDArray
A read-only view sharing storage with
a. Shape:a.shapewithaxis1andaxis2removed and the diagonal appended as the last axis.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.diagonal.html
Mirrors NumPy's PyArray_Diagonal (item_selection.c). The
view trick: combining the two strides into one
stride[axis1] + stride[axis2] walks the diagonal in one
step. Read-only by NumPy contract (the writeable-by-default
change pencilled in for NumPy 1.10 hasn't shipped in 2.x).
diff(NDArray, int, int, object, object)
Calculate the n-th discrete difference along the given axis.
The first difference is out[i] = a[i+1] - a[i]; higher
differences are computed recursively.
public static NDArray diff(NDArray a, int n = 1, int axis = -1, object prepend = null, object append = null)
Parameters
aNDArrayInput array (must be at least one dimensional).
nintThe number of times values are differenced. If zero, the input is returned as-is. Must be non-negative.
axisintThe axis along which the difference is taken; default is the last axis. Negative axes count from the end.
prependobjectValue(s) to prepend to
aalongaxisprior to differencing. Scalars expand to length 1 along the axis.nullmeans "not supplied" (NumPy'snp._NoValue).appendobjectValue(s) to append to
aalongaxisprior to differencing. Scalars expand to length 1 along the axis.nullmeans "not supplied".
Returns
- NDArray
The n-th differences. The shape matches the (optionally prepend/append-extended) input except along
axiswhere the size shrinks byn. The dtype is preserved (boolean input yields boolean output via not_equal).
Remarks
divide(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
public static NDArray divide(NDArray x1, NDArray x2, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
x1NDArrayx2NDArrayoutNDArraywhereNDArraydtypeNPTypeCode?
Returns
Remarks
dot(NDArray, NDArray)
Dot product of two arrays. See remarks.
public static NDArray dot(NDArray a, NDArray b)
Parameters
Returns
- NDArray
Returns the dot product of a and b. If a and b are both scalars or both 1-D arrays then a scalar is returned; otherwise an array is returned. If out is given, then it is returned.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.dot.html
Specifically,
- If both a and b are 1-D arrays, it is inner product of vectors (without complex conjugation).
- If both a and b are 2-D arrays, it is matrix multiplication, but using matmul or a @ b is preferred.
- If either a or b is 0-D(scalar), it is equivalent to multiply and using numpy.multiply(a, b) or a* b is preferred.
- If a is an N-D array and b is a 1-D array, it is a sum product over the last axis of a and b.
- If a is an N-D array and b is an M-D array(where M>=2), it is a sum product over the last axis of a and the second-to-last axis of b:
dot(a, b)[i,j,k,m] = sum(a[i,j,:] * b[k,:,m])
dsplit(NDArray, int)
Split array into multiple sub-arrays along the 3rd axis (depth).
public static NDArray[] dsplit(NDArray ary, int indices_or_sections)
Parameters
aryNDArrayArray to be divided into sub-arrays.
indices_or_sectionsintIf an integer, N, the array will be divided into N equal arrays along axis 2. If such a split is not possible, an error is raised.
Returns
- NDArray[]
A list of sub-arrays as views into ary.
Remarks
Equivalent to split with axis=2. Array must have ndim >= 3. https://numpy.org/doc/stable/reference/generated/numpy.dsplit.html
dsplit(NDArray, int[])
Split array into multiple sub-arrays along the 3rd axis (depth).
public static NDArray[] dsplit(NDArray ary, int[] indices)
Parameters
aryNDArrayArray to be divided into sub-arrays.
indicesint[]A 1-D array of sorted integers indicating where along axis 2 the array is split. For example, [2, 3] would result in ary[:,:,:2], ary[:,:,2:3], ary[:,:,3:].
Returns
- NDArray[]
A list of sub-arrays as views into ary.
Remarks
Equivalent to split with axis=2. Array must have ndim >= 3. https://numpy.org/doc/stable/reference/generated/numpy.dsplit.html
dstack(params NDArray[])
Stack arrays in sequence depth wise (along third axis). This is equivalent to concatenation along the third axis after 2-D arrays of shape(M, N) have been reshaped to(M, N,1) and 1-D arrays of shape(N,) have been reshaped to(1, N,1). Rebuilds arrays divided by dsplit. This function makes most sense for arrays with up to 3 dimensions.For instance, for pixel-data with a height(first axis), width(second axis), and r/g/b channels(third axis). The functions concatenate, stack and block provide more general stacking and concatenation operations.
public static NDArray dstack(params NDArray[] tup)
Parameters
tupNDArray[]The arrays must have the same shape along all but the third axis. 1-D or 2-D arrays must have the same shape.
Returns
- NDArray
The array formed by stacking the given arrays, will be at least 3-D.
Remarks
dtype(string)
Parse a string into a DType. 1:1 NumPy 2.x parity (with adaptations documented in NumSharp.np._dtype_string_map).
public static DType dtype(string dtype)
Parameters
dtypestringAny NumPy-style dtype string (e.g. "int8", "f4", "<i2", "complex128").
Returns
Remarks
Exceptions
- NotSupportedException
Thrown for valid-NumPy types NumSharp doesn't implement (S, U, M, m, O, V, a, c=S1), or for syntactically invalid strings (e.g. "f16", "b4", "xyz").
ediff1d(NDArray, object, object)
The differences between consecutive elements of an array. The input is flattened first; the result is always 1-D.
public static NDArray ediff1d(NDArray ary, object to_end = null, object to_begin = null)
Parameters
aryNDArrayInput array (flattened before differencing).
to_endobjectNumber(s) to append to the end of the returned differences.
nullmeans none. Cast toary's dtype under thesame_kindcasting rule.to_beginobjectNumber(s) to prepend to the beginning of the returned differences.
nullmeans none. Cast toary's dtype under thesame_kindcasting rule.
Returns
- NDArray
1-D array of consecutive differences (input dtype), optionally bracketed by
to_beginandto_end.
Remarks
empty(Shape)
Return a new array of given shape and type, without initializing entries.
public static NDArray empty(Shape shape)
Parameters
shapeShapeShape of the empty array, e.g., (2, 3) or 2.
Returns
- NDArray
Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None.
Remarks
empty(Shape, NPTypeCode)
Return a new array of given shape and type, without initializing entries.
public static NDArray empty(Shape shape, NPTypeCode typeCode)
Parameters
shapeShapeShape of the empty array, e.g., (2, 3) or 2.
typeCodeNPTypeCodeDesired output data-type for the array, e.g, numpy.int8. Default is numpy.float64.
Returns
- NDArray
Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None.
Remarks
empty(Shape, char, Type)
Return a new array of given shape and type with a specified memory layout.
public static NDArray empty(Shape shape, char order, Type dtype = null)
Parameters
shapeShapeShape of the empty array, e.g., (2, 3) or 2.
ordercharMemory layout: 'C' (row-major), 'F' (column-major), 'A' (any), 'K' (keep). With no source array, 'A' and 'K' default to 'C'.
dtypeTypeDesired output data-type. Default is numpy.float64.
Returns
- NDArray
Array of uninitialized data with the requested memory layout.
Remarks
empty(Shape, Type)
Return a new array of given shape and type, without initializing entries.
public static NDArray empty(Shape shape, Type dtype)
Parameters
shapeShapeShape of the empty array, e.g., (2, 3) or 2.
dtypeTypeDesired output data-type for the array, e.g, numpy.int8. Default is numpy.float64.
Returns
- NDArray
Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None.
Remarks
empty(int)
Return a new array of given shape and type, without initializing entries.
public static NDArray empty(int shape)
Parameters
shapeint
Returns
- NDArray
Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None.
Remarks
empty(int[])
Return a new array of given shape and type, without initializing entries.
public static NDArray empty(int[] shape)
Parameters
shapeint[]Shape of the empty array, e.g., (2, 3) or 2.
Returns
- NDArray
Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None.
Remarks
empty(long[])
Return a new array of given shape and type, without initializing entries.
public static NDArray empty(long[] shape)
Parameters
shapelong[]Shape of the empty array, e.g., (2, 3) or 2.
Returns
- NDArray
Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None.
Remarks
empty_like(NDArray, NPTypeCode, Shape)
Return a new array with the same shape and type as a given array.
public static NDArray empty_like(NDArray prototype, NPTypeCode typeCode, Shape shape = default)
Parameters
prototypeNDArrayThe shape and data-type of prototype define these same attributes of the returned array.
typeCodeNPTypeCodeOverrides the data type of the result.
shapeShapeOverrides the shape of the result.
Returns
- NDArray
Array of uninitialized (arbitrary) data with the same shape and type as prototype.
Remarks
empty_like(NDArray, NPTypeCode, Shape, char)
Return a new array with the same shape and type as a given array.
public static NDArray empty_like(NDArray prototype, NPTypeCode typeCode, Shape shape, char order)
Parameters
prototypeNDArrayThe shape and data-type of prototype define these same attributes of the returned array.
typeCodeNPTypeCodeOverrides the data type of the result.
shapeShapeOverrides the shape of the result.
ordercharMemory layout: 'C', 'F', 'A' or 'K' (default, preserves prototype layout).
Returns
- NDArray
Array of uninitialized (arbitrary) data with the same shape and type as prototype.
Remarks
empty_like(NDArray, Type, Shape)
Return a new array with the same shape and type as a given array.
public static NDArray empty_like(NDArray prototype, Type dtype = null, Shape shape = default)
Parameters
prototypeNDArrayThe shape and data-type of prototype define these same attributes of the returned array.
dtypeTypeOverrides the data type of the result.
shapeShapeOverrides the shape of the result.
Returns
- NDArray
Array of uninitialized (arbitrary) data with the same shape and type as prototype.
Remarks
empty_like(NDArray, Type, Shape, char)
Return a new array with the same shape and type as a given array.
public static NDArray empty_like(NDArray prototype, Type dtype, Shape shape, char order)
Parameters
prototypeNDArrayThe shape and data-type of prototype define these same attributes of the returned array.
dtypeTypeOverrides the data type of the result.
shapeShapeOverrides the shape of the result.
ordercharMemory layout: 'C', 'F', 'A' or 'K' (default, preserves prototype layout).
Returns
- NDArray
Array of uninitialized (arbitrary) data with the same shape and type as prototype.
Remarks
empty<T>(int[])
Return a new array of given shape and type, without initializing entries.
public static NDArray empty<T>(int[] shape)
Parameters
shapeint[]Shape of the empty array, e.g., (2, 3) or 2.
Returns
- NDArray
Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None.
Type Parameters
T
Remarks
empty<T>(long[])
Return a new array of given shape and type, without initializing entries.
public static NDArray empty<T>(long[] shape)
Parameters
shapelong[]Shape of the empty array, e.g., (2, 3) or 2.
Returns
- NDArray
Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None.
Type Parameters
T
Remarks
equal(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
Return (x1 == x2) element-wise.
Mirrors NumPy's ufunc signature: equal(x1, x2, /, out=None, *, where=True, dtype=None).
A plain call returns a bool-dtype array (the instance is an NDArray<TDType> of bool —
cast or use the == operator for the typed wrapper).
public static NDArray equal(NDArray x1, NDArray x2, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
x1NDArrayInput array.
x2NDArrayInput array.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written; masked-off out slots keep prior contents.
dtypeNPTypeCode?Validate-only (NumPy parity): comparisons have bool loops only — any non-bool request raises the no-loop TypeError.
Returns
Remarks
equal(NDArray, object)
Return (x1 == x2) element-wise with scalar.
public static NDArray<bool> equal(NDArray x1, object x2)
Parameters
Returns
equal(object, NDArray)
Return (x1 == x2) element-wise with scalar on left.
public static NDArray<bool> equal(object x1, NDArray x2)
Parameters
Returns
evaluate(NDExpr, NDArray)
Evaluate an expression tree over NDArrays in ONE fused pass — no intermediate arrays, one read of each operand, one write of the result (NumSharp extension; the NumPy-ecosystem equivalent is numexpr.evaluate).
public static NDArray evaluate(NDExpr expr, NDArray @out = null)
Parameters
exprNDExprExpression with embedded array leaves. NDArrays convert implicitly, so one cast lights up the whole operator set:
NDArray r = np.evaluate((NDExpr)a * b + 2); // a*b+2 fused NDArray d = np.evaluate((NDExpr.Arr(a) - b) / (NDExpr.Arr(a) + b)); NDArray s = np.evaluate(NDExpr.Sum((NDExpr)a * b)); // one-pass sum(a*b)A repeated NDArray reference becomes ONE iterator operand.
outNDArrayOptional pre-allocated result (ufunc out= rules: joins the broadcast but is never stretched; same_kind cast from the resolved dtype; may alias an input — overlap-safe).
Returns
- NDArray
The evaluated array at the tree's NumPy result_type — dtypes match the equivalent unfused NumPy expression node-for-node (NEP50, including weak python-scalar literals). Root reductions (Sum(NDExpr) / Prod / Min / Max / Mean) return a 0-d scalar array.
evaluate(NDExpr, NDArray[], NDArray)
Evaluate an expression built over positional
Input(int) leaves against an explicit operand
list: np.evaluate(NDExpr.Input(0) * NDExpr.Input(1), new[] { a, b }).
public static NDArray evaluate(NDExpr expr, NDArray[] operands, NDArray @out = null)
Parameters
Returns
exp(NDArray)
Base-e exponential, element-wise.
public static NDArray exp(NDArray a)
Parameters
aNDArrayInput value.
Returns
- NDArray
The natural logarithm of x, element-wise. This is a scalar NDArray.
Remarks
exp(NDArray, NDArray, NDArray, NPTypeCode?)
Calculate the exponential of all elements in the input array.
Mirrors NumPy's ufunc signature: exp(x, /, out=None, *, where=True, dtype=None).
public static NDArray exp(NDArray a, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
aNDArrayInput value.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?Explicit loop dtype (NumPy ufunc dtype=): the computation runs at this precision; integer/bool requests raise NumPy's "No loop matching" error.
Returns
Remarks
exp(NDArray, NPTypeCode)
Base-e exponential, element-wise.
public static NDArray exp(NDArray a, NPTypeCode typeCode)
Parameters
aNDArrayInput value.
typeCodeNPTypeCodeThe dtype of the returned NDArray
Returns
- NDArray
The natural logarithm of x, element-wise. This is a scalar NDArray.
Remarks
exp(NDArray, Type)
Base-e exponential, element-wise.
public static NDArray exp(NDArray a, Type dtype)
Parameters
Returns
- NDArray
The natural logarithm of x, element-wise. This is a scalar NDArray.
Remarks
exp2(NDArray)
Calculate 2**p for all p in the input array.
public static NDArray exp2(NDArray a)
Parameters
aNDArrayInput value.
Returns
- NDArray
Element-wise 2 to the power x. This is a scalar if x is a scalar.
Remarks
exp2(NDArray, NDArray, NDArray, NPTypeCode?)
Mirrors NumPy's ufunc signature: exp2(x, /, out=None, *, where=True, dtype=None).
public static NDArray exp2(NDArray a, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
aNDArrayInput array.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?Explicit loop dtype (NumPy ufunc dtype=): selects the loop; the input must be same_kind-castable to it.
Returns
Remarks
exp2(NDArray, NPTypeCode)
Calculate 2**p for all p in the input array.
public static NDArray exp2(NDArray a, NPTypeCode typeCode)
Parameters
aNDArrayInput value.
typeCodeNPTypeCode
Returns
- NDArray
Element-wise 2 to the power x. This is a scalar if x is a scalar.
Remarks
exp2(NDArray, Type)
Calculate 2**p for all p in the input array.
public static NDArray exp2(NDArray a, Type dtype)
Parameters
Returns
- NDArray
Element-wise 2 to the power x. This is a scalar if x is a scalar.
Remarks
expand_dims(NDArray, IEnumerable<int>)
Sequence overload — accepts any IEnumerable<T>, materializes to an array, and delegates to the tuple-axis path.
public static NDArray expand_dims(NDArray a, IEnumerable<int> axis)
Parameters
aNDArrayaxisIEnumerable<int>
Returns
expand_dims(NDArray, int)
public static NDArray expand_dims(NDArray a, int axis)
Parameters
Returns
expand_dims(NDArray, int[])
Expand the shape of an array. Insert new axes that will appear at
the axis positions in the expanded output.
public static NDArray expand_dims(NDArray a, int[] axis)
Parameters
Returns
Remarks
Matches NumPy 2.x: each axis in the tuple is normalized against
the FINAL output ndim (a.ndim + axis.Length). Duplicate
normalized positions raise ArgumentException
("repeated axis"); out-of-range axes throw the same.
Empty axis returns the input unchanged.
expm1(NDArray)
Calculate exp(x) - 1 for all elements in the array.
public static NDArray expm1(NDArray a)
Parameters
aNDArrayInput value.
Returns
- NDArray
Element-wise exponential minus one: out = exp(x) - 1. This is a scalar if x is a scalar.
Remarks
expm1(NDArray, NDArray, NDArray, NPTypeCode?)
Mirrors NumPy's ufunc signature: expm1(x, /, out=None, *, where=True, dtype=None).
public static NDArray expm1(NDArray a, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
aNDArrayInput array.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?Explicit loop dtype (NumPy ufunc dtype=): selects the loop; the input must be same_kind-castable to it.
Returns
Remarks
expm1(NDArray, NPTypeCode)
Calculate exp(x) - 1 for all elements in the array.
public static NDArray expm1(NDArray a, NPTypeCode typeCode)
Parameters
aNDArrayInput value.
typeCodeNPTypeCode
Returns
- NDArray
Element-wise exponential minus one: out = exp(x) - 1. This is a scalar if x is a scalar.
Remarks
expm1(NDArray, Type)
Calculate exp(x) - 1 for all elements in the array.
public static NDArray expm1(NDArray a, Type dtype)
Parameters
Returns
- NDArray
Element-wise exponential minus one: out = exp(x) - 1. This is a scalar if x is a scalar.
Remarks
extract(NDArray, NDArray)
Return the elements of arr that satisfy some
condition. Equivalent to
np.take(np.ravel(arr), np.flatnonzero(np.ravel(condition))) —
i.e. arr.ravel()[condition.ravel()] when condition is boolean.
public static NDArray extract(NDArray condition, NDArray arr)
Parameters
conditionNDArrayArray whose nonzero / True entries indicate the elements of
arrto extract. May be any dtype (treated as truthy via NumPy's "nonzero" semantics). May be any shape — it is ravel'd before alignment witharr.arrNDArrayInput array. May be any shape; it is ravel'd.
Returns
- NDArray
Rank-1 NDArray of values from
arrwhere the corresponding ravel'dconditionentry is truthy. Dtype matchesarr.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.extract.html
Two execution paths:
-
Fast path: bool condition, contig arr + condition,
condition.size <= arr.size. Runs a fused IL kernel (popcount → alloc → SIMD bit-scan + cpblk) avoiding the indices NDArray allocation that the generic path needs. -
Generic path: mirrors NumPy's literal chain
take(ravel(arr), flatnonzero(ravel(condition))). Handles non-bool conditions (any dtype interpreted as nonzero), broadcast / strided / negative-stride sources, and the OOB-True case (raises via take's RAISE mode).
Note that place(NDArray, NDArray, NDArray) is the inverse operation.
eye(int, int?, int, Type, char)
Return a 2-D array with ones on the diagonal and zeros elsewhere.
public static NDArray eye(int N, int? M = null, int k = 0, Type dtype = null, char order = 'C')
Parameters
NintNumber of rows in the output.
Mint?Number of columns in the output. If None, defaults to N.
kintIndex of the diagonal: 0 (the default) refers to the main diagonal, a positive value refers to an upper diagonal, and a negative value to a lower diagonal.
dtypeTypeData-type of the returned array.
ordercharMemory layout: 'C' (row-major, default) or 'F' (column-major).
Returns
- NDArray
An array where all elements are equal to zero, except for the k-th diagonal, whose values are equal to one.
Remarks
find_common_type(NPTypeCode[], NPTypeCode[])
Determine common type following standard coercion rules.
public static NPTypeCode find_common_type(NPTypeCode[] array_types, NPTypeCode[] scalar_types)
Parameters
array_typesNPTypeCode[]A list of dtypes or dtype convertible objects representing arrays. Can be null.
scalar_typesNPTypeCode[]A list of dtypes or dtype convertible objects representing scalars.Can be null.
Returns
- NPTypeCode
The common data type, which is the maximum of array_types ignoring scalar_types, unless the maximum of scalar_types is of a different kind (dtype.kind). If the kind is not understood, then None is returned.
Remarks
find_common_type(NPTypeCode[], Type[])
Determine common type following standard coercion rules.
public static NPTypeCode find_common_type(NPTypeCode[] array_types, Type[] scalar_types)
Parameters
array_typesNPTypeCode[]A list of dtypes or dtype convertible objects representing arrays. Can be null.
scalar_typesType[]A list of dtypes or dtype convertible objects representing scalars.Can be null.
Returns
- NPTypeCode
The common data type, which is the maximum of array_types ignoring scalar_types, unless the maximum of scalar_types is of a different kind (dtype.kind). If the kind is not understood, then None is returned.
Remarks
find_common_type(params string[])
Resolves to which type should the output be.
public static NPTypeCode find_common_type(params string[] involvedTypes)
Parameters
involvedTypesstring[]
Returns
find_common_type(string[], string[])
Determine common type following standard coercion rules.
public static NPTypeCode find_common_type(string[] array_types, string[] scalar_types)
Parameters
array_typesstring[]A list of dtypes or dtype convertible objects representing arrays. Can be null.
scalar_typesstring[]A list of dtypes or dtype convertible objects representing scalars.Can be null.
Returns
- NPTypeCode
The common data type, which is the maximum of array_types ignoring scalar_types, unless the maximum of scalar_types is of a different kind (dtype.kind). If the kind is not understood, then None is returned.
Remarks
find_common_type(Type[])
Determine common type following standard coercion rules.
public static NPTypeCode find_common_type(Type[] array_types)
Parameters
array_typesType[]A list of dtypes or dtype convertible objects representing arrays. Can be null.
Returns
- NPTypeCode
The common data type, which is the maximum of array_types ignoring scalar_types, unless the maximum of scalar_types is of a different kind (dtype.kind). If the kind is not understood, then None is returned.
Remarks
find_common_type(Type[], NPTypeCode[])
Determine common type following standard coercion rules.
public static NPTypeCode find_common_type(Type[] array_types, NPTypeCode[] scalar_types)
Parameters
array_typesType[]A list of dtypes or dtype convertible objects representing arrays. Can be null.
scalar_typesNPTypeCode[]A list of dtypes or dtype convertible objects representing scalars.Can be null.
Returns
- NPTypeCode
The common data type, which is the maximum of array_types ignoring scalar_types, unless the maximum of scalar_types is of a different kind (dtype.kind). If the kind is not understood, then None is returned.
Remarks
find_common_type(Type[], Type[])
Determine common type following standard coercion rules.
public static NPTypeCode find_common_type(Type[] array_types, Type[] scalar_types)
Parameters
array_typesType[]A list of dtypes or dtype convertible objects representing arrays. Can be null.
scalar_typesType[]A list of dtypes or dtype convertible objects representing scalars.Can be null.
Returns
- NPTypeCode
The common data type, which is the maximum of array_types ignoring scalar_types, unless the maximum of scalar_types is of a different kind (dtype.kind). If the kind is not understood, then None is returned.
Remarks
finfo(NDArray)
Machine limits for floating point types.
public static finfo finfo(NDArray arr)
Parameters
arrNDArrayAn NDArray with floating point dtype.
Returns
- finfo
An finfo object describing the array's floating point type limits.
Examples
var a = np.array(new double[] {1.0, 2.0, 3.0});
var info = np.finfo(a);
Console.WriteLine(info.bits); // 64
Exceptions
- ArgumentNullException
Thrown if arr is null.
finfo(NPTypeCode)
Machine limits for floating point types.
public static finfo finfo(NPTypeCode typeCode)
Parameters
typeCodeNPTypeCodeA floating point type code.
Returns
- finfo
An finfo object describing the floating point type limits.
Examples
var info = np.finfo(NPTypeCode.Double);
Console.WriteLine(info.bits); // 64
Console.WriteLine(info.eps); // ~2.22e-16
Console.WriteLine(info.precision); // 15
Remarks
finfo(string)
Machine limits for floating point types.
public static finfo finfo(string dtypeName)
Parameters
dtypeNamestringA dtype string (e.g., "float32", "float64", "double").
Returns
- finfo
An finfo object describing the floating point type limits.
Examples
var info = np.finfo("float64");
Console.WriteLine(info.bits); // 64
Exceptions
- ArgumentException
Thrown if dtypeName is not a valid floating point dtype.
finfo(Type)
Machine limits for floating point types.
public static finfo finfo(Type type)
Parameters
typeTypeA CLR floating point type.
Returns
- finfo
An finfo object describing the floating point type limits.
finfo<T>()
Machine limits for floating point types.
public static finfo finfo<T>() where T : struct
Returns
- finfo
An finfo object describing the floating point type limits.
Type Parameters
TA floating point type (float, double, decimal).
Examples
var info = np.finfo<double>();
Console.WriteLine(info.bits); // 64
flatnonzero(NDArray)
Return indices that are non-zero in the flattened version of a.
This is equivalent to np.nonzero(np.ravel(a))[0].
public static NDArray<long> flatnonzero(NDArray a)
Parameters
aNDArrayInput data.
Returns
- NDArray<long>
1-D NDArray<TDType> of long (NumPy
intp) containing the indices of elements ofa.ravel()that are non-zero. For 0-d input, returns[0]when the value is truthy and an empty array otherwise. For empty input, returns an empty 1-D array.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.flatnonzero.html
Faster than the literal composition nonzero(ravel(a))[0]: the engine
runs the SIMD popcount + bit-scan straight into the 1-D result buffer
without materializing the per-axis coordinate arrays produced by
nonzero(NDArray). For multi-dim inputs the cost is the same as a 1-D
input of equal element count (the layout is collapsed by materializing to
C-contig when needed).
floor(NDArray, NDArray, NDArray, NPTypeCode?)
public static NDArray floor(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayoutNDArraywhereNDArraydtypeNPTypeCode?
Returns
floor(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray floor(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayInput array.
dtypeNPTypeCodeThe loop dtype the computation should run in.
Returns
Remarks
floor(NDArray, Type)
public static NDArray floor(NDArray x, Type dtype)
Parameters
Returns
floor_divide(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
Return the largest integer smaller or equal to the division of the inputs.
It is equivalent to the Python // operator.
Mirrors NumPy's ufunc signature: floor_divide(x1, x2, /, out=None, *, where=True, dtype=None).
public static NDArray floor_divide(NDArray x1, NDArray x2, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
x1NDArrayDividend array.
x2NDArrayDivisor array.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?Explicit loop dtype (NumPy ufunc dtype=): the computation runs in this dtype; inputs must be same_kind-castable to it.
Returns
- NDArray
y = floor(x1/x2). This is a scalar if both x1 and x2 are scalars.
Remarks
floor_divide(NDArray, NDArray, NPTypeCode)
Return the largest integer smaller or equal to the division of the inputs. It is equivalent to the Python // operator.
public static NDArray floor_divide(NDArray x1, NDArray x2, NPTypeCode typeCode)
Parameters
x1NDArrayDividend array.
x2NDArrayDivisor array.
typeCodeNPTypeCodeThe dtype of the returned NDArray.
Returns
- NDArray
y = floor(x1/x2). This is a scalar if both x1 and x2 are scalars.
floor_divide(NDArray, NDArray, Type)
Return the largest integer smaller or equal to the division of the inputs. It is equivalent to the Python // operator.
public static NDArray floor_divide(NDArray x1, NDArray x2, Type dtype)
Parameters
Returns
- NDArray
y = floor(x1/x2). This is a scalar if both x1 and x2 are scalars.
floor_divide(NDArray, object)
Return the largest integer smaller or equal to the division of the inputs. Scalar or array-like divisor version.
public static NDArray floor_divide(NDArray x1, object x2)
Parameters
Returns
- NDArray
y = floor(x1/x2).
floor_divide(NDArray, object, NPTypeCode)
Return the largest integer smaller or equal to the division of the inputs. Scalar or array-like divisor version.
public static NDArray floor_divide(NDArray x1, object x2, NPTypeCode typeCode)
Parameters
x1NDArrayDividend array.
x2objectScalar or array-like divisor.
typeCodeNPTypeCodeThe dtype of the returned NDArray.
Returns
- NDArray
y = floor(x1/x2).
floor_divide(NDArray, object, Type)
Return the largest integer smaller or equal to the division of the inputs. Scalar or array-like divisor version.
public static NDArray floor_divide(NDArray x1, object x2, Type dtype)
Parameters
x1NDArrayDividend array.
x2objectScalar or array-like divisor.
dtypeTypeThe dtype of the returned NDArray.
Returns
- NDArray
y = floor(x1/x2).
fmax(NDArray, NDArray, NDArray)
Element-wise maximum of array elements, ignoring NaNs, writing into @out.
public static NDArray fmax(NDArray x1, NDArray x2, NDArray @out)
Parameters
Returns
fmax(NDArray, NDArray, NPTypeCode?)
Element-wise maximum of array elements, ignoring NaNs. Compare two arrays and returns a new array containing the element-wise maxima. If one of the elements being compared is a NaN, then the non-nan element is returned. If both elements are NaNs then the first is returned. The net effect is that NaNs are ignored when possible.
public static NDArray fmax(NDArray x1, NDArray x2, NPTypeCode? dtype = null)
Parameters
x1NDArrayThe arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).
x2NDArrayThe arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).
dtypeNPTypeCode?Loop dtype (NumPy ufunc dtype=): the comparison runs at this precision.
Returns
- NDArray
The maximum of x1 and x2, element-wise, ignoring NaNs.
fmax(NDArray, NDArray, Type)
Element-wise maximum of array elements, ignoring NaNs. See fmax(NDArray, NDArray, NPTypeCode?).
public static NDArray fmax(NDArray x1, NDArray x2, Type dtype)
Parameters
Returns
fmin(NDArray, NDArray, NDArray)
Element-wise minimum of array elements, ignoring NaNs, writing into @out.
public static NDArray fmin(NDArray x1, NDArray x2, NDArray @out)
Parameters
Returns
fmin(NDArray, NDArray, NPTypeCode?)
Element-wise minimum of array elements, ignoring NaNs. Compare two arrays and returns a new array containing the element-wise minima. If one of the elements being compared is a NaN, then the non-nan element is returned. If both elements are NaNs then the first is returned. The net effect is that NaNs are ignored when possible.
public static NDArray fmin(NDArray x1, NDArray x2, NPTypeCode? dtype = null)
Parameters
x1NDArrayThe arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).
x2NDArrayThe arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).
dtypeNPTypeCode?Loop dtype (NumPy ufunc dtype=): the comparison runs at this precision.
Returns
- NDArray
The minimum of x1 and x2, element-wise, ignoring NaNs.
fmin(NDArray, NDArray, Type)
Element-wise minimum of array elements, ignoring NaNs. See fmin(NDArray, NDArray, NPTypeCode?).
public static NDArray fmin(NDArray x1, NDArray x2, Type dtype)
Parameters
Returns
format_float_positional(double, int?, bool, bool, char, bool, int?, int?, int?)
Format a floating-point scalar as a decimal string in positional notation
(NumPy's np.format_float_positional).
public static string format_float_positional(double x, int? precision = null, bool unique = true, bool fractional = true, char trim = 'k', bool sign = false, int? pad_left = null, int? pad_right = null, int? min_digits = null)
Parameters
xdoubleprecisionint?uniqueboolfractionalbooltrimcharsignboolpad_leftint?pad_rightint?min_digitsint?
Returns
format_float_scientific(double, int?, bool, char, bool, int?, int?, int?)
Format a floating-point scalar as a decimal string in scientific notation
(NumPy's np.format_float_scientific).
public static string format_float_scientific(double x, int? precision = null, bool unique = true, char trim = 'k', bool sign = false, int? pad_left = null, int? exp_digits = null, int? min_digits = null)
Parameters
xdoubleprecisionint?uniquebooltrimcharsignboolpad_leftint?exp_digitsint?min_digitsint?
Returns
frombuffer(ArraySegment<byte>, NPTypeCode, long)
Interpret an ArraySegment as a 1-dimensional array.
public static NDArray frombuffer(ArraySegment<byte> segment, NPTypeCode dtype, long count = -1)
Parameters
segmentArraySegment<byte>dtypeNPTypeCodecountlong
Returns
frombuffer(ArraySegment<byte>, Type, long)
Interpret an ArraySegment as a 1-dimensional array. Uses the segment's Offset and Count automatically.
public static NDArray frombuffer(ArraySegment<byte> segment, Type dtype = null, long count = -1)
Parameters
segmentArraySegment<byte>The array segment to interpret.
dtypeTypeData-type of the returned array. Default is float64.
countlongNumber of items to read. -1 means all data in the segment.
Returns
- NDArray
1-dimensional NDArray viewing the segment's data.
frombuffer(byte[], NPTypeCode, long, long)
Interpret a buffer as a 1-dimensional array.
public static NDArray frombuffer(byte[] buffer, NPTypeCode dtype, long count = -1, long offset = 0)
Parameters
bufferbyte[]An object that exposes the buffer interface.
dtypeNPTypeCodeData-type of the returned array. Default is float64.
countlongNumber of items to read. -1 means all data in the buffer.
offsetlongStart reading the buffer from this offset (in bytes). Default is 0.
Returns
- NDArray
1-dimensional NDArray with data interpreted from the buffer.
frombuffer(byte[], string, long, long)
Interpret a buffer as a 1-dimensional array.
public static NDArray frombuffer(byte[] buffer, string dtype, long count = -1, long offset = 0)
Parameters
bufferbyte[]An object that exposes the buffer interface.
dtypestringData-type string (e.g., ">u4" for big-endian uint32).
countlongNumber of items to read. -1 means all data in the buffer.
offsetlongStart reading the buffer from this offset (in bytes). Default is 0.
Returns
- NDArray
1-dimensional NDArray with data interpreted from the buffer.
Remarks
Note: Big-endian dtype strings (">u4", ">i4", etc.) require a COPY to perform byte swapping. Little-endian and native endian create views without copying.
frombuffer(byte[], Type, long, long)
Interpret a buffer as a 1-dimensional array.
public static NDArray frombuffer(byte[] buffer, Type dtype = null, long count = -1, long offset = 0)
Parameters
bufferbyte[]An object that exposes the buffer interface.
dtypeTypeData-type of the returned array. Default is float64.
countlongNumber of items to read. -1 means all data in the buffer.
offsetlongStart reading the buffer from this offset (in bytes). Default is 0.
Returns
- NDArray
1-dimensional NDArray with data interpreted from the buffer.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.frombuffer.html
Like NumPy, this creates a VIEW of the buffer (pins the array, shares memory). Modifications to the NDArray will affect the original buffer. The buffer must stay alive while the NDArray is in use.
frombuffer(nint, long, NPTypeCode, long, long, Action)
Interpret unmanaged memory at a pointer as a 1-dimensional array.
public static NDArray frombuffer(nint address, long byteLength, NPTypeCode dtype, long count = -1, long offset = 0, Action dispose = null)
Parameters
Returns
frombuffer(nint, long, Type, long, long, Action)
Interpret unmanaged memory at a pointer as a 1-dimensional array.
public static NDArray frombuffer(nint address, long byteLength, Type dtype = null, long count = -1, long offset = 0, Action dispose = null)
Parameters
addressnintPointer to the start of the buffer.
byteLengthlongTotal length of the buffer in bytes.
dtypeTypeData-type of the returned array. Default is float64.
countlongNumber of items to read. -1 means all data.
offsetlongByte offset into the buffer. Default is 0.
disposeActionOptional cleanup action called when NDArray is disposed. Use to transfer ownership: dispose: () => Marshal.FreeHGlobal(ptr) If null, caller is responsible for memory lifetime (view semantics).
Returns
- NDArray
1-dimensional NDArray viewing/owning the memory.
Examples
// View only (caller manages lifetime): var arr = np.frombuffer(ptr, length, typeof(float));
// Take ownership (NumSharp frees on dispose): var ptr = Marshal.AllocHGlobal(1024); var arr = np.frombuffer(ptr, 1024, typeof(float), dispose: () => Marshal.FreeHGlobal(ptr));
frombuffer(Memory<byte>, NPTypeCode, long, long)
Interpret a Memory<byte> as a 1-dimensional array.
public static NDArray frombuffer(Memory<byte> memory, NPTypeCode dtype, long count = -1, long offset = 0)
Parameters
memoryMemory<byte>dtypeNPTypeCodecountlongoffsetlong
Returns
frombuffer(Memory<byte>, Type, long, long)
Interpret a Memory<byte> as a 1-dimensional array. Creates a view if backed by an array, otherwise copies.
public static NDArray frombuffer(Memory<byte> memory, Type dtype = null, long count = -1, long offset = 0)
Parameters
memoryMemory<byte>The memory to interpret.
dtypeTypeData-type of the returned array. Default is float64.
countlongNumber of items to read. -1 means all data.
offsetlongByte offset within the memory. Default is 0.
Returns
- NDArray
1-dimensional NDArray.
frombuffer(ReadOnlySpan<byte>, NPTypeCode, long, long)
Interpret a ReadOnlySpan as a 1-dimensional array. Note: ReadOnlySpan cannot be pinned, so this always creates a copy.
public static NDArray frombuffer(ReadOnlySpan<byte> buffer, NPTypeCode dtype, long count = -1, long offset = 0)
Parameters
bufferReadOnlySpan<byte>dtypeNPTypeCodecountlongoffsetlong
Returns
frombuffer(ReadOnlySpan<byte>, Type, long, long)
Interpret a ReadOnlySpan as a 1-dimensional array. Note: ReadOnlySpan cannot be pinned, so this always creates a copy.
public static NDArray frombuffer(ReadOnlySpan<byte> buffer, Type dtype = null, long count = -1, long offset = 0)
Parameters
bufferReadOnlySpan<byte>dtypeTypecountlongoffsetlong
Returns
frombuffer(void*, long, NPTypeCode, long, long, Action)
Interpret unmanaged memory at a pointer as a 1-dimensional array.
public static NDArray frombuffer(void* address, long byteLength, NPTypeCode dtype, long count = -1, long offset = 0, Action dispose = null)
Parameters
Returns
frombuffer(void*, long, Type, long, long, Action)
Interpret unmanaged memory at a pointer as a 1-dimensional array.
public static NDArray frombuffer(void* address, long byteLength, Type dtype = null, long count = -1, long offset = 0, Action dispose = null)
Parameters
addressvoid*Pointer to the start of the buffer.
byteLengthlongTotal length of the buffer in bytes.
dtypeTypeData-type of the returned array. Default is float64.
countlongNumber of items to read. -1 means all data.
offsetlongByte offset into the buffer. Default is 0.
disposeActionOptional cleanup action called when NDArray is disposed.
Returns
- NDArray
1-dimensional NDArray viewing/owning the memory.
frombuffer<TSource>(TSource[], NPTypeCode, long, long)
Reinterpret a typed array as a different dtype.
public static NDArray frombuffer<TSource>(TSource[] array, NPTypeCode dtype, long count = -1, long offset = 0) where TSource : unmanaged
Parameters
arrayTSource[]dtypeNPTypeCodecountlongoffsetlong
Returns
Type Parameters
TSource
frombuffer<TSource>(TSource[], Type, long, long)
Reinterpret a typed array as a different dtype. Like NumPy's view() but via frombuffer semantics.
public static NDArray frombuffer<TSource>(TSource[] array, Type dtype = null, long count = -1, long offset = 0) where TSource : unmanaged
Parameters
arrayTSource[]The source array to reinterpret.
dtypeTypeTarget data-type. Default preserves source type.
countlongNumber of items of target dtype. -1 for all.
offsetlongByte offset. Default is 0.
Returns
- NDArray
1-dimensional NDArray viewing the array as the target dtype.
Type Parameters
TSourceSource element type.
Examples
var ints = new int[] { 1, 2, 3, 4 }; var asBytes = np.frombuffer(ints, typeof(byte)); // 16 bytes var asFloats = np.frombuffer(ints, typeof(float)); // 4 floats (same bits)
fromfile(string, NPTypeCode)
Construct an array from data in a text or binary file. A highly efficient way of reading binary data with a known data-type, as well as parsing simply formatted text files. Data written using the tofile method can be read using this function.
public static NDArray fromfile(string file, NPTypeCode dtype)
Parameters
filestringfilename.
dtypeNPTypeCodeData type of the returned array. For binary files, it is used to determine the size and byte-order of the items in the file.
Returns
Remarks
fromfile(string, Type)
Construct an array from data in a text or binary file. A highly efficient way of reading binary data with a known data-type, as well as parsing simply formatted text files. Data written using the tofile method can be read using this function.
public static NDArray fromfile(string file, Type dtype)
Parameters
filestringfilename.
dtypeTypeData type of the returned array. For binary files, it is used to determine the size and byte-order of the items in the file.
Returns
Remarks
full(Shape, object, NPTypeCode)
Return a new array of given shape and type, filled with fill_value.
public static NDArray full(Shape shape, object fill_value, NPTypeCode typeCode)
Parameters
shapeShapeShape of the array, e.g., (2, 3) or 2.
fill_valueobjectFill value (scalar).
typeCodeNPTypeCodeThe desired data-type for the array.
Returns
- NDArray
Array of fill_value with the given shape, dtype, and order.
Remarks
full(Shape, object, Type)
Return a new array of given shape and type, filled with fill_value.
public static NDArray full(Shape shape, object fill_value, Type dtype = null)
Parameters
shapeShapeShape of the array, e.g., (2, 3) or 2.
fill_valueobjectFill value (scalar).
dtypeTypeThe desired data-type for the array. Default infers from fill_value.
Returns
- NDArray
Array of fill_value with the given shape, dtype, and order.
Remarks
full(int[], object)
Return a new array of given shape and type, filled with fill_value.
public static NDArray full(int[] shape, object fill_value)
Parameters
Returns
- NDArray
Array of fill_value with the given shape, dtype, and order.
Remarks
full(long[], object)
Return a new array of given shape and type, filled with fill_value.
public static NDArray full(long[] shape, object fill_value)
Parameters
Returns
- NDArray
Array of fill_value with the given shape, dtype, and order.
Remarks
full_like(NDArray, object, Type)
Return a full array with the same shape and type as a given array.
public static NDArray full_like(NDArray a, object fill_value, Type dtype = null)
Parameters
aNDArrayThe shape and data-type of a define these same attributes of the returned array.
fill_valueobjectFill value.
dtypeTypeOverrides the data type of the result.
Returns
- NDArray
Array of fill_value with the same shape and type as a.
Remarks
full_like(NDArray, object, Type, char)
Return a full array with the same shape and type as a given array.
public static NDArray full_like(NDArray a, object fill_value, Type dtype, char order)
Parameters
aNDArrayThe shape and data-type of a define these same attributes of the returned array.
fill_valueobjectFill value.
dtypeTypeOverrides the data type of the result.
ordercharMemory layout: 'C', 'F', 'A' or 'K' (default, preserves source layout).
Returns
- NDArray
Array of fill_value with the same shape and type as a.
Remarks
full<T>(int[], object)
Return a new array of given shape and type, filled with fill_value.
public static NDArray full<T>(int[] shape, object fill_value) where T : unmanaged
Parameters
Returns
- NDArray
Array of fill_value with the given shape, dtype, and order.
Type Parameters
T
Remarks
full<T>(long[], object)
Return a new array of given shape and type, filled with fill_value.
public static NDArray full<T>(long[] shape, object fill_value) where T : unmanaged
Parameters
Returns
- NDArray
Array of fill_value with the given shape, dtype, and order.
Type Parameters
T
Remarks
get_printoptions()
Return the current print options as a dictionary (NumPy's np.get_printoptions).
public static IReadOnlyDictionary<string, object> get_printoptions()
Returns
Remarks
greater(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
Return (x1 > x2) element-wise.
Mirrors NumPy's ufunc signature: greater(x1, x2, /, out=None, *, where=True, dtype=None).
A plain call returns a bool-dtype array (the instance is an NDArray<TDType> of bool —
cast or use the > operator for the typed wrapper).
public static NDArray greater(NDArray x1, NDArray x2, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
x1NDArrayInput array.
x2NDArrayInput array.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written; masked-off out slots keep prior contents.
dtypeNPTypeCode?Validate-only (NumPy parity): comparisons have bool loops only — any non-bool request raises the no-loop TypeError.
Returns
Remarks
greater(NDArray, object)
Return (x1 > x2) element-wise with scalar.
public static NDArray<bool> greater(NDArray x1, object x2)
Parameters
Returns
greater(object, NDArray)
Return (x1 > x2) element-wise with scalar on left.
public static NDArray<bool> greater(object x1, NDArray x2)
Parameters
Returns
greater_equal(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
Return (x1 >= x2) element-wise.
Mirrors NumPy's ufunc signature: greater_equal(x1, x2, /, out=None, *, where=True, dtype=None).
A plain call returns a bool-dtype array (the instance is an NDArray<TDType> of bool —
cast or use the >= operator for the typed wrapper).
public static NDArray greater_equal(NDArray x1, NDArray x2, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
x1NDArrayInput array.
x2NDArrayInput array.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written; masked-off out slots keep prior contents.
dtypeNPTypeCode?Validate-only (NumPy parity): comparisons have bool loops only — any non-bool request raises the no-loop TypeError.
Returns
Remarks
greater_equal(NDArray, object)
Return (x1 >= x2) element-wise with scalar.
public static NDArray<bool> greater_equal(NDArray x1, object x2)
Parameters
Returns
greater_equal(object, NDArray)
Return (x1 >= x2) element-wise with scalar on left.
public static NDArray<bool> greater_equal(object x1, NDArray x2)
Parameters
Returns
hsplit(NDArray, int)
Split an array into multiple sub-arrays horizontally (column-wise).
public static NDArray[] hsplit(NDArray ary, int indices_or_sections)
Parameters
aryNDArrayArray to be divided into sub-arrays.
indices_or_sectionsintIf an integer, N, the array will be divided into N equal arrays along the axis. If such a split is not possible, an error is raised.
Returns
- NDArray[]
A list of sub-arrays as views into ary.
Remarks
For 1-D arrays, splits along axis 0. For 2-D+ arrays, splits along axis 1 (columns). https://numpy.org/doc/stable/reference/generated/numpy.hsplit.html
hsplit(NDArray, int[])
Split an array into multiple sub-arrays horizontally (column-wise).
public static NDArray[] hsplit(NDArray ary, int[] indices)
Parameters
aryNDArrayArray to be divided into sub-arrays.
indicesint[]A 1-D array of sorted integers indicating where along the axis the array is split. For example, [2, 3] would result in ary[:2], ary[2:3], ary[3:].
Returns
- NDArray[]
A list of sub-arrays as views into ary.
Remarks
For 1-D arrays, splits along axis 0. For 2-D+ arrays, splits along axis 1 (columns). https://numpy.org/doc/stable/reference/generated/numpy.hsplit.html
hstack(params NDArray[])
Stack arrays in sequence horizontally (column wise). This is equivalent to concatenation along the second axis, except for 1-D arrays where it concatenates along the first axis.Rebuilds arrays divided by hsplit. This function makes most sense for arrays with up to 3 dimensions.For instance, for pixel-data with a height(first axis), width(second axis), and r/g/b channels(third axis). The functions concatenate, stack and block provide more general stacking and concatenation operations.
public static NDArray hstack(params NDArray[] tup)
Parameters
tupNDArray[]The arrays must have the same shape along all but the second axis, except 1-D arrays which can be any length.
Returns
- NDArray
The array formed by stacking the given arrays.
Remarks
identity(int, Type)
Return the identity array. The identity array is a square array with ones on the main diagonal.
public static NDArray identity(int n, Type dtype = null)
Parameters
nintNumber of rows (and columns) in n x n output.
dtypeTypeData-type of the output. Defaults to double.
Returns
- NDArray
n x n array with its main diagonal set to one, and all other elements 0.
Remarks
iinfo(NDArray)
Machine limits for integer types.
public static iinfo iinfo(NDArray arr)
Parameters
arrNDArrayAn NDArray with integer dtype.
Returns
- iinfo
An iinfo object describing the array's integer type limits.
Examples
var a = np.array(new int[] {1, 2, 3});
var info = np.iinfo(a);
Console.WriteLine(info.bits); // 32
Exceptions
- ArgumentNullException
Thrown if arr is null.
iinfo(NPTypeCode)
Machine limits for integer types.
public static iinfo iinfo(NPTypeCode typeCode)
Parameters
typeCodeNPTypeCodeAn integer type code.
Returns
- iinfo
An iinfo object describing the integer type limits.
Examples
var info = np.iinfo(NPTypeCode.Int32);
Console.WriteLine(info.bits); // 32
Console.WriteLine(info.min); // -2147483648
Console.WriteLine(info.max); // 2147483647
Remarks
iinfo(string)
Machine limits for integer types.
public static iinfo iinfo(string dtypeName)
Parameters
dtypeNamestringA dtype string (e.g., "int32", "uint8", "bool").
Returns
- iinfo
An iinfo object describing the integer type limits.
Examples
var info = np.iinfo("int32");
Console.WriteLine(info.bits); // 32
Exceptions
- ArgumentException
Thrown if dtypeName is not a valid integer dtype.
iinfo(Type)
Machine limits for integer types.
public static iinfo iinfo(Type type)
Parameters
typeTypeA CLR integer type.
Returns
- iinfo
An iinfo object describing the integer type limits.
iinfo<T>()
Machine limits for integer types.
public static iinfo iinfo<T>() where T : struct
Returns
- iinfo
An iinfo object describing the integer type limits.
Type Parameters
TAn integer type (bool, byte, short, ushort, int, uint, long, ulong, char).
Examples
var info = np.iinfo<int>();
Console.WriteLine(info.bits); // 32
indices(int[], NPTypeCode)
Return an array representing the indices of a grid. Dense form — for the sparse form, see indices_sparse(int[], NPTypeCode).
public static NDArray indices(int[] dimensions, NPTypeCode dtype = NPTypeCode.Int64)
Parameters
dimensionsint[]Shape of the grid.
dtypeNPTypeCodeElement type of the result. Default is long.
Returns
- NDArray
Single dense array of shape
(len(dimensions), *dimensions). The d-th sub-array contains the d-th coordinate of each output position.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.indices.html
NumPy's sparse=True mode is exposed as the separate method
indices_sparse(int[], NPTypeCode) — C# can't change return type based on a
parameter the way Python's dynamic typing does, so splitting the API is
clearer than throwing from a shared signature.
indices_sparse(int[], NPTypeCode)
Sparse counterpart to indices(int[], NPTypeCode) — returns a tuple of
broadcast-shaped arrays where each axis-d array has shape
(1, …, 1, dimensions[d], 1, …, 1). Equivalent to NumPy's
np.indices(dimensions, sparse=True).
public static NDArray[] indices_sparse(int[] dimensions, NPTypeCode dtype = NPTypeCode.Int64)
Parameters
dimensionsint[]dtypeNPTypeCode
Returns
- NDArray[]
insert(NDArray, NDArray, NDArray, int?)
NDArray-typed obj. Dispatches:
- 0-D / 1-element integer ⇒ scalar single-index path.
- 1-D bool ⇒ flatnonzero(NDArray) ⇒ multi-index path.
- 1-D integer ⇒ multi-index path.
- > 1-D ⇒ ArgumentException matching NumPy's "index array argument obj to insert must be one dimensional or scalar".
public static NDArray insert(NDArray arr, NDArray obj, NDArray values, int? axis = null)
Parameters
Returns
insert(NDArray, NDArray, object, int?)
NDArray-obj overload accepting a scalar value.
public static NDArray insert(NDArray arr, NDArray obj, object value, int? axis = null)
Parameters
Returns
insert(NDArray, Slice, NDArray, int?)
Slice-obj overload. obj is expanded via
Python slice.indices(N) into an indices array, then the
multi-index branch runs.
public static NDArray insert(NDArray arr, Slice obj, NDArray values, int? axis = null)
Parameters
Returns
insert(NDArray, Slice, object, int?)
Slice-obj overload accepting a scalar value.
public static NDArray insert(NDArray arr, Slice obj, object value, int? axis = null)
Parameters
Returns
insert(NDArray, int, NDArray, int?)
Insert values along axis
before the position obj. Scalar-obj path.
public static NDArray insert(NDArray arr, int obj, NDArray values, int? axis = null)
Parameters
Returns
Remarks
insert(NDArray, int, object, int?)
int-overload accepting a scalar value.
public static NDArray insert(NDArray arr, int obj, object value, int? axis = null)
Parameters
Returns
insert(NDArray, int[], NDArray, int?)
int[]-obj overload. Always routes through the multi-index branch
(NumPy parity: np.insert(arr, [1], v) != np.insert(arr, 1, v)
when v has multiple axes, even though both have one insertion point).
public static NDArray insert(NDArray arr, int[] obj, NDArray values, int? axis = null)
Parameters
Returns
insert(NDArray, int[], object, int?)
int[]-obj overload accepting a scalar value.
public static NDArray insert(NDArray arr, int[] obj, object value, int? axis = null)
Parameters
Returns
insert(NDArray, long, NDArray, int?)
Long-index overload of insert(NDArray, int, NDArray, int?).
public static NDArray insert(NDArray arr, long obj, NDArray values, int? axis = null)
Parameters
Returns
insert(NDArray, long, object, int?)
Scalar-obj overload accepting a scalar value (NumPy: np.insert(a, 1, 99)).
Broadcasts the value to the required shape using arr.dtype.
public static NDArray insert(NDArray arr, long obj, object value, int? axis = null)
Parameters
Returns
insert(NDArray, long[], NDArray, int?)
long[]-obj overload.
public static NDArray insert(NDArray arr, long[] obj, NDArray values, int? axis = null)
Parameters
Returns
insert(NDArray, long[], object, int?)
long[]-obj overload accepting a scalar value.
public static NDArray insert(NDArray arr, long[] obj, object value, int? axis = null)
Parameters
Returns
invert(NDArray, NDArray, NDArray, NPTypeCode?)
Compute bit-wise inversion, or bit-wise NOT, element-wise. Computes the bit-wise NOT of the underlying binary representation of the integers in the input arrays.For signed integer inputs, the two's complement is returned. In a two's-complement system negative numbers are represented by the two's complement of the absolute value.
public static NDArray invert(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayOnly integer and boolean types are handled.
outNDArraywhereNDArraydtypeNPTypeCode?
Returns
- NDArray
Result. This is a scalar if x is a scalar.
Remarks
invert(NDArray, NPTypeCode)
Compute bit-wise inversion in outType — positional-dtype
convenience overload (NumPy accepts dtype only as a keyword).
public static NDArray invert(NDArray x, NPTypeCode outType)
Parameters
xNDArrayoutTypeNPTypeCode
Returns
Remarks
invert(NDArray, Type)
Compute bit-wise inversion, or bit-wise NOT, element-wise.
public static NDArray invert(NDArray x, Type outType)
Parameters
xNDArrayOnly integer and boolean types are handled.
outTypeTypeThe dtype the returned ndarray should be of.
Returns
- NDArray
Result. This is a scalar if x is a scalar.
Remarks
isclose(NDArray, NDArray, double, double, bool)
Returns a boolean array where two arrays are element-wise equal within a
tolerance.
The tolerance values are positive, typically very small numbers.The
relative difference (rtol * abs(b)) and the absolute difference
atol are added together to compare against the absolute difference
between a and b.
Warning: The default atol is not appropriate for comparing numbers
that are much smaller than one(see Notes).
See also allclose(NDArray, NDArray, double, double, bool)
Notes: For finite values, isclose uses the following equation to test whether two floating point values are equivalent.
absolute(`a` - `b`) less than or equal to (`atol` + `rtol` * absolute(`b`))
Unlike the built-in math.isclose, the above equation is not symmetric
in a and b -- it assumes b is the reference value -- so that
isclose(a, b) might be different from isclose(b, a). Furthermore,
the default value of atol is not zero, and is used to determine what
small values should be considered close to zero.The default value is
appropriate for expected values of order unity: if the expected values
are significantly smaller than one, it can result in false positives.
atol should be carefully selected for the use case at hand. A zero value
for atol will result in False if either a or b is zero.
public static NDArray<bool> isclose(NDArray a, NDArray b, double rtol = 1E-05, double atol = 1E-08, bool equal_nan = false)
Parameters
aNDArrayInput array to compare with b
bNDArrayInput array to compare with a.
rtoldoubleThe relative tolerance parameter(see Notes)
atoldoubleThe absolute tolerance parameter(see Notes)
equal_nanboolWhether to compare NaN's as equal. If True, NaN's in
awill be considered equal to NaN's inbin the output array.
Returns
- NDArray<bool>
Returns a boolean array of where
aandbare equal within the given tolerance.If bothaandbare scalars, returns a single boolean value.
iscomplex(NDArray)
Returns a bool array, where True if input element is complex.
public static NDArray iscomplex(NDArray a)
Parameters
aNDArrayInput array.
Returns
- NDArray
Boolean array of same shape, True where element has non-zero imaginary part.
Examples
var a = np.array(new int[] {1, 2, 3});
np.iscomplex(a) // [False, False, False]
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.iscomplex.html
For non-complex arrays, all elements are considered not complex. For complex arrays, elements with non-zero imaginary part are complex.
iscomplexobj(NDArray)
Return True if x is a complex type or an array of complex numbers.
public static bool iscomplexobj(NDArray a)
Parameters
aNDArrayInput array or scalar.
Returns
- bool
True if the array's dtype is complex.
Examples
var a = np.array(new int[] {1, 2, 3});
np.iscomplexobj(a) // False (dtype is int, not complex)
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.iscomplexobj.html
The type of the input is checked, not the value.
isdtype(NDArray, string)
Returns True if the array's dtype is of a specified category.
public static bool isdtype(NDArray arr, string kind)
Parameters
Returns
- bool
True if array's dtype belongs to the specified category.
Exceptions
- ArgumentNullException
Thrown if arr is null.
isdtype(NDArray, string[])
Returns True if the array's dtype is of any of the specified categories.
public static bool isdtype(NDArray arr, string[] kinds)
Parameters
Returns
- bool
True if array's dtype belongs to any of the specified categories.
Exceptions
- ArgumentNullException
Thrown if arr is null.
isdtype(NPTypeCode, string)
Returns True if dtype is of a specified category.
public static bool isdtype(NPTypeCode dtype, string kind)
Parameters
dtypeNPTypeCodeThe dtype to check.
kindstringThe dtype category. Can be:
- "bool" - boolean
- "integral" - integer types (signed and unsigned)
- "real floating" - floating point types
- "complex floating" - complex types
- "numeric" - any numeric type
Returns
- bool
True if dtype belongs to the specified category.
Examples
np.isdtype(NPTypeCode.Int32, "integral") // True
np.isdtype(NPTypeCode.Double, "real floating") // True
np.isdtype(NPTypeCode.Int32, "numeric") // True
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.isdtype.html This is a NumPy 2.0+ function.
Uses NPTypeHierarchy for consistent type categorization across all typing functions.
isdtype(NPTypeCode, string[])
Returns True if dtype is of any of the specified categories.
public static bool isdtype(NPTypeCode dtype, string[] kinds)
Parameters
dtypeNPTypeCodeThe dtype to check.
kindsstring[]Array of dtype categories to check.
Returns
- bool
True if dtype belongs to any of the specified categories.
isdtype(Type, string)
Returns True if the CLR type is of a specified category.
public static bool isdtype(Type type, string kind)
Parameters
Returns
- bool
True if type belongs to the specified category.
isdtype(Type, string[])
Returns True if the CLR type is of any of the specified categories.
public static bool isdtype(Type type, string[] kinds)
Parameters
Returns
- bool
True if type belongs to any of the specified categories.
isfinite(NDArray, NDArray, NDArray, NPTypeCode?)
Test element-wise for finiteness (not infinity and not Not a Number).
Mirrors NumPy's ufunc signature: isfinite(x, /, out=None, *, where=True, dtype=None).
A plain call returns a bool-dtype array (the instance is an NDArray<TDType> of bool).
public static NDArray isfinite(NDArray a, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
aNDArrayInput array.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written; masked-off out slots keep prior contents.
dtypeNPTypeCode?Validate-only (NumPy parity): the predicate has bool loops only — any non-bool request raises the no-loop TypeError.
Returns
Remarks
isinf(NDArray, NDArray, NDArray, NPTypeCode?)
Test element-wise for positive or negative infinity.
Mirrors NumPy's ufunc signature: isinf(x, /, out=None, *, where=True, dtype=None).
A plain call returns a bool-dtype array (the instance is an NDArray<TDType> of bool).
public static NDArray isinf(NDArray a, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
aNDArrayInput array.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written; masked-off out slots keep prior contents.
dtypeNPTypeCode?Validate-only (NumPy parity): the predicate has bool loops only — any non-bool request raises the no-loop TypeError.
Returns
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.isinf.html
- Float/Double: True if value is +Inf or -Inf
- Integer types: Always False (integers cannot be Inf)
- NaN: Returns False (NaN is not infinity)
isnan(NDArray, NDArray, NDArray, NPTypeCode?)
Test element-wise for Not a Number.
Mirrors NumPy's ufunc signature: isnan(x, /, out=None, *, where=True, dtype=None).
A plain call returns a bool-dtype array (the instance is an NDArray<TDType> of bool).
public static NDArray isnan(NDArray a, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
aNDArrayInput array.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written; masked-off out slots keep prior contents.
dtypeNPTypeCode?Validate-only (NumPy parity): the predicate has bool loops only — any non-bool request raises the no-loop TypeError.
Returns
Remarks
isreal(NDArray)
Returns a bool array, where True if input element is real.
public static NDArray isreal(NDArray a)
Parameters
aNDArrayInput array.
Returns
- NDArray
Boolean array of same shape, True where element has no imaginary part.
Examples
var a = np.array(new int[] {1, 2, 3});
np.isreal(a) // [True, True, True]
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.isreal.html
For non-complex arrays, all elements are considered real. For complex arrays, elements with zero imaginary part are real.
isrealobj(NDArray)
Return True if x is a not complex type or an array of complex numbers.
public static bool isrealobj(NDArray a)
Parameters
aNDArrayInput array or scalar.
Returns
- bool
True if the array's dtype is not complex.
Examples
var a = np.array(new int[] {1, 2, 3});
np.isrealobj(a) // True (dtype is int, not complex)
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.isrealobj.html
The type of the input is checked, not the value. Even an array of complex numbers with zero imaginary parts will return False.
isscalar(object)
Returns true incase of a number, bool or string. If null, returns false.
public static bool isscalar(object obj)
Parameters
objobject
Returns
Remarks
issctype(object)
Determines whether the given object represents a scalar dtype.
public static bool issctype(object rep)
Parameters
repobjectThe object to check.
Returns
- bool
True if rep represents a scalar dtype.
Examples
np.issctype(typeof(int)) // True
np.issctype(NPTypeCode.Int32) // True
np.issctype(typeof(NDArray)) // False
Remarks
issubdtype(NDArray, string)
Returns True if first argument is a typecode lower/equal in type hierarchy.
public static bool issubdtype(NDArray arr, string arg2)
Parameters
arrNDArrayNDArray - array whose dtype to check.
arg2stringstring - string representing a typecode category.
Returns
- bool
True if array's dtype is a subtype of arg2 category.
Exceptions
- ArgumentNullException
Thrown if arr is null.
issubdtype(NPTypeCode, NPTypeCode)
Returns True if first argument is a typecode lower/equal in type hierarchy.
public static bool issubdtype(NPTypeCode arg1, NPTypeCode arg2)
Parameters
arg1NPTypeCodedtype - dtype representing a typecode.
arg2NPTypeCodedtype - dtype representing a typecode.
Returns
- bool
True if arg1 is equal to or a subtype of arg2.
Remarks
When comparing two concrete types, returns true only if they are the same type. For hierarchy checks, use the (NPTypeCode, string) overload.
issubdtype(NPTypeCode, string)
Returns True if first argument is a typecode lower/equal in type hierarchy.
public static bool issubdtype(NPTypeCode arg1, string arg2)
Parameters
arg1NPTypeCodedtype or string - dtype or string representing a typecode.
arg2stringdtype or string - dtype or string representing a typecode.
Returns
- bool
True if arg1 is a subtype of arg2.
Examples
np.issubdtype(NPTypeCode.Int32, "integer") // True
np.issubdtype(NPTypeCode.Double, "floating") // True
np.issubdtype(NPTypeCode.Boolean, "integer") // False (NumPy 2.x)
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.issubdtype.html
Implementation mirrors NumPy's issubdtype which uses issubclass() on the type hierarchy defined in numpy/_core/src/multiarray/multiarraymodule.c.
Type hierarchy in NumPy:
- generic → number → integer/inexact
- integer → signedinteger/unsignedinteger
- inexact → floating/complexfloating
Note: In NumPy 2.x, bool is NOT a subtype of integer (it's directly under generic).
issubdtype(Type, string)
Returns True if first argument is a typecode lower/equal in type hierarchy.
public static bool issubdtype(Type arg1, string arg2)
Parameters
arg1TypeType - CLR type representing a typecode.
arg2stringstring - string representing a typecode category.
Returns
- bool
True if arg1 is a subtype of arg2 category.
issubdtype(Type, Type)
Returns True if first argument is a typecode lower/equal in type hierarchy.
public static bool issubdtype(Type arg1, Type arg2)
Parameters
Returns
- bool
True if arg1 is equal to or a subtype of arg2.
issubsctype(NPTypeCode, NPTypeCode)
Determine if a class is a subclass of a second class.
public static bool issubsctype(NPTypeCode arg1, NPTypeCode arg2)
Parameters
arg1NPTypeCodeThe dtype to check.
arg2NPTypeCodeThe dtype to compare against.
Returns
- bool
True if arg1 is a subtype of arg2.
Remarks
left_shift(NDArray, NDArray)
Shift the bits of an integer to the left.
public static NDArray left_shift(NDArray x1, NDArray x2)
Parameters
x1NDArrayInput array (integer types only).
x2NDArrayNumber of bits to shift (integer types only).
Returns
- NDArray
Array with bits shifted left.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.left_shift.html
Bits are shifted to the left by appending x2 0s at the right of x1. Since the internal representation of numbers is in binary format, this operation is equivalent to multiplying x1 by 2**x2.
Example: np.left_shift(5, 2) = 20 # 0b101 -> 0b10100
left_shift(NDArray, object)
Shift the bits of an integer to the left by a scalar or array-like amount.
public static NDArray left_shift(NDArray x1, object x2)
Parameters
x1NDArrayInput array (integer types only).
x2objectNumber of bits to shift (scalar or array-like).
Returns
- NDArray
Array with bits shifted left.
less(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
Return (x1 < x2) element-wise.
Mirrors NumPy's ufunc signature: less(x1, x2, /, out=None, *, where=True, dtype=None).
A plain call returns a bool-dtype array (the instance is an NDArray<TDType> of bool —
cast or use the < operator for the typed wrapper).
public static NDArray less(NDArray x1, NDArray x2, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
x1NDArrayInput array.
x2NDArrayInput array.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written; masked-off out slots keep prior contents.
dtypeNPTypeCode?Validate-only (NumPy parity): comparisons have bool loops only — any non-bool request raises the no-loop TypeError.
Returns
Remarks
less(NDArray, object)
Return (x1 < x2) element-wise with scalar.
public static NDArray<bool> less(NDArray x1, object x2)
Parameters
Returns
less(object, NDArray)
Return (x1 < x2) element-wise with scalar on left.
public static NDArray<bool> less(object x1, NDArray x2)
Parameters
Returns
less_equal(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
Return (x1 <= x2) element-wise.
Mirrors NumPy's ufunc signature: less_equal(x1, x2, /, out=None, *, where=True, dtype=None).
A plain call returns a bool-dtype array (the instance is an NDArray<TDType> of bool —
cast or use the <= operator for the typed wrapper).
public static NDArray less_equal(NDArray x1, NDArray x2, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
x1NDArrayInput array.
x2NDArrayInput array.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written; masked-off out slots keep prior contents.
dtypeNPTypeCode?Validate-only (NumPy parity): comparisons have bool loops only — any non-bool request raises the no-loop TypeError.
Returns
Remarks
less_equal(NDArray, object)
Return (x1 <= x2) element-wise with scalar.
public static NDArray<bool> less_equal(NDArray x1, object x2)
Parameters
Returns
less_equal(object, NDArray)
Return (x1 <= x2) element-wise with scalar on left.
public static NDArray<bool> less_equal(object x1, NDArray x2)
Parameters
Returns
linspace(double, double, int, bool, NPTypeCode)
public static NDArray linspace(double start, double stop, int num, bool endpoint = true, NPTypeCode typeCode = NPTypeCode.Double)
Parameters
startdoublestopdoublenumintendpointbooltypeCodeNPTypeCode
Returns
linspace(double, double, int, bool, Type)
public static NDArray linspace(double start, double stop, int num, bool endpoint, Type dtype)
Parameters
Returns
linspace(double, double, long, bool, NPTypeCode)
public static NDArray linspace(double start, double stop, long num, bool endpoint = true, NPTypeCode typeCode = NPTypeCode.Double)
Parameters
startdoublestopdoublenumlongendpointbooltypeCodeNPTypeCode
Returns
linspace(double, double, long, bool, Type)
public static NDArray linspace(double start, double stop, long num, bool endpoint, Type dtype)
Parameters
Returns
linspace(float, float, int, bool, NPTypeCode)
public static NDArray linspace(float start, float stop, int num, bool endpoint = true, NPTypeCode typeCode = NPTypeCode.Double)
Parameters
startfloatstopfloatnumintendpointbooltypeCodeNPTypeCode
Returns
linspace(float, float, int, bool, Type)
public static NDArray linspace(float start, float stop, int num, bool endpoint, Type dtype)
Parameters
Returns
linspace(float, float, long, bool, NPTypeCode)
public static NDArray linspace(float start, float stop, long num, bool endpoint = true, NPTypeCode typeCode = NPTypeCode.Double)
Parameters
startfloatstopfloatnumlongendpointbooltypeCodeNPTypeCode
Returns
linspace(float, float, long, bool, Type)
public static NDArray linspace(float start, float stop, long num, bool endpoint, Type dtype)
Parameters
Returns
load(Stream)
public static NDArray load(Stream stream)
Parameters
streamStream
Returns
load(string)
public static NDArray load(string path)
Parameters
pathstring
Returns
log(NDArray)
Natural logarithm, element-wise. The natural logarithm log is the inverse of the exponential function, so that log(exp(x)) = x. The natural logarithm is logarithm in base e.
public static NDArray log(NDArray x)
Parameters
xNDArrayInput value.
Returns
- NDArray
The natural logarithm of x, element-wise. This is a scalar if x is a scalar.
Remarks
log(NDArray, NDArray, NDArray, NPTypeCode?)
Natural logarithm, element-wise.
Mirrors NumPy's ufunc signature: log(x, /, out=None, *, where=True, dtype=None).
public static NDArray log(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayInput value.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?Explicit loop dtype (NumPy ufunc dtype=): the computation runs at this precision; integer/bool requests raise NumPy's "No loop matching" error.
Returns
Remarks
log(NDArray, NPTypeCode)
Natural logarithm, element-wise, computed in dtype.
Positional-dtype convenience overload (NumPy accepts dtype only as a keyword).
public static NDArray log(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayInput value.
dtypeNPTypeCodeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
The natural logarithm of x, element-wise. This is a scalar if x is a scalar.
Remarks
log(NDArray, Type)
Natural logarithm, element-wise. The natural logarithm log is the inverse of the exponential function, so that log(exp(x)) = x. The natural logarithm is logarithm in base e.
public static NDArray log(NDArray x, Type dtype)
Parameters
xNDArrayInput value.
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
The natural logarithm of x, element-wise. This is a scalar if x is a scalar.
Remarks
log10(NDArray)
Return the base 10 logarithm of the input array, element-wise.
public static NDArray log10(NDArray x)
Parameters
xNDArrayInput value.
Returns
- NDArray
The logarithm to the base 10 of x, element-wise. NaNs are returned where x is negative. This is a scalar if x is a scalar.
Remarks
log10(NDArray, NDArray, NDArray, NPTypeCode?)
Return the base 10 logarithm of the input array, element-wise.
public static NDArray log10(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayInput value.
outNDArraywhereNDArraydtypeNPTypeCode?
Returns
- NDArray
The logarithm to the base 10 of x, element-wise. NaNs are returned where x is negative. This is a scalar if x is a scalar.
Remarks
log10(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray log10(NDArray x, NPTypeCode dtype)
Parameters
xNDArraydtypeNPTypeCode
Returns
Remarks
log10(NDArray, Type)
Return the base 10 logarithm of the input array, element-wise.
public static NDArray log10(NDArray x, Type dtype)
Parameters
Returns
- NDArray
The logarithm to the base 10 of x, element-wise. NaNs are returned where x is negative. This is a scalar if x is a scalar.
Remarks
log1p(NDArray)
Return the natural logarithm of one plus the input array, element-wise.
Calculates log(1 + x).
public static NDArray log1p(NDArray x)
Parameters
xNDArrayInput value.
Returns
- NDArray
Natural logarithm of 1 + x, element-wise. This is a scalar if x is a scalar.
Remarks
log1p(NDArray, NDArray, NDArray, NPTypeCode?)
Return the natural logarithm of one plus the input array, element-wise.
Calculates log(1 + x).
public static NDArray log1p(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayInput value.
outNDArraywhereNDArraydtypeNPTypeCode?
Returns
- NDArray
Natural logarithm of 1 + x, element-wise. This is a scalar if x is a scalar.
Remarks
log1p(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray log1p(NDArray x, NPTypeCode dtype)
Parameters
xNDArraydtypeNPTypeCode
Returns
Remarks
log1p(NDArray, Type)
Return the natural logarithm of one plus the input array, element-wise.
Calculates log(1 + x).
public static NDArray log1p(NDArray x, Type dtype)
Parameters
Returns
- NDArray
Natural logarithm of 1 + x, element-wise. This is a scalar if x is a scalar.
Remarks
log2(NDArray)
Base-2 logarithm of x.
public static NDArray log2(NDArray x)
Parameters
xNDArrayInput value.
Returns
- NDArray
Base-2 logarithm of x. This is a scalar if x is a scalar.
Remarks
log2(NDArray, NDArray, NDArray, NPTypeCode?)
Base-2 logarithm of x.
public static NDArray log2(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayInput value.
outNDArraywhereNDArraydtypeNPTypeCode?
Returns
- NDArray
Base-2 logarithm of x. This is a scalar if x is a scalar.
Remarks
log2(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray log2(NDArray x, NPTypeCode dtype)
Parameters
xNDArraydtypeNPTypeCode
Returns
Remarks
log2(NDArray, Type)
Base-2 logarithm of x.
public static NDArray log2(NDArray x, Type dtype)
Parameters
Returns
- NDArray
Base-2 logarithm of x. This is a scalar if x is a scalar.
Remarks
logical_and(NDArray, NDArray)
Compute the truth value of x1 AND x2 element-wise.
public static NDArray<bool> logical_and(NDArray x1, NDArray x2)
Parameters
Returns
- NDArray<bool>
Boolean result of the logical AND operation applied to the elements of x1 and x2; the shape is determined by broadcasting.
Remarks
logical_not(NDArray)
Compute the truth value of NOT x element-wise.
public static NDArray<bool> logical_not(NDArray x)
Parameters
xNDArrayLogical NOT is applied to the elements of x.
Returns
Remarks
logical_or(NDArray, NDArray)
Compute the truth value of x1 OR x2 element-wise.
public static NDArray<bool> logical_or(NDArray x1, NDArray x2)
Parameters
Returns
- NDArray<bool>
Boolean result of the logical OR operation applied to the elements of x1 and x2; the shape is determined by broadcasting.
Remarks
logical_xor(NDArray, NDArray)
Compute the truth value of x1 XOR x2 element-wise.
public static NDArray<bool> logical_xor(NDArray x1, NDArray x2)
Parameters
Returns
- NDArray<bool>
Boolean result of the logical XOR operation applied to the elements of x1 and x2; the shape is determined by broadcasting.
Remarks
matmul(NDArray, NDArray)
Matrix product of two arrays.
public static NDArray matmul(NDArray x1, NDArray x2)
Parameters
Returns
- NDArray
The matrix product of the inputs. This is a scalar only when both x1, x2 are 1-d vectors.
Remarks
max(NDArray, int?, bool, Type)
Return the maximum of an array or maximum along an axis.
public static NDArray max(NDArray a, int? axis = null, bool keepdims = false, Type dtype = null)
Parameters
aNDArrayaxisint?Axis or axes along which to operate.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
dtypeTypethe type expected as a return, null will remain the same dtype.
Returns
- NDArray
Maximum of a. If axis is None, the result is a scalar value. If axis is given, the result is an array of dimension a.ndim - 1.
Remarks
maximum(NDArray, NDArray, NDArray)
Element-wise maximum of array elements (NaN-propagating), writing into @out.
public static NDArray maximum(NDArray x1, NDArray x2, NDArray @out)
Parameters
Returns
maximum(NDArray, NDArray, NPTypeCode?)
Element-wise maximum of array elements. Compare two arrays and returns a new array containing the element-wise maxima. If one of the elements being compared is a NaN, then that element is returned. If both elements are NaNs then the first is returned. The latter distinction is important for complex NaNs, which are defined as at least one of the real or imaginary parts being a NaN. The net effect is that NaNs are propagated.
public static NDArray maximum(NDArray x1, NDArray x2, NPTypeCode? dtype = null)
Parameters
x1NDArrayThe arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).
x2NDArrayThe arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).
dtypeNPTypeCode?Loop dtype (NumPy ufunc dtype=): the comparison runs at this precision.
Returns
- NDArray
The maximum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.
maximum(NDArray, NDArray, Type)
Element-wise maximum of array elements (NaN-propagating). See maximum(NDArray, NDArray, NPTypeCode?).
public static NDArray maximum(NDArray x1, NDArray x2, Type dtype)
Parameters
Returns
maximum_sctype(NPTypeCode)
Return the scalar type of highest precision of the same kind as the input.
public static NPTypeCode maximum_sctype(NPTypeCode t)
Parameters
tNPTypeCodeThe input scalar type.
Returns
- NPTypeCode
The highest precision type of the same kind.
Examples
np.maximum_sctype(NPTypeCode.Int32) // Int64
np.maximum_sctype(NPTypeCode.Single) // Double (or Decimal)
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.maximum_sctype.html
Uses NPTypeHierarchy for consistent type categorization across all typing functions.
mean(NDArray)
Compute the arithmetic mean along the specified axis. Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis. float64 intermediate and return values are used for integer inputs.
public static NDArray mean(NDArray a)
Parameters
aNDArrayArray containing numbers whose mean is desired. If a is not an array, a conversion is attempted.
Returns
- NDArray
returns a new array containing the mean values, otherwise a reference to the output array is returned.
Remarks
mean(NDArray, bool)
Compute the arithmetic mean along the specified axis. Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis. float64 intermediate and return values are used for integer inputs.
public static NDArray mean(NDArray a, bool keepdims)
Parameters
aNDArrayArray containing numbers whose mean is desired. If a is not an array, a conversion is attempted.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array. If the default value is passed, then keepdims will not be passed through to the mean method of sub-classes of ndarray, however any non-default value will be.If the sub-class’ method does not implement keepdims any exceptions will be raised.
Returns
- NDArray
returns a new array containing the mean values, otherwise a reference to the output array is returned.
Remarks
mean(NDArray, int)
Compute the arithmetic mean along the specified axis. Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis. float64 intermediate and return values are used for integer inputs.
public static NDArray mean(NDArray a, int axis)
Parameters
aNDArrayArray containing numbers whose mean is desired. If a is not an array, a conversion is attempted.
axisintAxis or axes along which the means are computed. The default is to compute the mean of the flattened array.
Returns
- NDArray
returns a new array containing the mean values, otherwise a reference to the output array is returned.
Remarks
mean(NDArray, int, NPTypeCode, bool)
Compute the arithmetic mean along the specified axis. Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis. float64 intermediate and return values are used for integer inputs.
public static NDArray mean(NDArray a, int axis, NPTypeCode type, bool keepdims = false)
Parameters
aNDArrayArray containing numbers whose mean is desired. If a is not an array, a conversion is attempted.
axisintAxis or axes along which the means are computed. The default is to compute the mean of the flattened array.
typeNPTypeCodeType to use in computing the mean. For integer inputs, the default is float64; for floating point inputs, it is the same as the input dtype.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array. If the default value is passed, then keepdims will not be passed through to the mean method of sub-classes of ndarray, however any non-default value will be.If the sub-class’ method does not implement keepdims any exceptions will be raised.
Returns
- NDArray
returns a new array containing the mean values, otherwise a reference to the output array is returned.
Remarks
mean(NDArray, int, bool)
Compute the arithmetic mean along the specified axis. Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis. float64 intermediate and return values are used for integer inputs.
public static NDArray mean(NDArray a, int axis, bool keepdims)
Parameters
aNDArrayArray containing numbers whose mean is desired. If a is not an array, a conversion is attempted.
axisintAxis or axes along which the means are computed. The default is to compute the mean of the flattened array.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array. If the default value is passed, then keepdims will not be passed through to the mean method of sub-classes of ndarray, however any non-default value will be.If the sub-class’ method does not implement keepdims any exceptions will be raised.
Returns
- NDArray
returns a new array containing the mean values, otherwise a reference to the output array is returned.
mean(NDArray, int, Type, bool)
Compute the arithmetic mean along the specified axis. Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis. float64 intermediate and return values are used for integer inputs.
public static NDArray mean(NDArray a, int axis, Type dtype, bool keepdims = false)
Parameters
aNDArrayArray containing numbers whose mean is desired. If a is not an array, a conversion is attempted.
axisintAxis or axes along which the means are computed. The default is to compute the mean of the flattened array.
dtypeTypeType to use in computing the mean. For integer inputs, the default is float64; for floating point inputs, it is the same as the input dtype.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array. If the default value is passed, then keepdims will not be passed through to the mean method of sub-classes of ndarray, however any non-default value will be.If the sub-class’ method does not implement keepdims any exceptions will be raised.
Returns
- NDArray
returns a new array containing the mean values, otherwise a reference to the output array is returned.
Remarks
median(NDArray, int[], NDArray, bool, bool)
public static NDArray median(NDArray a, int[] axis, NDArray @out = null, bool overwrite_input = false, bool keepdims = false)
Parameters
Returns
median(NDArray, int?, NDArray, bool, bool)
Compute the median along the specified axis.
For an even-sized slice the median is the mean of the two central values;
for an odd-sized slice it is the single central value. Equivalent to
np.quantile(a, 0.5) for our purposes, which matches NumPy's contract.
public static NDArray median(NDArray a, int? axis = null, NDArray @out = null, bool overwrite_input = false, bool keepdims = false)
Parameters
Returns
Remarks
meshgrid(NDArray, NDArray, Kwargs)
Return coordinate matrices from coordinate vectors. Make N-D coordinate arrays for vectorized evaluations of N-D scalar/vector fields over N-D grids, given one-dimensional coordinate arrays x1, x2,..., xn. .. versionchanged:: 1.9 1-D and 0-D cases are allowed.
public static (NDArray, NDArray) meshgrid(NDArray x1, NDArray x2, Kwargs kwargs = null)
Parameters
x1NDArray1-D arrays representing the coordinates of a grid
x2NDArray1-D arrays representing the coordinates of a grid
kwargsKwargs
Returns
mgrid(NDArray, NDArray)
nd_grid instance which returns a dense multi-dimensional “meshgrid”. An instance of numpy.lib.index_tricks.nd_grid which returns an dense (or fleshed out) mesh-grid when indexed, so that each returned argument has the same shape. The dimensions and number of the output arrays are equal to the number of indexing dimensions.If the step length is not a complex number, then the stop is not inclusive.
public static (NDArray, NDArray) mgrid(NDArray lhs, NDArray rhs)
Parameters
Returns
Remarks
min(NDArray, int?, bool, Type)
Return the minimum of an array or minimum along an axis.
public static NDArray min(NDArray a, int? axis = null, bool keepdims = false, Type dtype = null)
Parameters
aNDArrayInput data.
axisint?Axis or axes along which to operate.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
dtypeTypethe type expected as a return, null will remain the same dtype.
Returns
- NDArray
Minimum of a. If axis is None, the result is a scalar value. If axis is given, the result is an array of dimension a.ndim - 1.
Remarks
min_scalar_type(object)
For scalar value, returns the data type with the smallest size and smallest scalar kind which can hold its value.
public static NPTypeCode min_scalar_type(object value)
Parameters
valueobjectThe scalar value to check.
Returns
- NPTypeCode
The minimum dtype that can represent the value.
Examples
np.min_scalar_type(10) // Byte (uint8)
np.min_scalar_type(-10) // Int16 (no int8 in NumSharp)
np.min_scalar_type(1000) // UInt16
np.min_scalar_type(1.0) // Single (float32)
np.min_scalar_type(true) // Boolean
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.min_scalar_type.html
For integers, finds the smallest integer type that can hold the value. For floats, finds the smallest float type that can represent the value exactly.
minimum(NDArray, NDArray, NDArray)
Element-wise minimum of array elements (NaN-propagating), writing into @out.
public static NDArray minimum(NDArray x1, NDArray x2, NDArray @out)
Parameters
Returns
minimum(NDArray, NDArray, NPTypeCode?)
Element-wise minimum of array elements. Compare two arrays and returns a new array containing the element-wise minima. If one of the elements being compared is a NaN, then that element is returned. If both elements are NaNs then the first is returned. The latter distinction is important for complex NaNs, which are defined as at least one of the real or imaginary parts being a NaN. The net effect is that NaNs are propagated.
public static NDArray minimum(NDArray x1, NDArray x2, NPTypeCode? dtype = null)
Parameters
x1NDArrayThe arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).
x2NDArrayThe arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).
dtypeNPTypeCode?Loop dtype (NumPy ufunc dtype=): the comparison runs at this precision.
Returns
- NDArray
The minimum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.
minimum(NDArray, NDArray, Type)
Element-wise minimum of array elements (NaN-propagating). See minimum(NDArray, NDArray, NPTypeCode?).
public static NDArray minimum(NDArray x1, NDArray x2, Type dtype)
Parameters
Returns
mintypecode(char[], string, char)
Return the character for the minimum-size type to which given types can be safely cast. The returned type character must represent the smallest size dtype such that an array of the returned type can handle the data from an array of all types in typechars(or if typechars is an array, then its dtype.char).
public static char mintypecode(char[] typechars, string typeset = "GDFgdf", char @default = 'd')
Parameters
typecharschar[]typesetstringThe set of characters that the returned character is chosen from. The default set is ‘GDFgdf’.
defaultcharThe default character, this is returned if none of the characters in typechars matches a character in typeset.
Returns
- char
The character representing the minimum-size type that was found.
mintypecode(string, string, char)
Return the character for the minimum-size type to which given types can be safely cast. The returned type character must represent the smallest size dtype such that an array of the returned type can handle the data from an array of all types in typechars(or if typechars is an array, then its dtype.char).
public static char mintypecode(string typechars, string typeset = "GDFgdf", char @default = 'd')
Parameters
typecharsstringevery character represents a type. see char
typesetstringThe set of characters that the returned character is chosen from. The default set is ‘GDFgdf’.
defaultcharThe default character, this is returned if none of the characters in typechars matches a character in typeset.
Returns
- char
The character representing the minimum-size type that was found.
mod(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
public static NDArray mod(NDArray x1, NDArray x2, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
x1NDArrayx2NDArrayoutNDArraywhereNDArraydtypeNPTypeCode?
Returns
Remarks
mod(NDArray, float)
public static NDArray mod(NDArray x1, float x2)
Parameters
Returns
modf(NDArray, NPTypeCode?)
Return the fractional and integral parts of an array, element-wise. The fractional and integral parts are negative if the given number is negative.
public static (NDArray Fractional, NDArray Intergral) modf(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array.
dtypeNPTypeCode?The dtype the returned ndarray should be of, only non integer values are supported.
Returns
Remarks
modf(NDArray, Type)
Return the fractional and integral parts of an array, element-wise. The fractional and integral parts are negative if the given number is negative.
public static (NDArray Fractional, NDArray Intergral) modf(NDArray x, Type dtype)
Parameters
xNDArrayInput array.
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
Remarks
moveaxis(NDArray, int, int)
Move axes of an array to new positions. Other axes remain in their original order.
public static NDArray moveaxis(NDArray a, int source, int destination)
Parameters
aNDArrayThe array whose axes should be reordered.
sourceintOriginal positions of the axes to move. These must be unique (distinct).
destinationintDestination positions for each of the original axes. These must also be unique (distinct).
Returns
- NDArray
Array with moved axes.
Remarks
moveaxis(NDArray, int, int[])
Move axes of an array to new positions. Other axes remain in their original order.
public static NDArray moveaxis(NDArray a, int source, int[] destination)
Parameters
aNDArrayThe array whose axes should be reordered.
sourceintOriginal positions of the axes to move. These must be unique (distinct).
destinationint[]Destination positions for each of the original axes. These must also be unique (distinct).
Returns
- NDArray
Array with moved axes.
Remarks
moveaxis(NDArray, int[], int)
Move axes of an array to new positions. Other axes remain in their original order.
public static NDArray moveaxis(NDArray a, int[] source, int destination)
Parameters
aNDArrayThe array whose axes should be reordered.
sourceint[]Original positions of the axes to move. These must be unique (distinct).
destinationintDestination positions for each of the original axes. These must also be unique (distinct).
Returns
- NDArray
Array with moved axes.
Remarks
moveaxis(NDArray, int[], int[])
Move axes of an array to new positions. Other axes remain in their original order.
public static NDArray moveaxis(NDArray a, int[] source, int[] destination)
Parameters
aNDArrayThe array whose axes should be reordered.
sourceint[]Original positions of the axes to move. These must be unique (distinct).
destinationint[]Destination positions for each of the original axes. These must also be unique (distinct).
Returns
- NDArray
Array with moved axes.
Remarks
multiply(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
public static NDArray multiply(NDArray x1, NDArray x2, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
x1NDArrayx2NDArrayoutNDArraywhereNDArraydtypeNPTypeCode?
Returns
Remarks
multithreading(bool, int)
Enable or disable NumSharp's multithreaded kernels and cap the worker thread count.
public static void multithreading(bool enabled, int max_threads = 8)
Parameters
enabledboolWhether kernels are allowed to use more than one thread.
max_threadsintUpper bound on worker threads (clamped to at least 1 and to the processor count). Defaults to 8.
Remarks
Multithreading is disabled by default, so the default behavior — and the exact summation order — is unchanged unless you opt in.
Currently this controls the fused 1-D dot product (dot(NDArray, NDArray)
for vector·vector) on contiguous float / double inputs. Only large
vectors are parallelized; small and medium ones stay single-threaded because thread
fan-out would cost more than it saves. With multithreading on, the inner product is
summed per-chunk and combined, so results may differ from the single-threaded path in
the last few ULPs (the same floating-point reordering NumPy's threaded BLAS exhibits).
np.multithreading(true); // enable, up to 8 threads
np.multithreading(true, 16); // enable, up to 16 threads
np.multithreading(false); // back to single-threaded
nanmax(NDArray, int?, bool)
Return maximum of an array or maximum along an axis, ignoring any NaNs.
public static NDArray nanmax(NDArray a, int? axis = null, bool keepdims = false)
Parameters
aNDArrayArray containing numbers whose maximum is desired. If a is not an array, a conversion is attempted.
axisint?Axis or axes along which the maximum is computed. The default is to compute the maximum of the flattened array.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one.
Returns
- NDArray
A new array containing the maximum. If all values are NaN, returns NaN.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.nanmax.html Only applicable to float and double arrays. For integer arrays, this is equivalent to np.amax (no NaN values possible).
nanmean(NDArray, int?, bool)
Compute the arithmetic mean along the specified axis, ignoring NaNs. Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis. float64 intermediate and return values are used for integer inputs.
public static NDArray nanmean(NDArray a, int? axis = null, bool keepdims = false)
Parameters
aNDArrayArray containing numbers whose mean is desired. If a is not an array, a conversion is attempted.
axisint?Axis or axes along which the means are computed. The default is to compute the mean of the flattened array.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one.
Returns
- NDArray
A new array containing the mean values, with NaN values ignored. If all values along an axis are NaN, returns NaN for that slice.
Remarks
nanmedian(NDArray, int[], NDArray, bool, bool)
public static NDArray nanmedian(NDArray a, int[] axis, NDArray @out = null, bool overwrite_input = false, bool keepdims = false)
Parameters
Returns
nanmedian(NDArray, int?, NDArray, bool, bool)
Compute the median along the specified axis, ignoring NaNs.
Equivalent to np.nanquantile(a, 0.5). A slice that is entirely NaN
(or empty) yields NaN, matching NumPy's "All-NaN slice" behaviour.
public static NDArray nanmedian(NDArray a, int? axis = null, NDArray @out = null, bool overwrite_input = false, bool keepdims = false)
Parameters
Returns
Remarks
nanmin(NDArray, int?, bool)
Return minimum of an array or minimum along an axis, ignoring any NaNs.
public static NDArray nanmin(NDArray a, int? axis = null, bool keepdims = false)
Parameters
aNDArrayArray containing numbers whose minimum is desired. If a is not an array, a conversion is attempted.
axisint?Axis or axes along which the minimum is computed. The default is to compute the minimum of the flattened array.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one.
Returns
- NDArray
A new array containing the minimum. If all values are NaN, returns NaN.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.nanmin.html Only applicable to float and double arrays. For integer arrays, this is equivalent to np.amin (no NaN values possible).
nanpercentile(NDArray, NDArray, int?, NDArray, bool, string, bool)
public static NDArray nanpercentile(NDArray a, NDArray q, int? axis = null, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
nanpercentile(NDArray, double, int[], NDArray, bool, string, bool)
public static NDArray nanpercentile(NDArray a, double q, int[] axis, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
nanpercentile(NDArray, double, int?, NDArray, bool, string, bool)
Compute the q-th percentile of the data along the specified axis, ignoring NaNs.
q must be in [0, 100]. Equivalent to np.nanquantile(a, q/100).
A slice that is entirely NaN (or empty) yields NaN.
public static NDArray nanpercentile(NDArray a, double q, int? axis = null, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
Remarks
nanpercentile(NDArray, double[], int[], NDArray, bool, string, bool)
public static NDArray nanpercentile(NDArray a, double[] q, int[] axis, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
nanpercentile(NDArray, double[], int?, NDArray, bool, string, bool)
public static NDArray nanpercentile(NDArray a, double[] q, int? axis = null, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
nanprod(NDArray, int?, bool)
Return the product of array elements over a given axis treating Not a Numbers (NaNs) as ones.
public static NDArray nanprod(NDArray a, int? axis = null, bool keepdims = false)
Parameters
aNDArrayArray containing numbers whose product is desired. If a is not an array, a conversion is attempted.
axisint?Axis or axes along which the product is computed. The default is to compute the product of the flattened array.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one.
Returns
- NDArray
A new array containing the product, with NaN values treated as one.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.nanprod.html Only applicable to float and double arrays. For integer arrays, this is equivalent to np.prod (no NaN values possible).
nanquantile(NDArray, NDArray, int?, NDArray, bool, string, bool)
NDArray-q overload — accepts a 0-D or 1-D NDArray of quantile values. Higher-rank q is rejected (NumPy raises "q must be a scalar or 1d").
public static NDArray nanquantile(NDArray a, NDArray q, int? axis = null, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
nanquantile(NDArray, double, int[], NDArray, bool, string, bool)
public static NDArray nanquantile(NDArray a, double q, int[] axis, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
nanquantile(NDArray, double, int?, NDArray, bool, string, bool)
Compute the q-th quantile of the data along the specified axis, ignoring NaNs.
q must be in the range [0, 1]. A slice that is entirely NaN
(or empty) yields NaN, matching NumPy's "All-NaN slice" behaviour.
public static NDArray nanquantile(NDArray a, double q, int? axis = null, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
Remarks
nanquantile(NDArray, double[], int[], NDArray, bool, string, bool)
public static NDArray nanquantile(NDArray a, double[] q, int[] axis, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
nanquantile(NDArray, double[], int?, NDArray, bool, string, bool)
public static NDArray nanquantile(NDArray a, double[] q, int? axis = null, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
nanstd(NDArray, int?, bool, int)
Compute the standard deviation along the specified axis, while ignoring NaNs. Returns the standard deviation, a measure of the spread of a distribution, of the non-NaN array elements. The standard deviation is computed for the flattened array by default, otherwise over the specified axis.
public static NDArray nanstd(NDArray a, int? axis = null, bool keepdims = false, int ddof = 0)
Parameters
aNDArrayCalculate the standard deviation of the non-NaN values.
axisint?Axis or axes along which the standard deviation is computed. The default is to compute the standard deviation of the flattened array.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one.
ddofintMeans Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of non-NaN elements. By default ddof is zero.
Returns
- NDArray
A new array containing the standard deviation. If all values along an axis are NaN, returns NaN for that slice.
Remarks
nansum(NDArray, int?, bool)
Return the sum of array elements over a given axis treating Not a Numbers (NaNs) as zero.
public static NDArray nansum(NDArray a, int? axis = null, bool keepdims = false)
Parameters
aNDArrayArray containing numbers whose sum is desired. If a is not an array, a conversion is attempted.
axisint?Axis or axes along which the sum is computed. The default is to compute the sum of the flattened array.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one.
Returns
- NDArray
A new array containing the sum, with NaN values treated as zero.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.nansum.html Only applicable to float and double arrays. For integer arrays, this is equivalent to np.sum (no NaN values possible).
nanvar(NDArray, int?, bool, int)
Compute the variance along the specified axis, while ignoring NaNs. Returns the variance of the array elements, a measure of the spread of a distribution. The variance is computed for the flattened array by default, otherwise over the specified axis.
public static NDArray nanvar(NDArray a, int? axis = null, bool keepdims = false, int ddof = 0)
Parameters
aNDArrayArray containing numbers whose variance is desired.
axisint?Axis or axes along which the variance is computed. The default is to compute the variance of the flattened array.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one.
ddofintMeans Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of non-NaN elements. By default ddof is zero.
Returns
- NDArray
A new array containing the variance. If all values along an axis are NaN, returns NaN for that slice.
Remarks
ndarray(Shape, Type, Array, char)
Create an array.
public static NDArray ndarray(Shape shape, Type dtype = null, Array buffer = null, char order = 'F')
Parameters
shapeShapeShape of the array.
dtypeTypeData type. Default is float32.
bufferArrayOptional buffer to use for data. If null, allocates new memory filled with zeros.
ordercharMemory order. Note: Only C-order is supported, F-order parameter is accepted but ignored.
Returns
- NDArray
New NDArray with the specified shape and dtype.
Remarks
This function creates an NDArray directly without going through TensorEngine. Memory allocation is not backend-specific - all backends use the same unmanaged memory.
negative(NDArray, NDArray, NDArray, NPTypeCode?)
Numerical negative, element-wise.
Mirrors NumPy's ufunc signature: negative(x, /, out=None, *, where=True, dtype=None).
public static NDArray negative(NDArray nd, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
ndNDArrayoutNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?Explicit loop dtype (NumPy ufunc dtype=): selects the loop, so negative(bool, dtype: float64) is legal while plain negative(bool) raises (NumPy parity).
Returns
Remarks
nonzero(NDArray)
Return the indices of the elements that are non-zero. Returns a tuple of arrays, one for each dimension of a, containing the indices of the non-zero elements in that dimension.The values in a are always tested and returned in row-major, C-style order. To group the indices by element, rather than dimension, use argwhere, which returns a row for each non-zero element.
public static NDArray<long>[] nonzero(NDArray a)
Parameters
aNDArrayInput array.
Returns
Remarks
not_equal(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
Return (x1 != x2) element-wise.
Mirrors NumPy's ufunc signature: not_equal(x1, x2, /, out=None, *, where=True, dtype=None).
A plain call returns a bool-dtype array (the instance is an NDArray<TDType> of bool —
cast or use the != operator for the typed wrapper).
public static NDArray not_equal(NDArray x1, NDArray x2, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
x1NDArrayInput array.
x2NDArrayInput array.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written; masked-off out slots keep prior contents.
dtypeNPTypeCode?Validate-only (NumPy parity): comparisons have bool loops only — any non-bool request raises the no-loop TypeError.
Returns
Remarks
not_equal(NDArray, object)
Return (x1 != x2) element-wise with scalar.
public static NDArray<bool> not_equal(NDArray x1, object x2)
Parameters
Returns
not_equal(object, NDArray)
Return (x1 != x2) element-wise with scalar on left.
public static NDArray<bool> not_equal(object x1, NDArray x2)
Parameters
Returns
ones(Shape)
Return a new array of given shape and type, filled with ones.
public static NDArray ones(Shape shape)
Parameters
shapeShapeShape of the new array.
Returns
Remarks
ones(Shape, NPTypeCode)
Return a new array of given shape and type, filled with ones.
public static NDArray ones(Shape shape, NPTypeCode typeCode)
Parameters
shapeShapeShape of the new array.
typeCodeNPTypeCodeThe desired data-type for the array, e.g., uint8. Default is float64 / double.
Returns
Remarks
ones(Shape, Type)
Return a new array of given shape and type, filled with ones.
public static NDArray ones(Shape shape, Type dtype)
Parameters
shapeShapeShape of the new array.
dtypeTypeThe desired data-type for the array, e.g., uint8. Default is float64 / double.
Returns
Remarks
ones(int)
Return a new array of given shape and type, filled with ones.
public static NDArray ones(int shape)
Parameters
shapeint
Returns
Remarks
ones(int[])
Return a new array of given shape and type, filled with ones.
public static NDArray ones(int[] shape)
Parameters
shapeint[]Shape of the new array.
Returns
Remarks
ones(int[], Type)
Return a new array of given shape and type, filled with ones.
public static NDArray ones(int[] shape, Type dtype)
Parameters
shapeint[]Shape of the new array.
dtypeTypeThe desired data-type for the array, e.g., uint8. Default is float64 / double.
Returns
Remarks
ones(long[])
Return a new array of given shape and type, filled with ones.
public static NDArray ones(long[] shape)
Parameters
shapelong[]Shape of the new array.
Returns
Remarks
ones_like(NDArray, Type)
Return an array of ones with the same shape and type as a given array.
public static NDArray ones_like(NDArray a, Type dtype = null)
Parameters
aNDArrayArray of ones with the same shape and type as a.
dtypeTypeOverrides the data type of the result.
Returns
- NDArray
Array of zeros with the same shape and type as
nd.
Remarks
ones_like(NDArray, Type, char)
Return an array of ones with the same shape and type as a given array.
public static NDArray ones_like(NDArray a, Type dtype, char order)
Parameters
aNDArrayArray of ones with the same shape and type as a.
dtypeTypeOverrides the data type of the result.
ordercharMemory layout: 'C', 'F', 'A' or 'K' (default, preserves source layout).
Returns
- NDArray
Array of ones with the same shape and type as
nd.
Remarks
ones<T>(int[])
Return a new array of given shape and type, filled with ones.
public static NDArray ones<T>(int[] shape) where T : unmanaged
Parameters
shapeint[]Shape of the new array.
Returns
Type Parameters
Remarks
outer(NDArray, NDArray)
Compute the outer product of two vectors. Given two vectors, a = [a0, a1, ..., aM] and b = [b0, b1, ..., bN], the outer product[R60] is:
public static NDArray outer(NDArray a, NDArray b)
Parameters
aNDArrayFirst input vector. Input is flattened if not already 1-dimensional.
bNDArraySecond input vector. Input is flattened if not already 1-dimensional.
Returns
- NDArray
out[i, j] = a[i] * b[j]
Remarks
pad(NDArray, IDictionary<int, object>, PadFunc, object)
public static NDArray pad(NDArray array, IDictionary<int, object> pad_width, np.PadFunc mode, object kwargs = null)
Parameters
Returns
pad(NDArray, IDictionary<int, object>, string, object, object, object, string)
public static NDArray pad(NDArray array, IDictionary<int, object> pad_width, string mode = "constant", object constant_values = null, object end_values = null, object stat_length = null, string reflect_type = "even")
Parameters
arrayNDArraypad_widthIDictionary<int, object>modestringconstant_valuesobjectend_valuesobjectstat_lengthobjectreflect_typestring
Returns
pad(NDArray, int, PadFunc, object)
public static NDArray pad(NDArray array, int pad_width, np.PadFunc mode, object kwargs = null)
Parameters
Returns
pad(NDArray, int, string, object, object, object, string)
Pad an array. Scalar pad_width applies (pad_width, pad_width)
to every axis.
public static NDArray pad(NDArray array, int pad_width, string mode = "constant", object constant_values = null, object end_values = null, object stat_length = null, string reflect_type = "even")
Parameters
arrayNDArraypad_widthintmodestringconstant_valuesobjectend_valuesobjectstat_lengthobjectreflect_typestring
Returns
Remarks
pad(NDArray, int[,], PadFunc, object)
public static NDArray pad(NDArray array, int[,] pad_width, np.PadFunc mode, object kwargs = null)
Parameters
Returns
pad(NDArray, int[,], string, object, object, object, string)
public static NDArray pad(NDArray array, int[,] pad_width, string mode = "constant", object constant_values = null, object end_values = null, object stat_length = null, string reflect_type = "even")
Parameters
arrayNDArraypad_widthint[,]modestringconstant_valuesobjectend_valuesobjectstat_lengthobjectreflect_typestring
Returns
pad(NDArray, int[], PadFunc, object)
public static NDArray pad(NDArray array, int[] pad_width, np.PadFunc mode, object kwargs = null)
Parameters
Returns
pad(NDArray, int[], string, object, object, object, string)
public static NDArray pad(NDArray array, int[] pad_width, string mode = "constant", object constant_values = null, object end_values = null, object stat_length = null, string reflect_type = "even")
Parameters
arrayNDArraypad_widthint[]modestringconstant_valuesobjectend_valuesobjectstat_lengthobjectreflect_typestring
Returns
pad(NDArray, (int before, int after), PadFunc, object)
public static NDArray pad(NDArray array, (int before, int after) pad_width, np.PadFunc mode, object kwargs = null)
Parameters
Returns
pad(NDArray, (int before, int after), string, object, object, object, string)
public static NDArray pad(NDArray array, (int before, int after) pad_width, string mode = "constant", object constant_values = null, object end_values = null, object stat_length = null, string reflect_type = "even")
Parameters
arrayNDArraypad_width(int before, int after)modestringconstant_valuesobjectend_valuesobjectstat_lengthobjectreflect_typestring
Returns
percentile(NDArray, NDArray, int?, NDArray, bool, string, bool)
public static NDArray percentile(NDArray a, NDArray q, int? axis = null, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
percentile(NDArray, double, int[], NDArray, bool, string, bool)
public static NDArray percentile(NDArray a, double q, int[] axis, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
percentile(NDArray, double, int?, NDArray, bool, string, bool)
Compute the q-th percentile of the data along the specified axis.
q must be in [0, 100]. Equivalent to np.quantile(a, q/100).
public static NDArray percentile(NDArray a, double q, int? axis = null, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
Remarks
percentile(NDArray, double[], int[], NDArray, bool, string, bool)
public static NDArray percentile(NDArray a, double[] q, int[] axis, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
percentile(NDArray, double[], int?, NDArray, bool, string, bool)
public static NDArray percentile(NDArray a, double[] q, int? axis = null, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
place(NDArray, NDArray, NDArray)
Change elements of arr based on a boolean mask.
Where mask is true (walked in C-order), the
next value from vals (cycling) is written into
arr. In-place.
public static void place(NDArray arr, NDArray mask, NDArray vals)
Parameters
arrNDArrayTarget array (modified in place).
maskNDArrayBoolean mask. Must have the same total size as
arr— NumPy allows shape mismatch as long as element counts match.valsNDArrayValues to write. Cast to
arr's dtype and cycled to fill the True positions. Must be non-empty when at least one mask entry is True (NumPy parity).
Remarks
positive(NDArray, NDArray, NDArray, NPTypeCode?)
Numerical positive, element-wise (identity: returns +x, a copy).
Mirrors NumPy's ufunc signature: positive(x, /, out=None, *, where=True, dtype=None).
public static NDArray positive(NDArray nd, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
ndNDArrayoutNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?Explicit loop dtype (NumPy ufunc dtype=): positive(i32, dtype: float64) widens; bool loop requests raise NumPy's did-not-contain-a-loop TypeError (positive has no bool loop, but positive(bool, dtype: float64) is legal).
Returns
Remarks
power(NDArray, NDArray)
First array elements raised to powers from second array, element-wise. Supports broadcasting between x1 and x2.
public static NDArray power(NDArray x1, NDArray x2)
Parameters
Returns
- NDArray
The bases in x1 raised to the exponents in x2.
Remarks
power(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
First array elements raised to powers from second array, element-wise.
Mirrors NumPy's ufunc signature: power(x1, x2, /, out=None, *, where=True, dtype=None).
public static NDArray power(NDArray x1, NDArray x2, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
x1NDArrayThe bases.
x2NDArrayThe exponents (array).
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?Explicit loop dtype (NumPy ufunc dtype=): the computation runs in this dtype (power(2, -1, dtype: float64) = 0.5; inputs must be same_kind-castable to it).
Returns
Remarks
power(NDArray, NDArray, NPTypeCode)
First array elements raised to powers from second array, element-wise. Supports broadcasting between x1 and x2.
public static NDArray power(NDArray x1, NDArray x2, NPTypeCode typeCode)
Parameters
x1NDArrayThe bases.
x2NDArrayThe exponents (array).
typeCodeNPTypeCodeThe dtype of the returned NDArray.
Returns
- NDArray
The bases in x1 raised to the exponents in x2.
Remarks
power(NDArray, NDArray, Type)
First array elements raised to powers from second array, element-wise. Supports broadcasting between x1 and x2.
public static NDArray power(NDArray x1, NDArray x2, Type dtype)
Parameters
x1NDArrayThe bases.
x2NDArrayThe exponents (array).
dtypeTypeThe dtype of the returned NDArray.
Returns
- NDArray
The bases in x1 raised to the exponents in x2.
Remarks
power(NDArray, object)
First array elements raised to powers from second array, element-wise.
public static NDArray power(NDArray x1, object x2)
Parameters
Returns
- NDArray
The bases in x1 raised to the exponents in x2. This is a scalar NDArray if both x1 and x2 are scalars.
Remarks
power(NDArray, object, NPTypeCode)
First array elements raised to powers from second array, element-wise.
public static NDArray power(NDArray x1, object x2, NPTypeCode typeCode)
Parameters
x1NDArrayThe bases.
x2objectThe exponents (scalar or array-like).
typeCodeNPTypeCodeThe dtype of the returned NDArray
Returns
- NDArray
The bases in x1 raised to the exponents in x2. This is a scalar NDArray if both x1 and x2 are scalars.
Remarks
power(NDArray, object, Type)
First array elements raised to powers from second array, element-wise.
public static NDArray power(NDArray x1, object x2, Type dtype)
Parameters
x1NDArrayThe bases.
x2objectThe exponents (scalar or array-like).
dtypeTypeThe dtype of the returned NDArray
Returns
- NDArray
The bases in x1 raised to the exponents in x2. This is a scalar NDArray if both x1 and x2 are scalars.
Remarks
power(in NDArray, in NDArray)
First array elements raised to powers from second array, element-wise. Supports broadcasting between x1 and x2.
public static NDArray power(in NDArray x1, in NDArray x2)
Parameters
Returns
- NDArray
The bases in x1 raised to the exponents in x2.
Remarks
power(in NDArray, in NDArray, NPTypeCode)
First array elements raised to powers from second array, element-wise. Supports broadcasting between x1 and x2.
public static NDArray power(in NDArray x1, in NDArray x2, NPTypeCode typeCode)
Parameters
x1NDArrayThe bases.
x2NDArrayThe exponents (array).
typeCodeNPTypeCodeThe dtype of the returned NDArray.
Returns
- NDArray
The bases in x1 raised to the exponents in x2.
Remarks
power(in NDArray, in NDArray, Type)
First array elements raised to powers from second array, element-wise. Supports broadcasting between x1 and x2.
public static NDArray power(in NDArray x1, in NDArray x2, Type dtype)
Parameters
x1NDArrayThe bases.
x2NDArrayThe exponents (array).
dtypeTypeThe dtype of the returned NDArray.
Returns
- NDArray
The bases in x1 raised to the exponents in x2.
Remarks
printoptions(int?, int?, int?, int?, bool?, string, string, char?, string)
Context manager for setting print options (NumPy's np.printoptions). Restores the
previous options when disposed.
public static IDisposable printoptions(int? precision = null, int? threshold = null, int? edgeitems = null, int? linewidth = null, bool? suppress = null, string nanstr = null, string infstr = null, char? sign = null, string floatmode = null)
Parameters
precisionint?thresholdint?edgeitemsint?linewidthint?suppressbool?nanstrstringinfstrstringsignchar?floatmodestring
Returns
Examples
using (np.printoptions(precision: 2, suppress: true)) { Console.WriteLine(arr); }
Remarks
prod(NDArray, int?, Type, bool)
Return the product of array elements over a given axis.
public static NDArray prod(NDArray a, int? axis = null, Type dtype = null, bool keepdims = false)
Parameters
aNDArrayInput data.
axisint?Axis or axes along which a product is performed. The default, axis=None, will calculate the product of all the elements in the input array. If axis is negative it counts from the last to the first axis.
dtypeTypeThe type of the returned array, as well as of the accumulator in which the elements are multiplied. The dtype of a is used by default unless a has an integer dtype of less precision than the default platform integer. In that case, if a is signed then the platform integer is used while if a is unsigned then an unsigned integer of the same precision as the platform integer is used.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
Returns
- NDArray
An array shaped as a but with the specified axis removed.
Remarks
promote_types(NPTypeCode, NPTypeCode)
Returns the data type with the smallest size and smallest scalar kind to which both type1 and type2 can be safely cast.
public static NPTypeCode promote_types(NPTypeCode type1, NPTypeCode type2)
Parameters
type1NPTypeCodeFirst data type.
type2NPTypeCodeSecond data type.
Returns
- NPTypeCode
The promoted type.
Examples
np.promote_types(NPTypeCode.Int32, NPTypeCode.Single) // Double
np.promote_types(NPTypeCode.Int16, NPTypeCode.UInt16) // Int32
np.promote_types(NPTypeCode.Int8, NPTypeCode.Int8) // Int8
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.promote_types.html
Unlike result_type, promote_types only considers types (not values), and always returns the smallest safe type.
promote_types(Type, Type)
Returns the data type with the smallest size and smallest scalar kind to which both type1 and type2 can be safely cast.
public static NPTypeCode promote_types(Type type1, Type type2)
Parameters
Returns
- NPTypeCode
The promoted type as NPTypeCode.
promote_types<T1, T2>()
Returns the data type with the smallest size and smallest scalar kind to which both T1 and T2 can be safely cast.
public static NPTypeCode promote_types<T1, T2>() where T1 : struct where T2 : struct
Returns
- NPTypeCode
The promoted type as NPTypeCode.
Type Parameters
T1First type.
T2Second type.
Examples
np.promote_types<int, long>() // Int64
np.promote_types<float, double>() // Double
ptp(NDArray, int[], NDArray, bool)
public static NDArray ptp(NDArray a, int[] axis, NDArray @out = null, bool keepdims = false)
Parameters
Returns
ptp(NDArray, int?, NDArray, bool)
Range of values (maximum - minimum) along an axis.
Equivalent to np.amax(a, axis) - np.amin(a, axis); dtype is preserved,
so unsigned/signed integer overflow wraps the same way NumPy does
(e.g. ptp(uint8[0,255]) == 255, ptp(int8[-128,127]) == -1).
public static NDArray ptp(NDArray a, int? axis = null, NDArray @out = null, bool keepdims = false)
Parameters
Returns
Remarks
put(NDArray, NDArray, NDArray, string)
Replace elements of a with given values, at the
specified flat indices. In-place — modifies a.
Equivalent to a.flat[indices] = values with cyclic
broadcasting of values.
public static void put(NDArray a, NDArray indices, NDArray values, string mode = "raise")
Parameters
aNDArrayTarget array (modified in place).
indicesNDArrayInteger array of flat indices (cast to int64 internally). Indexing is into the C-order flattening of
a.valuesNDArrayValues to write. Cast to
a's dtype. Cycles modulo its size — shorter thanindicesis fine.modestringBoundary mode:
"raise"(default),"wrap", or"clip".
Remarks
put(NDArray, long, object, string)
Scalar-index, scalar-value convenience overload.
public static void put(NDArray a, long index, object value, string mode = "raise")
Parameters
quantile(NDArray, NDArray, int?, NDArray, bool, string, bool)
NDArray-q overload — accepts a 0-D or 1-D NDArray of quantile values. Higher-rank q is rejected (NumPy raises "q must be a scalar or 1d").
public static NDArray quantile(NDArray a, NDArray q, int? axis = null, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
quantile(NDArray, double, int[], NDArray, bool, string, bool)
Compute the q-th quantile, reducing along multiple axes.
public static NDArray quantile(NDArray a, double q, int[] axis, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
quantile(NDArray, double, int?, NDArray, bool, string, bool)
Compute the q-th quantile of the data along the specified axis.
q must be in the range [0, 1].
public static NDArray quantile(NDArray a, double q, int? axis = null, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
Remarks
quantile(NDArray, double[], int[], NDArray, bool, string, bool)
public static NDArray quantile(NDArray a, double[] q, int[] axis, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
quantile(NDArray, double[], int?, NDArray, bool, string, bool)
Compute the q-th quantiles of the data along the specified axis.
Each value in q must be in [0, 1]. Result's first axis is q.
public static NDArray quantile(NDArray a, double[] q, int? axis = null, NDArray @out = null, bool overwrite_input = false, string method = "linear", bool keepdims = false)
Parameters
Returns
rad2deg(NDArray, NDArray, NDArray, NPTypeCode?)
Convert angles from radians to degrees.
public static NDArray rad2deg(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayAngle in radians.
outNDArraywhereNDArraydtypeNPTypeCode?The dtype the returned ndarray should be of.
Returns
- NDArray
The corresponding angle in degrees. This is a scalar if x is a scalar.
Remarks
rad2deg(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray rad2deg(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayInput array.
dtypeNPTypeCodeThe loop dtype the computation should run in.
Returns
Remarks
rad2deg(NDArray, Type)
Convert angles from radians to degrees.
public static NDArray rad2deg(NDArray x, Type dtype)
Parameters
Returns
- NDArray
The corresponding angle in degrees. This is a scalar if x is a scalar.
Remarks
radians(NDArray, NDArray, NDArray, NPTypeCode?)
Convert angles from degrees to radians. Alias for deg2rad.
public static NDArray radians(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayAngles in degrees.
outNDArraywhereNDArraydtypeNPTypeCode?The dtype the returned ndarray should be of.
Returns
- NDArray
The corresponding angle in radians. This is a scalar if x is a scalar.
Remarks
radians(NDArray, NPTypeCode)
Alias for deg2rad — positional-dtype convenience overload.
public static NDArray radians(NDArray x, NPTypeCode dtype)
Parameters
xNDArraydtypeNPTypeCode
Returns
Remarks
radians(NDArray, Type)
Convert angles from degrees to radians. Alias for deg2rad.
public static NDArray radians(NDArray x, Type dtype)
Parameters
Returns
- NDArray
The corresponding angle in radians. This is a scalar if x is a scalar.
Remarks
ravel(NDArray)
Return a contiguous flattened array. A 1-D array, containing the elements of the input, is returned
public static NDArray ravel(NDArray a)
Parameters
aNDArrayInput array. The elements in a are read in the order specified by order, and packed as a 1-D array.
Returns
Remarks
ravel(NDArray, char)
Return a contiguous flattened array. A 1-D array, containing the elements of the input, is returned
public static NDArray ravel(NDArray a, char order)
Parameters
aNDArrayInput array.
ordercharThe order in which to read the elements. 'C' - row-major, 'F' - column-major, 'A' - 'F' if a is F-contiguous (and not C-contiguous) else 'C', 'K' - memory order.
Returns
Remarks
ravel_multi_index(NDArray[], int[], string, char)
Converts a tuple of coordinate arrays into an array of flat indices, applying boundary modes per axis. Inverse of unravel_index(NDArray, int[], char).
public static NDArray<long> ravel_multi_index(NDArray[] multi_index, int[] dims, string mode = "raise", char order = 'C')
Parameters
multi_indexNDArray[]Tuple of integer arrays, one per dimension. All arrays must share the same shape, which becomes the shape of the result.
dimsint[]Shape of the array the indices are unravelling into.
modestringBoundary mode:
"raise"(default — throw on OOB),"wrap"(modulo with sign correction), or"clip"(saturate). Applied to every axis.orderchar'C'(row-major, default) or'F'(column-major). Selects the stride ordering used to fold coordinates into a flat index.
Returns
- NDArray<long>
1-D (or shape-preserving) NDArray<TDType> of long.
Remarks
ravel_multi_index(NDArray[], int[], string[], char)
Per-axis mode overload. modes length must match
dims length.
public static NDArray<long> ravel_multi_index(NDArray[] multi_index, int[] dims, string[] modes, char order = 'C')
Parameters
Returns
ravel_multi_index(long[], int[], string, char)
Scalar convenience overload — folds a single coordinate tuple into a flat index. Equivalent to wrapping each coord in a 0-d NDArray but returns a long directly.
public static long ravel_multi_index(long[] coords, int[] dims, string mode = "raise", char order = 'C')
Parameters
Returns
reciprocal(NDArray, NDArray, NDArray, NPTypeCode?)
Return the reciprocal of the argument, element-wise. Calculates 1/x.
public static NDArray reciprocal(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array.
outNDArraywhereNDArraydtypeNPTypeCode?The dtype the returned ndarray should be of.
Returns
- NDArray
Return array containing 1/x for each element in x. This is a scalar if x is a scalar.
Remarks
reciprocal(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray reciprocal(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayInput array.
dtypeNPTypeCodeThe loop dtype the computation should run in.
Returns
Remarks
reciprocal(NDArray, Type)
Return the reciprocal of the argument, element-wise. Calculates 1/x.
public static NDArray reciprocal(NDArray x, Type dtype)
Parameters
Returns
- NDArray
Return array containing 1/x for each element in x. This is a scalar if x is a scalar.
Remarks
repeat(NDArray, NDArray, int?)
Repeat elements of an array with per-element repeat counts. Mirrors NumPy
np.repeat(a, repeats, axis): scalar / size-1 repeats broadcasts to
every element along the (flattened or selected) axis; otherwise the length must match.
public static NDArray repeat(NDArray a, NDArray repeats, int? axis = null)
Parameters
aNDArrayInput array.
repeatsNDArrayRepeat counts. Either a 0-d/size-1 array (broadcast) or a 1-D array of length equal to
a.size(axis=None) ora.shape[axis].axisint?Axis along which to repeat.
nullflattens the input.
Returns
- NDArray
A new array with elements repeated according to
repeats.
Remarks
repeat(NDArray, int, int?)
Repeat each element of an array after themselves.
public static NDArray repeat(NDArray a, int repeats, int? axis = null)
Parameters
aNDArrayInput array.
repeatsintThe number of repetitions for each element.
axisint?Axis along which to repeat values.
null(NumPyNone) flattens the input and returns a flat array.
Returns
- NDArray
Output array which has the same shape as
a, except alongaxis.
Remarks
repeat(NDArray, long, int?)
Repeat each element of an array after themselves.
public static NDArray repeat(NDArray a, long repeats, int? axis = null)
Parameters
aNDArrayInput array.
repeatslongThe number of repetitions for each element.
axisint?Axis along which to repeat values.
null(NumPyNone) flattens the input.
Returns
- NDArray
Output array.
Remarks
repeat<T>(T, int)
Repeat a scalar value.
public static NDArray repeat<T>(T a, int repeats) where T : unmanaged
Parameters
aTInput scalar.
repeatsintThe number of repetitions.
Returns
- NDArray
A 1-D array with the scalar repeated.
Type Parameters
T
Remarks
repeat<T>(T, long)
Repeat a scalar value.
public static NDArray repeat<T>(T a, long repeats) where T : unmanaged
Parameters
aTInput scalar.
repeatslongThe number of repetitions.
Returns
- NDArray
A 1-D array with the scalar repeated.
Type Parameters
T
Remarks
reshape(NDArray, Shape)
Gives a new shape to an array without changing its data.
public static NDArray reshape(NDArray nd, Shape shape)
Parameters
ndNDArrayArray to be reshaped.
shapeShapeThe new shape should be compatible with the original shape.
Returns
- NDArray
original
ndreshaped without copying.
Remarks
reshape(NDArray, ref Shape)
Gives a new shape to an array without changing its data.
public static NDArray reshape(NDArray nd, ref Shape shape)
Parameters
ndNDArrayArray to be reshaped.
shapeShapeThe new shape should be compatible with the original shape.
Returns
- NDArray
original
ndreshaped without copying.
Remarks
reshape(NDArray, int[])
Gives a new shape to an array without changing its data.
public static NDArray reshape(NDArray nd, int[] shape)
Parameters
ndNDArrayArray to be reshaped.
shapeint[]The new shape should be compatible with the original shape.
Returns
- NDArray
original
ndreshaped without copying.
Remarks
reshape(NDArray, long[])
Gives a new shape to an array without changing its data.
public static NDArray reshape(NDArray nd, long[] shape)
Parameters
ndNDArrayArray to be reshaped.
shapelong[]The new shape should be compatible with the original shape.
Returns
- NDArray
original
ndreshaped without copying.
Remarks
result_type(NDArray, NDArray)
Returns the type that results from applying the NumPy type promotion rules to the two arrays. Convenience overload to avoid params array allocation.
public static NPTypeCode result_type(NDArray arr1, NDArray arr2)
Parameters
Returns
- NPTypeCode
The result type from combining the array dtypes.
result_type(params NDArray[])
Returns the type that results from applying the NumPy type promotion rules to the arguments.
public static NPTypeCode result_type(params NDArray[] arrays)
Parameters
arraysNDArray[]One or more NDArray objects.
Returns
- NPTypeCode
The result type from combining the array dtypes.
result_type(NPTypeCode, NPTypeCode)
Returns the type that results from applying the NumPy type promotion rules to the two type codes. Convenience overload to avoid params array allocation.
public static NPTypeCode result_type(NPTypeCode type1, NPTypeCode type2)
Parameters
type1NPTypeCodeFirst type code.
type2NPTypeCodeSecond type code.
Returns
- NPTypeCode
The result type from combining the inputs.
result_type(params NPTypeCode[])
Returns the type that results from applying the NumPy type promotion rules to the arguments.
public static NPTypeCode result_type(params NPTypeCode[] types)
Parameters
typesNPTypeCode[]One or more NPTypeCode values.
Returns
- NPTypeCode
The result type from combining the inputs.
result_type(params object[])
Returns the type that results from applying the NumPy type promotion rules to the arguments.
public static NPTypeCode result_type(params object[] arrays_and_dtypes)
Parameters
arrays_and_dtypesobject[]Arrays and/or dtype arguments. Can be any mix of NDArray, NPTypeCode, or Type.
Returns
- NPTypeCode
The result type from combining the inputs.
Examples
np.result_type(NPTypeCode.Int32, NPTypeCode.Int64) // Int64
np.result_type(NPTypeCode.Int32, NPTypeCode.Single) // Double
np.result_type(a, b) // where a, b are NDArrays
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.result_type.html
Type promotion is the operation of determining the result type of an operation involving operands of different types.
result_type(Type, Type)
Returns the type that results from applying the NumPy type promotion rules to the two CLR types. Convenience overload to avoid params array allocation.
public static NPTypeCode result_type(Type type1, Type type2)
Parameters
Returns
- NPTypeCode
The result type from combining the inputs.
right_shift(NDArray, NDArray)
Shift the bits of an integer to the right.
public static NDArray right_shift(NDArray x1, NDArray x2)
Parameters
x1NDArrayInput array (integer types only).
x2NDArrayNumber of bits to shift (integer types only).
Returns
- NDArray
Array with bits shifted right.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.right_shift.html
Bits are shifted to the right by removing x2 bits from the right of x1. For unsigned integers, this is logical shift (zeros filled from left). For signed integers, this is arithmetic shift (sign bit extended). This operation is equivalent to floor division by 2**x2.
Example: np.right_shift(20, 2) = 5 # 0b10100 -> 0b101
right_shift(NDArray, object)
Shift the bits of an integer to the right by a scalar or array-like amount.
public static NDArray right_shift(NDArray x1, object x2)
Parameters
x1NDArrayInput array (integer types only).
x2objectNumber of bits to shift (scalar or array-like).
Returns
- NDArray
Array with bits shifted right.
roll(NDArray, int, int?)
Roll array elements along a given axis.
Elements that roll beyond the last position are re-introduced at the first.
public static NDArray roll(NDArray a, int shift, int? axis = null)
Parameters
aNDArrayInput array.
shiftintThe number of places by which elements are shifted.
axisint?Axis along which elements are shifted. By default, the array is flattened before shifting, after which the original shape is restored.
Returns
- NDArray
Output array, with the same shape as
a.
Remarks
Matches NumPy's algorithm: empty_like + slice-copy pairs. https://numpy.org/doc/stable/reference/generated/numpy.roll.html
roll(NDArray, long, int?)
Roll array elements along a given axis.
Elements that roll beyond the last position are re-introduced at the first.
public static NDArray roll(NDArray a, long shift, int? axis = null)
Parameters
aNDArrayInput array.
shiftlongThe number of places by which elements are shifted.
axisint?Axis along which elements are shifted. By default, the array is flattened before shifting, after which the original shape is restored.
Returns
- NDArray
Output array, with the same shape as
a.
Remarks
Matches NumPy's algorithm: empty_like + slice-copy pairs. https://numpy.org/doc/stable/reference/generated/numpy.roll.html
rollaxis(NDArray, int, int)
Roll the specified axis backwards, until it lies in a given position.
This function continues to be supported for backward compatibility, but you should prefer moveaxis. The moveaxis function was added in NumPy 1.11.
public static NDArray rollaxis(NDArray a, int axis, int start = 0)
Parameters
aNDArrayInput array.
axisintThe axis to roll backwards. The positions of the other axes do not change relative to one another.
startintThe axis is rolled until it lies before this position. The default, 0, results in a “complete” roll.
Returns
Remarks
round_(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload. NumPy's np.round/np.around accept out= only (they are
functions, not ufuncs — no where=/dtype= kwargs; probed 2.4.2).
public static NDArray round_(NDArray x, NPTypeCode dtype)
Parameters
xNDArraydtypeNPTypeCode
Returns
Remarks
round_(NDArray, int, NDArray)
Evenly round to the given number of decimals.
public static NDArray round_(NDArray x, int decimals = 0, NDArray @out = null)
Parameters
Returns
- NDArray
An array of the same type as a, containing the rounded values. Unless out was specified, a new array is created. A reference to the result is returned. The real and imaginary parts of complex numbers are rounded separately.The result of rounding a float is a float.
Remarks
round_(NDArray, int, NPTypeCode)
Evenly round to the given number of decimals.
public static NDArray round_(NDArray x, int decimals, NPTypeCode dtype)
Parameters
xNDArrayInput array
decimalsintNumber of decimal places to round to
dtypeNPTypeCodeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
An array of the same type as a, containing the rounded values. Unless out was specified, a new array is created. A reference to the result is returned. The real and imaginary parts of complex numbers are rounded separately.The result of rounding a float is a float.
Remarks
round_(NDArray, int, Type)
Evenly round to the given number of decimals.
public static NDArray round_(NDArray x, int decimals, Type dtype)
Parameters
xNDArrayInput array
decimalsintNumber of decimal places to round to
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
An array of the same type as a, containing the rounded values. Unless out was specified, a new array is created. A reference to the result is returned. The real and imaginary parts of complex numbers are rounded separately.The result of rounding a float is a float.
Remarks
round_(NDArray, Type)
Evenly round to the given number of decimals.
public static NDArray round_(NDArray x, Type dtype)
Parameters
xNDArrayInput array
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
An array of the same type as a, containing the rounded values. Unless out was specified, a new array is created. A reference to the result is returned. The real and imaginary parts of complex numbers are rounded separately.The result of rounding a float is a float.
Remarks
save(string, NDArray)
public static void save(string filepath, NDArray arr)
Parameters
save(string, Array)
public static void save(string filepath, Array arr)
Parameters
sctype2char(NPTypeCode)
Return the string representation of a scalar dtype.
public static char sctype2char(NPTypeCode sctype)
Parameters
sctypeNPTypeCodeA scalar type.
Returns
- char
The character code for the type.
Examples
np.sctype2char(NPTypeCode.Int32) // 'i'
np.sctype2char(NPTypeCode.Double) // 'd'
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.sctype2char.html
Character codes (NumPy): '?' - boolean 'b' - int8 (signed byte) 'B' - uint8 (unsigned byte) 'h' - int16 (short) 'H' - uint16 (unsigned short) 'i' - int32 'I' - uint32 'q' - int64 'Q' - uint64 'e' - float16 (Half) 'f' - float32 'd' - float64 'D' - complex128
searchsorted(NDArray, NDArray, string, NDArray)
Find indices where elements should be inserted to maintain order.
Find the indices into a sorted array a such that, if the corresponding elements
in v were inserted before the indices, the order of a would be preserved.
public static NDArray searchsorted(NDArray a, NDArray v, string side = "left", NDArray sorter = null)
Parameters
aNDArrayInput 1-D array. Must be sorted ascending unless
sorteris provided.vNDArrayValues to insert into
a. May be a scalar or any shape.sidestringIf "left" (default), the index of the first suitable location is returned. If "right", the last such index.
sorterNDArrayOptional indices that sort
ainto ascending order (typicallyargsort(a)).
Returns
- NDArray
Array of insertion points with the same shape as
v, or a scalar ifvis a scalar.
Remarks
searchsorted(NDArray, double, string, NDArray)
Find index where a scalar should be inserted to maintain order.
public static long searchsorted(NDArray a, double v, string side = "left", NDArray sorter = null)
Parameters
Returns
searchsorted(NDArray, int, string, NDArray)
Find index where a scalar should be inserted to maintain order.
public static long searchsorted(NDArray a, int v, string side = "left", NDArray sorter = null)
Parameters
aNDArrayInput 1-D array. Must be sorted ascending unless
sorteris provided.vintValue to insert into
a.sidestringIf "left" (default), index of the first suitable location is returned. If "right", the last such index.
sorterNDArrayOptional indices that sort
ainto ascending order (typicallyargsort(a)).
Returns
- long
Scalar index for insertion point.
Remarks
set_printoptions(int?, int?, int?, int?, bool?, string, string, char?, string)
Set printing options (NumPy's np.set_printoptions). These options determine the
way floating point numbers, arrays and other NumPy objects are displayed.
public static void set_printoptions(int? precision = null, int? threshold = null, int? edgeitems = null, int? linewidth = null, bool? suppress = null, string nanstr = null, string infstr = null, char? sign = null, string floatmode = null)
Parameters
precisionint?thresholdint?edgeitemsint?linewidthint?suppressbool?nanstrstringinfstrstringsignchar?floatmodestring
Remarks
sign(NDArray, NDArray, NDArray, NPTypeCode?)
public static NDArray sign(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayoutNDArraywhereNDArraydtypeNPTypeCode?
Returns
sign(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray sign(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayInput array.
dtypeNPTypeCodeThe loop dtype the computation should run in.
Returns
Remarks
sign(NDArray, Type)
public static NDArray sign(NDArray x, Type dtype)
Parameters
Returns
sin(NDArray, NDArray, NDArray, NPTypeCode?)
Trigonometric sine, element-wise.
Mirrors NumPy's ufunc signature: sin(x, /, out=None, *, where=True, dtype=None).
public static NDArray sin(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayAngle, in radians (2 \pi rad equals 360 degrees).
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?Explicit loop dtype (NumPy ufunc dtype=): the computation runs at this precision; integer/bool requests raise NumPy's "No loop matching" error.
Returns
- NDArray
The sine of each element of x. This is a scalar if x is a scalar.
Remarks
sin(NDArray, NPTypeCode)
Trigonometric sine, element-wise, computed in dtype.
Positional-dtype convenience overload (NumPy accepts dtype only as a keyword).
public static NDArray sin(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayAngle, in radians (2 \pi rad equals 360 degrees).
dtypeNPTypeCodeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
Remarks
sin(NDArray, Type)
Trigonometric sine, element-wise.
public static NDArray sin(NDArray x, Type dtype)
Parameters
xNDArrayAngle, in radians (2 \pi rad equals 360 degrees).
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
The sine of each element of x. This is a scalar if x is a scalar.
Remarks
sinh(NDArray, NDArray, NDArray, NPTypeCode?)
Hyperbolic sine, element-wise.
Equivalent to 1/2 * (np.exp(x) - np.exp(-x)) or -1j * np.sin(1j*x).
public static NDArray sinh(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array.
outNDArraywhereNDArraydtypeNPTypeCode?The dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
The sine of each element of x. This is a scalar if x is a scalar.
Remarks
sinh(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray sinh(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayInput array.
dtypeNPTypeCodeThe loop dtype the computation should run in.
Returns
Remarks
sinh(NDArray, Type)
Hyperbolic sine, element-wise.
Equivalent to 1/2 * (np.exp(x) - np.exp(-x)) or -1j * np.sin(1j*x).
public static NDArray sinh(NDArray x, Type dtype)
Parameters
xNDArrayInput array.
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
The sine of each element of x. This is a scalar if x is a scalar.
Remarks
size(NDArray, int?)
Return the number of elements along a given axis.
public static long size(NDArray a, int? axis = null)
Parameters
aNDArrayInput data.
axisint?Axis along which the elements are counted. By default, give the total number of elements.
Returns
- long
Number of elements along the specified axis.
Remarks
sort(NDArray, int?, string)
Return a sorted copy of an array, sorted along axis
(default last; null flattens first). NumPy np.sort.
public static NDArray sort(NDArray a, int? axis = -1, string kind = null)
Parameters
aNDArrayArray to sort.
axisint?Axis to sort along. -1 = last axis. null = sort the flattened array.
kindstringSort algorithm name (NumPy compatibility). All kinds produce identical sorted output; the kernel is a stable LSD radix (numeric) or BCL introsort (Half/Complex/Decimal).
Returns
Remarks
NaN floats sort to the end; complex sorts lexicographically (real then imaginary), any-NaN-part last — matching NumPy 2.4.2.
split(NDArray, int, int)
Split an array into multiple sub-arrays as views into ary.
public static NDArray[] split(NDArray ary, int indices_or_sections, int axis = 0)
Parameters
aryNDArrayArray to be divided into sub-arrays.
indices_or_sectionsintIf an integer, N, the array will be divided into N equal arrays along axis. If such a split is not possible, an error is raised.
axisintThe axis along which to split, default is 0.
Returns
- NDArray[]
A list of sub-arrays as views into ary.
Remarks
Exceptions
- ArgumentException
If indices_or_sections is an integer and does not result in equal division.
split(NDArray, int[], int)
Split an array into multiple sub-arrays as views into ary.
public static NDArray[] split(NDArray ary, int[] indices, int axis = 0)
Parameters
Returns
- NDArray[]
split(NDArray, long[], int)
Split an array into multiple sub-arrays as views into ary.
public static NDArray[] split(NDArray ary, long[] indices, int axis = 0)
Parameters
Returns
- NDArray[]
sqrt(NDArray, NDArray, NDArray, NPTypeCode?)
Return the non-negative square-root of an array, element-wise.
Mirrors NumPy's ufunc signature: sqrt(x, /, out=None, *, where=True, dtype=None).
public static NDArray sqrt(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayThe values whose square-roots are required.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?Explicit loop dtype (NumPy ufunc dtype=): the computation runs at this precision; integer/bool requests raise NumPy's "No loop matching" error.
Returns
- NDArray
An array of the same shape as x, containing the positive square-root of each element in x. If any element in x is complex, a complex array is returned (and the square-roots of negative reals are calculated). If all of the elements in x are real, so is y, with negative elements returning nan. If out was provided, y is a reference to it. This is a scalar if x is a scalar.
Remarks
sqrt(NDArray, NPTypeCode)
Return the non-negative square-root of an array, element-wise, computed in dtype.
Positional-dtype convenience overload (NumPy accepts dtype only as a keyword; the
NumPy-shaped overload above takes it after out/where).
public static NDArray sqrt(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayThe values whose square-roots are required.
dtypeNPTypeCodeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
Remarks
sqrt(NDArray, Type)
Return the non-negative square-root of an array, element-wise.
public static NDArray sqrt(NDArray x, Type dtype)
Parameters
xNDArrayThe values whose square-roots are required.
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
An array of the same shape as x, containing the positive square-root of each element in x. If any element in x is complex, a complex array is returned (and the square-roots of negative reals are calculated). If all of the elements in x are real, so is y, with negative elements returning nan. If out was provided, y is a reference to it. This is a scalar if x is a scalar.
Remarks
square(NDArray)
Return the element-wise square of the input.
public static NDArray square(NDArray x)
Parameters
xNDArrayInput data.
Returns
- NDArray
Element-wise x*x, of the same shape and dtype as x. Returns scalar if x is a scalar.
Remarks
square(NDArray, NDArray, NDArray, NPTypeCode?)
Return the element-wise square of the input.
Mirrors NumPy's ufunc signature: square(x, /, out=None, *, where=True, dtype=None).
public static NDArray square(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayInput data.
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?Explicit loop dtype (NumPy ufunc dtype=): the input must be same_kind-castable to it.
Returns
Remarks
squeeze(NDArray)
Remove single-dimensional entries from the shape of an array.
public static NDArray squeeze(NDArray a)
Parameters
aNDArrayInput data.
Returns
- NDArray
The input array, but with all or a subset of the dimensions of length 1 removed. This is always a itself or a view into a.
Remarks
squeeze(NDArray, int)
Remove single-dimensional entries from the shape of an array.
public static NDArray squeeze(NDArray a, int axis)
Parameters
aNDArrayInput data.
axisintSelects a subset of the single-dimensional entries in the shape. If an axis is selected with shape entry greater than one, an error is raised.
Returns
- NDArray
The input array, but with all or a subset of the dimensions of length 1 removed. This is always a itself or a view into a.
Remarks
Exceptions
- IncorrectShapeException
If axis is not None, and an axis being squeezed is not of length 1
squeeze(Shape)
Remove single-dimensional entries from a shape.
public static Shape squeeze(Shape shape)
Parameters
shapeShapeInput shape.
Returns
- Shape
The input array, but with all or a subset of the dimensions of length 1 removed. This is always a itself or a view into a.
Remarks
stack(NDArray[], int)
Join a sequence of arrays along a new axis. The axis parameter specifies the index of the new axis in the dimensions of the result. For example, if axis=0 it will be the first dimension and if axis=-1 it will be the last dimension.
public static NDArray stack(NDArray[] arrays, int axis = 0)
Parameters
arraysNDArray[]Each array must have the same shape.
axisintThe axis in the result array along which the input arrays are stacked.
Returns
- NDArray
The stacked array has one more dimension than the input arrays.
Remarks
std(NDArray, bool, int?, NPTypeCode?)
Compute the standard deviation along the specified axis. Returns the standard deviation, a measure of the spread of a distribution, of the array elements. The standard deviation is computed for the flattened array by default, otherwise over the specified axis.
public static NDArray std(NDArray a, bool keepdims = false, int? ddof = null, NPTypeCode? dtype = null)
Parameters
aNDArrayCalculate the standard deviation of these values.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
ddofint?Means Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements. By default ddof is zero.
dtypeNPTypeCode?
Returns
- NDArray
returns a new array containing the std values, otherwise a reference to the output array is returned.
Remarks
std(NDArray, int, NPTypeCode, bool, int?)
Compute the standard deviation along the specified axis. Returns the standard deviation, a measure of the spread of a distribution, of the array elements. The standard deviation is computed for the flattened array by default, otherwise over the specified axis.
public static NDArray std(NDArray a, int axis, NPTypeCode type, bool keepdims = false, int? ddof = null)
Parameters
aNDArrayCalculate the standard deviation of these values.
axisintAxis or axes along which the standard deviation is computed. The default is to compute the standard deviation of the flattened array.
typeNPTypeCodekeepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
ddofint?Means Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements. By default ddof is zero.
Returns
- NDArray
returns a new array containing the std values, otherwise a reference to the output array is returned.
Remarks
std(NDArray, int, bool, int?, NPTypeCode?)
Compute the standard deviation along the specified axis. Returns the standard deviation, a measure of the spread of a distribution, of the array elements. The standard deviation is computed for the flattened array by default, otherwise over the specified axis.
public static NDArray std(NDArray a, int axis, bool keepdims = false, int? ddof = null, NPTypeCode? dtype = null)
Parameters
aNDArrayCalculate the standard deviation of these values.
axisintAxis or axes along which the standard deviation is computed. The default is to compute the standard deviation of the flattened array.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
ddofint?Means Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements. By default ddof is zero.
dtypeNPTypeCode?
Returns
- NDArray
returns a new array containing the std values, otherwise a reference to the output array is returned.
Remarks
std(NDArray, int, Type, bool, int?)
Compute the standard deviation along the specified axis. Returns the standard deviation, a measure of the spread of a distribution, of the array elements. The standard deviation is computed for the flattened array by default, otherwise over the specified axis.
public static NDArray std(NDArray a, int axis, Type dtype, bool keepdims = false, int? ddof = null)
Parameters
aNDArrayCalculate the standard deviation of these values.
axisintAxis or axes along which the standard deviation is computed. The default is to compute the standard deviation of the flattened array.
dtypeTypekeepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
ddofint?Means Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements. By default ddof is zero.
Returns
- NDArray
returns a new array containing the std values, otherwise a reference to the output array is returned.
Remarks
subtract(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
public static NDArray subtract(NDArray x1, NDArray x2, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
x1NDArrayx2NDArrayoutNDArraywhereNDArraydtypeNPTypeCode?
Returns
Remarks
sum(NDArray)
Sum of array elements over a given axis.
public static NDArray sum(NDArray a)
Parameters
aNDArrayElements to sum.
Returns
- NDArray
An array with the same shape as a, with the specified axis removed. If a is a 0-d array, or if axis is None, a scalar is returned. If an output array is specified, a reference to out is returned.
Remarks
sum(NDArray, bool)
Sum of array elements over a given axis.
public static NDArray sum(NDArray a, bool keepdims)
Parameters
aNDArrayElements to sum.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array. If the default value is passed, then keepdims will not be passed through to the sum method of sub-classes of ndarray, however any non-default value will be.If the sub-class’ method does not implement keepdims any exceptions will be raised.
Returns
- NDArray
An array with the same shape as a, with the specified axis removed. If a is a 0-d array, or if axis is None, a scalar is returned. If an output array is specified, a reference to out is returned.
Remarks
sum(NDArray, int)
Sum of array elements over a given axis.
public static NDArray sum(NDArray a, int axis)
Parameters
aNDArrayElements to sum.
axisintAxis or axes along which a sum is performed. The default, axis=None, will sum all of the elements of the input array. If axis is negative it counts from the last to the first axis.
Returns
- NDArray
An array with the same shape as a, with the specified axis removed. If a is a 0-d array, or if axis is None, a scalar is returned. If an output array is specified, a reference to out is returned.
Remarks
sum(NDArray, NPTypeCode?)
Sum of array elements over a given axis.
public static NDArray sum(NDArray a, NPTypeCode? typeCode)
Parameters
aNDArrayElements to sum.
typeCodeNPTypeCode?The type of the returned array and of the accumulator in which the elements are summed. The dtype of a is used by default unless a has an integer dtype of less precision than the default platform integer. In that case, if a is signed then the platform integer is used while if a is unsigned then an unsigned integer of the same precision as the platform integer is used.
Returns
- NDArray
An array with the same shape as a, with the specified axis removed. If a is a 0-d array, or if axis is None, a scalar is returned. If an output array is specified, a reference to out is returned.
Remarks
sum(NDArray, int?, bool)
Sum of array elements over a given axis.
public static NDArray sum(NDArray a, int? axis, bool keepdims)
Parameters
aNDArrayElements to sum.
axisint?Axis or axes along which a sum is performed. The default, axis=None, will sum all of the elements of the input array. If axis is negative it counts from the last to the first axis.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array. If the default value is passed, then keepdims will not be passed through to the sum method of sub-classes of ndarray, however any non-default value will be.If the sub-class’ method does not implement keepdims any exceptions will be raised.
Returns
- NDArray
An array with the same shape as a, with the specified axis removed. If a is a 0-d array, or if axis is None, a scalar is returned. If an output array is specified, a reference to out is returned.
Remarks
sum(NDArray, int?, bool, NPTypeCode?)
Sum of array elements over a given axis.
public static NDArray sum(NDArray a, int? axis, bool keepdims, NPTypeCode? typeCode)
Parameters
aNDArrayElements to sum.
axisint?Axis or axes along which a sum is performed. The default, axis=None, will sum all of the elements of the input array. If axis is negative it counts from the last to the first axis.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array. If the default value is passed, then keepdims will not be passed through to the sum method of sub-classes of ndarray, however any non-default value will be.If the sub-class’ method does not implement keepdims any exceptions will be raised.
typeCodeNPTypeCode?The type of the returned array and of the accumulator in which the elements are summed. The dtype of a is used by default unless a has an integer dtype of less precision than the default platform integer. In that case, if a is signed then the platform integer is used while if a is unsigned then an unsigned integer of the same precision as the platform integer is used.
Returns
- NDArray
An array with the same shape as a, with the specified axis removed. If a is a 0-d array, or if axis is None, a scalar is returned. If an output array is specified, a reference to out is returned.
Remarks
sum(NDArray, int?, bool, Type)
Sum of array elements over a given axis.
public static NDArray sum(NDArray a, int? axis, bool keepdims, Type dtype)
Parameters
aNDArrayElements to sum.
axisint?Axis or axes along which a sum is performed. The default, axis=None, will sum all of the elements of the input array. If axis is negative it counts from the last to the first axis.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array. If the default value is passed, then keepdims will not be passed through to the sum method of sub-classes of ndarray, however any non-default value will be.If the sub-class’ method does not implement keepdims any exceptions will be raised.
dtypeTypeThe type of the returned array and of the accumulator in which the elements are summed. The dtype of a is used by default unless a has an integer dtype of less precision than the default platform integer. In that case, if a is signed then the platform integer is used while if a is unsigned then an unsigned integer of the same precision as the platform integer is used.
Returns
- NDArray
An array with the same shape as a, with the specified axis removed. If a is a 0-d array, or if axis is None, a scalar is returned. If an output array is specified, a reference to out is returned.
Remarks
sum(NDArray, int?, NPTypeCode?)
Sum of array elements over a given axis.
public static NDArray sum(NDArray a, int? axis, NPTypeCode? typeCode)
Parameters
aNDArrayElements to sum.
axisint?Axis or axes along which a sum is performed. The default, axis=None, will sum all of the elements of the input array. If axis is negative it counts from the last to the first axis.
typeCodeNPTypeCode?The type of the returned array and of the accumulator in which the elements are summed. The dtype of a is used by default unless a has an integer dtype of less precision than the default platform integer. In that case, if a is signed then the platform integer is used while if a is unsigned then an unsigned integer of the same precision as the platform integer is used.
Returns
- NDArray
An array with the same shape as a, with the specified axis removed. If a is a 0-d array, or if axis is None, a scalar is returned. If an output array is specified, a reference to out is returned.
Remarks
sum(NDArray, int?, Type)
Sum of array elements over a given axis.
public static NDArray sum(NDArray a, int? axis, Type dtype)
Parameters
aNDArrayElements to sum.
axisint?Axis or axes along which a sum is performed. The default, axis=None, will sum all of the elements of the input array. If axis is negative it counts from the last to the first axis.
dtypeTypeThe type of the returned array and of the accumulator in which the elements are summed. The dtype of a is used by default unless a has an integer dtype of less precision than the default platform integer. In that case, if a is signed then the platform integer is used while if a is unsigned then an unsigned integer of the same precision as the platform integer is used.
Returns
- NDArray
An array with the same shape as a, with the specified axis removed. If a is a 0-d array, or if axis is None, a scalar is returned. If an output array is specified, a reference to out is returned.
Remarks
sum(NDArray, Type)
Sum of array elements over a given axis.
public static NDArray sum(NDArray a, Type dtype)
Parameters
aNDArrayElements to sum.
dtypeTypeThe type of the returned array and of the accumulator in which the elements are summed. The dtype of a is used by default unless a has an integer dtype of less precision than the default platform integer. In that case, if a is signed then the platform integer is used while if a is unsigned then an unsigned integer of the same precision as the platform integer is used.
Returns
- NDArray
An array with the same shape as a, with the specified axis removed. If a is a 0-d array, or if axis is None, a scalar is returned. If an output array is specified, a reference to out is returned.
Remarks
swapaxes(NDArray, int, int)
Interchange two axes of an array.
public static NDArray swapaxes(NDArray a, int axis1, int axis2)
Parameters
Returns
Remarks
take(NDArray, NDArray, int?, NDArray, string)
Take elements from an array along an axis. Equivalent to fancy indexing along the specified axis.
public static NDArray take(NDArray a, NDArray indices, int? axis = null, NDArray @out = null, string mode = "raise")
Parameters
aNDArraySource array.
indicesNDArrayInteger array of indices to take.
axisint?Axis along which to take.
null(default) flattensaand treatsindicesas flat indices.outNDArrayOptional destination array. When supplied, its shape must match the natural take output; values are cast to
out's dtype via copyto(NDArray, NDArray, string, NDArray) with unsafe casting and the method returnsoutitself. Whennull(default), a fresh array is allocated witha's dtype.modestringBoundary mode:
"raise"(default — throw on OOB),"wrap"(modulo with sign correction), or"clip"(saturate).
Returns
- NDArray
New array with shape:
axis=None: same asindices.axis=k:a.shape[:k] + indices.shape + a.shape[k+1:].
Dtype matches
a(orout's dtype whenoutis supplied).
Remarks
take(NDArray, long, int?, NDArray, string)
Scalar convenience overload — take a single element by flat index.
public static NDArray take(NDArray a, long index, int? axis = null, NDArray @out = null, string mode = "raise")
Parameters
Returns
tan(NDArray, NDArray, NDArray, NPTypeCode?)
Compute tangent element-wise.
Equivalent to np.sin(x)/np.cos(x) element-wise.
Mirrors NumPy's ufunc signature: tan(x, /, out=None, *, where=True, dtype=None).
public static NDArray tan(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayAngle, in radians (2 \pi rad equals 360 degrees).
outNDArraywhereNDArrayBoolean mask: only mask-true elements are computed/written (NumPy ufunc where=).
dtypeNPTypeCode?Explicit loop dtype (NumPy ufunc dtype=): the computation runs at this precision; integer/bool requests raise NumPy's "No loop matching" error.
Returns
- NDArray
The tangent of each element of x. This is a scalar if x is a scalar.
Remarks
tan(NDArray, NPTypeCode)
Compute tangent element-wise, computed in dtype.
Positional-dtype convenience overload (NumPy accepts dtype only as a keyword).
public static NDArray tan(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayAngle, in radians (2 \pi rad equals 360 degrees).
dtypeNPTypeCodeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
Remarks
tan(NDArray, Type)
Trigonometric sine, element-wise.
public static NDArray tan(NDArray x, Type dtype)
Parameters
xNDArrayAngle, in radians (2 \pi rad equals 360 degrees).
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
The sine of each element of x. This is a scalar if x is a scalar.
Remarks
tanh(NDArray, NDArray, NDArray, NPTypeCode?)
Compute hyperbolic tangent element-wise.
Equivalent to np.sinh(x)/np.cosh(x) or -1j * np.tan(1j*x).
public static NDArray tanh(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array.
outNDArraywhereNDArraydtypeNPTypeCode?The dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
The sine of each element of x. This is a scalar if x is a scalar.
Remarks
tanh(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray tanh(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayInput array.
dtypeNPTypeCodeThe loop dtype the computation should run in.
Returns
Remarks
tanh(NDArray, Type)
Compute hyperbolic tangent element-wise.
Equivalent to np.sinh(x)/np.cosh(x) or -1j * np.tan(1j*x).
public static NDArray tanh(NDArray x, Type dtype)
Parameters
xNDArrayInput array.
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
Returns
- NDArray
The sine of each element of x. This is a scalar if x is a scalar.
Remarks
tile(NDArray, params int[])
Construct an array by repeating A the number of times given by reps.
If reps has length d, the result has dimension max(d, A.ndim).
If A.ndim < d, A is promoted to be d-dimensional by prepending size-1 axes.
If A.ndim > d, reps is promoted to A.ndim by prepending 1s.
public static NDArray tile(NDArray A, params int[] reps)
Parameters
ANDArrayThe input array.
repsint[]The number of repetitions of A along each axis. Each rep must be non-negative.
Returns
- NDArray
The tiled output array. Expanded outputs are C-contiguous; all-one reps produce a keep-order copy. Dtype matches
A.
Remarks
Exceptions
- ArgumentNullException
If
Aorrepsis null.- ArgumentException
If any element of
repsis negative.
tile(NDArray, long[])
Construct an array by repeating A the number of times given by reps.
Long overload — see tile(NDArray, params int[]).
public static NDArray tile(NDArray A, long[] reps)
Parameters
Returns
trace(NDArray, int, int, int, Type, NDArray)
Return the sum along diagonals of the array. For a 2-D array,
trace(a) == sum(a.diagonal()). For an N-D array, traces
the diagonals along the 2-D sub-arrays defined by
axis1 / axis2 and reduces
them, leaving an array with those two axes removed.
public static NDArray trace(NDArray a, int offset = 0, int axis1 = 0, int axis2 = 1, Type dtype = null, NDArray @out = null)
Parameters
aNDArraySource array. Must have at least 2 dimensions.
offsetintOffset of the diagonal from the main diagonal. See diagonal(NDArray, int, int, int) for details.
axis1intFirst axis of the 2-D sub-array. Default 0.
axis2intSecond axis of the 2-D sub-array. Default 1.
dtypeTypeOutput dtype.
null(default) preservesa.dtype, except integer dtypes narrower than long promote to long (NEP50 / matches NumPy's "default platform integer" rule). Bool input promotes to long.outNDArrayOptional output array. Shape must equal the natural reduction output; values are copied with unsafe casting and the method returns
outitself.
Returns
- NDArray
Sum along the diagonal. 2-D input → 0-d scalar. N-D input → array with
a.shapeminusaxis1andaxis2.
Remarks
https://numpy.org/doc/stable/reference/generated/numpy.trace.html
Mirrors NumPy's PyArray_Trace: sum(diagonal(a,
offset, axis1, axis2), axis=-1, dtype=dtype, out=out). The
diagonal view is the heavy lifting; the sum is a regular
reduction that goes through NumSharp's IL reduction kernels.
transpose(NDArray, int[])
Permute the dimensions of an array.
public static NDArray transpose(NDArray a, int[] premute = null)
Parameters
aNDArrayInput array.
premuteint[]By default, reverse the dimensions, otherwise permute the axes according to the values given.
Returns
- NDArray
a with its axes permuted. A view is returned whenever possible.
Remarks
true_divide(NDArray, NDArray, NDArray, NDArray, NPTypeCode?)
public static NDArray true_divide(NDArray x1, NDArray x2, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
x1NDArrayx2NDArrayoutNDArraywhereNDArraydtypeNPTypeCode?
Returns
Remarks
trunc(NDArray, NDArray, NDArray, NPTypeCode?)
Return the truncated value of the input, element-wise. The truncated value of the scalar x is the nearest integer i which is closer to zero than x is.
public static NDArray trunc(NDArray x, NDArray @out = null, NDArray where = null, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array.
outNDArraywhereNDArraydtypeNPTypeCode?The dtype the returned ndarray should be of.
Returns
- NDArray
The truncated value of each element in x. This is a scalar if x is a scalar.
Remarks
trunc(NDArray, NPTypeCode)
Computed in dtype — positional-dtype convenience
overload (NumPy accepts dtype only as a keyword).
public static NDArray trunc(NDArray x, NPTypeCode dtype)
Parameters
xNDArrayInput array.
dtypeNPTypeCodeThe loop dtype the computation should run in.
Returns
Remarks
trunc(NDArray, Type)
Return the truncated value of the input, element-wise. The truncated value of the scalar x is the nearest integer i which is closer to zero than x is.
public static NDArray trunc(NDArray x, Type dtype)
Parameters
Returns
- NDArray
The truncated value of each element in x. This is a scalar if x is a scalar.
Remarks
unique(NDArray)
Find the unique elements of an array.
Returns the sorted unique elements of an array.There are three optional outputs in addition to the unique elements:
- the indices of the input array that give the unique values
- the indices of the unique array that reconstruct the input array
- the number of times each unique value comes up in the input array
public static NDArray unique(NDArray ar)
Parameters
arNDArray
Returns
- NDArray
The sorted unique values.
Remarks
unique(NDArray, bool, bool, bool, int?, bool)
Find the unique elements of an array with full NumPy keyword argument support.
Returns sorted unique elements; optionally returns first-occurrence indices, reconstruction indices, and counts. Supports axis-aware uniqueness.
public static NDArray[] unique(NDArray ar, bool return_index, bool return_inverse = false, bool return_counts = false, int? axis = null, bool equal_nan = true)
Parameters
arNDArrayInput array.
return_indexboolIf True, also return indices of
ar(along the specified axis, if provided) that result in the unique array.return_inverseboolIf True, also return the indices of the unique array that can be used to reconstruct
ar.return_countsboolIf True, also return the number of times each unique item appears in
ar.axisint?The axis to operate on. If
null, the array is flattened first.equal_nanboolIf True (default), all NaN values are considered equal so only one appears in the output. If False, each NaN is treated as unique.
Returns
- NDArray[]
An array of NDArrays in order: [values, index?, inverse?, counts?]. The first element is always the sorted unique values; remaining elements are present only when the corresponding flag is True.
Remarks
unravel_index(NDArray, int[], char)
Converts a flat index or array of flat indices into a tuple of coordinate arrays. Inverse of ravel_multi_index(NDArray[], int[], string, char).
public static NDArray<long>[] unravel_index(NDArray indices, int[] shape, char order = 'C')
Parameters
indicesNDArrayAn integer array whose elements are indices into the flattened version of an array of dimensions
shape. Cast to int64 internally.shapeint[]The shape of the array to use for unraveling.
orderchar'C'(row-major, default) or'F'(column-major) — selects the extraction order for the coordinate tuple.
Returns
- NDArray<long>[]
A tuple of
shape.LengthNDArrays. Each output array has the same shape asindices. Element dtype is always Int64.
Remarks
Exceptions
- ArgumentException
shapeis empty, has non-positive dims, or the dims' product overflows int64.- ArgumentOutOfRangeException
Any index in
indicesis < 0 or= product of
shape.
unravel_index(long, int[], char)
Scalar convenience overload — converts a single flat index into a coord
array. Equivalent to unravel_index(NDArray.Scalar(index), shape, order)
but returns a long[] directly without NDArray wrapping.
public static long[] unravel_index(long index, int[] shape, char order = 'C')
Parameters
Returns
- long[]
var(NDArray, bool, int?, NPTypeCode?)
Compute the variance along the specified axis. Returns the variance of the array elements, a measure of the spread of a distribution. The variance is computed for the flattened array by default, otherwise over the specified axis.
public static NDArray var(NDArray a, bool keepdims = false, int? ddof = null, NPTypeCode? dtype = null)
Parameters
aNDArrayArray containing numbers whose variance is desired. If a is not an array, a conversion is attempted.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
ddofint?Means Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements. By default ddof is zero.
dtypeNPTypeCode?
Returns
- NDArray
returns a new array containing the var values, otherwise a reference to the output array is returned.
Remarks
var(NDArray, int, NPTypeCode, bool, int?)
Compute the variance along the specified axis. Returns the variance of the array elements, a measure of the spread of a distribution. The variance is computed for the flattened array by default, otherwise over the specified axis.
public static NDArray var(NDArray a, int axis, NPTypeCode type, bool keepdims = false, int? ddof = null)
Parameters
aNDArrayArray containing numbers whose variance is desired. If a is not an array, a conversion is attempted.
axisintAxis or axes along which the variance is computed. The default is to compute the variance of the flattened array.
typeNPTypeCodekeepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
ddofint?Means Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements. By default ddof is zero.
Returns
- NDArray
returns a new array containing the var values, otherwise a reference to the output array is returned.
Remarks
var(NDArray, int, bool, int?, NPTypeCode?)
Compute the variance along the specified axis. Returns the variance of the array elements, a measure of the spread of a distribution. The variance is computed for the flattened array by default, otherwise over the specified axis.
public static NDArray var(NDArray a, int axis, bool keepdims = false, int? ddof = null, NPTypeCode? dtype = null)
Parameters
aNDArrayArray containing numbers whose variance is desired. If a is not an array, a conversion is attempted.
axisintAxis or axes along which the variance is computed. The default is to compute the variance of the flattened array.
keepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
ddofint?Means Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements. By default ddof is zero.
dtypeNPTypeCode?
Returns
- NDArray
returns a new array containing the var values, otherwise a reference to the output array is returned.
Remarks
var(NDArray, int, Type, bool, int?)
Compute the variance along the specified axis. Returns the variance of the array elements, a measure of the spread of a distribution. The variance is computed for the flattened array by default, otherwise over the specified axis.
public static NDArray var(NDArray a, int axis, Type dtype, bool keepdims = false, int? ddof = null)
Parameters
aNDArrayArray containing numbers whose variance is desired. If a is not an array, a conversion is attempted.
axisintAxis or axes along which the variance is computed. The default is to compute the variance of the flattened array.
dtypeTypekeepdimsboolIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
ddofint?Means Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements. By default ddof is zero.
Returns
- NDArray
returns a new array containing the var values, otherwise a reference to the output array is returned.
Remarks
vsplit(NDArray, int)
Split an array into multiple sub-arrays vertically (row-wise).
public static NDArray[] vsplit(NDArray ary, int indices_or_sections)
Parameters
aryNDArrayArray to be divided into sub-arrays.
indices_or_sectionsintIf an integer, N, the array will be divided into N equal arrays along axis 0. If such a split is not possible, an error is raised.
Returns
- NDArray[]
A list of sub-arrays as views into ary.
Remarks
Equivalent to split with axis=0. Array must have ndim >= 2. https://numpy.org/doc/stable/reference/generated/numpy.vsplit.html
vsplit(NDArray, int[])
Split an array into multiple sub-arrays vertically (row-wise).
public static NDArray[] vsplit(NDArray ary, int[] indices)
Parameters
aryNDArrayArray to be divided into sub-arrays.
indicesint[]A 1-D array of sorted integers indicating where along axis 0 the array is split. For example, [2, 3] would result in ary[:2], ary[2:3], ary[3:].
Returns
- NDArray[]
A list of sub-arrays as views into ary.
Remarks
Equivalent to split with axis=0. Array must have ndim >= 2. https://numpy.org/doc/stable/reference/generated/numpy.vsplit.html
vstack(params NDArray[])
Stack arrays in sequence vertically (row wise).
This is equivalent to concatenation along the first axis after 1-D arrays of shape(N,) have been reshaped to(1, N). Rebuilds arrays divided by vsplit.
public static NDArray vstack(params NDArray[] tup)
Parameters
tupNDArray[]The arrays must have the same shape along all but the first axis. 1-D arrays must have the same length.
Returns
- NDArray
The array formed by stacking the given arrays, will be at least 2-D.
Remarks
where(NDArray)
Equivalent to nonzero(NDArray): returns the indices where
condition is non-zero.
public static NDArray<long>[] where(NDArray condition)
Parameters
conditionNDArrayInput array. Non-zero entries yield their indices.
Returns
Remarks
where(NDArray, NDArray, NDArray)
Return elements chosen from x or y depending on condition.
public static NDArray where(NDArray condition, NDArray x, NDArray y)
Parameters
conditionNDArrayWhere True, yield
x, otherwise yieldy.xNDArrayValues from which to choose where condition is True.
yNDArrayValues from which to choose where condition is False.
Returns
- NDArray
An array with elements from
xwhereconditionis True, and elements fromyelsewhere.
Remarks
where(NDArray, NDArray, object)
Return elements chosen from x or y depending on condition.
Scalar overload for y.
public static NDArray where(NDArray condition, NDArray x, object y)
Parameters
Returns
where(NDArray, object, NDArray)
Return elements chosen from x or y depending on condition.
Scalar overload for x.
public static NDArray where(NDArray condition, object x, NDArray y)
Parameters
Returns
where(NDArray, object, object)
Return elements chosen from x or y depending on condition.
Scalar overload for both x and y.
public static NDArray where(NDArray condition, object x, object y)
Parameters
Returns
zeros(Shape)
Return a new double array of given shape, filled with zeros.
public static NDArray zeros(Shape shape)
Parameters
shapeShapeShape of the new array,
Returns
- NDArray
Array of zeros with the given shape, dtype.
Remarks
zeros(Shape, NPTypeCode)
Return a new double array of given shape, filled with zeros.
public static NDArray zeros(Shape shape, NPTypeCode typeCode)
Parameters
shapeShapeShape of the new array,
typeCodeNPTypeCodeThe desired data-type for the array, e.g., uint8. Default is float64 / double.
Returns
- NDArray
Array of zeros with the given shape, dtype.
Remarks
zeros(Shape, Type)
Return a new double array of given shape, filled with zeros.
public static NDArray zeros(Shape shape, Type dtype)
Parameters
shapeShapeShape of the new array,
dtypeTypeThe desired data-type for the array, e.g., uint8. Default is float64 / double.
Returns
- NDArray
Array of zeros with the given shape, dtype.
Remarks
zeros(int)
Return a new double array of given shape, filled with zeros.
public static NDArray zeros(int shape)
Parameters
shapeint
Returns
- NDArray
Array of zeros with the given shape, dtype.
Remarks
zeros(int[])
Return a new double array of given shape, filled with zeros.
public static NDArray zeros(int[] shape)
Parameters
shapeint[]Shape of the new array,
Returns
- NDArray
Array of zeros with the given shape, dtype.
Remarks
zeros(long[])
Return a new double array of given shape, filled with zeros.
public static NDArray zeros(long[] shape)
Parameters
shapelong[]Shape of the new array,
Returns
- NDArray
Array of zeros with the given shape, dtype.
Remarks
zeros_like(NDArray, Type)
Return an array of zeros with the same shape and type as a given array.
public static NDArray zeros_like(NDArray a, Type dtype = null)
Parameters
aNDArrayThe shape and data-type of a define these same attributes of the returned array.
dtypeTypeOverrides the data type of the result.
Returns
- NDArray
Array of zeros with the same shape and type as
nd.
Remarks
zeros_like(NDArray, Type, char)
Return an array of zeros with the same shape and type as a given array.
public static NDArray zeros_like(NDArray a, Type dtype, char order)
Parameters
aNDArrayThe shape and data-type of a define these same attributes of the returned array.
dtypeTypeOverrides the data type of the result.
ordercharMemory layout: 'C', 'F', 'A' or 'K' (default, preserves source layout).
Returns
- NDArray
Array of zeros with the same shape and type as
nd.
Remarks
zeros<T>(int[])
Return a new double array of given shape, filled with zeros.
public static NDArray zeros<T>(int[] shape) where T : unmanaged
Parameters
shapeint[]Shape of the new array,
Returns
- NDArray
Array of zeros with the given shape, type
T.
Type Parameters
T
Remarks
zeros<T>(long[])
Return a new double array of given shape, filled with zeros.
public static NDArray zeros<T>(long[] shape) where T : unmanaged
Parameters
shapelong[]Shape of the new array,
Returns
- NDArray
Array of zeros with the given shape, type
T.
Type Parameters
T