Addressing elements by sequential indices

More than one element can be addressed simulteanoulsy inside an ILArray. This is done by providing exactly one numeric array holding the indices of the elements as values to one of the following functions:

  • ILArrays member function SetRange(params ILArray<[numeric]> indices,ILArray<BaseT> values),
  • the indexer this[params ILBaseArray[] indices] = values
  • the indexer this[params string[] indices] = values
The new values for the elements addressed are given in a second array values. The size of both - the index array and the value array must match.

The values of indices must be interpretable as integer values. They reflect the position of the elements in the array after walking the array column after column.

ILArray<double> A = ILMath.rand(4,3);
ILArray<int> ind = new int[]{ 2, 5, 7, 11 };

// A is now: 
//(:,:) 
//  0,88948   0,99717   0,52597 
//  0,31577   0,05963   0,39585 
//  0,34534   0,00640   0,82419 
//  0,09452   0,44099   0,68355 

// now set the 3rd, 6th, 8th and the 12th element to 20,21,22,23 respectivly
A[ind] = values; 
// - or - 
A["3,6,8,12"] = values; 
// - or - 
A.SetRange(ind,values); 
// A is now: 
//(:,:) 1e+001 * 
//  0,08895   0,09972   0,05260 
//  0,03158   2,10000   0,03958 
//  2,00000   0,00064   0,08242 
//  0,00945   2,20000   2,30000  

For sequential index access the array elements can be imagined as lined up one after another - starting with the first column and walking along all the other columns until the last element has passed. The sequential index of a specific element then is the position of the element on the line.

The shape of the index array ind is not specified. Most the time it will be expected to be a vector - but might as well be a n-dimensional array of arbitrary shape.

Valid CSS! Valid XHTML 1.0 Transitional