[ILNumerics Computing Engine]
Namespace: ILNumerics
Assembly: ILNumerics.Computing (in ILNumerics.Computing.dll) Version: 5.5.0.0 (5.5.7503.3146)
public static RetArray<Tout> apply<Tin1, Tin2, Tout>( BaseArray<Tin1> A, BaseArray<Tin2> B, Func<Tin1, Tin2, long, Tout> func )
Parameters
- A
- Type: ILNumericsBaseArrayTin1
The one array. - B
- Type: ILNumericsBaseArrayTin2
The other array. - func
- Type: SystemFuncTin1, Tin2, Int64, Tout
The elementary (scalar) function to be used to perform the operation on corresponding elements of A and B, utilizing respective element values and the index used to locate the output array in iteration order.
Type Parameters
- Tin1
- Tin2
- Tout
Return Value
Type: RetArrayToutNew or reused array with result of operating elements of A and B elementwise.
The iteration order depends on the order of input arrays: for column major input i will run in column major order and in row major order for row major inputs. If inputs have other, undefined or different storage orders the result is undefined. It is recommended to use this function on vector input(s) or with a well defined storage order for inputs A and/or B.
This function may automatically work inplace on either of both input parameters, if possible.
[ILNumerics Computing Engine]
'Merge' elements a of an vector of 0's with a scalar -1, weighting with the location index i by applying the function: c = a + i * b.
Array<int> C = apply(zeros<int>(10,1), vector(-1), (a, b, i) => (int)(a + i * b)); C <Int32> [10,1] 0...-9 | [0]: 0 [1]: -1 [2]: -2 [3]: -3 [4]: -4 [5]: -5 [6]: -6 [7]: -7 [8]: -8 [9]: -9
Efficiently overwrite/initialize the content of an uninitialized array with upwards counting values, row major storage order.
Array<double> D = apply(empty<double>(4, 3, 2, StorageOrders.RowMajor), zeros(1), (a, b, i) => (double)i); D <Double> [4,3,2] 0...23 - [0]: (:,:,0) [1]: 0 2 4 [2]: 6 8 10 [3]: 12 14 16 [4]: 18 20 22 [5]: (:,:,1) [6]: 1 3 5 [7]: 7 9 11 [8]: 13 15 17 [9]: 19 21 23
The last example produces the same result as the expression: counter(4,3,2, StorageOrders.RowMajor);. The larger flexibility in the generator function func comes with a slight computational overhead, though.