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 int 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
_arrayDecimal
protected ArraySlice<decimal> _arrayDecimal
Field Value
_arrayDouble
protected ArraySlice<double> _arrayDouble
Field Value
_arrayInt16
protected ArraySlice<short> _arrayInt16
Field Value
_arrayInt32
protected ArraySlice<int> _arrayInt32
Field Value
_arrayInt64
protected ArraySlice<long> _arrayInt64
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
- 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
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>()
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
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(int)
public ValueType GetAtIndex(int index)
Parameters
indexint
Returns
GetAtIndex<T>(int)
public T GetAtIndex<T>(int index) where T : unmanaged
Parameters
indexint
Returns
- T
Type Parameters
T
GetBoolean(params int[])
Retrieves value of type bool from internal storage.
public bool GetBoolean(params int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetByte(params int[])
Retrieves value of type byte from internal storage.
public byte GetByte(params int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetChar(params int[])
Retrieves value of type char from internal storage.
public char GetChar(params int[] indices)
Parameters
indicesint[]The shape's indices to get.
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(params int[])
Gets a sub-array based on the given indices, returning a view that shares memory.
public UnmanagedStorage GetData(params 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<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(params int[])
Retrieves value of type decimal from internal storage.
public decimal GetDecimal(params int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetDouble(params int[])
Retrieves value of type double from internal storage.
public double GetDouble(params int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetInt16(params int[])
Retrieves value of type short from internal storage.
public short GetInt16(params int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetInt32(params int[])
Retrieves value of type int from internal storage.
public int GetInt32(params int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetInt64(params int[])
Retrieves value of type long from internal storage.
public long GetInt64(params int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetSingle(params int[])
Retrieves value of type float from internal storage.
public float GetSingle(params int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetUInt16(params int[])
Retrieves value of type ushort from internal storage.
public ushort GetUInt16(params int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetUInt32(params int[])
Retrieves value of type uint from internal storage.
public uint GetUInt32(params int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetUInt64(params int[])
Retrieves value of type ulong from internal storage.
public ulong GetUInt64(params int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
Exceptions
GetValue(params int[])
Retrieves value of unspecified type (will figure using IStorage.DType).
public ValueType GetValue(params int[] indices)
Parameters
indicesint[]The shape's indices to get.
Returns
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
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
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 int[])
Changes the shape representing this storage.
public void Reshape(params int[] dimensions)
Parameters
dimensionsint[]
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
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, int)
public void SetAtIndex(object value, int index)
Parameters
SetAtIndexUnsafe(ValueType, int)
Performs a set of index without calling TransformOffset(int).
public void SetAtIndexUnsafe(ValueType value, int index)
Parameters
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
valueTindexint
Type Parameters
T
SetAtIndex<T>(T, int)
public void SetAtIndex<T>(T value, int index) where T : unmanaged
Parameters
valueTindexint
Type Parameters
T
SetBoolean(bool, params int[])
Sets a bool at specific coordinates.
public void SetBoolean(bool value, params int[] indices)
Parameters
SetByte(byte, params int[])
Sets a byte at specific coordinates.
public void SetByte(byte value, params int[] indices)
Parameters
SetChar(char, params int[])
Sets a char at specific coordinates.
public void SetChar(char value, params int[] indices)
Parameters
SetData(IArraySlice, params int[])
Set a IArraySlice at given indices.
public void SetData(IArraySlice value, params 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(NDArray, params int[])
Set a NDArray at given indices.
public void SetData(NDArray value, params int[] indices)
Parameters
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
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
SetDouble(double, params int[])
Sets a double at specific coordinates.
public void SetDouble(double value, params int[] indices)
Parameters
SetInt16(short, params int[])
Sets a short at specific coordinates.
public void SetInt16(short value, params int[] indices)
Parameters
SetInt32(int, params int[])
Sets a int at specific coordinates.
public void SetInt32(int value, params int[] indices)
Parameters
SetInt64(long, params int[])
Sets a long at specific coordinates.
public void SetInt64(long value, params int[] 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
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
SetSingle(float, params int[])
Sets a float at specific coordinates.
public void SetSingle(float value, params int[] indices)
Parameters
SetUInt16(ushort, params int[])
Sets a ushort at specific coordinates.
public void SetUInt16(ushort value, params int[] indices)
Parameters
SetUInt32(uint, params int[])
Sets a uint at specific coordinates.
public void SetUInt32(uint value, params int[] indices)
Parameters
SetUInt64(ulong, params int[])
Sets a ulong at specific coordinates.
public void SetUInt64(ulong value, params int[] indices)
Parameters
SetValue(object, params int[])
Set a single value at given indices.
public void SetValue(object value, params int[] indices)
Parameters
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
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.
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.