Class UnmanagedStorage
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
arraySliceIArraySliceThe slice to wrap
shapeShape
UnmanagedStorage(NPTypeCode)
Creates an empty storage of type typeCode.
public UnmanagedStorage(NPTypeCode typeCode)
Parameters
typeCodeNPTypeCodeThe type of this storage
Remarks
Usually Allocate(Shape, Type) is called after this constructor.
UnmanagedStorage(bool)
public UnmanagedStorage(bool scalar)
Parameters
scalarbool
UnmanagedStorage(bool[])
public UnmanagedStorage(bool[] values)
Parameters
valuesbool[]
UnmanagedStorage(byte)
public UnmanagedStorage(byte scalar)
Parameters
scalarbyte
UnmanagedStorage(byte[])
public UnmanagedStorage(byte[] values)
Parameters
valuesbyte[]
UnmanagedStorage(char)
public UnmanagedStorage(char scalar)
Parameters
scalarchar
UnmanagedStorage(char[])
public UnmanagedStorage(char[] values)
Parameters
valueschar[]
UnmanagedStorage(decimal)
public UnmanagedStorage(decimal scalar)
Parameters
scalardecimal
UnmanagedStorage(decimal[])
public UnmanagedStorage(decimal[] values)
Parameters
valuesdecimal[]
UnmanagedStorage(double)
public UnmanagedStorage(double scalar)
Parameters
scalardouble
UnmanagedStorage(double[])
public UnmanagedStorage(double[] values)
Parameters
valuesdouble[]
UnmanagedStorage(short)
public UnmanagedStorage(short scalar)
Parameters
scalarshort
UnmanagedStorage(short[])
public UnmanagedStorage(short[] values)
Parameters
valuesshort[]
UnmanagedStorage(int)
public UnmanagedStorage(int scalar)
Parameters
scalarint
UnmanagedStorage(int[])
public UnmanagedStorage(int[] values)
Parameters
valuesint[]
UnmanagedStorage(long)
public UnmanagedStorage(long scalar)
Parameters
scalarlong
UnmanagedStorage(long[])
public UnmanagedStorage(long[] values)
Parameters
valueslong[]
UnmanagedStorage(float)
public UnmanagedStorage(float scalar)
Parameters
scalarfloat
UnmanagedStorage(float[])
public UnmanagedStorage(float[] values)
Parameters
valuesfloat[]
UnmanagedStorage(Type)
Creates an empty storage of type dtype.
public UnmanagedStorage(Type dtype)
Parameters
dtypeTypeThe type of this storage
Remarks
Usually Allocate(Shape, Type) is called after this constructor.
UnmanagedStorage(ushort)
public UnmanagedStorage(ushort scalar)
Parameters
scalarushort
UnmanagedStorage(ushort[])
public UnmanagedStorage(ushort[] values)
Parameters
valuesushort[]
UnmanagedStorage(uint)
public UnmanagedStorage(uint scalar)
Parameters
scalaruint
UnmanagedStorage(uint[])
public UnmanagedStorage(uint[] values)
Parameters
valuesuint[]
UnmanagedStorage(ulong)
public UnmanagedStorage(ulong scalar)
Parameters
scalarulong
UnmanagedStorage(ulong[])
public UnmanagedStorage(ulong[] values)
Parameters
valuesulong[]
Fields
Address
public byte* Address
Field Value
- byte*
Count
public long Count
Field Value
InternalArray
public IArraySlice InternalArray
Field Value
_arrayBoolean
protected ArraySlice<bool> _arrayBoolean
Field Value
_arrayByte
protected ArraySlice<byte> _arrayByte
Field Value
_arrayChar
protected ArraySlice<char> _arrayChar
Field Value
_arrayComplex
protected ArraySlice<Complex> _arrayComplex
Field Value
_arrayDecimal
protected ArraySlice<decimal> _arrayDecimal
Field Value
_arrayDouble
protected ArraySlice<double> _arrayDouble
Field Value
_arrayHalf
protected ArraySlice<Half> _arrayHalf
Field Value
_arrayInt16
protected ArraySlice<short> _arrayInt16
Field Value
_arrayInt32
protected ArraySlice<int> _arrayInt32
Field Value
_arrayInt64
protected ArraySlice<long> _arrayInt64
Field Value
_arraySByte
protected ArraySlice<sbyte> _arraySByte
Field Value
_arraySingle
protected ArraySlice<float> _arraySingle
Field Value
_arrayUInt16
protected ArraySlice<ushort> _arrayUInt16
Field Value
_arrayUInt32
protected ArraySlice<uint> _arrayUInt32
Field Value
_arrayUInt64
protected ArraySlice<ulong> _arrayUInt64
Field Value
_dtype
protected Type _dtype
Field Value
_shape
protected Shape _shape
Field Value
_typecode
protected NPTypeCode _typecode
Field Value
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
nullfor 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
Remarks
Computed by SizeOf(object)
Engine
The engine that was used to create this IStorage.
public TensorEngine Engine { get; protected set; }
Property Value
IsView
Gets a value indicating whether this storage is a view of another storage.
public bool IsView { get; }
Property Value
- bool
trueif this storage shares memory with another storage (does not own its data);falseif 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
ShapeReference
The shape representing the data in this storage.
public ref Shape ShapeReference { get; }
Property Value
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
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
shapeShapeThe 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
shapeShapeThe 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
AliasAs(NPTypeCode)
Creates an alias (view) of this storage with a different dtype, reinterpreting bytes.
public UnmanagedStorage AliasAs(NPTypeCode typeCode)
Parameters
typeCodeNPTypeCodeThe new dtype to interpret the bytes as.
Returns
- UnmanagedStorage
A view with reinterpreted bytes.
AliasAs(Type)
Creates an alias (view) of this storage with a different dtype, reinterpreting bytes.
public UnmanagedStorage AliasAs(Type dtype)
Parameters
dtypeTypeThe new dtype to interpret the bytes as.
Returns
- UnmanagedStorage
A view with reinterpreted bytes.
AliasAs<T>()
Creates an alias (view) of this storage with a different dtype, reinterpreting bytes.
public UnmanagedStorage AliasAs<T>() where T : unmanaged
Returns
- UnmanagedStorage
A new UnmanagedStorage that shares memory with this storage but interprets the bytes as a different type. Shape is adjusted if type sizes differ.
Type Parameters
TThe new dtype to interpret the bytes as.
Remarks
Byte Reinterpretation: This does NOT convert values. It reinterprets the raw bytes as a different type, like NumPy's view(). For example, viewing float64 as int64 will show the IEEE 754 bit patterns, not converted values.
Shape Adjustment: If the new type has a different size, the last dimension is adjusted. E.g., float64[3] viewed as float32 becomes float32[6].
Contiguous Requirement: Only contiguous arrays can be viewed with different dtype when sizes differ.
Exceptions
- InvalidOperationException
If the array is not contiguous and type sizes differ.
- ArgumentException
If the total byte size is not divisible by the new type size.
Allocate(IArraySlice, Shape, bool)
Allocate values into memory.
public void Allocate(IArraySlice values, Shape shape, bool copy = false)
Parameters
valuesIArraySliceThe array to set as internal data storage
shapeShapeThe shape of the array.
copyboolShould 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
shapeShapeThe shape of the array.
dtypeNPTypeCodeThe type of the Array, if null DType is used.
fillZerosbool
Allocate(Shape, Type)
Allocates a new Array into memory.
public void Allocate(Shape shape, Type dtype = null)
Parameters
Allocate(Shape, Type, bool)
Allocates a new Array into memory.
public void Allocate(Shape shape, Type dtype, bool fillZeros)
Parameters
shapeShapeThe shape of the array.
dtypeTypeThe type of the Array, if null DType is used.
fillZerosbool
Allocate(Array)
Allocate array into memory.
public void Allocate(Array array)
Parameters
arrayArrayThe 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
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
valuesArraySlice<T>The array to set as internal data storage
shapeShapeThe shape of the array.
copyboolShould 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
valuesT[]The array to set as internal data storage
Type Parameters
T
Remarks
Does not copy values
AsSpan<T>()
Returns an UnmanagedSpan representing this storage's memory.
public Span<T> AsSpan<T>() where T : unmanaged
Returns
- Span<T>
Type Parameters
T
Remarks
This ignores completely slicing. Supports long indexing for arrays > 2B elements.
AsUnmanagedSpan<T>()
Returns an UnmanagedSpan representing this storage's memory.
public UnmanagedSpan<T> AsUnmanagedSpan<T>() where T : unmanaged
Returns
Type Parameters
T
Remarks
This ignores completely slicing. Supports long indexing for arrays > 2B elements.
Cast(NPTypeCode)
Return a casted UnmanagedStorage to a specific dtype.
public UnmanagedStorage Cast(NPTypeCode typeCode)
Parameters
typeCodeNPTypeCodeThe 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
dtypeTypeThe 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
typeCodeNPTypeCodeThe 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
dtypeTypeThe 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
TThe 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
TThe 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
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
Tcloned storgae dtype
CopyTo(IMemoryBlock)
Copies the entire contents of this storage to given address (using Count).
public void CopyTo(IMemoryBlock block)
Parameters
blockIMemoryBlockThe block to copy to.
CopyTo(nint)
Copies the entire contents of this storage to given address.
public void CopyTo(nint ptr)
Parameters
ptrnint
CopyTo(void*)
Copies the entire contents of this storage to given address.
public void CopyTo(void* address)
Parameters
addressvoid*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
blockIMemoryBlock<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
addressT*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
arrayT[]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
arraySliceIArraySliceThe array slice to wrap.
shapeShapeThe 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
storageUnmanagedStorageThe source storage to take InternalArray from.
shapeShapeThe 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
axisint
GetAtIndex(long)
public object GetAtIndex(long index)
Parameters
indexlong
Returns
GetAtIndex<T>(long)
public T GetAtIndex<T>(long index) where T : unmanaged
Parameters
indexlong
Returns
- T
Type Parameters
T
GetBoolean(int[])
Retrieves value of type bool from internal storage.
public bool GetBoolean(int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetBoolean(params long[])
Retrieves value of type bool from internal storage.
public bool GetBoolean(params long[] indices)
Parameters
indiceslong[]The shape's indices to get (long version).
Returns
Exceptions
GetByte(int[])
Retrieves value of type byte from internal storage.
public byte GetByte(int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetByte(params long[])
Retrieves value of type byte from internal storage.
public byte GetByte(params long[] indices)
Parameters
indiceslong[]The shape's indices to get (long version).
Returns
Exceptions
GetChar(int[])
Retrieves value of type char from internal storage.
public char GetChar(int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetChar(params long[])
Retrieves value of type char from internal storage.
public char GetChar(params long[] indices)
Parameters
indiceslong[]The shape's indices to get (long version).
Returns
Exceptions
GetComplex(int[])
Retrieves value of type Complex from internal storage.
public Complex GetComplex(int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetComplex(params long[])
Retrieves value of type Complex from internal storage.
public Complex GetComplex(params long[] indices)
Parameters
indiceslong[]The shape's indices to get (long version).
Returns
Exceptions
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
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(int[])
Gets a sub-array based on the given indices, returning a view that shares memory.
public UnmanagedStorage GetData(int[] indices)
Parameters
indicesint[]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(long*, int)
Gets a sub-array based on the given indices (long pointer version), returning a view that shares memory.
public UnmanagedStorage GetData(long* dims, int ndims)
Parameters
dimslong*Pointer to an array of long dimension indices.
ndimsintThe number of indices in the array.
Returns
- UnmanagedStorage
A new UnmanagedStorage representing the sub-array.
GetData(params long[])
Gets a sub-array based on the given indices (long array version), returning a view that shares memory.
public UnmanagedStorage GetData(params long[] indices)
Parameters
indiceslong[]The dimension indices specifying the sub-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.
- 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
Tnew storage data type
Remarks
Copies if T does not equal to DType or if Shape is sliced.
GetDecimal(int[])
Retrieves value of type decimal from internal storage.
public decimal GetDecimal(int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetDecimal(params long[])
Retrieves value of type decimal from internal storage.
public decimal GetDecimal(params long[] indices)
Parameters
indiceslong[]The shape's indices to get (long version).
Returns
Exceptions
GetDouble(int[])
Retrieves value of type double from internal storage.
public double GetDouble(int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetDouble(params long[])
Retrieves value of type double from internal storage.
public double GetDouble(params long[] indices)
Parameters
indiceslong[]The shape's indices to get (long version).
Returns
Exceptions
GetHalf(int[])
Retrieves value of type Half from internal storage.
public Half GetHalf(int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetHalf(params long[])
Retrieves value of type Half from internal storage.
public Half GetHalf(params long[] indices)
Parameters
indiceslong[]The shape's indices to get (long version).
Returns
Exceptions
GetInt16(int[])
Retrieves value of type short from internal storage.
public short GetInt16(int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetInt16(params long[])
Retrieves value of type short from internal storage.
public short GetInt16(params long[] indices)
Parameters
indiceslong[]The shape's indices to get (long version).
Returns
Exceptions
GetInt32(int[])
Retrieves value of type int from internal storage.
public int GetInt32(int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetInt32(params long[])
Retrieves value of type int from internal storage.
public int GetInt32(params long[] indices)
Parameters
indiceslong[]The shape's indices to get (long version).
Returns
Exceptions
GetInt64(int[])
Retrieves value of type long from internal storage.
public long GetInt64(int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetInt64(params long[])
Retrieves value of type long from internal storage.
public long GetInt64(params long[] indices)
Parameters
indiceslong[]The shape's indices to get (long version).
Returns
Exceptions
GetSByte(int[])
Retrieves value of type sbyte from internal storage.
public sbyte GetSByte(int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetSByte(params long[])
Retrieves value of type sbyte from internal storage.
public sbyte GetSByte(params long[] indices)
Parameters
indiceslong[]The shape's indices to get (long version).
Returns
Exceptions
GetSingle(int[])
Retrieves value of type float from internal storage.
public float GetSingle(int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetSingle(params long[])
Retrieves value of type float from internal storage.
public float GetSingle(params long[] indices)
Parameters
indiceslong[]The shape's indices to get (long version).
Returns
Exceptions
GetUInt16(int[])
Retrieves value of type ushort from internal storage.
public ushort GetUInt16(int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetUInt16(params long[])
Retrieves value of type ushort from internal storage.
public ushort GetUInt16(params long[] indices)
Parameters
indiceslong[]The shape's indices to get (long version).
Returns
Exceptions
GetUInt32(int[])
Retrieves value of type uint from internal storage.
public uint GetUInt32(int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetUInt32(params long[])
Retrieves value of type uint from internal storage.
public uint GetUInt32(params long[] indices)
Parameters
indiceslong[]The shape's indices to get (long version).
Returns
Exceptions
GetUInt64(int[])
Retrieves value of type ulong from internal storage.
public ulong GetUInt64(int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetUInt64(params long[])
Retrieves value of type ulong from internal storage.
public ulong GetUInt64(params long[] indices)
Parameters
indiceslong[]The shape's indices to get (long version).
Returns
Exceptions
GetValue(int[])
Retrieves value of unspecified type (will figure using IStorage.DType).
public object GetValue(int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
- NullReferenceException
When IStorage.DType is not object
GetValue(params long[])
Retrieves value of unspecified type (will figure using IStorage.DType).
public object GetValue(params long[] indices)
Parameters
indiceslong[]The shape's indices to get (long array version).
Returns
GetValue<T>(int[])
Get single value from internal storage as type T and cast dtype to T
public T GetValue<T>(int[] indices) where T : unmanaged
Parameters
indicesint[]indices
Returns
- T
element from internal storage
Type Parameters
Tnew storage data type
Remarks
If you provide less indices than there are dimensions, the rest are filled with 0.
Exceptions
- NullReferenceException
When
Tdoes not equal to DType
GetValue<T>(params long[])
Get element from internal storage as T
public T GetValue<T>(params long[] indices) where T : unmanaged
Parameters
indiceslong[]indices
Returns
- T
element from internal storage
Type Parameters
Tnew storage data type
Remarks
If you provide less indices than there are dimensions, the rest are filled with 0.
Exceptions
- NullReferenceException
When
Tdoes not equal to DType
GetView(params Slice[])
public UnmanagedStorage GetView(params Slice[] slices)
Parameters
slicesSlice[]
Returns
GetView(string)
public UnmanagedStorage GetView(string slicing_notation)
Parameters
slicing_notationstring
Returns
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
valuesIArraySlice
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
valuesIArraySliceshapeShapeThe 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
valuesIArraySlicedtypeType
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
valuesIArraySlicedtypeTypeshapeShapeThe 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
ndNDArray
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
ndNDArrayshapeShapeThe 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
valuesArray
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
valuesArraytypeCodeNPTypeCode
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
valuesArraytypeCodeNPTypeCodeshapeShapeThe 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
valuesArrayshapeShapeThe 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
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
valuesArraydtypeTypeshapeShapeThe 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
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
Exceptions
- IncorrectShapeException
If shape's size mismatches current shape size.
- ArgumentException
If
newShape's size == 0
Reshape(params long[])
Changes the shape representing this storage.
public void Reshape(params long[] dimensions)
Parameters
dimensionslong[]
Exceptions
- IncorrectShapeException
If shape's size mismatches current shape size.
Reshape(long[], bool)
Changes the shape representing this storage.
public void Reshape(long[] dimensions, bool @unsafe)
Parameters
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
valueobject
Returns
Scalar(object, NPTypeCode)
public static UnmanagedStorage Scalar(object value, NPTypeCode typeCode)
Parameters
valueobjecttypeCodeNPTypeCode
Returns
Scalar<T>(T)
public static UnmanagedStorage Scalar<T>(T value) where T : unmanaged
Parameters
valueT
Returns
Type Parameters
T
SetAtIndex(object, long)
public void SetAtIndex(object value, long index)
Parameters
SetAtIndexUnsafe(object, long)
Performs a set of index without calling TransformOffset(long).
public void SetAtIndexUnsafe(object value, long index)
Parameters
SetAtIndexUnsafe<T>(T, long)
Performs a set of index without calling TransformOffset(long).
public void SetAtIndexUnsafe<T>(T value, long index) where T : unmanaged
Parameters
valueTindexlong
Type Parameters
T
SetAtIndex<T>(T, long)
public void SetAtIndex<T>(T value, long index) where T : unmanaged
Parameters
valueTindexlong
Type Parameters
T
SetBoolean(bool, int[])
Sets a bool at specific coordinates.
public void SetBoolean(bool value, int[] indices)
Parameters
SetBoolean(bool, params long[])
Sets a bool at specific coordinates.
public void SetBoolean(bool value, params long[] indices)
Parameters
SetByte(byte, int[])
Sets a byte at specific coordinates.
public void SetByte(byte value, int[] indices)
Parameters
SetByte(byte, params long[])
Sets a byte at specific coordinates.
public void SetByte(byte value, params long[] indices)
Parameters
SetChar(char, int[])
Sets a char at specific coordinates.
public void SetChar(char value, int[] indices)
Parameters
SetChar(char, params long[])
Sets a char at specific coordinates.
public void SetChar(char value, params long[] indices)
Parameters
SetComplex(Complex, int[])
Sets a Complex at specific coordinates.
public void SetComplex(Complex value, int[] indices)
Parameters
SetComplex(Complex, params long[])
Sets a Complex at specific coordinates.
public void SetComplex(Complex value, params long[] indices)
Parameters
SetData(IArraySlice, int[])
Set a IArraySlice at given indices.
public void SetData(IArraySlice value, int[] indices)
Parameters
valueIArraySliceThe value to set
indicesint[]The
Remarks
Does not change internal storage data type.
If value does not match DType, value will be converted.
SetData(IArraySlice, params long[])
Set a IArraySlice at given indices (long version).
public void SetData(IArraySlice value, params long[] indices)
Parameters
valueIArraySliceindiceslong[]
SetData(NDArray, int[])
Set a NDArray at given indices.
public void SetData(NDArray value, int[] indices)
Parameters
Remarks
Does not change internal storage data type.
If value does not match DType, value will be converted.
SetData(NDArray, params long[])
Set a NDArray at given indices (long version).
public void SetData(NDArray value, params long[] indices)
Parameters
SetData(object, int[])
Set a single value at given indices.
public void SetData(object value, int[] indices)
Parameters
Remarks
Does not change internal storage data type.
If value does not match DType, value will be converted.
SetData(object, params long[])
Set a value at given indices (long version).
public void SetData(object value, params long[] indices)
Parameters
SetDecimal(decimal, int[])
Sets a decimal at specific coordinates.
public void SetDecimal(decimal value, int[] indices)
Parameters
SetDecimal(decimal, params long[])
Sets a decimal at specific coordinates.
public void SetDecimal(decimal value, params long[] indices)
Parameters
SetDouble(double, int[])
Sets a double at specific coordinates.
public void SetDouble(double value, int[] indices)
Parameters
SetDouble(double, params long[])
Sets a double at specific coordinates.
public void SetDouble(double value, params long[] indices)
Parameters
SetHalf(Half, int[])
Sets a Half at specific coordinates.
public void SetHalf(Half value, int[] indices)
Parameters
SetHalf(Half, params long[])
Sets a Half at specific coordinates.
public void SetHalf(Half value, params long[] indices)
Parameters
SetInt16(short, int[])
Sets a short at specific coordinates.
public void SetInt16(short value, int[] indices)
Parameters
SetInt16(short, params long[])
Sets a short at specific coordinates.
public void SetInt16(short value, params long[] indices)
Parameters
SetInt32(int, int[])
Sets a int at specific coordinates.
public void SetInt32(int value, int[] indices)
Parameters
SetInt32(int, params long[])
Sets a int at specific coordinates.
public void SetInt32(int value, params long[] indices)
Parameters
SetInt64(long, int[])
Sets a long at specific coordinates.
public void SetInt64(long value, int[] indices)
Parameters
SetInt64(long, params long[])
Sets a long at specific coordinates.
public void SetInt64(long value, params long[] indices)
Parameters
SetInternalArray(IArraySlice)
Replace internal storage array with given array.
protected void SetInternalArray(IArraySlice array)
Parameters
arrayIArraySliceThe array to set as internal storage
Exceptions
- InvalidCastException
When type of
arraydoes not match DType of this storage
SetInternalArray(Array)
Replace internal storage array with given array.
protected void SetInternalArray(Array array)
Parameters
arrayArrayThe array to set as internal storage
Exceptions
- InvalidCastException
When type of
arraydoes not match DType of this storage
SetSByte(sbyte, int[])
Sets a sbyte at specific coordinates.
public void SetSByte(sbyte value, int[] indices)
Parameters
SetSByte(sbyte, params long[])
Sets a sbyte at specific coordinates.
public void SetSByte(sbyte value, params long[] indices)
Parameters
SetShapeUnsafe(Shape)
Set the shape of this storage without checking if sizes match.
protected void SetShapeUnsafe(Shape shape)
Parameters
shapeShape
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
shapeShape
Remarks
Used during broadcasting. Uses bufferSize (not size) because broadcast shapes have logical size != physical buffer size.
SetSingle(float, int[])
Sets a float at specific coordinates.
public void SetSingle(float value, int[] indices)
Parameters
SetSingle(float, params long[])
Sets a float at specific coordinates.
public void SetSingle(float value, params long[] indices)
Parameters
SetUInt16(ushort, int[])
Sets a ushort at specific coordinates.
public void SetUInt16(ushort value, int[] indices)
Parameters
SetUInt16(ushort, params long[])
Sets a ushort at specific coordinates.
public void SetUInt16(ushort value, params long[] indices)
Parameters
SetUInt32(uint, int[])
Sets a uint at specific coordinates.
public void SetUInt32(uint value, int[] indices)
Parameters
SetUInt32(uint, params long[])
Sets a uint at specific coordinates.
public void SetUInt32(uint value, params long[] indices)
Parameters
SetUInt64(ulong, int[])
Sets a ulong at specific coordinates.
public void SetUInt64(ulong value, int[] indices)
Parameters
SetUInt64(ulong, params long[])
Sets a ulong at specific coordinates.
public void SetUInt64(ulong value, params long[] indices)
Parameters
SetValue(object, int[])
Set a single value at given indices.
public void SetValue(object value, int[] indices)
Parameters
Remarks
Does not change internal storage data type.
If value does not match DType, value will be converted.
SetValue(object, params long[])
Set a single value at given indices.
public void SetValue(object value, params long[] indices)
Parameters
Remarks
Does not change internal storage data type.
If value does not match DType, value will be converted.
SetValue<T>(T, int[])
Set a single value at given indices.
public void SetValue<T>(T value, int[] indices) where T : unmanaged
Parameters
valueTThe value to set
indicesint[]The
Type Parameters
T
Remarks
Does not change internal storage data type.
If value does not match DType, value will be converted.
SetValue<T>(T, params long[])
Set a single value at given indices.
public void SetValue<T>(T value, params long[] indices) where T : unmanaged
Parameters
valueTThe value to set
indiceslong[]The coordinates (long version).
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
shapeShapevaluesIArraySlice
_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
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
sourceArrayIArraySliceThe 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.