Altering single elements
Single elements are altered by using eitherILArrays member functionSetValue(BaseT value, params int[] dimensions)- or- the indexer
this[params int[] dimensions] = value.
ILArray<double> A = ILMath.rand(4,3);
// A is now:
//(:,:)
// 0,13760 0,04765 0,32318
// 0,87603 0,24729 0,94904
// 0,32142 0,79835 0,63228
// 0,21493 0,80214 0,30360
//Set the second element in the second column to 10.0
A[1,1] = 10.0;
// - or -
A.SetValue(10.0,1,1)
// A is now:
// (:,:) 1e+001 *
// 0,01376 0,00476 0,03232
// 0,08760 1,00000 0,09490
// 0,03214 0,07983 0,06323
// 0,02149 0,08021 0,03036
In the example above a single element has been altered. Depending on the number of dimension in the array the dimension specifier may adress arbitrary dimensions. Missing trailing dimensions will default to the first element in corresponding dimensions.
The new value for the element addressed must be of the same type as all other elements in the array. Alternatively an implicit cast operator must exist which can transform the value given into the type needed.