double linear(dofft_closure *k, int realp, int n, C *inA, C *inB, C *inC, C *outA, C *outB, C *outC, C *tmp, int rounds, double tol) { int j; double e = 0.0; for (j = 0; j < rounds; ++j) { C alpha, beta; c_re(alpha) = mydrand(); c_im(alpha) = realp ? 0.0 : mydrand(); c_re(beta) = mydrand(); c_im(beta) = realp ? 0.0 : mydrand(); arand(inA, n); arand(inB, n); k->apply(k, inA, outA); k->apply(k, inB, outB); ascale(outA, alpha, n); ascale(outB, beta, n); aadd(tmp, outA, outB, n); ascale(inA, alpha, n); ascale(inB, beta, n); aadd(inC, inA, inB, n); k->apply(k, inC, outC); e = dmax(e, acmp(outC, tmp, n, "linear", tol)); } return e; }
int symbol(double x, double y, char *text, double h, double s, double th) { plot(x, y, 3); ascale(_plnorm(h)); aspace(_plnorm(s)); arotate(_plnorm(th)); print(text); return (0); }
static double verify_linear(fftd_func *dft, int N, COMPLEX *inA, COMPLEX *inB, COMPLEX *inC, COMPLEX *outA, COMPLEX *outB, COMPLEX *outC, COMPLEX *tmp, int rounds) { int i; double maxerr = 0.0; double e; /* test 1: check linearity */ for (i = 0; i < rounds; ++i) { COMPLEX alpha, beta; RE(alpha) = double_rand(); IM(alpha) = double_rand(); RE(beta) = double_rand(); IM(beta) = double_rand(); fill_random(inA, N); fill_random(inB, N); dft((double *)outA, (double *)inA); dft((double *)outB, (double *)inB); ascale(outA, alpha, N); ascale(outB, beta, N); aadd(tmp, outA, outB, N); ascale(inA, alpha, N); ascale(inB, beta, N); aadd(inC, inA, inB, N); dft((double *)outC, (double *)inC); e = acmp(outC, tmp, N); if(e > maxerr) maxerr = e; } return maxerr; }
int mark(int mrk, double ax[], double ay[], int n, double f, int m) { int i; if (mrk < 0 || mrk > 15) return (1); m = (n < 0) ? m : 1; if ((n = abs(n)) < 1 || m < 0) return (1); ascale(_plnorm(f * 1.75)); arotate(0); for (i = 0; i < n; i += m) { plot(ax[i], ay[i], 3); _mark(mrk); } return (0); }