/*
 * Decompiled with CFR 0_132.
 */
package DFT;

import DFT.Complex;
import DFT.Point;
import java.util.Vector;

public class Dft {
    private int N = 0;
    private Vector data = null;

    public Dft(Vector d) {
        int len;
        if (d != null && (len = d.size()) > 0) {
            Point p = (Point)d.elementAt(0);
            this.N = len;
            this.data = d;
        }
    }

    public Complex dftPoint(int m) {
        double twoPi = 6.283185307179586;
        Complex cx = new Complex(0.0f, 0.0f);
        if (m >= 0 && m < this.N) {
            double R = 0.0;
            double I = 0.0;
            if (m == 0) {
                int n = 0;
                while (n < this.N) {
                    Point p = (Point)this.data.elementAt(n);
                    R += (double)p.y;
                    ++n;
                }
            } else {
                int n = 0;
                while (n < this.N) {
                    Point p = (Point)this.data.elementAt(n);
                    double x = p.y;
                    double scale = 6.283185307179586 * (double)n * (double)m / (double)this.N;
                    R += x * Math.cos(scale);
                    I -= x * Math.sin(scale);
                    ++n;
                }
            }
            cx.real((float)R);
            cx.imag((float)I);
        }
        return cx;
    }
}

