package jeranvier.math.dsp;

import jeranvier.math.linearAlgebra.Vector;
import jeranvier.math.util.Complex;

public class Fourier {
	
	public static Vector dft(Vector in) {
		Vector.Builder outBuilder = new Vector.Builder(in.size());
		int size = in.size();
	    for (int o = 1; o <= in.size(); o++) {
	    	Complex sum = new Complex();
	        for (int i = 1; i <= in.size(); i++) {
	            double angle = 2 * Math.PI * i * o / size;
	            Complex multiple = new Complex(Math.cos(angle), Math.sin(angle));
	            sum = sum.add(in.get(i).multiplyBy(multiple));

	        }
	        outBuilder.set(o, sum);
        }
	    return outBuilder.build();
	}

}

@@ -496,16 +496,19 @@
 angle), 
+-1*
 Math.sin
@@ -666,12 +666,565 @@
 ld();%0A%09%7D
+%0A%09%0A%09public static Vector ift(Vector in) %7B%0A%09%09Vector.Builder outBuilder = new Vector.Builder(in.size());%0A%09%09int size = in.size();%0A%09    for (int o = 1; o %3C= in.size(); o++) %7B%0A%09    %09Complex sum = new Complex();%0A%09        for (int i = 1; i %3C= in.size(); i++) %7B%0A%09            double angle = 2 * Math.PI * i * o / size;%0A%09            Complex multiple = new Complex(Math.cos(angle), Math.sin(angle));%0A%09            sum = sum.add(in.get(i).multiplyBy(multiple));%0A%0A%09        %7D%0A%09        outBuilder.set(o, sum.divideBy(size));%0A        %7D%0A%09    return outBuilder.build();%0A%09%7D
 %0A%0A%7D%0A

add inverse fourier transform