ILNumerics Ultimate VS

ILMathsub2indT, LocalT, InT, OutT, RetT, StorageT Method (ConcreteArrayT, LocalT, InT, OutT, RetT, StorageT, InArrayInt64)

ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development
Computes sequential (linear) indices from dimensional indices.

[ILNumerics Computing Engine]

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

public static RetArray<long> sub2ind<T, LocalT, InT, OutT, RetT, StorageT>(
	ConcreteArray<T, LocalT, InT, OutT, RetT, StorageT> A,
	InArray<long> indices
)
where LocalT : Mutable<T, LocalT, InT, OutT, RetT, StorageT>
where InT : Immutable<T, LocalT, InT, OutT, RetT, StorageT>
where OutT : Mutable<T, LocalT, InT, OutT, RetT, StorageT>
where RetT : ConcreteRetArray<T, LocalT, InT, OutT, RetT, StorageT>
where StorageT : new(), BaseStorage<T, LocalT, InT, OutT, RetT, StorageT>

Parameters

A
Type: ILNumerics.Core.ArraysConcreteArrayT, LocalT, InT, OutT, RetT, StorageT
The input array providing the size, strides and element type to compute the sequential indices for.
indices
Type: ILNumericsInArrayInt64
Dimensional index tuples into A as m elements of n rows. Matrix [m, n].

Type Parameters

T
LocalT
InT
OutT
RetT
StorageT

Return Value

Type: RetArrayInt64
Vector [m] with sequential element indices into A according to the subscript indices (rows) from indices.
Exceptions

ExceptionCondition
ArgumentExceptionif A has less than 1 dimension.
ArgumentNullException if A or indices are null.
Remarks

This function converts subscript indices into sequential element indices. Subscript indices specify the position of an element in A by giving the position of the element in each dimension individually. Hence, n subscript indices are required to describe a single element position in A. In contrast to that, sequential indices specify the position of an element in A by a single sequential index, where all elements are considered to be 'lined-up'. The sequential index is than simply the index of the element in the line.

The (virtual) lining-up of the elements in A is performed in column major order. Note, that the order considered by ind2sub``6(ConcreteArrayUMP, UMP, UMP, UMP, UMP, UMP, InArrayInt64, Int32) and by sub2ind``6(ConcreteArrayUMP, UMP, UMP, UMP, UMP, UMP, InArrayInt64) is not related to the actual order of the elements as they are stored in memory.

If indices has fewer columns as dimensions exist in A indices into unspecified dimensions are considered 0. The last column of indices may contains values as indices into the merged trailing dimensions of A.

The vector returned gives the sequential index for each element specified as a row in indices. A sequential index corresponds to the 0-based index of the element after lining-up all elements of A, starting at element 0 and walking along the array in column major order.

indices can contain values addressing non-existing elements in A (indices out-of-range). These indices will produce invalid sequential indices and do not produce an error. Also, no error is generated for negative values in indices! The special meaning of latter (i.e.: counting from the end) is not considered here.

sub2ind``6(ConcreteArrayUMP, UMP, UMP, UMP, UMP, UMP, InArrayInt64) and ind2sub``6(ConcreteArrayUMP, UMP, UMP, UMP, UMP, UMP, InArrayInt64, Int32) are equivalent operations, inverting the results of the respective other function. Combining both functions creates a roundtrip and gives the original data.

[ILNumerics Computing Engine]

See Also

Reference