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, 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, 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)
public static NDArray add(NDArray x1, NDArray x2)
Parameters
Returns
Remarks
all(NDArray)
public static bool all(NDArray a)
Parameters
aNDArray
Returns
all(NDArray, int, bool)
public static NDArray<bool> all(NDArray nd, int axis, bool keepdims = false)
Parameters
Returns
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)
public static bool any(NDArray a)
Parameters
aNDArray
Returns
any(NDArray, int, bool)
public static NDArray<bool> any(NDArray nd, int axis, bool keepdims = false)
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, 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, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array.
dtypeNPTypeCode?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, 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, 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, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array.
dtypeNPTypeCode?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, 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, 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, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array.
dtypeNPTypeCode?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, 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, 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, NPTypeCode? dtype = null)
Parameters
yNDArrayxNDArrayInput array y-coordinates.
dtypeNPTypeCode?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, 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<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
around(NDArray, int, NPTypeCode?)
Evenly round to the given number of decimals.
public static NDArray around(NDArray x, int decimals, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array
decimalsintNumber of decimal places to round to
dtypeNPTypeCode?The 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, NPTypeCode?)
Evenly round to the given number of decimals.
public static NDArray around(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array
dtypeNPTypeCode?The 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)
Wraps given nd in an alias. If copy is true then returns a clone.
public static NDArray array(NDArray nd, bool copy = false)
Parameters
Returns
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.
ordercharNot used.
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
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_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
aryNDArrayArray to be divided into sub-arrays.
indices_or_sectionsintIf an integer, N, the array will be divided into N sub-arrays along axis. If N does not divide the array equally, it returns l % n sub-arrays of size l//n + 1 and the rest of size l//n.
axisintThe axis along which to split, default is 0.
Returns
- NDArray[]
A list of sub-arrays.
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
aryNDArrayArray to be divided into sub-arrays.
indicesint[]A 1-D array of sorted integers indicating where along axis the array is split. For example, [2, 3] would result in ary[:2], ary[2:3], ary[3:]. If an index exceeds the dimension of the array along axis, an empty sub-array is returned correspondingly.
axisintThe axis along which to split, default is 0.
Returns
- NDArray[]
A list of sub-arrays.
Remarks
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
aryNDArrayArray to be divided into sub-arrays.
indiceslong[]A 1-D array of sorted integers indicating where along axis the array is split. For example, [2, 3] would result in ary[:2], ary[2:3], ary[3:]. If an index exceeds the dimension of the array along axis, an empty sub-array is returned correspondingly.
axisintThe axis along which to split, default is 0.
Returns
- NDArray[]
A list of sub-arrays.
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
asarray(NDArray, Type)
Convert the input to an array. If the input is already an NDArray,
it is returned as-is when no dtype is requested, or converted
to the target dtype otherwise. Mirrors numpy.asarray(a, dtype=...).
public static NDArray asarray(NDArray a, Type dtype = null)
Parameters
Returns
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
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
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 = null)
Parameters
xNDArrayOnly integer and boolean types are handled.
outTypeNPTypeCode?The dtype the returned ndarray should be of.
Returns
- NDArray
Result. This is a scalar if x is a scalar.
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
broadcast(NDArray, NDArray)
Produce an object that mimics broadcasting.
public static np.Broadcast broadcast(NDArray nd1, NDArray nd2)
Parameters
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, NPTypeCode?)
Return the cube-root of an array, element-wise.
public static NDArray cbrt(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArrayThe values whose cube-roots are required.
dtypeNPTypeCode?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, 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, 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, NPTypeCode? dtype = null)
Parameters
xNDArrayInput data.
dtypeNPTypeCode?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, 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)
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.
public static NDArray clip(NDArray a, NDArray a_min, NDArray a_max, NDArray @out)
Parameters
aNDArrayArray containing elements to clip.
a_minNDArrayMinimum value. If None, clipping is not performed on lower interval edge. Not more than one of a_min and a_max may be None.
a_maxNDArrayMaximum value. If None, clipping is not performed on upper interval edge. Not more than one of a_min and a_max may be None.
outNDArrayThe results will be placed in this array. It may be the input array for in-place clipping. out must be of the right shape to hold the output. Its type is preserved.
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
clip(NDArray, NDArray, NDArray, NPTypeCode?)
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.
public static NDArray clip(NDArray a, NDArray a_min, NDArray a_max, NPTypeCode? dtype = null)
Parameters
aNDArrayArray containing elements to clip.
a_minNDArrayMinimum value. If None, clipping is not performed on lower interval edge. Not more than one of a_min and a_max may be None.
a_maxNDArrayMaximum value. If None, clipping is not performed on upper interval edge. Not more than one of a_min and a_max may be None.
dtypeNPTypeCode?The dtype the returned ndarray should be of, only non integer values are supported.
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
clip(NDArray, NDArray, NDArray, Type)
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.
public static NDArray clip(NDArray a, NDArray a_min, NDArray a_max, Type dtype)
Parameters
aNDArrayArray containing elements to clip.
a_minNDArrayMinimum value. If None, clipping is not performed on lower interval edge. Not more than one of a_min and a_max may be None.
a_maxNDArrayMaximum value. If None, clipping is not performed on upper interval edge. Not more than one of a_min and a_max may be None.
dtypeTypeThe dtype the returned ndarray should be of, only non integer values are supported.
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.
concatenate(NDArray[], int)
Join a sequence of arrays along an existing axis.
public static NDArray concatenate(NDArray[] arrays, int axis = 0)
Parameters
arraysNDArray[]The arrays must have the same shape, except in the dimension corresponding to axis (the first, by default).
axisintThe axis along which the arrays will be joined. If axis is None, arrays are flattened before use. Default is 0.
Returns
- NDArray
The concatenated array.
Remarks
concatenate((NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray), int)
Join a sequence of arrays along an existing axis.
public static NDArray concatenate((NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray) arrays, int axis = 0)
Parameters
arrays(NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray)The arrays must have the same shape, except in the dimension corresponding to axis (the first, by default).
axisintThe axis along which the arrays will be joined. If axis is None, arrays are flattened before use. Default is 0.
Returns
- NDArray
The concatenated array.
Remarks
concatenate((NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray), int)
Join a sequence of arrays along an existing axis.
public static NDArray concatenate((NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray) arrays, int axis = 0)
Parameters
arrays(NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray)The arrays must have the same shape, except in the dimension corresponding to axis (the first, by default).
axisintThe axis along which the arrays will be joined. If axis is None, arrays are flattened before use. Default is 0.
Returns
- NDArray
The concatenated array.
Remarks
concatenate((NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray), int)
Join a sequence of arrays along an existing axis.
public static NDArray concatenate((NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray) arrays, int axis = 0)
Parameters
arrays(NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray)The arrays must have the same shape, except in the dimension corresponding to axis (the first, by default).
axisintThe axis along which the arrays will be joined. If axis is None, arrays are flattened before use. Default is 0.
Returns
- NDArray
The concatenated array.
Remarks
concatenate((NDArray, NDArray, NDArray, NDArray, NDArray, NDArray), int)
Join a sequence of arrays along an existing axis.
public static NDArray concatenate((NDArray, NDArray, NDArray, NDArray, NDArray, NDArray) arrays, int axis = 0)
Parameters
arrays(NDArray, NDArray, NDArray, NDArray, NDArray, NDArray)The arrays must have the same shape, except in the dimension corresponding to axis (the first, by default).
axisintThe axis along which the arrays will be joined. If axis is None, arrays are flattened before use. Default is 0.
Returns
- NDArray
The concatenated array.
Remarks
concatenate((NDArray, NDArray, NDArray, NDArray, NDArray), int)
Join a sequence of arrays along an existing axis.
public static NDArray concatenate((NDArray, NDArray, NDArray, NDArray, NDArray) arrays, int axis = 0)
Parameters
arrays(NDArray, NDArray, NDArray, NDArray, NDArray)The arrays must have the same shape, except in the dimension corresponding to axis (the first, by default).
axisintThe axis along which the arrays will be joined. If axis is None, arrays are flattened before use. Default is 0.
Returns
- NDArray
The concatenated array.
Remarks
concatenate((NDArray, NDArray, NDArray, NDArray), int)
Join a sequence of arrays along an existing axis.
public static NDArray concatenate((NDArray, NDArray, NDArray, NDArray) arrays, int axis = 0)
Parameters
arrays(NDArray, NDArray, NDArray, NDArray)The arrays must have the same shape, except in the dimension corresponding to axis (the first, by default).
axisintThe axis along which the arrays will be joined. If axis is None, arrays are flattened before use. Default is 0.
Returns
- NDArray
The concatenated array.
Remarks
concatenate((NDArray, NDArray, NDArray), int)
Join a sequence of arrays along an existing axis.
public static NDArray concatenate((NDArray, NDArray, NDArray) arrays, int axis = 0)
Parameters
arrays(NDArray, NDArray, NDArray)The arrays must have the same shape, except in the dimension corresponding to axis (the first, by default).
axisintThe axis along which the arrays will be joined. If axis is None, arrays are flattened before use. Default is 0.
Returns
- NDArray
The concatenated array.
Remarks
concatenate((NDArray, NDArray), int)
Join a sequence of arrays along an existing axis.
public static NDArray concatenate((NDArray, NDArray) arrays, int axis = 0)
Parameters
arrays(NDArray Lhs, NDArray Rhs)The arrays must have the same shape, except in the dimension corresponding to axis (the first, by default).
axisintThe axis along which the arrays will be joined. If axis is None, arrays are flattened before use. Default is 0.
Returns
- NDArray
The concatenated array.
Remarks
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 a copy of the array.
public static NDArray copy(NDArray a, char order = 'C')
Parameters
Returns
- NDArray
Array interpretation of a.
Remarks
copyto(NDArray, NDArray)
Copies values from one array to another, broadcasting as necessary.
public static void copyto(NDArray dst, NDArray src)
Parameters
dstNDArrayThe array into which values are copied.
srcNDArrayThe array from which values are copied.
Remarks
cos(NDArray, NPTypeCode?)
Cosine element-wise.
public static NDArray cos(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array in radians.
dtypeNPTypeCode?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
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, 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, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array.
dtypeNPTypeCode?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, 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, NPTypeCode?)
Convert angles from degrees to radians.
public static NDArray deg2rad(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArrayAngles in degrees.
dtypeNPTypeCode?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, 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, NPTypeCode?)
Convert angles from radians to degrees. Alias for rad2deg.
public static NDArray degrees(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArrayAngle in radians.
dtypeNPTypeCode?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, 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
divide(NDArray, NDArray)
public static NDArray divide(NDArray x1, NDArray x2)
Parameters
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").
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, 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, 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<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)
Return (x1 == x2) element-wise.
public static NDArray<bool> equal(NDArray x1, NDArray x2)
Parameters
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
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, 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, 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, int)
public static NDArray expand_dims(NDArray a, int axis)
Parameters
Returns
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, 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
eye(int, int?, int, Type)
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)
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.
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
floor(NDArray, NPTypeCode?)
public static NDArray floor(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArraydtypeNPTypeCode?
Returns
floor(NDArray, Type)
public static NDArray floor(NDArray x, Type dtype)
Parameters
Returns
floor_divide(NDArray, NDArray)
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)
Parameters
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. 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 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 ignored when possible.
public static NDArray fmax(NDArray x1, NDArray x2, NDArray @out)
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).
outNDArray
Returns
- NDArray
The maximum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.
fmax(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 the non-nan 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 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?
Returns
- NDArray
The maximum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.
fmax(NDArray, NDArray, Type)
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 the non-nan 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 ignored when possible.
public static NDArray fmax(NDArray x1, NDArray x2, Type dtype)
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).
dtypeType
Returns
- NDArray
The maximum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.
fmin(NDArray, NDArray, NDArray)
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 fmin(NDArray x1, NDArray x2, NDArray @out)
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).
outNDArray
Returns
- NDArray
The maximum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.
fmin(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 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?
Returns
- NDArray
The maximum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.
fmin(NDArray, NDArray, Type)
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 fmin(NDArray x1, NDArray x2, Type dtype)
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).
dtypeType
Returns
- NDArray
The maximum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.
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<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
greater(NDArray, NDArray)
Return (x1 > x2) element-wise.
public static NDArray<bool> greater(NDArray x1, NDArray x2)
Parameters
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)
Return (x1 >= x2) element-wise.
public static NDArray<bool> greater_equal(NDArray x1, NDArray x2)
Parameters
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
invert(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, NPTypeCode? outType = null)
Parameters
xNDArrayOnly integer and boolean types are handled.
outTypeNPTypeCode?The dtype the returned ndarray should be of.
Returns
- NDArray
Result. This is a scalar if x is a scalar.
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)
Test element-wise for finiteness (not infinity or not Not a Number).
public static NDArray<bool> isfinite(NDArray a)
Parameters
aNDArray
Returns
isinf(NDArray)
Test element-wise for positive or negative infinity.
public static NDArray<bool> isinf(NDArray a)
Parameters
aNDArrayInput array
Returns
Remarks
NumPy reference: 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)
Test element-wise for Not a Number.
public static NDArray<bool> isnan(NDArray a)
Parameters
aNDArray
Returns
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)
Return (x1 < x2) element-wise.
public static NDArray<bool> less(NDArray x1, NDArray x2)
Parameters
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)
Return (x1 <= x2) element-wise.
public static NDArray<bool> less_equal(NDArray x1, NDArray x2)
Parameters
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, NPTypeCode?)
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, NPTypeCode? dtype = null)
Parameters
xNDArrayInput value.
dtypeNPTypeCode?The 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, NPTypeCode?)
Return the base 10 logarithm of the input array, element-wise.
public static NDArray log10(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArrayInput value.
dtypeNPTypeCode?
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, 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, NPTypeCode?)
Return the natural logarithm of one plus the input array, element-wise.
Calculates log(1 + x).
public static NDArray log1p(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArrayInput value.
dtypeNPTypeCode?
Returns
- NDArray
Natural logarithm of 1 + x, element-wise. This is a scalar if x is a scalar.
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, NPTypeCode?)
Base-2 logarithm of x.
public static NDArray log2(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArrayInput value.
dtypeNPTypeCode?
Returns
- NDArray
Base-2 logarithm of x. This is a scalar if x is a scalar.
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. 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, NDArray @out)
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).
outNDArray
Returns
- NDArray
The maximum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.
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?
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. 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, Type dtype)
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).
dtypeType
Returns
- NDArray
The maximum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.
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
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. 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, NDArray @out)
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).
outNDArray
Returns
- NDArray
The maximum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.
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?
Returns
- NDArray
The maximum 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. 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, Type dtype)
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).
dtypeType
Returns
- NDArray
The maximum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.
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)
public static NDArray mod(NDArray x1, NDArray x2)
Parameters
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)
public static NDArray multiply(NDArray x1, NDArray x2)
Parameters
Returns
Remarks
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
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).
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).
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)
Numerical negative, element-wise.
public static NDArray negative(NDArray nd)
Parameters
ndNDArray
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)
Return (x1 != x2) element-wise.
public static NDArray<bool> not_equal(NDArray x1, NDArray x2)
Parameters
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<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
positive(NDArray)
Numerical positive, element-wise.
public static NDArray positive(NDArray nd)
Parameters
ndNDArray
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, 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
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
rad2deg(NDArray, NPTypeCode?)
Convert angles from radians to degrees.
public static NDArray rad2deg(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArrayAngle in radians.
dtypeNPTypeCode?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, 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, NPTypeCode?)
Convert angles from degrees to radians. Alias for deg2rad.
public static NDArray radians(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArrayAngles in degrees.
dtypeNPTypeCode?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, 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
reciprocal(NDArray, NPTypeCode?)
Return the reciprocal of the argument, element-wise. Calculates 1/x.
public static NDArray reciprocal(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array.
dtypeNPTypeCode?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, 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)
public static NDArray repeat(NDArray a, NDArray repeats)
Parameters
Returns
repeat(NDArray, int)
public static NDArray repeat(NDArray a, int repeats)
Parameters
Returns
repeat(NDArray, long)
public static NDArray repeat(NDArray a, long repeats)
Parameters
Returns
repeat<T>(T, int)
public static NDArray repeat<T>(T a, int repeats) where T : unmanaged
Parameters
aTrepeatsint
Returns
Type Parameters
T
repeat<T>(T, long)
public static NDArray repeat<T>(T a, long repeats) where T : unmanaged
Parameters
aTrepeatslong
Returns
Type Parameters
T
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, int, NPTypeCode?)
Evenly round to the given number of decimals.
public static NDArray round_(NDArray x, int decimals, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array
decimalsintNumber of decimal places to round to
dtypeNPTypeCode?The 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, NPTypeCode?)
Evenly round to the given number of decimals.
public static NDArray round_(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array
dtypeNPTypeCode?The 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)
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)
Parameters
Returns
- NDArray
Array of insertion points with the same shape as v.
Remarks
searchsorted(NDArray, double)
Find index where a scalar should be inserted to maintain order.
public static long searchsorted(NDArray a, double v)
Parameters
Returns
- long
Scalar index for insertion point.
Remarks
searchsorted(NDArray, int)
Find index where a scalar should be inserted to maintain order.
public static long searchsorted(NDArray a, int v)
Parameters
Returns
- long
Scalar index for insertion point.
Remarks
sign(NDArray, NPTypeCode?)
public static NDArray sign(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArraydtypeNPTypeCode?
Returns
sign(NDArray, Type)
public static NDArray sign(NDArray x, Type dtype)
Parameters
Returns
sin(NDArray, NPTypeCode?)
Trigonometric sine, element-wise.
public static NDArray sin(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArrayAngle, in radians (2 \pi rad equals 360 degrees).
dtypeNPTypeCode?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
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, 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, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array.
dtypeNPTypeCode?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, 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
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
- ValueError
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
aryNDArrayArray to be divided into sub-arrays.
indicesint[]A 1-D array of sorted integers indicating where along axis the array is split. For example, [2, 3] would result in ary[:2], ary[2:3], ary[3:].
axisintThe axis along which to split, default is 0.
Returns
- NDArray[]
A list of sub-arrays as views into ary.
Remarks
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
aryNDArrayArray to be divided into sub-arrays.
indiceslong[]A 1-D array of sorted integers indicating where along axis the array is split. For example, [2, 3] would result in ary[:2], ary[2:3], ary[3:].
axisintThe axis along which to split, default is 0.
Returns
- NDArray[]
A list of sub-arrays as views into ary.
Remarks
sqrt(NDArray, NPTypeCode?)
Return the non-negative square-root of an array, element-wise.
public static NDArray sqrt(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArrayThe values whose square-roots are required.
dtypeNPTypeCode?The 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
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
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)
public static NDArray subtract(NDArray x1, NDArray x2)
Parameters
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
tan(NDArray, NPTypeCode?)
Compute tangent element-wise.
Equivalent to np.sin(x)/np.cos(x) element-wise.
public static NDArray tan(NDArray x, NPTypeCode? dtype = null)
Parameters
xNDArrayAngle, in radians (2 \pi rad equals 360 degrees).
dtypeNPTypeCode?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
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, 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, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array.
dtypeNPTypeCode?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, 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
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)
public static NDArray true_divide(NDArray x1, NDArray x2)
Parameters
Returns
Remarks
trunc(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, NPTypeCode? dtype = null)
Parameters
xNDArrayInput array.
dtypeNPTypeCode?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, 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 a)
Parameters
aNDArray
Returns
- NDArray
The sorted unique values.
Remarks
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<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