Show / Hide Table of Contents

Class NDArray

A powerful N-dimensional array object Inspired from https://www.numpy.org/devdocs/user/quickstart.html

Inheritance
System.Object
NDArray
matrix
NDArray<T>
Implements
System.ICloneable
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: NumSharp.Core
Assembly: NumSharp.Core.dll
Syntax
public class NDArray : ICloneable

Constructors

| Improve this Doc View Source

NDArray()

Default constructor Create a 1D double array with 1 element one element is 1

Declaration
public NDArray()
| Improve this Doc View Source

NDArray(Array)

Constructor which takes .NET array dtype and shape is determined from array

Declaration
public NDArray(Array values)
Parameters
Type Name Description
System.Array values
| Improve this Doc View Source

NDArray(Type)

Constructor for init data type internal storage is 1D with 1 element

Declaration
public NDArray(Type dtype)
Parameters
Type Name Description
System.Type dtype

Data type of elements

| Improve this Doc View Source

NDArray(Type, IShape)

Constructor which initialize elements with 0 type and shape are given.

Declaration
public NDArray(Type dtype, IShape shape)
Parameters
Type Name Description
System.Type dtype

internal data type

IShape shape

Shape of NDArray

| Improve this Doc View Source

NDArray(Type, Int32[])

Constructor which initialize elements with 0 type and dimensions are given.

Declaration
public NDArray(Type dtype, params int[] shapes)
Parameters
Type Name Description
System.Type dtype

internal data type

System.Int32[] shapes

dimensions

Properties

| Improve this Doc View Source

dtype

Data type of NDArray

Declaration
public Type dtype { get; }
Property Value
Type Description
System.Type
| Improve this Doc View Source

Item[Int32[]]

Declaration
public object this[params int[] select] { get; set; }
Parameters
Type Name Description
System.Int32[] select
Property Value
Type Description
System.Object
| Improve this Doc View Source

ndim

Dimension count

Declaration
public int ndim { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

shape

Data length of every dimension

Declaration
public IShape shape { get; }
Property Value
Type Description
IShape
| Improve this Doc View Source

size

Total of elements

Declaration
public int size { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Storage

The internal storage for elements of NDArray

Declaration
public NDStorage Storage { get; set; }
Property Value
Type Description
NDStorage

Internal Storage

Methods

| Improve this Doc View Source

_ParseNumber(Object, ref Int32, ref Int32)

Declaration
protected string _ParseNumber(object number, ref int noBefore, ref int noAfter)
Parameters
Type Name Description
System.Object number
System.Int32 noBefore
System.Int32 noAfter
Returns
Type Description
System.String
| Improve this Doc View Source

_ToMatrixString<T>()

Declaration
protected string _ToMatrixString<T>()
Returns
Type Description
System.String
Type Parameters
Name Description
T
| Improve this Doc View Source

_ToVectorString<T>()

Declaration
protected string _ToVectorString<T>()
Returns
Type Description
System.String
Type Parameters
Name Description
T
| Improve this Doc View Source

absolute()

Declaration
public NDArray absolute()
Returns
Type Description
NDArray
| Improve this Doc View Source

amax(Nullable<Int32>)

Return the maximum of an array or minimum along an axis

Declaration
public NDArray amax(int? axis = default(int? ))
Parameters
Type Name Description
System.Nullable<System.Int32> axis
Returns
Type Description
NDArray
| Improve this Doc View Source

amin(Nullable<Int32>)

Return the maximum of an array or minimum along an axis

Declaration
public NDArray amin(int? axis = default(int? ))
Parameters
Type Name Description
System.Nullable<System.Int32> axis
Returns
Type Description
NDArray
| Improve this Doc View Source

arange(Int32, Int32, Int32)

Declaration
public NDArray arange(int stop, int start = 0, int step = 1)
Parameters
Type Name Description
System.Int32 stop
System.Int32 start
System.Int32 step
Returns
Type Description
NDArray
| Improve this Doc View Source

argmax()

Declaration
public int argmax()
Returns
Type Description
System.Int32
| Improve this Doc View Source

argmax<T>()

Declaration
public int argmax<T>()
Returns
Type Description
System.Int32
Type Parameters
Name Description
T
| Improve this Doc View Source

CalculateNegativeShape(Int32, IList<Int32>, Int32[])

Declaration
protected static int[] CalculateNegativeShape(int negativeIndex, IList<int> currentShape, params int[] shapeParams)
Parameters
Type Name Description
System.Int32 negativeIndex
System.Collections.Generic.IList<System.Int32> currentShape
System.Int32[] shapeParams
Returns
Type Description
System.Int32[]
| Improve this Doc View Source

Clone()

Clone the whole NDArray internal storage is also cloned into 2nd memory area

Declaration
public object Clone()
Returns
Type Description
System.Object

Cloned NDArray

| Improve this Doc View Source

Convolve(NDArray, String)

Convolution of 2 series

Declaration
public NDArray Convolve(NDArray numSharpArray2, string mode = "full")
Parameters
Type Name Description
NDArray numSharpArray2
System.String mode
Returns
Type Description
NDArray
| Improve this Doc View Source

copy(String)

Declaration
public NDArray copy(string order = null)
Parameters
Type Name Description
System.String order
Returns
Type Description
NDArray
| Improve this Doc View Source

delete(IEnumerable)

Declaration
public NDArray delete(IEnumerable delete)
Parameters
Type Name Description
System.Collections.IEnumerable delete
Returns
Type Description
NDArray
| Improve this Doc View Source

dot(NDArray)

Matrix or vector product between given NDArray and 2nd one. if both NDArrays are 1D, scalar product is returned independend of shape if both NDArrays are 2D matrix product is returned.

Declaration
public NDArray dot(NDArray nd2)
Parameters
Type Name Description
NDArray nd2

2nd NDArray

Returns
Type Description
NDArray

Scalarproduct or matrix prod

| Improve this Doc View Source

Equals(Object)

Determines if NDarray references are the same

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj

NDArray to compare

Returns
Type Description
System.Boolean

if reference is same

Overrides
System.Object.Equals(System.Object)
| Improve this Doc View Source

eye(Int32, Int32)

Declaration
public NDArray eye(int dim, int diagonalIndex = 0)
Parameters
Type Name Description
System.Int32 dim
System.Int32 diagonalIndex
Returns
Type Description
NDArray
| Improve this Doc View Source

FindNegativeIndex(Int32[])

Declaration
protected static int FindNegativeIndex(params int[] shape)
Parameters
Type Name Description
System.Int32[] shape
Returns
Type Description
System.Int32
| Improve this Doc View Source

FromMultiDimArray(Array)

Declaration
public void FromMultiDimArray(Array dotNetArray)
Parameters
Type Name Description
System.Array dotNetArray
| Improve this Doc View Source

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32
Overrides
System.Object.GetHashCode()
| Improve this Doc View Source

hstack(NDArray[])

Stack arrays in sequence horizontally

Declaration
public NDArray hstack(params NDArray[] nps)
Parameters
Type Name Description
NDArray[] nps
Returns
Type Description
NDArray
| Improve this Doc View Source

inv()

Declaration
public NDArray inv()
Returns
Type Description
NDArray
| Improve this Doc View Source

linspace(Double, Double, Int32, Boolean)

Declaration
public NDArray linspace(double start, double stop, int num, bool entdpoint = true)
Parameters
Type Name Description
System.Double start
System.Double stop
System.Int32 num
System.Boolean entdpoint
Returns
Type Description
NDArray
| Improve this Doc View Source

log()

Declaration
public NDArray log()
Returns
Type Description
NDArray
| Improve this Doc View Source

lstqr(NDArray, Double)

Least Square method

Determines NDArray X which reduces least square error of Linear System A * X = B. This NDArray is equal to A.

Declaration
public NDArray lstqr(NDArray nDArrayB, double rcon = 0.0001)
Parameters
Type Name Description
NDArray nDArrayB

Result NDArray B

System.Double rcon
Returns
Type Description
NDArray

NArray X

| Improve this Doc View Source

MakeGeneric<T>()

Declaration
public NDArray<T> MakeGeneric<T>()
    where T : struct
Returns
Type Description
NDArray<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

matrix_power(Int32)

Declaration
public NDArray matrix_power(int power)
Parameters
Type Name Description
System.Int32 power
Returns
Type Description
NDArray
| Improve this Doc View Source

max(Nullable<Int32>)

Declaration
public NDArray max(int? axis = default(int? ))
Parameters
Type Name Description
System.Nullable<System.Int32> axis
Returns
Type Description
NDArray
| Improve this Doc View Source

min(Nullable<Int32>)

Declaration
public NDArray min(int? axis = default(int? ))
Parameters
Type Name Description
System.Nullable<System.Int32> axis
Returns
Type Description
NDArray
| Improve this Doc View Source

min<T>(Nullable<Int32>)

Declaration
public NDArray min<T>(int? axis = default(int? ))
Parameters
Type Name Description
System.Nullable<System.Int32> axis
Returns
Type Description
NDArray
Type Parameters
Name Description
T
| Improve this Doc View Source

multi_dot(NDArray[])

Declaration
public NDArray multi_dot(params NDArray[] np2Multi)
Parameters
Type Name Description
NDArray[] np2Multi
Returns
Type Description
NDArray
| Improve this Doc View Source

normalize()

Declaration
public void normalize()
| Improve this Doc View Source

ones(Int32[])

Declaration
public NDArray ones(params int[] shapes)
Parameters
Type Name Description
System.Int32[] shapes
Returns
Type Description
NDArray
| Improve this Doc View Source

ones(Type, Int32[])

Declaration
public NDArray ones(Type dtype = null, params int[] shapes)
Parameters
Type Name Description
System.Type dtype
System.Int32[] shapes
Returns
Type Description
NDArray
| Improve this Doc View Source

power(ValueType)

Declaration
public NDArray power(ValueType exponent)
Parameters
Type Name Description
System.ValueType exponent
Returns
Type Description
NDArray
| Improve this Doc View Source

qr()

Declaration
public (NDArray, NDArray)qr()
Returns
Type Description
System.ValueTuple<NDArray, NDArray>
| Improve this Doc View Source

ravel()

Declaration
public NDArray ravel()
Returns
Type Description
NDArray
| Improve this Doc View Source

reshape(Shape)

Declaration
public NDArray reshape(Shape shape)
Parameters
Type Name Description
Shape shape
Returns
Type Description
NDArray
| Improve this Doc View Source

reshape(Int32[])

Declaration
public NDArray reshape(params int[] shape)
Parameters
Type Name Description
System.Int32[] shape
Returns
Type Description
NDArray
| Improve this Doc View Source

sin()

Declaration
public NDArray sin()
Returns
Type Description
NDArray
| Improve this Doc View Source

sqrt()

Declaration
public NDArray sqrt()
Returns
Type Description
NDArray
| Improve this Doc View Source

sum(NDArray)

Declaration
public int sum(NDArray np2)
Parameters
Type Name Description
NDArray np2
Returns
Type Description
System.Int32
| Improve this Doc View Source

svd()

Declaration
public (NDArray, NDArray, NDArray)svd()
Returns
Type Description
System.ValueTuple<NDArray, NDArray, NDArray>
| Improve this Doc View Source

ToJaggedArray<T>()

Declaration
public Array ToJaggedArray<T>()
Returns
Type Description
System.Array
Type Parameters
Name Description
T
| Improve this Doc View Source

ToMuliDimArray<T>()

Declaration
public Array ToMuliDimArray<T>()
Returns
Type Description
System.Array
Type Parameters
Name Description
T
| Improve this Doc View Source

ToString()

Declaration
public override string ToString()
Returns
Type Description
System.String
Overrides
System.Object.ToString()
| Improve this Doc View Source

transpose()

Declaration
public NDArray transpose()
Returns
Type Description
NDArray
| Improve this Doc View Source

unique<T>()

Declaration
public NDArray unique<T>()
Returns
Type Description
NDArray
Type Parameters
Name Description
T
| Improve this Doc View Source

vstack(NDArray[])

Declaration
public NDArray vstack(params NDArray[] nps)
Parameters
Type Name Description
NDArray[] nps
Returns
Type Description
NDArray

Operators

| Improve this Doc View Source

Addition(NDArray, NDArray)

Declaration
public static NDArray operator +(NDArray np1, NDArray np2)
Parameters
Type Name Description
NDArray np1
NDArray np2
Returns
Type Description
NDArray
| Improve this Doc View Source

Addition(NDArray, ValueType)

Declaration
public static NDArray operator +(NDArray np1, ValueType scalar)
Parameters
Type Name Description
NDArray np1
System.ValueType scalar
Returns
Type Description
NDArray
| Improve this Doc View Source

Addition(Double, NDArray)

Declaration
public static NDArray operator +(double scalar, NDArray np1)
Parameters
Type Name Description
System.Double scalar
NDArray np1
Returns
Type Description
NDArray
| Improve this Doc View Source

Division(NDArray, NDArray)

Declaration
public static NDArray operator /(NDArray np1, NDArray np2)
Parameters
Type Name Description
NDArray np1
NDArray np2
Returns
Type Description
NDArray
| Improve this Doc View Source

Division(NDArray, ValueType)

Declaration
public static NDArray operator /(NDArray np1, ValueType scalar)
Parameters
Type Name Description
NDArray np1
System.ValueType scalar
Returns
Type Description
NDArray
| Improve this Doc View Source

Division(Double, NDArray)

Declaration
public static NDArray operator /(double scalar, NDArray np1)
Parameters
Type Name Description
System.Double scalar
NDArray np1
Returns
Type Description
NDArray
| Improve this Doc View Source

Equality(NDArray, Object)

Declaration
public static bool operator ==(NDArray np, object obj)
Parameters
Type Name Description
NDArray np
System.Object obj
Returns
Type Description
System.Boolean
| Improve this Doc View Source

Implicit(NDArray to Array)

Declaration
public static implicit operator Array(NDArray nd)
Parameters
Type Name Description
NDArray nd
Returns
Type Description
System.Array
| Improve this Doc View Source

Implicit(Array to NDArray)

Declaration
public static implicit operator NDArray(Array d)
Parameters
Type Name Description
System.Array d
Returns
Type Description
NDArray
| Improve this Doc View Source

Implicit(String to NDArray)

Declaration
public static implicit operator NDArray(string str)
Parameters
Type Name Description
System.String str
Returns
Type Description
NDArray
| Improve this Doc View Source

Inequality(NDArray, Object)

Declaration
public static bool operator !=(NDArray np, object obj)
Parameters
Type Name Description
NDArray np
System.Object obj
Returns
Type Description
System.Boolean
| Improve this Doc View Source

Multiply(NDArray, NDArray)

Declaration
public static NDArray operator *(NDArray np1, NDArray np2)
Parameters
Type Name Description
NDArray np1
NDArray np2
Returns
Type Description
NDArray
| Improve this Doc View Source

Multiply(NDArray, ValueType)

Declaration
public static NDArray operator *(NDArray np1, ValueType scalar)
Parameters
Type Name Description
NDArray np1
System.ValueType scalar
Returns
Type Description
NDArray
| Improve this Doc View Source

Multiply(ValueType, NDArray)

Declaration
public static NDArray operator *(ValueType scalar, NDArray np1)
Parameters
Type Name Description
System.ValueType scalar
NDArray np1
Returns
Type Description
NDArray
| Improve this Doc View Source

Subtraction(NDArray, NDArray)

Declaration
public static NDArray operator -(NDArray np1, NDArray np2)
Parameters
Type Name Description
NDArray np1
NDArray np2
Returns
Type Description
NDArray
| Improve this Doc View Source

Subtraction(NDArray, ValueType)

Declaration
public static NDArray operator -(NDArray np1, ValueType scalar)
Parameters
Type Name Description
NDArray np1
System.ValueType scalar
Returns
Type Description
NDArray
| Improve this Doc View Source

Subtraction(ValueType, NDArray)

Declaration
public static NDArray operator -(ValueType scalar, NDArray np1)
Parameters
Type Name Description
System.ValueType scalar
NDArray np1
Returns
Type Description
NDArray

Implements

System.ICloneable

Extension Methods

NDArrayExtensions.AsMatrix(NDArray)
NDArrayExtensions.ArgMax<T>(NDArray)
NDArrayExtensions.mean(NDArray, Int32)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX