public static Complex QuoteOf(Complex X, Complex Y) { double e = Math.pow(Y.real, 2) + Math.pow(Y.imag, 2); Complex Z = new Complex(); Z.setReal((X.real * Y.real + X.imag * Y.imag) / e); Z.setImag((X.imag * Y.real - X.real * Y.imag) / e); return Z; }
public Abs toAbs(String real, String immaginary) { Abs abs = new Abs(); Complex complex = new Complex(); complex.setImmaginary(Float.parseFloat(immaginary)); complex.setReal(Float.parseFloat(real)); abs.setComplex(complex); return abs; }
public Abs toAbs(float real, float immaginary) { Abs abs = new Abs(); Complex complex = new Complex(); complex.setImmaginary(immaginary); complex.setReal(real); abs.setComplex(complex); return abs; }
public static void main(String[] args) { new Complex(2, 4).printNum(); new Complex(6, 7).addNum(new Complex(4, 6)).printNum(); new Complex(6, 7).multiplyNum(new Complex(4, 6)).printNum(); Complex c = new Complex(4, 7); c.setImag(6); c.setReal(3); c.printNum(); }
private void ift(Complex[] F, byte[] img, int width, int height) { for (int x = 0; x < height; x++) { for (int y = 0; y < width; y++) { Complex c = new Complex(); for (int u = 0; u < height; u++) { for (int v = 0; v < width; v++) { Complex tmp = Complex.fromPolar( 1, 2.0 * Math.PI * (u * x / (double) height + v * y / (double) width)); c = c.plus(tmp.mul(F[u * width + v])); } } c = c.div(height * width); c = c.mul(Math.pow(-1, (x + y))); if (c.getReal() < 0) c.setReal(0.0); System.out.println(c.getReal()); img[x * width + y] = (byte) (c.getReal()); } } }
public static Complex DiffOf(Complex X, Complex Y) { Complex Z = new Complex(); Z.setReal(X.real - Y.real); Z.setImag(X.imag - Y.imag); return Z; }
public static Complex prodOf(Complex X, Complex Y) { Complex Z = new Complex(); Z.setReal(X.real * Y.real - X.imag * Y.imag); Z.setImag(X.real * Y.imag + X.imag * Y.real); return Z; }
public static Complex sumOf(Complex X, Complex Y) { Complex Z = new Complex(); Z.setReal(X.real + Y.real); Z.setImag(X.imag + Y.imag); return Z; }