Class ArraySlice
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
typeCodeNPTypeCodecountint
Returns
Allocate(NPTypeCode, int, bool)
Backwards-compatible overload accepting int count.
public static IArraySlice Allocate(NPTypeCode typeCode, int count, bool fillDefault)
Parameters
typeCodeNPTypeCodecountintfillDefaultbool
Returns
Allocate(NPTypeCode, int, object)
Backwards-compatible overload accepting int count.
public static IArraySlice Allocate(NPTypeCode typeCode, int count, object fill)
Parameters
typeCodeNPTypeCodecountintfillobject
Returns
Allocate(NPTypeCode, long)
public static IArraySlice Allocate(NPTypeCode typeCode, long count)
Parameters
typeCodeNPTypeCodecountlong
Returns
Allocate(NPTypeCode, long, bool)
public static IArraySlice Allocate(NPTypeCode typeCode, long count, bool fillDefault)
Parameters
typeCodeNPTypeCodecountlongfillDefaultbool
Returns
Allocate(NPTypeCode, long, object)
public static IArraySlice Allocate(NPTypeCode typeCode, long count, object fill)
Parameters
typeCodeNPTypeCodecountlongfillobject
Returns
Allocate(Type, int)
Backwards-compatible overload accepting int count.
public static IArraySlice Allocate(Type elementType, int count)
Parameters
Returns
Allocate(Type, int, bool)
Backwards-compatible overload accepting int count.
public static IArraySlice Allocate(Type elementType, int count, bool fillDefault)
Parameters
Returns
Allocate(Type, int, object)
Backwards-compatible overload accepting int count.
public static IArraySlice Allocate(Type elementType, int count, object fill)
Parameters
Returns
Allocate(Type, long)
public static IArraySlice Allocate(Type elementType, long count)
Parameters
Returns
Allocate(Type, long, bool)
public static IArraySlice Allocate(Type elementType, long count, bool fillDefault)
Parameters
Returns
Allocate(Type, long, object)
public static IArraySlice Allocate(Type elementType, long count, object fill)
Parameters
Returns
Allocate<T>(long)
Allocate an array filled with noisy memory.
public static ArraySlice<T> Allocate<T>(long count) where T : unmanaged
Parameters
countlongHow 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
countlongHow many items this array will have (aka Count).
fillDefaultboolShould 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
countlongHow many items this array will have (aka Count).
fillTThe 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
Returns
FromArray(bool[], bool)
public static ArraySlice<bool> FromArray(bool[] bools, bool copy = false)
Parameters
Returns
FromArray(byte[], bool)
public static ArraySlice<byte> FromArray(byte[] bytes, bool copy = false)
Parameters
Returns
FromArray(char[], bool)
public static ArraySlice<char> FromArray(char[] chars, bool copy = false)
Parameters
Returns
FromArray(decimal[], bool)
public static ArraySlice<decimal> FromArray(decimal[] decimals, bool copy = false)
Parameters
Returns
FromArray(double[], bool)
public static ArraySlice<double> FromArray(double[] doubles, bool copy = false)
Parameters
Returns
FromArray(Half[], bool)
public static ArraySlice<Half> FromArray(Half[] halfs, bool copy = false)
Parameters
Returns
FromArray(short[], bool)
public static ArraySlice<short> FromArray(short[] shorts, bool copy = false)
Parameters
Returns
FromArray(int[], bool)
public static ArraySlice<int> FromArray(int[] ints, bool copy = false)
Parameters
Returns
FromArray(long[], bool)
public static ArraySlice<long> FromArray(long[] longs, bool copy = false)
Parameters
Returns
FromArray(Complex[], bool)
public static ArraySlice<Complex> FromArray(Complex[] complexes, bool copy = false)
Parameters
Returns
FromArray(sbyte[], bool)
public static ArraySlice<sbyte> FromArray(sbyte[] sbytes, bool copy = false)
Parameters
Returns
FromArray(float[], bool)
public static ArraySlice<float> FromArray(float[] floats, bool copy = false)
Parameters
Returns
FromArray(ushort[], bool)
public static ArraySlice<ushort> FromArray(ushort[] ushorts, bool copy = false)
Parameters
Returns
FromArray(uint[], bool)
public static ArraySlice<uint> FromArray(uint[] uints, bool copy = false)
Parameters
Returns
FromArray(ulong[], bool)
public static ArraySlice<ulong> FromArray(ulong[] ulongs, bool copy = false)
Parameters
Returns
FromArray<T>(T[,,,,,,,,,,,,,,,], bool)
public static ArraySlice<T> FromArray<T>(T[,,,,,,,,,,,,,,,] array, bool copy = false) where T : unmanaged
Parameters
arrayT[,,,,,,,,,,,,,,,]copybool
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
arrayT[,,,,,,,,,,,,,,]copybool
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
arrayT[,,,,,,,,,,,,,]copybool
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
arrayT[,,,,,,,,,,,,]copybool
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
arrayT[,,,,,,,,,,,]copybool
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
arrayT[,,,,,,,,,,]copybool
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
arrayT[,,,,,,,,,]copybool
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
arrayT[,,,,,,,,]copybool
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
arrayT[,,,,,,,]copybool
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
arrayT[,,,,,,]copybool
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
arrayT[,,,,,]copybool
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
arrayT[,,,,]copybool
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
arrayT[,,,]copybool
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
arrayT[,,]copybool
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
arrayT[,]copybool
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
arrayT[]copybool
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
Returns
- ArraySlice<T>
Type Parameters
T
FromMemoryBlock(IMemoryBlock, bool)
public static IArraySlice FromMemoryBlock(IMemoryBlock block, bool copy = false)
Parameters
blockIMemoryBlockcopybool
Returns
FromPool<T>(StackedMemoryPool)
public static ArraySlice<T> FromPool<T>(StackedMemoryPool pool) where T : unmanaged
Parameters
poolStackedMemoryPool
Returns
- ArraySlice<T>
Type Parameters
T
Scalar(object)
Wrap a val inside ArraySlice<T>.
public static IArraySlice Scalar(object val)
Parameters
valobjectThe value to wrap into an arrayslice.
Returns
Scalar(object, NPTypeCode)
Wrap a T inside ArraySlice<T>.
public static IArraySlice Scalar(object val, NPTypeCode typeCode)
Parameters
valobjectThe value to wrap into an arrayslice.
typeCodeNPTypeCodeThe type expected to be returned
Returns
Scalar<T>(T)
Wrap a T inside ArraySlice<T>.
public static ArraySlice<T> Scalar<T>(T val) where T : unmanaged
Parameters
valT
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
typeCodeNPTypeCodeThe element type of the alias.
addressvoid*The first aliased element (inside
arcOwner's memory). It need not be aligned fortypeCode: NumSharp reads elements with unaligned loads.countlongThe count of elements (not bytes).
arcOwnerIArraySliceThe 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
arcOwneris null.- NotSupportedException
typeCodeis 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
addressvoid*The first aliased element (inside
arcOwner's buffer).countlongThe count of items of type
T(not bytes count).arcOwnerIArraySliceThe 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
arcOwneris 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
addressvoid*The address at which the memory block starts
countlongThe 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
addressT*The address at which the memory block starts
countlongThe count of items of type
T(not bytes count)
Returns
- ArraySlice<T>
A wrapped memory block as ArraySlice<T>
Type Parameters
T