public void rdft(int n, int isgn, double[] a, int[] ip, double[] w) {
        int nw, nc;
        double xi;

        nw = ip[0];
        if (n > (nw << 2)) {
            nw = n >> 2;
            makewt(nw, ip, w);
        }
        nc = ip[1];
        if (n > (nc << 2)) {
            nc = n >> 2;
            makect(nc, ip, w, nw);
        }
        if (isgn >= 0) {
            if (n > 4) {
                cftfsub(n, a, ip, 2, nw, w);
                rftfsub(n, a, nc, w, nw);
            } else if (n == 4) {
                cftfsub(n, a, ip, 2, nw, w);
            }
            xi = a[0] - a[1];
            a[0] += a[1];
            a[1] = xi;
        } else {
            a[1] = 0.5 * (a[0] - a[1]);
            a[0] -= a[1];
            if (n > 4) {
                rftbsub(n, a, nc, w, nw);
                cftbsub(n, a, ip, 2, nw, w);
            } else if (n == 4) {
                cftbsub(n, a, ip, 2, nw, w);
            }
        }
    }