Class Complex

java.lang.Object
de.das.encrypter.fourier.Complex

public class Complex extends Object
Class to represent complex numbers.
  • Field Details

    • re

      public double re
    • im

      public double im
  • Constructor Details

    • Complex

      public Complex(double re, double im)
      Creates an instance of a complex number.
      Parameters:
      re - the real part of the complex number.
      im - the imaginary part of the complex number.
  • Method Details

    • add

      public static Complex add(Complex z1, Complex z2)
      Adds two given complex numbers.
      Parameters:
      z1 - the complex number one.
      z2 - the complex number two.
      Returns:
      the sum of the given complex numbers.
    • subtract

      public static Complex subtract(Complex z1, Complex z2)
      Subtracts a given complex numbers from anther given complex number.
      Parameters:
      z1 - the complex number one.
      z2 - the complex number two.
      Returns:
      the difference of z2 subtracted from z1.
    • multiply

      public static Complex multiply(Complex z1, Complex z2)
      Multiplies two given complex numbers.
      Parameters:
      z1 - the complex number one.
      z2 - the complex number two.
      Returns:
      the product of the given complex numbers.
    • divideR

      public static Complex divideR(Complex z, double r)
      Divides a given complex number by a real value.
      Parameters:
      z - a complex number.
      r - a real value.
      Returns:
      the quotient of z1 divided by z2.
    • magnitude

      public static double magnitude(Complex z)
      Calculates and returns the absolute value of a given complex number.
      Parameters:
      z - a given complex number.
      Returns:
      the magnitude of a given complex number.