[ILNumerics Computing Engine]
Namespace: ILNumerics
Assembly: ILNumerics.Computing (in ILNumerics.Computing.dll) Version: 5.5.0.0 (5.5.7503.3146)
public static RetArray<T> counter<T>( T start, T step, long dim0, long dim1, long dim2, long dim3, long dim4, StorageOrders order = StorageOrders.ColumnMajor ) where T : struct, new(), IEquatable<T>, IConvertible
Parameters
- start
- Type: T
The start value for the new elements. - step
- Type: T
The step size value for the new elements. - dim0
- Type: SystemInt64
Length of dimension #0. - dim1
- Type: SystemInt64
Length of dimension #1. - dim2
- Type: SystemInt64
Length of dimension #2. - dim3
- Type: SystemInt64
Length of dimension #3. - dim4
- Type: SystemInt64
Length of dimension #4. - order (Optional)
- Type: ILNumericsStorageOrders
[Optional] The storage order for the new array. Default: ColumnMajor.
Type Parameters
- T
- Element type.
Return Value
Type: RetArrayTNew ILNumerics array initialized with linearly spaced elements according to start and counting up/downwards by step along the storage order.
The counter``1(UMP, UMP, InArrayInt64, StorageOrders) function and the corresponding overloads for providing individual dimension length parameters counter``1(UMP, UMP, Int64, StorageOrders),... create n-dimensional numeric arrays with automatically generated values based on a given start value and a step value. The size of the new array is determined by the 'size' parameter(s). The firsts element value is assigned the start value. Subsequent values are computed by adding the value of step to each elements predecessor.
The term 'predecessor' here means: the predecessor E0 of element E1 is the element having an index I(E0) of I(E1) - 1, where the index I() corresponds to the storage location of the element in memory, relative to the first element.
The storage order is determined by order. By default, elements are lined up in memory in column major storage order. order must be one out of ColumnMajor or RowMajor. Note, how the storage order affects the order of values in the new array.
[ILNumerics Computing Engine]
Creating a new array of size [4,3], filled with upwards counting values, starting at 1.
Array<double> A = counter<double>(1, 1, 4, 3); //<Double> [4,3] 1...12 | // [0]: 1 5 9 // [1]: 2 6 10 // [2]: 3 7 11 // [3]: 4 8 12
Creating a new array of size [4,3,2] of ushort values:
counter<sbyte>(10, -10, 4,3,2) //<SByte> [4,3] 1...12 | // [0]: (:,:,0) // [1]: 10 -30 -70 // [2]: 0 -40 -80 // [3]: -10 -50 -90 // [4]: -20 -60 -100 // [5]: (:,:,1) // [6]: -110 106 66 // [7]: -120 96 56 // [8]: 126 86 46 // [9]: 116 76 36
Note, how the computed values of data type 'sbyte' wrap around at the limits of 'sbyte' without notice!
Creating a new array of size [4,3] with upwards counting values in row major order:
counter<float>(1, 1, 4,3, StorageOrders.RowMajor) //<Single> [4,3] 1...12 - // [0]: 1 2 3 // [1]: 4 5 6 // [2]: 7 8 9 // [3]: 10 11 12