Ejemplo n.º 1
0
        public static void main(string[] args)
        {
            Complex_F64      a      = new Complex_F64(1, 2);
            Complex_F64      b      = new Complex_F64(-1, -0.6);
            Complex_F64      c      = new Complex_F64();
            ComplexPolar_F64 polarC = new ComplexPolar_F64();

            Console.WriteLine("a = " + a);
            Console.WriteLine("b = " + b);
            Console.WriteLine("------------------");

            ComplexMath_F64.plus(a, b, c);
            Console.WriteLine("a + b = " + c);
            ComplexMath_F64.minus(a, b, c);
            Console.WriteLine("a - b = " + c);
            ComplexMath_F64.multiply(a, b, c);
            Console.WriteLine("a * b = " + c);
            ComplexMath_F64.divide(a, b, c);
            Console.WriteLine("a / b = " + c);

            Console.WriteLine("------------------");
            ComplexPolar_F64 polarA = new ComplexPolar_F64();

            ComplexMath_F64.convert(a, polarA);
            Console.WriteLine("polar notation of a = " + polarA);
            ComplexMath_F64.pow(polarA, 3, polarC);
            Console.WriteLine("a ** 3 = " + polarC);
            ComplexMath_F64.convert(polarC, c);
            Console.WriteLine("a ** 3 = " + c);
        }
Ejemplo n.º 2
0
 /**
  * <p>
  * Converts a complex number into polar notation.
  * </p>
  *
  * @param input Standard notation
  * @param output Polar notation
  */
 public static void convert(Complex_F64 input, ComplexPolar_F64 output)
 {
     output.r     = input.getMagnitude();
     output.theta = Math.Atan2(input.imaginary, input.real);
 }
Ejemplo n.º 3
0
 /**
  * Computes the N<sup>th</sup> root of a complex number in polar notation.  There are
  * N distinct N<sup>th</sup> roots.
  *
  * @param a Complex number
  * @param N The root's magnitude
  * @param k Specifies which root.  0 &le; k &lt; N
  * @param result Computed root
  */
 public static void root(ComplexPolar_F64 a, int N, int k, ComplexPolar_F64 result)
 {
     result.r     = Math.Pow(a.r, 1.0 / N);
     result.theta = (a.theta + 2.0 * k * UtilEjml.PI) / N;
 }
Ejemplo n.º 4
0
 /**
  * Computes the power of a complex number in polar notation
  *
  * @param a Complex number
  * @param N Power it is to be multiplied by
  * @param result Result
  */
 public static void pow(ComplexPolar_F64 a, int N, ComplexPolar_F64 result)
 {
     result.r     = Math.Pow(a.r, N);
     result.theta = N * a.theta;
 }
Ejemplo n.º 5
0
 /**
  * Division in polar notation.
  *
  * @param a Complex number in polar notation. Not modified.
  * @param b Complex number in polar notation. Not modified.
  * @param result Storage for output.
  */
 public static void divide(ComplexPolar_F64 a, ComplexPolar_F64 b, ComplexPolar_F64 result)
 {
     result.r     = a.r / b.r;
     result.theta = a.theta - b.theta;
 }
Ejemplo n.º 6
0
 /**
  * Division in polar notation.
  *
  * @param a Complex number in polar notation. Not modified.
  * @param b Complex number in polar notation. Not modified.
  * @param result Storage for output.
  */
 public static void multiply(ComplexPolar_F64 a, ComplexPolar_F64 b, ComplexPolar_F64 result)
 {
     result.r     = a.r * b.r;
     result.theta = a.theta + b.theta;
 }
Ejemplo n.º 7
0
 /**
  * <p>
  * Converts a complex number in polar notation into standard notation.
  * </p>
  *
  * @param input Standard notation
  * @param output Polar notation
  */
 public static void convert(ComplexPolar_F64 input, Complex_F64 output)
 {
     output.real      = input.r * Math.Cos(input.theta);
     output.imaginary = input.r * Math.Sin(input.theta);
 }