ILNumerics Ultimate VS

ConcreteArrayT1, LocalT, InT, OutT, RetT, StorageTGetHostPointerForRead Method

ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development
[Expert API - UNSAFE!] Acquire a read pointer to the memory storing the first element of this array.

[ILNumerics Core Module]

Namespace:  ILNumerics.Core.Arrays
Assembly:  ILNumerics.Core (in ILNumerics.Core.dll) Version: 5.5.0.0 (5.5.7503.3146)
Syntax

public virtual IntPtr GetHostPointerForRead(
	Nullable<StorageOrders> order = null
)

Parameters

order (Optional)
Type: SystemNullableStorageOrders
[Optional] Ensures that the array is in a specific storage layout before acquiring the pointer. Default: (null) don't change the storage layout.

Return Value

Type: IntPtr
Pointer to the first element of this array.
Exceptions

ExceptionCondition
InvalidOperationException if called on a return type array or if the elements are not of a ValueType.
Remarks

This function returns a pointer to the first element stored in this array. Any base offset configured for the array is taken into account. The pointer points to the memory used by this array directly - not to a copy of this memory!

Do not use this pointer for modifying the value of an element of this array! This pointer is for read purposes only!

For empty arrays A (where A.IsEmpty is true) the value of the pointer returned is undefined.

This pointer is valid only as long as this array is not modified or released! Do not attempt to use this pointer after the array has been released, ran out of the current scope (meaning the current function scope as well as Enter(BaseArray, NullableArrayStyles)), or is modified!

The order of elements in this array is determined by the size descriptor Size. Use the strides, dimension lengths and the size of the T1 elements (SizeOfT) in order to compute the byte offset to individual elements relative to this pointer.

The memory region addressed by the pointer returned exists on the unmanaged heap. Hence, it does not need to be pinned and will not be moved by the GC. However, this memory is subject of deterministic disposal, pooling and frequent reuse by other arrays. Do not use the pointer returned after this array left the current function scope, was modified, reassigned or released!

When order is not null the storage order of the array is modified according to order. Valid values for order are RowMajor, ColumnMajor, and null. The order parameter can be convenient in order to access elements of non-continous array layouts. Instead of computing the address of individual elements (GetSeqIndex(Int64, Int64, Int64, Int64), or GetStride(UInt32)) the array can be brought into a continous storage layout before acquiring the pointer. Afterwards, elements can be accessed sequentially in memory, with unity strides. The price is the rearranging of the whole storage which commonly requires a copy of all elements.

[ILNumerics Core Module]

See Also

Reference