Sinc1D constructor
Computes the "sine cardinal" = "sinc" function
f(x) = offset + amplitudesin(x+phase)/(x+phase)
The resulting array of size npoints
will contain "nperiods
" (2pi)
of the damped sinc wave with the specified amplitude
and phase
.
Implementation
Sinc1D(int npoints, double amplitude, double phase,
int nperiods, double offset) {
double xmax = 2 * math.pi * nperiods;
_xvals = Float64List(npoints);
_sinc = Float64List(npoints);
double x, y, a;
a = amplitude;
for (int i = 0; i < npoints; i++) {
x = (i * xmax) / npoints;
if (i == 0 && phase.abs() < 0.00001) {
y = a;
} else {
double ph = x + phase;
y = a * math.sin(ph) / ph;
}
_xvals[i] = x;
_sinc[i] = y + offset;
}
}