Table of Contents

Class NDArray<TDType>

Namespace
NumSharp.Generic
Assembly
NumSharp.dll
public class NDArray<TDType> : NDArray, IIndex, ICloneable, IEnumerable where TDType : unmanaged

Type Parameters

TDType
Inheritance
NDArray<TDType>
Implements
Inherited Members
Extension Methods

Constructors

NDArray()

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

public NDArray()

Remarks

This constructor does not call allocation/>

NDArray(IArraySlice, Shape, char)

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

public NDArray(IArraySlice values, Shape shape = default, char order = 'C')

Parameters

values IArraySlice
shape Shape
order char

Remarks

This constructor calls IStorage.Allocate(NumSharp.Shape,System.Type)

NDArray(UnmanagedStorage)

Creates a new NDArray with this storage.

protected NDArray(UnmanagedStorage storage)

Parameters

storage UnmanagedStorage

NDArray(UnmanagedStorage, Shape)

Creates a new NDArray with this storage.

protected NDArray(UnmanagedStorage storage, Shape shape)

Parameters

storage UnmanagedStorage
shape Shape

NDArray(UnmanagedStorage, ref Shape)

Creates a new NDArray with this storage.

protected NDArray(UnmanagedStorage storage, ref Shape shape)

Parameters

storage UnmanagedStorage
shape Shape

NDArray(Shape)

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

public NDArray(Shape shape)

Parameters

shape Shape

Shape of NDArray

Remarks

This constructor calls IStorage.Allocate(NumSharp.Shape,System.Type)

NDArray(Shape, bool)

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

public NDArray(Shape shape, bool fillZeros)

Parameters

shape Shape

Shape of NDArray

fillZeros bool

Should set the values of the new allocation to default(dtype)? otherwise - old memory noise

Remarks

This constructor calls IStorage.Allocate(NumSharp.Shape,System.Type)

NDArray(TensorEngine)

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

protected NDArray(TensorEngine engine)

Parameters

engine TensorEngine

The engine of this NDArray

Remarks

This constructor does not call allocation/>

NDArray(Array, Shape, char)

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

public NDArray(Array values, Shape shape = default, char order = 'C')

Parameters

values Array
shape Shape
order char

Remarks

This constructor calls IStorage.Allocate(NumSharp.Shape,System.Type)

NDArray(int)

Constructor which initialize elements with length of size

public NDArray(int size)

Parameters

size int

The size as a single dimension shape

Remarks

This constructor calls IStorage.Allocate(NumSharp.Shape,System.Type)

NDArray(int, bool)

Constructor which initialize elements with length of size

public NDArray(int size, bool fillZeros)

Parameters

size int

The size as a single dimension shape

fillZeros bool

Should set the values of the new allocation to default(dtype)? otherwise - old memory noise

Remarks

This constructor calls IStorage.Allocate(NumSharp.Shape,System.Type)

Properties

Address

Gets the address that this NDArray starts from.

protected TDType* Address { get; }

Property Value

TDType*

Array

Array access to storage data - overridden on purpose

protected ArraySlice<TDType> Array { get; set; }

Property Value

ArraySlice<TDType>

this[Slice[]]

slicing of generic - overridden on purpose

public NDArray<TDType> this[params Slice[] slices] { get; set; }

Parameters

slices Slice[]

Property Value

NDArray<TDType>

this[int[]]

public TDType this[params int[] indices] { get; set; }

Parameters

indices int[]

Property Value

TDType

this[string]

slicing of generic - overridden on purpose

public NDArray<TDType> this[string slice] { get; set; }

Parameters

slice string

Property Value

NDArray<TDType>

T

The transposed array.
Same as self.transpose().

public NDArray<TDType> T { get; }

Property Value

NDArray<TDType>

Remarks

flat

A 1-D iterator over the array.

public NDArray<TDType> flat { get; }

Property Value

NDArray<TDType>

Remarks

Methods

GetAtIndex(int)

public TDType GetAtIndex(int index)

Parameters

index int

Returns

TDType

reshape(Shape)

Gives a new shape to an array without changing its data.

public NDArray<TDType> reshape(Shape newShape)

Parameters

newShape Shape

The new shape should be compatible with the original shape. If an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions.

Returns

NDArray<TDType>

This will be a new view object if possible; otherwise, it will be a copy. Note there is no guarantee of the memory layout (C- or Fortran- contiguous) of the returned array.

Remarks

reshape(ref Shape)

Gives a new shape to an array without changing its data.

public NDArray<TDType> reshape(ref Shape newShape)

Parameters

newShape Shape

The new shape should be compatible with the original shape. If an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions.

Returns

NDArray<TDType>

This will be a new view object if possible; otherwise, it will be a copy. Note there is no guarantee of the memory layout (C- or Fortran- contiguous) of the returned array.

Remarks

reshape(params int[])

Gives a new shape to an array without changing its data.

[SuppressMessage("ReSharper", "ParameterHidesMember")]
public NDArray<TDType> reshape(params int[] shape)

Parameters

shape int[]

The new shape should be compatible with the original shape. If an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions.

Returns

NDArray<TDType>

This will be a new view object if possible; otherwise, it will be a copy. Note there is no guarantee of the memory layout (C- or Fortran- contiguous) of the returned array.

Remarks

reshape_unsafe(Shape)

Gives a new shape to an array without changing its data.

public NDArray<TDType> reshape_unsafe(Shape newshape)

Parameters

newshape Shape

The new shape should be compatible with the original shape. If an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions.

Returns

NDArray<TDType>

This will be a new view object if possible; otherwise, it will be a copy. Note there is no guarantee of the memory layout (C- or Fortran- contiguous) of the returned array.

Remarks

reshape_unsafe(ref Shape)

Gives a new shape to an array without changing its data.

public NDArray<TDType> reshape_unsafe(ref Shape newShape)

Parameters

newShape Shape

Returns

NDArray<TDType>

This will be a new view object if possible; otherwise, it will be a copy. Note there is no guarantee of the memory layout (C- or Fortran- contiguous) of the returned array.

Remarks

reshape_unsafe(params int[])

Gives a new shape to an array without changing its data.

[SuppressMessage("ReSharper", "ParameterHidesMember")]
public NDArray<TDType> reshape_unsafe(params int[] shape)

Parameters

shape int[]

The new shape should be compatible with the original shape. If an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions.

Returns

NDArray<TDType>

This will be a new view object if possible; otherwise, it will be a copy. Note there is no guarantee of the memory layout (C- or Fortran- contiguous) of the returned array.

Remarks

Operators

explicit operator NDArray<TDType>(TDType[])

public static explicit operator NDArray<TDType>(TDType[] tArray)

Parameters

tArray TDType[]

Returns

NDArray<TDType>

implicit operator ArraySlice<TDType>(NDArray<TDType>)

public static implicit operator ArraySlice<TDType>(NDArray<TDType> nd)

Parameters

nd NDArray<TDType>

Returns

ArraySlice<TDType>