bcOffset method
Subtracts a number from array
which is the mean value of the array
region defined by bcstart
and bcsize
.
If complex
is true, array
is considered as a sequence of real, imag
pairs.
In this case bcsize
must be even and is considered as the number of real points
and the number of imaginary points for which the mean value is computed.
Implementation
static void bcOffset(
Float64List array, bool isComplex, int bcstart, int bcsize) {
double meanReal = 0.0, meanImag = 0.0;
if (isComplex) {
for (int i = bcstart; i < bcstart + bcsize - 1; i += 2) {
meanReal += array[i];
meanImag += array[i + 1];
}
meanReal /= bcsize / 2;
meanImag /= bcsize / 2;
for (int i = 0; i < array.length - 1; i += 2) {
if (meanReal.abs() > 1.0e-10) {
array[i] -= meanReal;
}
if (meanImag.abs() > 1.0e-10) {
array[i + 1] -= meanImag;
}
}
} else {
for (int i = bcstart; i < bcstart + bcsize; i++) {
meanReal += array[i];
}
meanReal /= bcsize;
for (int i = 0; i < array.length; i++) {
if (meanReal.abs() > 1.0e-10) {
array[i] -= meanReal;
}
}
}
}