unshuffle method
Makes 2 arrays "resultArray" (of half length) from array
:
resultArray0
consists of the even indices of array
.
resultArray1
consists of the even indices of array
.
Application: array
represents a sequence complex numbers:
real, imag, real, imag, ....
. Then:
resultArray0
is the real part: real, real, ...
,
resultArray1
is the imaginary part: imag, imag, ...
.
See also method shuffle.
Implementation
static List<Float64List> unshuffle(Float64List array) {
if (array.length % 2 != 0)
throw "unshuffle: Data length=${array.length} must be even!";
Float64List real = new Float64List(array.length ~/ 2);
Float64List imag = new Float64List(array.length ~/ 2);
int i = 0, ir = 0, ii = 0;
while (true) {
if (i > array.length - 1) break; // end reached
real[ir] = array[i];
i++;
ir++;
if (i > array.length - 1) break; // end reached
imag[ii] = array[i];
i++;
ii++;
}
return [real, imag];
}