Beispiel #1
0
        public Complex_F32 minus(Complex_F32 a)
        {
            Complex_F32 ret = new Complex_F32();

            ComplexMath_F32.minus(this, a, ret);
            return(ret);
        }
Beispiel #2
0
        public override void get(int row, int col, Complex_F32 output)
        {
            int index = row * numCols * 2 + col * 2;

            output.real      = data[index];
            output.imaginary = data[index + 1];
        }
Beispiel #3
0
        public Complex_F32 divide(Complex_F32 a)
        {
            Complex_F32 ret = new Complex_F32();

            ComplexMath_F32.divide(this, a, ret);
            return(ret);
        }
Beispiel #4
0
        /**
         * <p>
         * Division: result = a / b
         * </p>
         *
         * @param a Complex number. Not modified.
         * @param b Complex number. Not modified.
         * @param result Storage for output
         */
        public static void divide(Complex_F32 a, Complex_F32 b, Complex_F32 result)
        {
            float norm = b.getMagnitude2();

            result.real      = (a.real * b.real + a.imaginary * b.imaginary) / norm;
            result.imaginary = (a.imaginary * b.real - a.real * b.imaginary) / norm;
        }
Beispiel #5
0
        public Complex_F32 times(Complex_F32 a)
        {
            Complex_F32 ret = new Complex_F32();

            ComplexMath_F32.multiply(this, a, ret);
            return(ret);
        }
Beispiel #6
0
        public Complex_F32 toStandard()
        {
            Complex_F32 ret = new Complex_F32();

            ComplexMath_F32.convert(this, ret);
            return(ret);
        }
Beispiel #7
0
        /**
         * Computes the N<sup>th</sup> root of a complex number.  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(Complex_F32 a, int N, int k, Complex_F32 result)
        {
            float r     = a.getMagnitude();
            float theta = (float)Math.Atan2(a.imaginary, a.real);

            r     = (float)Math.Pow(r, 1.0f / N);
            theta = (theta + 2.0f * k * UtilEjml.F_PI) / N;

            result.real      = r * (float)Math.Cos(theta);
            result.imaginary = r * (float)Math.Sin(theta);
        }
Beispiel #8
0
        /**
         * Computes the square root of the complex number.
         *
         * @param input Input complex number.
         * @param root Output. The square root of the input
         */
        public static void sqrt(Complex_F32 input, Complex_F32 root)
        {
            float r = input.getMagnitude();
            float a = input.real;

            root.real      = (float)Math.Sqrt((r + a) / 2.0f);
            root.imaginary = (float)Math.Sqrt((r - a) / 2.0f);
            if (input.imaginary < 0)
            {
                root.imaginary = -root.imaginary;
            }
        }
Beispiel #9
0
        public override void set(Matrix original)
        {
            reshape(original.getNumRows(), original.getNumCols());

            CMatrix n = (CMatrix)original;

            Complex_F32 c = new Complex_F32();

            for (int i = 0; i < numRows; i++)
            {
                for (int j = 0; j < numCols; j++)
                {
                    n.get(i, j, c);
                    set(i, j, c.real, c.imaginary);
                }
            }
        }
Beispiel #10
0
 public void set(Complex_F32 a)
 {
     this.real      = a.real;
     this.imaginary = a.imaginary;
 }
Beispiel #11
0
 /**
  * Complex conjugate
  * @param input Input complex number
  * @param conj Complex conjugate of the input number
  */
 public static void conj(Complex_F32 input, Complex_F32 conj)
 {
     conj.real      = input.real;
     conj.imaginary = -input.imaginary;
 }
Beispiel #12
0
 /**
  * <p>
  * Converts a complex number into polar notation.
  * </p>
  *
  * @param input Standard notation
  * @param output Polar notation
  */
 public static void convert(Complex_F32 input, ComplexPolar_F32 output)
 {
     output.r     = input.getMagnitude();
     output.theta = (float)Math.Atan2(input.imaginary, input.real);
 }
Beispiel #13
0
 /**
  * <p>
  * Multiplication: result = a * b
  * </p>
  *
  * @param a Complex number. Not modified.
  * @param b Complex number. Not modified.
  * @param result Storage for output
  */
 public static void multiply(Complex_F32 a, Complex_F32 b, Complex_F32 result)
 {
     result.real      = a.real * b.real - a.imaginary * b.imaginary;
     result.imaginary = a.real * b.imaginary + a.imaginary * b.real;
 }
Beispiel #14
0
 /**
  * <p>
  * Subtraction: result = a - b
  * </p>
  *
  * @param a Complex number. Not modified.
  * @param b Complex number. Not modified.
  * @param result Storage for output
  */
 public static void minus(Complex_F32 a, Complex_F32 b, Complex_F32 result)
 {
     result.real      = a.real - b.real;
     result.imaginary = a.imaginary - b.imaginary;
 }
Beispiel #15
0
 /**
  * <p>
  * Addition: result = a + b
  * </p>
  *
  * @param a Complex number. Not modified.
  * @param b Complex number. Not modified.
  * @param result Storage for output
  */
 public static void plus(Complex_F32 a, Complex_F32 b, Complex_F32 result)
 {
     result.real      = a.real + b.real;
     result.imaginary = a.imaginary + b.imaginary;
 }
Beispiel #16
0
 public ComplexPolar_F32(Complex_F32 n)
 {
     ComplexMath_F32.convert(n, this);
 }
Beispiel #17
0
 public abstract void get(int row, int col, Complex_F32 output);
Beispiel #18
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_F32 input, Complex_F32 output)
 {
     output.real      = input.r * (float)Math.Cos(input.theta);
     output.imaginary = input.r * (float)Math.Sin(input.theta);
 }