Table of Contents

Class UnmanagedStorage

Namespace
NumSharp.Backends
Assembly
NumSharp.dll

Serves as a typed storage for an array.

public class UnmanagedStorage : ICloneable
Inheritance
UnmanagedStorage
Implements
Inherited Members
Extension Methods

Remarks

Responsible for :

  • store data type, elements, Shape
  • offers methods for accessing elements depending on shape
  • offers methods for casting elements
  • offers methods for change tensor order
  • GetData always return reference object to the true storage
  • GetData{T} and SetData{T} change dtype and cast storage
  • CloneData always create a clone of storage and return this as reference object
  • CloneData{T} clone storage and cast this clone

Constructors

UnmanagedStorage(IArraySlice, Shape)

Wraps given arraySlice in UnmanagedStorage.

public UnmanagedStorage(IArraySlice arraySlice, Shape shape)

Parameters

arraySlice IArraySlice

The slice to wrap

shape Shape

UnmanagedStorage(NPTypeCode)

Creates an empty storage of type typeCode.

public UnmanagedStorage(NPTypeCode typeCode)

Parameters

typeCode NPTypeCode

The type of this storage

Remarks

Usually Allocate(Shape, Type) is called after this constructor.

UnmanagedStorage(bool)

public UnmanagedStorage(bool scalar)

Parameters

scalar bool

UnmanagedStorage(bool[])

public UnmanagedStorage(bool[] values)

Parameters

values bool[]

UnmanagedStorage(byte)

public UnmanagedStorage(byte scalar)

Parameters

scalar byte

UnmanagedStorage(byte[])

public UnmanagedStorage(byte[] values)

Parameters

values byte[]

UnmanagedStorage(char)

public UnmanagedStorage(char scalar)

Parameters

scalar char

UnmanagedStorage(char[])

public UnmanagedStorage(char[] values)

Parameters

values char[]

UnmanagedStorage(decimal)

public UnmanagedStorage(decimal scalar)

Parameters

scalar decimal

UnmanagedStorage(decimal[])

public UnmanagedStorage(decimal[] values)

Parameters

values decimal[]

UnmanagedStorage(double)

public UnmanagedStorage(double scalar)

Parameters

scalar double

UnmanagedStorage(double[])

public UnmanagedStorage(double[] values)

Parameters

values double[]

UnmanagedStorage(short)

public UnmanagedStorage(short scalar)

Parameters

scalar short

UnmanagedStorage(short[])

public UnmanagedStorage(short[] values)

Parameters

values short[]

UnmanagedStorage(int)

public UnmanagedStorage(int scalar)

Parameters

scalar int

UnmanagedStorage(int[])

public UnmanagedStorage(int[] values)

Parameters

values int[]

UnmanagedStorage(long)

public UnmanagedStorage(long scalar)

Parameters

scalar long

UnmanagedStorage(long[])

public UnmanagedStorage(long[] values)

Parameters

values long[]

UnmanagedStorage(float)

public UnmanagedStorage(float scalar)

Parameters

scalar float

UnmanagedStorage(float[])

public UnmanagedStorage(float[] values)

Parameters

values float[]

UnmanagedStorage(Type)

Creates an empty storage of type dtype.

public UnmanagedStorage(Type dtype)

Parameters

dtype Type

The type of this storage

Remarks

Usually Allocate(Shape, Type) is called after this constructor.

UnmanagedStorage(ushort)

public UnmanagedStorage(ushort scalar)

Parameters

scalar ushort

UnmanagedStorage(ushort[])

public UnmanagedStorage(ushort[] values)

Parameters

values ushort[]

UnmanagedStorage(uint)

public UnmanagedStorage(uint scalar)

Parameters

scalar uint

UnmanagedStorage(uint[])

public UnmanagedStorage(uint[] values)

Parameters

values uint[]

UnmanagedStorage(ulong)

public UnmanagedStorage(ulong scalar)

Parameters

scalar ulong

UnmanagedStorage(ulong[])

public UnmanagedStorage(ulong[] values)

Parameters

values ulong[]

Fields

Address

public byte* Address

Field Value

byte*

Count

public int Count

Field Value

int

InternalArray

public IArraySlice InternalArray

Field Value

IArraySlice

_arrayBoolean

protected ArraySlice<bool> _arrayBoolean

Field Value

ArraySlice<bool>

_arrayByte

protected ArraySlice<byte> _arrayByte

Field Value

ArraySlice<byte>

_arrayChar

protected ArraySlice<char> _arrayChar

Field Value

ArraySlice<char>

_arrayDecimal

protected ArraySlice<decimal> _arrayDecimal

Field Value

ArraySlice<decimal>

_arrayDouble

protected ArraySlice<double> _arrayDouble

Field Value

ArraySlice<double>

_arrayInt16

protected ArraySlice<short> _arrayInt16

Field Value

ArraySlice<short>

_arrayInt32

protected ArraySlice<int> _arrayInt32

Field Value

ArraySlice<int>

_arrayInt64

protected ArraySlice<long> _arrayInt64

Field Value

ArraySlice<long>

_arraySingle

protected ArraySlice<float> _arraySingle

Field Value

ArraySlice<float>

_arrayUInt16

protected ArraySlice<ushort> _arrayUInt16

Field Value

ArraySlice<ushort>

_arrayUInt32

protected ArraySlice<uint> _arrayUInt32

Field Value

ArraySlice<uint>

_arrayUInt64

protected ArraySlice<ulong> _arrayUInt64

Field Value

ArraySlice<ulong>

_dtype

protected Type _dtype

Field Value

Type

_shape

protected Shape _shape

Field Value

Shape

_typecode

protected NPTypeCode _typecode

Field Value

NPTypeCode

Properties

BaseStorage

Gets the original storage this is a view of, or null if this storage owns its data.

public UnmanagedStorage? BaseStorage { get; }

Property Value

UnmanagedStorage

The ultimate owner storage for views, or null for owned data.

Remarks

NumPy-compatible: All views chain to the ultimate owner (not intermediate views).

Example:

var a = np.arange(10);           // a.Storage.BaseStorage == null (owns data)
var b = a["2:5"];                // b.Storage.BaseStorage == a.Storage
var c = b["1:2"];                // c.Storage.BaseStorage == a.Storage (chains to original!)

Note: This property is read-only by design. Allowing external modification would risk breaking the memory ownership chain and could lead to use-after-free bugs.

See Also

DType

The data type of internal storage array.

public Type DType { get; }

Property Value

Type

numpys equal dtype

Remarks

Has to be compliant with NPTypeCode.

DTypeSize

The size in bytes of a single value of DType

public int DTypeSize { get; }

Property Value

int

Remarks

Computed by SizeOf(object)

Engine

The engine that was used to create this IStorage.

public TensorEngine Engine { get; protected set; }

Property Value

TensorEngine

IsView

Gets a value indicating whether this storage is a view of another storage.

public bool IsView { get; }

Property Value

bool

true if this storage shares memory with another storage (does not own its data); false if this storage owns its data.

Remarks

Equivalent to checking BaseStorage != null.

Use cases:

  • Determine if an array can be safely modified without affecting other arrays
  • Optimize copy-on-write patterns
  • Debug memory sharing issues

Shape

The shape representing the data in this storage.

public Shape Shape { get; set; }

Property Value

Shape

ShapeReference

The shape representing the data in this storage.

public ref Shape ShapeReference { get; }

Property Value

Shape

Remarks

It is dangerous to set Shape by reference. use Reshape(Shape) instead.

TypeCode

The NPTypeCode of IStorage.DType.

public NPTypeCode TypeCode { get; }

Property Value

NPTypeCode

Methods

Alias()

Creates an alias (view) of this storage that shares the same underlying memory.

public UnmanagedStorage Alias()

Returns

UnmanagedStorage

A new UnmanagedStorage that shares memory with this storage. The returned storage's NumSharp.Backends.UnmanagedStorage._baseStorage points to the ultimate owner.

Remarks

Memory Sharing: The alias shares the same InternalArray and underlying memory. Modifications through the alias affect the original data.

Base Tracking: Sets _baseStorage to chain to the ultimate owner:

  • If this storage owns its data: alias._baseStorage = this
  • If this storage is a view: alias._baseStorage = this._baseStorage
This ensures all views in a chain point to the original owner, not intermediate views.
See Also

Alias(Shape)

Creates an alias (view) of this storage with a different shape.

public UnmanagedStorage Alias(Shape shape)

Parameters

shape Shape

The shape for the alias. Should be compatible with the storage size (not validated).

Returns

UnmanagedStorage

A new UnmanagedStorage that shares memory with this storage but has the specified shape. The returned storage's NumSharp.Backends.UnmanagedStorage._baseStorage points to the ultimate owner.

Remarks

Memory Sharing: The alias shares the same InternalArray and underlying memory. Modifications through the alias affect the original data.

Shape Compatibility: This method does NOT validate that the shape is compatible with the storage size. Use with caution.

Base Tracking: Sets _baseStorage to chain to the ultimate owner.

See Also

Alias(ref Shape)

Creates an alias (view) of this storage with a different shape (by reference).

public UnmanagedStorage Alias(ref Shape shape)

Parameters

shape Shape

The shape for the alias. Should be compatible with the storage size (not validated).

Returns

UnmanagedStorage

A new UnmanagedStorage that shares memory with this storage but has the specified shape. The returned storage's NumSharp.Backends.UnmanagedStorage._baseStorage points to the ultimate owner.

Remarks

Memory Sharing: The alias shares the same InternalArray and underlying memory. Modifications through the alias affect the original data.

Shape Compatibility: This method does NOT validate that the shape is compatible with the storage size. Use with caution.

Base Tracking: Sets _baseStorage to chain to the ultimate owner.

See Also

Allocate(IArraySlice, Shape, bool)

Allocate values into memory.

public void Allocate(IArraySlice values, Shape shape, bool copy = false)

Parameters

values IArraySlice

The array to set as internal data storage

shape Shape

The shape of the array.

copy bool

Should perform a copy of values

Remarks

Does not copy values

Allocate(Shape, NPTypeCode, bool)

Allocates a new Array into memory.

public void Allocate(Shape shape, NPTypeCode dtype, bool fillZeros)

Parameters

shape Shape

The shape of the array.

dtype NPTypeCode

The type of the Array, if null DType is used.

fillZeros bool

Allocate(Shape, Type)

Allocates a new Array into memory.

public void Allocate(Shape shape, Type dtype = null)

Parameters

shape Shape

The shape of the array.

dtype Type

The type of the Array, if null DType is used.

Allocate(Shape, Type, bool)

Allocates a new Array into memory.

public void Allocate(Shape shape, Type dtype, bool fillZeros)

Parameters

shape Shape

The shape of the array.

dtype Type

The type of the Array, if null DType is used.

fillZeros bool

Allocate(Array)

Allocate array into memory.

public void Allocate(Array array)

Parameters

array Array

The array to set as internal data storage

Remarks

Does not copy array

Allocate(Array, Shape)

Allocate values into memory.

public void Allocate(Array values, Shape shape)

Parameters

values Array

The array to set as internal data storage

shape Shape

The shape of given array

Remarks

Does not copy values

Allocate<T>(ArraySlice<T>, Shape, bool)

Assign this ArraySlice<T> as the internal array storage and assign shape to it.

public void Allocate<T>(ArraySlice<T> values, Shape shape, bool copy = false) where T : unmanaged

Parameters

values ArraySlice<T>

The array to set as internal data storage

shape Shape

The shape of the array.

copy bool

Should perform a copy of values

Type Parameters

T

Remarks

Does not copy values

Allocate<T>(T[])

Allocate values into memory.

public void Allocate<T>(T[] values) where T : unmanaged

Parameters

values T[]

The array to set as internal data storage

Type Parameters

T

Remarks

Does not copy values

AsSpan<T>()

Spans Address <-> Count

public Span<T> AsSpan<T>()

Returns

Span<T>

Type Parameters

T

Remarks

This ignores completely slicing.

Cast(NPTypeCode)

Return a casted UnmanagedStorage to a specific dtype.

public UnmanagedStorage Cast(NPTypeCode typeCode)

Parameters

typeCode NPTypeCode

The dtype to convert to

Returns

UnmanagedStorage

A copy of this UnmanagedStorage casted to a specific dtype.

Remarks

Always copies, If dtype==typeof(T) then a Clone() is returned.

Cast(Type)

Return a casted UnmanagedStorage to a specific dtype.

public UnmanagedStorage Cast(Type dtype)

Parameters

dtype Type

The dtype to convert to

Returns

UnmanagedStorage

A copy of this UnmanagedStorage casted to a specific dtype.

Remarks

Always copies, If dtype==typeof(T) then a Clone() is returned.

CastIfNecessary(NPTypeCode)

Return a casted UnmanagedStorage to a specific dtype only if necessary

public UnmanagedStorage CastIfNecessary(NPTypeCode typeCode)

Parameters

typeCode NPTypeCode

The dtype to convert to

Returns

UnmanagedStorage

A copy of this UnmanagedStorage casted to a specific dtype.

Remarks

Copies only if dtypes does not match typeCode

CastIfNecessary(Type)

Return a casted UnmanagedStorage to a specific dtype.

public UnmanagedStorage CastIfNecessary(Type dtype)

Parameters

dtype Type

The dtype to convert to

Returns

UnmanagedStorage

A copy of this UnmanagedStorage casted to a specific dtype.

Remarks

Copies only if dtypes does not match typeCode

CastIfNecessary<T>()

Return a casted UnmanagedStorage to a specific dtype only if necessary.

public UnmanagedStorage CastIfNecessary<T>() where T : unmanaged

Returns

UnmanagedStorage

A copy of this UnmanagedStorage casted to a specific dtype.

Type Parameters

T

The dtype to convert to

Remarks

Copies only if dtypes does not match T

Cast<T>()

Return a casted UnmanagedStorage to a specific dtype.

public UnmanagedStorage Cast<T>() where T : unmanaged

Returns

UnmanagedStorage

A copy of this UnmanagedStorage casted to a specific dtype.

Type Parameters

T

The dtype to convert to

Remarks

Always copies, If dtype==typeof(T) then a Clone() is returned.

Clone()

Perform a complete copy of this UnmanagedStorage and InternalArray.

public UnmanagedStorage Clone()

Returns

UnmanagedStorage

Remarks

If shape is sliced, discards any slicing properties but copies only the sliced data

CloneData()

Clone internal storage and get reference to it

public IArraySlice CloneData()

Returns

IArraySlice

reference to cloned storage as System.Array

CloneData<T>()

Get all elements from cloned storage as ArraySlice<T> and cast if necessary.

public ArraySlice<T> CloneData<T>() where T : unmanaged

Returns

ArraySlice<T>

reference to cloned storage and casted (if necessary) as ArraySlice<T>

Type Parameters

T

cloned storgae dtype

CopyTo(IMemoryBlock)

Copies the entire contents of this storage to given address (using Count).

public void CopyTo(IMemoryBlock block)

Parameters

block IMemoryBlock

The block to copy to.

CopyTo(nint)

Copies the entire contents of this storage to given address.

public void CopyTo(nint ptr)

Parameters

ptr nint

CopyTo(void*)

Copies the entire contents of this storage to given address.

public void CopyTo(void* address)

Parameters

address void*

The address to copy to.

CopyTo<T>(IMemoryBlock<T>)

Copies the entire contents of this storage to given address (using Count).

public void CopyTo<T>(IMemoryBlock<T> block) where T : unmanaged

Parameters

block IMemoryBlock<T>

The block to copy to.

Type Parameters

T

CopyTo<T>(T*)

Copies the entire contents of this storage to given address.

public void CopyTo<T>(T* address) where T : unmanaged

Parameters

address T*

The address to copy to.

Type Parameters

T

CopyTo<T>(T[])

Copies the entire contents of this storage to given array.

public void CopyTo<T>(T[] array) where T : unmanaged

Parameters

array T[]

The array to copy to.

Type Parameters

T

CreateBroadcastedUnsafe(IArraySlice, Shape)

Creates a new storage with a broadcasted shape from an array slice.

public static UnmanagedStorage CreateBroadcastedUnsafe(IArraySlice arraySlice, Shape shape)

Parameters

arraySlice IArraySlice

The array slice to wrap.

shape Shape

The broadcasted shape to represent this storage.

Returns

UnmanagedStorage

A new UnmanagedStorage that owns the data (not a view). The returned storage's NumSharp.Backends.UnmanagedStorage._baseStorage is null.

Remarks

Named "Unsafe": This method does not validate that the shape is compatible with the array slice size.

Ownership: This overload creates owned storage (not a view) because it receives raw data without storage context. Compare with the CreateBroadcastedUnsafe(UnmanagedStorage, Shape) overload which preserves base tracking.

CreateBroadcastedUnsafe(UnmanagedStorage, Shape)

Creates a broadcasted view of an existing storage with a new shape.

public static UnmanagedStorage CreateBroadcastedUnsafe(UnmanagedStorage storage, Shape shape)

Parameters

storage UnmanagedStorage

The source storage to take InternalArray from.

shape Shape

The broadcasted shape to represent this storage.

Returns

UnmanagedStorage

A new UnmanagedStorage that shares memory with the source storage. The returned storage's NumSharp.Backends.UnmanagedStorage._baseStorage points to the ultimate owner.

Remarks

Named "Unsafe": This method does not validate that the shape is compatible with the storage size.

Base Tracking: Sets _baseStorage to chain to the ultimate owner:

  • If source storage owns its data: result._baseStorage = storage
  • If source storage is a view: result._baseStorage = storage._baseStorage

Used By: np.broadcast_to(), np.broadcast_arrays(), and internal broadcasting operations.

See Also

ExpandDimension(int)

protected void ExpandDimension(int axis)

Parameters

axis int

GetAtIndex(int)

public ValueType GetAtIndex(int index)

Parameters

index int

Returns

ValueType

GetAtIndex<T>(int)

public T GetAtIndex<T>(int index) where T : unmanaged

Parameters

index int

Returns

T

Type Parameters

T

GetBoolean(params int[])

Retrieves value of type bool from internal storage.

public bool GetBoolean(params int[] indices)

Parameters

indices int[]

The shape's indices to get.

Returns

bool

Exceptions

NullReferenceException

When DType is not bool

GetByte(params int[])

Retrieves value of type byte from internal storage.

public byte GetByte(params int[] indices)

Parameters

indices int[]

The shape's indices to get.

Returns

byte

Exceptions

NullReferenceException

When DType is not byte

GetChar(params int[])

Retrieves value of type char from internal storage.

public char GetChar(params int[] indices)

Parameters

indices int[]

The shape's indices to get.

Returns

char

Exceptions

NullReferenceException

When DType is not char

GetData()

Get reference to internal data storage

public IArraySlice GetData()

Returns

IArraySlice

reference to internal storage as System.Array

GetData(int*, int)

Gets a sub-array based on the given indices (pointer version), returning a view that shares memory.

public UnmanagedStorage GetData(int* dims, int ndims)

Parameters

dims int*

Pointer to an array of dimension indices.

ndims int

The number of indices in the array.

Returns

UnmanagedStorage

A new UnmanagedStorage representing the sub-array. This is a view that shares memory with the original storage. The returned storage's NumSharp.Backends.UnmanagedStorage._baseStorage points to the ultimate owner.

Remarks

Memory Sharing: The returned storage shares memory with this storage. Modifications through either storage affect the same underlying data.

Base Tracking: Sets _baseStorage to chain to the ultimate owner, ensuring all views in a chain point to the original storage, not intermediate views.

Code Paths:

  • Broadcasted shapes: Creates a broadcasted view with base tracking
  • Non-contiguous shapes: Delegates to GetView(params Slice[]) which uses Alias(Shape)
  • Contiguous shapes: Creates a direct memory slice with base tracking
See Also

GetData(params int[])

Gets a sub-array based on the given indices, returning a view that shares memory.

public UnmanagedStorage GetData(params int[] indices)

Parameters

indices int[]

The indices specifying which dimensions to select. Negative indices are supported and are converted to positive indices relative to the dimension size.

Returns

UnmanagedStorage

A new UnmanagedStorage representing the sub-array. This is a view that shares memory with the original storage. The returned storage's NumSharp.Backends.UnmanagedStorage._baseStorage points to the ultimate owner.

Remarks

Memory Sharing: The returned storage shares memory with this storage. Modifications through either storage affect the same underlying data.

Base Tracking: Sets _baseStorage to chain to the ultimate owner, ensuring all views in a chain point to the original storage, not intermediate views.

Code Paths:

  • Broadcasted shapes: Creates a broadcasted view with base tracking
  • Non-contiguous shapes: Delegates to GetView(params Slice[]) which uses Alias(Shape)
  • Contiguous shapes: Creates a direct memory slice with base tracking
See Also

GetData<T>()

Get reference to internal data storage and cast (also copies) elements to new dtype if necessary

public ArraySlice<T> GetData<T>() where T : unmanaged

Returns

ArraySlice<T>

reference to internal (casted) storage as T[]

Type Parameters

T

new storage data type

Remarks

Copies if T does not equal to DType or if Shape is sliced.

GetDecimal(params int[])

Retrieves value of type decimal from internal storage.

public decimal GetDecimal(params int[] indices)

Parameters

indices int[]

The shape's indices to get.

Returns

decimal

Exceptions

NullReferenceException

When DType is not decimal

GetDouble(params int[])

Retrieves value of type double from internal storage.

public double GetDouble(params int[] indices)

Parameters

indices int[]

The shape's indices to get.

Returns

double

Exceptions

NullReferenceException

When DType is not double

GetInt16(params int[])

Retrieves value of type short from internal storage.

public short GetInt16(params int[] indices)

Parameters

indices int[]

The shape's indices to get.

Returns

short

Exceptions

NullReferenceException

When DType is not short

GetInt32(params int[])

Retrieves value of type int from internal storage.

public int GetInt32(params int[] indices)

Parameters

indices int[]

The shape's indices to get.

Returns

int

Exceptions

NullReferenceException

When DType is not int

GetInt64(params int[])

Retrieves value of type long from internal storage.

public long GetInt64(params int[] indices)

Parameters

indices int[]

The shape's indices to get.

Returns

long

Exceptions

NullReferenceException

When DType is not long

GetSingle(params int[])

Retrieves value of type float from internal storage.

public float GetSingle(params int[] indices)

Parameters

indices int[]

The shape's indices to get.

Returns

float

Exceptions

NullReferenceException

When DType is not float

GetUInt16(params int[])

Retrieves value of type ushort from internal storage.

public ushort GetUInt16(params int[] indices)

Parameters

indices int[]

The shape's indices to get.

Returns

ushort

Exceptions

NullReferenceException

When DType is not ushort

GetUInt32(params int[])

Retrieves value of type uint from internal storage.

public uint GetUInt32(params int[] indices)

Parameters

indices int[]

The shape's indices to get.

Returns

uint

Exceptions

NullReferenceException

When DType is not uint

GetUInt64(params int[])

Retrieves value of type ulong from internal storage.

public ulong GetUInt64(params int[] indices)

Parameters

indices int[]

The shape's indices to get.

Returns

ulong

Exceptions

NullReferenceException

When DType is not ulong

GetValue(params int[])

Retrieves value of unspecified type (will figure using IStorage.DType).

public ValueType GetValue(params int[] indices)

Parameters

indices int[]

The shape's indices to get.

Returns

ValueType

Exceptions

NullReferenceException

When IStorage.DType is not object

GetValue<T>(params int[])

Get single value from internal storage as type T and cast dtype to T

public T GetValue<T>(params int[] indices) where T : unmanaged

Parameters

indices int[]

indices

Returns

T

element from internal storage

Type Parameters

T

new storage data type

Remarks

If you provide less indices than there are dimensions, the rest are filled with 0.

Exceptions

NullReferenceException

When T does not equal to DType

GetView(params Slice[])

public UnmanagedStorage GetView(params Slice[] slices)

Parameters

slices Slice[]

Returns

UnmanagedStorage

GetView(string)

public UnmanagedStorage GetView(string slicing_notation)

Parameters

slicing_notation string

Returns

UnmanagedStorage

ReplaceData(IArraySlice)

Sets values as the internal data source and changes the internal storage data type to values type.

public void ReplaceData(IArraySlice values)

Parameters

values IArraySlice

Remarks

Does not copy values and doesn't change shape.

ReplaceData(IArraySlice, Shape)

Sets values as the internal data source and changes the internal storage data type to values type.

public void ReplaceData(IArraySlice values, Shape shape)

Parameters

values IArraySlice
shape Shape

The shape to set in this storage. (without checking if shape matches storage)

Remarks

Does not copy values and doesn't change shape. Doesn't check if shape size matches.

ReplaceData(IArraySlice, Type)

Sets values as the internal data source and changes the internal storage data type to values type.

public void ReplaceData(IArraySlice values, Type dtype)

Parameters

values IArraySlice
dtype Type

Remarks

Does not copy values and doesn't change shape.

ReplaceData(IArraySlice, Type, Shape)

Sets values as the internal data source and changes the internal storage data type to values type.

public void ReplaceData(IArraySlice values, Type dtype, Shape shape)

Parameters

values IArraySlice
dtype Type
shape Shape

The shape to set in this storage. (without checking if shape matches storage)

Remarks

Does not copy values and doesn't change shape. Doesn't check if shape size matches.

ReplaceData(NDArray)

Sets nd as the internal data storage and changes the internal storage data type to nd type.

public void ReplaceData(NDArray nd)

Parameters

nd NDArray

Remarks

Does not copy values and does change shape and dtype.

ReplaceData(NDArray, Shape)

Sets nd as the internal data storage and changes the internal storage data type to nd type.

public void ReplaceData(NDArray nd, Shape shape)

Parameters

nd NDArray
shape Shape

The shape to set in this storage. (without checking if shape matches storage)

Remarks

Does not copy values and does change shape and dtype. Doesn't check if shape size matches.

ReplaceData(Array)

Sets values as the internal data source and changes the internal storage data type to values type.

public void ReplaceData(Array values)

Parameters

values Array

Remarks

Copies values only if values type does not match DType and doesn't change shape.

ReplaceData(Array, NPTypeCode)

Set an Array to internal storage, cast it to new dtype and if necessary change dtype

public void ReplaceData(Array values, NPTypeCode typeCode)

Parameters

values Array
typeCode NPTypeCode

Remarks

Does not copy values unless cast is necessary and doesn't change shape.

ReplaceData(Array, NPTypeCode, Shape)

Set an Array to internal storage, cast it to new dtype and if necessary change dtype

public void ReplaceData(Array values, NPTypeCode typeCode, Shape shape)

Parameters

values Array
typeCode NPTypeCode
shape Shape

The shape to set in this storage. (without checking if shape matches storage)

Remarks

Does not copy values unless cast is necessary and doesn't change shape. Doesn't check if shape size matches.

ReplaceData(Array, Shape)

Sets values as the internal data source and changes the internal storage data type to values type.

public void ReplaceData(Array values, Shape shape)

Parameters

values Array
shape Shape

The shape to set in this storage. (without checking if shape matches storage)

Remarks

Copies values only if values type does not match DType and doesn't change shape. Doesn't check if shape size matches.

ReplaceData(Array, Type)

Set an Array to internal storage, cast it to new dtype and change dtype

public void ReplaceData(Array values, Type dtype)

Parameters

values Array
dtype Type

Remarks

Does not copy values unless cast in necessary and doesn't change shape.

ReplaceData(Array, Type, Shape)

Set an Array to internal storage, cast it to new dtype and change dtype

public void ReplaceData(Array values, Type dtype, Shape shape)

Parameters

values Array
dtype Type
shape Shape

The shape to set in this storage. (without checking if shape matches storage)

Remarks

Does not copy values unless cast in necessary and doesn't change shape. Doesn't check if shape size matches.

Reshape(Shape, bool)

Changes the shape representing this storage.

public void Reshape(Shape newShape, bool @unsafe = false)

Parameters

newShape Shape
unsafe bool

Exceptions

IncorrectShapeException

If shape's size mismatches current shape size.

ArgumentException

If newShape's size == 0

Reshape(ref Shape, bool)

Changes the shape representing this storage.

public void Reshape(ref Shape newShape, bool @unsafe = false)

Parameters

newShape Shape
unsafe bool

Exceptions

IncorrectShapeException

If shape's size mismatches current shape size.

ArgumentException

If newShape's size == 0

Reshape(params int[])

Changes the shape representing this storage.

public void Reshape(params int[] dimensions)

Parameters

dimensions int[]

Exceptions

IncorrectShapeException

If shape's size mismatches current shape size.

Reshape(int[], bool)

Changes the shape representing this storage.

public void Reshape(int[] dimensions, bool @unsafe)

Parameters

dimensions int[]
unsafe bool

Exceptions

IncorrectShapeException

If shape's size mismatches current shape size.

ArgumentException

If dimensions's size == 0

Scalar(object)

public static UnmanagedStorage Scalar(object value)

Parameters

value object

Returns

UnmanagedStorage

Scalar(object, NPTypeCode)

public static UnmanagedStorage Scalar(object value, NPTypeCode typeCode)

Parameters

value object
typeCode NPTypeCode

Returns

UnmanagedStorage

Scalar<T>(T)

public static UnmanagedStorage Scalar<T>(T value) where T : unmanaged

Parameters

value T

Returns

UnmanagedStorage

Type Parameters

T

SetAtIndex(object, int)

public void SetAtIndex(object value, int index)

Parameters

value object
index int

SetAtIndexUnsafe(ValueType, int)

Performs a set of index without calling TransformOffset(int).

public void SetAtIndexUnsafe(ValueType value, int index)

Parameters

value ValueType
index int

SetAtIndexUnsafe<T>(T, int)

Performs a set of index without calling TransformOffset(int).

public void SetAtIndexUnsafe<T>(T value, int index) where T : unmanaged

Parameters

value T
index int

Type Parameters

T

SetAtIndex<T>(T, int)

public void SetAtIndex<T>(T value, int index) where T : unmanaged

Parameters

value T
index int

Type Parameters

T

SetBoolean(bool, params int[])

Sets a bool at specific coordinates.

public void SetBoolean(bool value, params int[] indices)

Parameters

value bool

The values to assign

indices int[]

The coordinates to set value at.

SetByte(byte, params int[])

Sets a byte at specific coordinates.

public void SetByte(byte value, params int[] indices)

Parameters

value byte

The values to assign

indices int[]

The coordinates to set value at.

SetChar(char, params int[])

Sets a char at specific coordinates.

public void SetChar(char value, params int[] indices)

Parameters

value char

The values to assign

indices int[]

The coordinates to set value at.

SetData(IArraySlice, params int[])

Set a IArraySlice at given indices.

public void SetData(IArraySlice value, params int[] indices)

Parameters

value IArraySlice

The value to set

indices int[]

The

Remarks

Does not change internal storage data type.
If value does not match DType, value will be converted.

SetData(NDArray, params int[])

Set a NDArray at given indices.

public void SetData(NDArray value, params int[] indices)

Parameters

value NDArray

The value to set

indices int[]

The

Remarks

Does not change internal storage data type.
If value does not match DType, value will be converted.

SetData(object, params int[])

Set a single value at given indices.

public void SetData(object value, params int[] indices)

Parameters

value object

The value to set

indices int[]

The

Remarks

Does not change internal storage data type.
If value does not match DType, value will be converted.

SetDecimal(decimal, params int[])

Sets a decimal at specific coordinates.

public void SetDecimal(decimal value, params int[] indices)

Parameters

value decimal

The values to assign

indices int[]

The coordinates to set value at.

SetDouble(double, params int[])

Sets a double at specific coordinates.

public void SetDouble(double value, params int[] indices)

Parameters

value double

The values to assign

indices int[]

The coordinates to set value at.

SetInt16(short, params int[])

Sets a short at specific coordinates.

public void SetInt16(short value, params int[] indices)

Parameters

value short

The values to assign

indices int[]

The coordinates to set value at.

SetInt32(int, params int[])

Sets a int at specific coordinates.

public void SetInt32(int value, params int[] indices)

Parameters

value int

The values to assign

indices int[]

The coordinates to set value at.

SetInt64(long, params int[])

Sets a long at specific coordinates.

public void SetInt64(long value, params int[] indices)

Parameters

value long

The values to assign

indices int[]

The coordinates to set value at.

SetInternalArray(IArraySlice)

Replace internal storage array with given array.

protected void SetInternalArray(IArraySlice array)

Parameters

array IArraySlice

The array to set as internal storage

Exceptions

InvalidCastException

When type of array does not match DType of this storage

SetInternalArray(Array)

Replace internal storage array with given array.

protected void SetInternalArray(Array array)

Parameters

array Array

The array to set as internal storage

Exceptions

InvalidCastException

When type of array does not match DType of this storage

SetShapeUnsafe(Shape)

Set the shape of this storage without checking if sizes match.

protected void SetShapeUnsafe(Shape shape)

Parameters

shape Shape

Remarks

Used during broadcasting

SetShapeUnsafe(ref Shape)

Set the shape of this storage without checking if sizes match.

protected void SetShapeUnsafe(ref Shape shape)

Parameters

shape Shape

Remarks

Used during broadcasting

SetSingle(float, params int[])

Sets a float at specific coordinates.

public void SetSingle(float value, params int[] indices)

Parameters

value float

The values to assign

indices int[]

The coordinates to set value at.

SetUInt16(ushort, params int[])

Sets a ushort at specific coordinates.

public void SetUInt16(ushort value, params int[] indices)

Parameters

value ushort

The values to assign

indices int[]

The coordinates to set value at.

SetUInt32(uint, params int[])

Sets a uint at specific coordinates.

public void SetUInt32(uint value, params int[] indices)

Parameters

value uint

The values to assign

indices int[]

The coordinates to set value at.

SetUInt64(ulong, params int[])

Sets a ulong at specific coordinates.

public void SetUInt64(ulong value, params int[] indices)

Parameters

value ulong

The values to assign

indices int[]

The coordinates to set value at.

SetValue(object, params int[])

Set a single value at given indices.

public void SetValue(object value, params int[] indices)

Parameters

value object

The value to set

indices int[]

The

Remarks

Does not change internal storage data type.
If value does not match DType, value will be converted.

SetValue<T>(T, params int[])

Set a single value at given indices.

public void SetValue<T>(T value, params int[] indices) where T : unmanaged

Parameters

value T

The value to set

indices int[]

The

Type Parameters

T

Remarks

Does not change internal storage data type.
If value does not match DType, value will be converted.

ToArray<T>()

public T[] ToArray<T>() where T : unmanaged

Returns

T[]

Type Parameters

T

_Allocate(Shape, IArraySlice)

protected void _Allocate(Shape shape, IArraySlice values)

Parameters

shape Shape
values IArraySlice

_ChangeTypeOfArray(Array, Type)

Changes the type of sourceArray to to_dtype if necessary.

[SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")]
protected static Array _ChangeTypeOfArray(Array sourceArray, Type to_dtype)

Parameters

sourceArray Array

The array to change his type

to_dtype Type

The type to change to.

Returns

Array

Returns sourceArray or new array with changed type to to_dtype

Remarks

If the return type is equal to source type, this method does not return a copy.

_ChangeTypeOfArray<TOut>(IArraySlice)

Changes the type of sourceArray to to_dtype if necessary.

[SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")]
protected static ArraySlice<TOut> _ChangeTypeOfArray<TOut>(IArraySlice sourceArray) where TOut : unmanaged

Parameters

sourceArray IArraySlice

The array to change his type

Returns

ArraySlice<TOut>

Returns sourceArray or new array with changed type to to_dtype

Type Parameters

TOut

Remarks

If the return type is equal to source type, this method does not return a copy.