public virtual Complex_F64 minus(Complex_F64 a) { Complex_F64 ret = new Complex_F64(); ComplexMath_F64.minus(this, a, ret); return(ret); }
public virtual Complex_F64 times(Complex_F64 a) { Complex_F64 ret = new Complex_F64(); ComplexMath_F64.multiply(this, a, ret); return(ret); }
public override void get(int row, int col, Complex_F64 output) { int index = row * numCols * 2 + col * 2; output.real = data[index]; output.imaginary = data[index + 1]; }
public virtual Complex_F64 divide(Complex_F64 a) { Complex_F64 ret = new Complex_F64(); ComplexMath_F64.divide(this, a, ret); return(ret); }
/** * <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_F64 a, Complex_F64 b, Complex_F64 result) { double 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; }
public virtual Complex_F64 toStandard() { Complex_F64 ret = new Complex_F64(); ComplexMath_F64.convert(this, ret); return(ret); }
/** * 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 ≤ k < N * @param result Computed root */ public static void root(Complex_F64 a, int N, int k, Complex_F64 result) { double r = a.getMagnitude(); double theta = Math.Atan2(a.imaginary, a.real); r = Math.Pow(r, 1.0 / N); theta = (theta + 2.0 * k * UtilEjml.PI) / N; result.real = r * (double)Math.Cos(theta); result.imaginary = r * (double)Math.Sin(theta); }
/** * 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_F64 input, Complex_F64 root) { double r = input.getMagnitude(); double a = input.real; root.real = Math.Sqrt((r + a) / 2.0); root.imaginary = Math.Sqrt((r - a) / 2.0); if (input.imaginary < 0) { root.imaginary = -root.imaginary; } }
public virtual void setTo(Matrix original) { reshape(original.NumRows, original.NumCols); ZMatrix n = (ZMatrix)original; Complex_F64 c = new Complex_F64(); 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); } } }
public abstract void get(int row, int col, Complex_F64 output);
/** * <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_F64 a, Complex_F64 b, Complex_F64 result) { result.real = a.real * b.real - a.imaginary * b.imaginary; result.imaginary = a.real * b.imaginary + a.imaginary * b.real; }
/** * <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_F64 a, Complex_F64 b, Complex_F64 result) { result.real = a.real - b.real; result.imaginary = a.imaginary - b.imaginary; }
/** * <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_F64 a, Complex_F64 b, Complex_F64 result) { result.real = a.real + b.real; result.imaginary = a.imaginary + b.imaginary; }
/** * Complex conjugate * * @param input Input complex number * @param conj Complex conjugate of the input number */ public static void conj(Complex_F64 input, Complex_F64 conj) { conj.real = input.real; conj.imaginary = -input.imaginary; }
public ComplexPolar_F64(Complex_F64 n) { ComplexMath_F64.convert(n, this); }
/** * <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); }
/** * <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 * (double)Math.Cos(input.theta); output.imaginary = input.r * (double)Math.Sin(input.theta); }