Any SPL function can automatically iterate through each column of an input array, one by one, by specifying the ITERATE modifier.

Consider two similar SPL routines:

scale1(x)

{

y = x / min(x);

** return**(y);

}

ITERATE scale2(x)

{

y = x / min(x);

** return**(y);

}

A = {{1, 2, 3},

{2, 4, 6},

{3, 6, 9}};

y1 = scale1(A);

y2 = scale2(A);

y1 == {{1, 2, 3},

{2, 4, 6},

{3, 6, 9}}

y2 == {{1, 1, 1},

{2, 2, 2},

{3, 3, 3}}

scale1 is defined as a standard SPL function and receives the entire array A as input. Consequently, the minimum is calculated as the minimum of the entire array, in this case 1.0.

Because scale2 is declared as an ITERATE function, it automatically iterates through each column of the input array one at a time. Since each iteration only receives a single column of the original input, the minimum is calculated as the minimum of the current column. Thus, scale1 behaves as:

A / min(A)

but scale2 behaves as:

A / colmin(A)

The ITERATE keyword makes it very easy to write a routine to handle each column of an array in the same manner without having to get bogged down in the details of multi-column operations. Simply write the function as if it will only receive a single column input and DADiSP will automatically apply the function to each column of the input array and accumulate the results.

The iteration behavior of an SPL function can be temporarily set or cleared at run time with the iterate function. For example:

iterate("scale1", 1)

or

iterate scale1

converts scale1 to an iterator function such that it operates identically to scale2. This behavior persists only for the duration of the current session. Use the ITERATE modifier in the function definition to make the behavior permanent.