Table of Contents

Class ArraySlice

Namespace
NumSharp.Backends.Unmanaged
Assembly
NumSharp.dll
public static class ArraySlice
Inheritance
ArraySlice
Inherited Members

Methods

Allocate(NPTypeCode, int)

Backwards-compatible overload accepting int count.

public static IArraySlice Allocate(NPTypeCode typeCode, int count)

Parameters

typeCode NPTypeCode
count int

Returns

IArraySlice

Allocate(NPTypeCode, int, bool)

Backwards-compatible overload accepting int count.

public static IArraySlice Allocate(NPTypeCode typeCode, int count, bool fillDefault)

Parameters

typeCode NPTypeCode
count int
fillDefault bool

Returns

IArraySlice

Allocate(NPTypeCode, int, object)

Backwards-compatible overload accepting int count.

public static IArraySlice Allocate(NPTypeCode typeCode, int count, object fill)

Parameters

typeCode NPTypeCode
count int
fill object

Returns

IArraySlice

Allocate(NPTypeCode, long)

public static IArraySlice Allocate(NPTypeCode typeCode, long count)

Parameters

typeCode NPTypeCode
count long

Returns

IArraySlice

Allocate(NPTypeCode, long, bool)

public static IArraySlice Allocate(NPTypeCode typeCode, long count, bool fillDefault)

Parameters

typeCode NPTypeCode
count long
fillDefault bool

Returns

IArraySlice

Allocate(NPTypeCode, long, object)

public static IArraySlice Allocate(NPTypeCode typeCode, long count, object fill)

Parameters

typeCode NPTypeCode
count long
fill object

Returns

IArraySlice

Allocate(Type, int)

Backwards-compatible overload accepting int count.

public static IArraySlice Allocate(Type elementType, int count)

Parameters

elementType Type
count int

Returns

IArraySlice

Allocate(Type, int, bool)

Backwards-compatible overload accepting int count.

public static IArraySlice Allocate(Type elementType, int count, bool fillDefault)

Parameters

elementType Type
count int
fillDefault bool

Returns

IArraySlice

Allocate(Type, int, object)

Backwards-compatible overload accepting int count.

public static IArraySlice Allocate(Type elementType, int count, object fill)

Parameters

elementType Type
count int
fill object

Returns

IArraySlice

Allocate(Type, long)

public static IArraySlice Allocate(Type elementType, long count)

Parameters

elementType Type
count long

Returns

IArraySlice

Allocate(Type, long, bool)

public static IArraySlice Allocate(Type elementType, long count, bool fillDefault)

Parameters

elementType Type
count long
fillDefault bool

Returns

IArraySlice

Allocate(Type, long, object)

public static IArraySlice Allocate(Type elementType, long count, object fill)

Parameters

elementType Type
count long
fill object

Returns

IArraySlice

Allocate<T>(long)

Allocate an array filled with noisy memory.

public static ArraySlice<T> Allocate<T>(long count) where T : unmanaged

Parameters

count long

How many items this array will have (aka Count).

Returns

ArraySlice<T>

A newly allocated array.

Type Parameters

T

Allocate<T>(long, bool)

Allocate an array filled with default value of T.

public static ArraySlice<T> Allocate<T>(long count, bool fillDefault) where T : unmanaged

Parameters

count long

How many items this array will have (aka Count).

fillDefault bool

Should the newly allocated memory be filled with the default of T

Returns

ArraySlice<T>

A newly allocated array.

Type Parameters

T

Allocate<T>(long, T)

Allocate an array filled filled with fill.

public static ArraySlice<T> Allocate<T>(long count, T fill) where T : unmanaged

Parameters

count long

How many items this array will have (aka Count).

fill T

The item to fill the newly allocated memory with.

Returns

ArraySlice<T>

A newly allocated array.

Type Parameters

T

FromArray(Array, bool)

public static IArraySlice FromArray(Array arr, bool copy = false)

Parameters

arr Array
copy bool

Returns

IArraySlice

FromArray(bool[], bool)

public static ArraySlice<bool> FromArray(bool[] bools, bool copy = false)

Parameters

bools bool[]
copy bool

Returns

ArraySlice<bool>

FromArray(byte[], bool)

public static ArraySlice<byte> FromArray(byte[] bytes, bool copy = false)

Parameters

bytes byte[]
copy bool

Returns

ArraySlice<byte>

FromArray(char[], bool)

public static ArraySlice<char> FromArray(char[] chars, bool copy = false)

Parameters

chars char[]
copy bool

Returns

ArraySlice<char>

FromArray(decimal[], bool)

public static ArraySlice<decimal> FromArray(decimal[] decimals, bool copy = false)

Parameters

decimals decimal[]
copy bool

Returns

ArraySlice<decimal>

FromArray(double[], bool)

public static ArraySlice<double> FromArray(double[] doubles, bool copy = false)

Parameters

doubles double[]
copy bool

Returns

ArraySlice<double>

FromArray(Half[], bool)

public static ArraySlice<Half> FromArray(Half[] halfs, bool copy = false)

Parameters

halfs Half[]
copy bool

Returns

ArraySlice<Half>

FromArray(short[], bool)

public static ArraySlice<short> FromArray(short[] shorts, bool copy = false)

Parameters

shorts short[]
copy bool

Returns

ArraySlice<short>

FromArray(int[], bool)

public static ArraySlice<int> FromArray(int[] ints, bool copy = false)

Parameters

ints int[]
copy bool

Returns

ArraySlice<int>

FromArray(long[], bool)

public static ArraySlice<long> FromArray(long[] longs, bool copy = false)

Parameters

longs long[]
copy bool

Returns

ArraySlice<long>

FromArray(Complex[], bool)

public static ArraySlice<Complex> FromArray(Complex[] complexes, bool copy = false)

Parameters

complexes Complex[]
copy bool

Returns

ArraySlice<Complex>

FromArray(sbyte[], bool)

public static ArraySlice<sbyte> FromArray(sbyte[] sbytes, bool copy = false)

Parameters

sbytes sbyte[]
copy bool

Returns

ArraySlice<sbyte>

FromArray(float[], bool)

public static ArraySlice<float> FromArray(float[] floats, bool copy = false)

Parameters

floats float[]
copy bool

Returns

ArraySlice<float>

FromArray(ushort[], bool)

public static ArraySlice<ushort> FromArray(ushort[] ushorts, bool copy = false)

Parameters

ushorts ushort[]
copy bool

Returns

ArraySlice<ushort>

FromArray(uint[], bool)

public static ArraySlice<uint> FromArray(uint[] uints, bool copy = false)

Parameters

uints uint[]
copy bool

Returns

ArraySlice<uint>

FromArray(ulong[], bool)

public static ArraySlice<ulong> FromArray(ulong[] ulongs, bool copy = false)

Parameters

ulongs ulong[]
copy bool

Returns

ArraySlice<ulong>

FromArray<T>(T[,,,,,,,,,,,,,,,], bool)

public static ArraySlice<T> FromArray<T>(T[,,,,,,,,,,,,,,,] array, bool copy = false) where T : unmanaged

Parameters

array T[,,,,,,,,,,,,,,,]
copy bool

Returns

ArraySlice<T>

Type Parameters

T

FromArray<T>(T[,,,,,,,,,,,,,,], bool)

public static ArraySlice<T> FromArray<T>(T[,,,,,,,,,,,,,,] array, bool copy = false) where T : unmanaged

Parameters

array T[,,,,,,,,,,,,,,]
copy bool

Returns

ArraySlice<T>

Type Parameters

T

FromArray<T>(T[,,,,,,,,,,,,,], bool)

public static ArraySlice<T> FromArray<T>(T[,,,,,,,,,,,,,] array, bool copy = false) where T : unmanaged

Parameters

array T[,,,,,,,,,,,,,]
copy bool

Returns

ArraySlice<T>

Type Parameters

T

FromArray<T>(T[,,,,,,,,,,,,], bool)

public static ArraySlice<T> FromArray<T>(T[,,,,,,,,,,,,] array, bool copy = false) where T : unmanaged

Parameters

array T[,,,,,,,,,,,,]
copy bool

Returns

ArraySlice<T>

Type Parameters

T

FromArray<T>(T[,,,,,,,,,,,], bool)

public static ArraySlice<T> FromArray<T>(T[,,,,,,,,,,,] array, bool copy = false) where T : unmanaged

Parameters

array T[,,,,,,,,,,,]
copy bool

Returns

ArraySlice<T>

Type Parameters

T

FromArray<T>(T[,,,,,,,,,,], bool)

public static ArraySlice<T> FromArray<T>(T[,,,,,,,,,,] array, bool copy = false) where T : unmanaged

Parameters

array T[,,,,,,,,,,]
copy bool

Returns

ArraySlice<T>

Type Parameters

T

FromArray<T>(T[,,,,,,,,,], bool)

public static ArraySlice<T> FromArray<T>(T[,,,,,,,,,] array, bool copy = false) where T : unmanaged

Parameters

array T[,,,,,,,,,]
copy bool

Returns

ArraySlice<T>

Type Parameters

T

FromArray<T>(T[,,,,,,,,], bool)

public static ArraySlice<T> FromArray<T>(T[,,,,,,,,] array, bool copy = false) where T : unmanaged

Parameters

array T[,,,,,,,,]
copy bool

Returns

ArraySlice<T>

Type Parameters

T

FromArray<T>(T[,,,,,,,], bool)

public static ArraySlice<T> FromArray<T>(T[,,,,,,,] array, bool copy = false) where T : unmanaged

Parameters

array T[,,,,,,,]
copy bool

Returns

ArraySlice<T>

Type Parameters

T

FromArray<T>(T[,,,,,,], bool)

public static ArraySlice<T> FromArray<T>(T[,,,,,,] array, bool copy = false) where T : unmanaged

Parameters

array T[,,,,,,]
copy bool

Returns

ArraySlice<T>

Type Parameters

T

FromArray<T>(T[,,,,,], bool)

public static ArraySlice<T> FromArray<T>(T[,,,,,] array, bool copy = false) where T : unmanaged

Parameters

array T[,,,,,]
copy bool

Returns

ArraySlice<T>

Type Parameters

T

FromArray<T>(T[,,,,], bool)

public static ArraySlice<T> FromArray<T>(T[,,,,] array, bool copy = false) where T : unmanaged

Parameters

array T[,,,,]
copy bool

Returns

ArraySlice<T>

Type Parameters

T

FromArray<T>(T[,,,], bool)

public static ArraySlice<T> FromArray<T>(T[,,,] array, bool copy = false) where T : unmanaged

Parameters

array T[,,,]
copy bool

Returns

ArraySlice<T>

Type Parameters

T

FromArray<T>(T[,,], bool)

public static ArraySlice<T> FromArray<T>(T[,,] array, bool copy = false) where T : unmanaged

Parameters

array T[,,]
copy bool

Returns

ArraySlice<T>

Type Parameters

T

FromArray<T>(T[,], bool)

public static ArraySlice<T> FromArray<T>(T[,] array, bool copy = false) where T : unmanaged

Parameters

array T[,]
copy bool

Returns

ArraySlice<T>

Type Parameters

T

FromArray<T>(T[], bool)

public static ArraySlice<T> FromArray<T>(T[] array, bool copy = false) where T : unmanaged

Parameters

array T[]
copy bool

Returns

ArraySlice<T>

Type Parameters

T

FromBuffer<T>(byte[], bool)

public static ArraySlice<T> FromBuffer<T>(byte[] arr, bool copy = false) where T : unmanaged

Parameters

arr byte[]
copy bool

Returns

ArraySlice<T>

Type Parameters

T

FromMemoryBlock(IMemoryBlock, bool)

public static IArraySlice FromMemoryBlock(IMemoryBlock block, bool copy = false)

Parameters

block IMemoryBlock
copy bool

Returns

IArraySlice

FromPool<T>(StackedMemoryPool)

public static ArraySlice<T> FromPool<T>(StackedMemoryPool pool) where T : unmanaged

Parameters

pool StackedMemoryPool

Returns

ArraySlice<T>

Type Parameters

T

Scalar(object)

Wrap a val inside ArraySlice<T>.

public static IArraySlice Scalar(object val)

Parameters

val object

The value to wrap into an arrayslice.

Returns

IArraySlice

Scalar(object, NPTypeCode)

Wrap a T inside ArraySlice<T>.

public static IArraySlice Scalar(object val, NPTypeCode typeCode)

Parameters

val object

The value to wrap into an arrayslice.

typeCode NPTypeCode

The type expected to be returned

Returns

IArraySlice

Scalar<T>(T)

Wrap a T inside ArraySlice<T>.

public static ArraySlice<T> Scalar<T>(T val) where T : unmanaged

Parameters

val T

Returns

ArraySlice<T>

Type Parameters

T

WrapShared(NPTypeCode, void*, long, IArraySlice)

WrapShared<T>(void*, long, IArraySlice) for an element type known only at run time: an alias of count elements of typeCode at address, whose reference counting forwards to arcOwner. np.ndarray(shape, dtype, buffer=...) lays its result over a buffer this way, in one step instead of a byte view reinterpreted afterwards.

public static IArraySlice WrapShared(NPTypeCode typeCode, void* address, long count, IArraySlice arcOwner)

Parameters

typeCode NPTypeCode

The element type of the alias.

address void*

The first aliased element (inside arcOwner's memory). It need not be aligned for typeCode: NumSharp reads elements with unaligned loads.

count long

The count of elements (not bytes).

arcOwner IArraySlice

The slice whose block owns the memory (or forwards to the one that does).

Returns

IArraySlice

A non-owning slice whose ARC operations forward to arcOwner.

Remarks

Footgun, as for the generic form: nothing checks that the alias stays inside arcOwner's buffer.

Exceptions

ArgumentNullException

arcOwner is null.

NotSupportedException

typeCode is not a storage type.

WrapShared<T>(void*, long, IArraySlice)

Wrap an ALIAS of memory another array owns — reinterpreted as T — whose reference counting is the owner's. Use it for every byte-reinterpreting view (a complex lane, view(dtype), getfield): an NDArray over the returned slice keeps the owner's buffer alive until the alias itself is disposed, exactly as an ordinary view sharing the owner's slice does. (A plain Wrap<T>(void*, long) counts nothing, so disposing the owner freed the buffer under the alias.)

public static ArraySlice<T> WrapShared<T>(void* address, long count, IArraySlice arcOwner) where T : unmanaged

Parameters

address void*

The first aliased element (inside arcOwner's buffer).

count long

The count of items of type T (not bytes count).

arcOwner IArraySlice

The owner's slice — the source storage's InternalArray.

Returns

ArraySlice<T>

A non-owning slice whose ARC operations forward to arcOwner.

Type Parameters

T

Remarks

The route a bridge package takes to lay a typed view over memory a NumSharp array already owns without risking a free under it. Footgun: nothing checks that address and count stay inside arcOwner's buffer - an alias past its end reads and writes memory the owner never had.

Exceptions

ArgumentNullException

arcOwner is null.

Wrap<T>(void*, long)

Wrap around a address with given count without claiming ownership of the address.

public static ArraySlice<T> Wrap<T>(void* address, long count) where T : unmanaged

Parameters

address void*

The address at which the memory block starts

count long

The count of items of type T (not bytes count)

Returns

ArraySlice<T>

A wrapped memory block as ArraySlice<T>

Type Parameters

T

Wrap<T>(T*, long)

Wrap around a address with given count without claiming ownership of the address.

public static ArraySlice<T> Wrap<T>(T* address, long count) where T : unmanaged

Parameters

address T*

The address at which the memory block starts

count long

The count of items of type T (not bytes count)

Returns

ArraySlice<T>

A wrapped memory block as ArraySlice<T>

Type Parameters

T