/// <summary> /// Divides a complex by a complex and put the result in a third complex number. /// </summary> /// <param name="left">A <see cref="ComplexF"/> instance.</param> /// <param name="right">A <see cref="ComplexF"/> instance.</param> /// <param name="result">A <see cref="ComplexF"/> instance to hold the result.</param> /// <remarks>See http://mathworld.wolfram.com/ComplexFivision.html for further details.</remarks> public static void Divide(ComplexF left, ComplexF right, ref ComplexF result) { float x = left.Real, y = left.Imaginary; float u = right.Real, v = right.Imaginary; float modulusSquared = u * u + v * v; if (modulusSquared == 0) { throw new DivideByZeroException(); } float invModulusSquared = 1 / modulusSquared; result.Real = (x * u + y * v) * invModulusSquared; result.Imaginary = (y * u - x * v) * invModulusSquared; }
/// <summary> /// Calculates the hyperbolic cotangent of the specified complex number. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> instance.</param> /// <returns>Returns the hyperbolic cotangent of the specified complex number.</returns> public static ComplexF Coth(ComplexF complex) { if (complex.IsReal) { return new ComplexF((float)MathFunctions.Coth(complex.Real), 0.0f); } //return ComplexF.Divide(Cosh(complex), Sinh(complex)); float sini = -(float)System.Math.Sin(complex.Imaginary); float sinhr = (float)System.Math.Sinh(complex.Real); float denom = (sini * sini) + (sinhr * sinhr); return new ComplexF( (sinhr * (float)System.Math.Cosh(complex.Real)) / denom, (sini * (float)System.Math.Cos(complex.Imaginary)) / denom ); }
/// <summary> /// Subtracts a complex from a complex and put the result in the third complex number. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="b">A <see cref="ComplexF"/> instance.</param> /// <param name="result">A <see cref="ComplexF"/> instance to hold the result.</param> public static void Subtract(ComplexF a, ComplexF b, ref ComplexF result) { result.Real = a.Real - b.Real; result.Imaginary = a.Imaginary - b.Imaginary; }
/// <summary> /// Calculates the cosecant of the specified complex number. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> instance.</param> /// <returns>The cosecant of <paramref name="complex"/>.</returns> public static ComplexF Csc(ComplexF complex) { ComplexF result = ComplexF.Zero; if (complex.IsReal) { result.Real = (float)MathFunctions.Csc(complex.Real); } else { float sinr = (float)MathFunctions.Sin(complex.Real); float sinhi = (float)MathFunctions.Sinh(complex.Imaginary); float denom = sinr * sinr + sinhi * sinhi; result.Real = (sinr * (float)MathFunctions.Cosh(complex.Imaginary)) / denom; result.Imaginary = (-(float)MathFunctions.Cos(complex.Real) * sinhi) / denom; } return result; }
public static ComplexF Acot(ComplexF complex) { ComplexF tmp = new ComplexF(-complex.Imaginary, complex.Real); return (new ComplexF(0.0f, 0.5f)) * (ComplexF.Log(1.0f + tmp) - ComplexF.Log(1.0f - tmp)) + (float)MathFunctions.HalfPI; }
/// <summary> /// Calculates the square root of a complex number. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> instance.</param> /// <returns>The square root of the complex number given in <paramref name="complex"/>.</returns> /// <remarks>See http://mathworld.wolfram.com/SquareRoot.html for further details.</remarks> public static ComplexF Sqrt(ComplexF complex) { ComplexF result = ComplexF.Zero; if ((complex.Real == 0.0f) && (complex.Imaginary == 0.0f)) { return result; } else if (complex.IsReal) { result.Real = (complex.Real > 0) ? (float)System.Math.Sqrt(complex.Real) : (float)System.Math.Sqrt(-complex.Real); result.Imaginary = 0.0f; } else { float modulus = complex.Modulus; result.Real = (float)System.Math.Sqrt(0.5f * (modulus + complex.Real)); result.Imaginary = (float)System.Math.Sqrt(0.5f * (modulus - complex.Real)); if (complex.Imaginary < 0.0f) result.Imaginary = -result.Imaginary; } return result; }
/// <summary> /// Calculates a specified complex number raised by a specified power. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> representing the number to raise.</param> /// <param name="power">A <see cref="ComplexF"/> representing the power.</param> /// <returns>The complex <paramref name="complex"/> raised by <paramref name="power"/>.</returns> public static ComplexF Pow(ComplexF complex, ComplexF power) { return Exp(power * Log(complex)); }
/// <summary> /// Tests whether two complex numbers are approximately equal using default tolerance value. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="b">A <see cref="ComplexF"/> instance.</param> /// <returns><see langword="true"/> if the two vectors are approximately equal; otherwise, <see langword="false"/>.</returns> public static bool ApproxEqual(ComplexF a, ComplexF b) { return(ApproxEqual(a, b, MathFunctions.EpsilonF)); }
/// <summary> /// Initializes a new instance of the <see cref="ComplexF"/> class using values from a given complex instance. /// </summary> /// <param name="c">A complex number to get values from.</param> public ComplexF(ComplexF c) { _real = c.Real; _image = c.Imaginary; }
/// <summary> /// Multiplies a complex by a scalar and put the result into another complex number. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="s">A scalar.</param> /// <param name="result">A <see cref="ComplexF"/> instance to hold the result.</param> public static void Multiply(float s, ComplexF a, ref ComplexF result) { result.Real = a.Real * s; result.Imaginary = a.Imaginary * s; }
/// <summary> /// Negates a complex number. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the negated values.</returns> public static ComplexF Negate(ComplexF a) { return(new ComplexF(-a.Real, -a.Imaginary)); }
/// <summary> /// Multiplies a complex by a scalar. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the result.</returns> public static ComplexF Multiply(float s, ComplexF a) { return(new ComplexF(a.Real * s, a.Imaginary * s)); }
/// <summary> /// Subtracts a complex from a scalar and put the result into another complex. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="s">A scalar.</param> /// <param name="result">A <see cref="ComplexF"/> instance to hold the result.</param> public static void Subtract(float s, ComplexF a, ref ComplexF result) { result.Real = s - a.Real; result.Imaginary = a.Imaginary; }
/// <summary> /// Subtracts a scalar from a complex and put the result into another complex. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="s">A scalar.</param> /// <param name="result">A <see cref="ComplexF"/> instance to hold the result.</param> public static void Subtract(ComplexF a, float s, ref ComplexF result) { result.Real = a.Real - s; result.Imaginary = a.Imaginary; }
/// <summary> /// Divides a scalar by a complex and put the result into another complex number. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> instance.</param> /// <param name="scalar">A single-precision floating-point value.</param> /// <param name="result">A <see cref="ComplexF"/> instance to hold the result.</param> public static void Divide(float scalar, ComplexF complex, ref ComplexF result) { if ((complex.Real == 0) || (complex.Imaginary == 0)) { throw new DivideByZeroException(); } result.Real = scalar / complex.Real; result.Imaginary = scalar / complex.Imaginary; }
/// <summary> /// Negates the complex number. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the negated values.</returns> public static ComplexF operator-(ComplexF a) { return(ComplexF.Negate(a)); }
/// <summary> /// Tests whether two complex numbers are approximately equal using default tolerance value. /// </summary> /// <param name="left">A <see cref="ComplexF"/> instance.</param> /// <param name="right">A <see cref="ComplexF"/> instance.</param> /// <returns><see langword="true"/> if the two vectors are approximately equal; otherwise, <see langword="false"/>.</returns> public static bool ApproxEqual(ComplexF left, ComplexF right) { return ApproxEqual(left, right, MathFunctions.EpsilonF); }
/// <summary> /// Adds two complex numbers. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="b">A <see cref="ComplexF"/> instance.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the sum.</returns> public static ComplexF operator+(ComplexF a, ComplexF b) { return(ComplexF.Add(a, b)); }
/// <summary> /// Calculates the logarithm of a specified complex number. /// Calculates the natural (base e) logarithm of a specified complex number. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> instance.</param> /// <returns>The natural (base e) logarithm of the complex number given in <paramref name="complex"/>.</returns> public static ComplexF Log(ComplexF complex) { ComplexF result = ComplexF.Zero; if ((complex.Real > 0.0) && (complex.Imaginary == 0.0)) { result.Real = (float)System.Math.Log(complex.Real); result.Imaginary = 0.0f; } else if (complex.Real == 0.0f) { if (complex.Imaginary > 0.0f) { result.Real = (float)System.Math.Log(complex.Imaginary); result.Imaginary = (float)MathFunctions.HalfPI; } else { result.Real = (float)System.Math.Log(-(complex.Imaginary)); result.Imaginary = -(float)MathFunctions.HalfPI; } } else { result.Real = (float)System.Math.Log(complex.Modulus); result.Imaginary = (float)System.Math.Atan2(complex.Imaginary, complex.Real); } return result; }
/// <summary> /// Adds a complex number and a scalar. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the sum.</returns> public static ComplexF operator+(float s, ComplexF a) { return(ComplexF.Add(a, s)); }
/// <summary> /// Calculates the cosine of the specified complex number. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> instance.</param> /// <returns>The cosine of <paramref name="complex"/>.</returns> public static ComplexF Cos(ComplexF complex) { ComplexF result = ComplexF.Zero; if (complex.IsReal) { result.Real = (float)System.Math.Cos(complex.Real); result.Imaginary = 0.0f; } else { result.Real = (float)(System.Math.Cos(complex.Real) * System.Math.Cosh(complex.Imaginary)); result.Imaginary = (float)(-System.Math.Sin(complex.Real) * System.Math.Sinh(complex.Imaginary)); } return result; }
/// <summary> /// Subtracts a complex from a complex. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="b">A <see cref="ComplexF"/> instance.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the difference.</returns> public static ComplexF operator-(ComplexF a, ComplexF b) { return(ComplexF.Subtract(a, b)); }
public static ComplexF Acos(ComplexF complex) { ComplexF result = 1 - ComplexF.Square(complex); result = ComplexF.Sqrt(result); result = ComplexF.I * result; result = complex + result; result = ComplexF.Log(result); result = -ComplexF.I * result; return result; }
/// <summary> /// Subtracts a scalar from a complex. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the difference.</returns> public static ComplexF operator-(ComplexF a, float s) { return(ComplexF.Subtract(a, s)); }
/// <summary> /// Calculates the hyperbolic cosine of the specified complex number. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> instance.</param> /// <returns>Returns the hyperbolic cosine of the specified complex number.</returns> public static ComplexF Cosh(ComplexF complex) { if (complex.IsReal) { return new ComplexF((float)System.Math.Cosh(complex.Real), 0.0f); } return new ComplexF( (float)(System.Math.Cosh(complex.Real) * System.Math.Cos(complex.Imaginary)), (float)(System.Math.Sinh(complex.Real) * System.Math.Sin(complex.Imaginary)) ); }
/// <summary> /// Subtracts a complex from a scalar. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the difference.</returns> public static ComplexF operator-(float s, ComplexF a) { return(ComplexF.Subtract(s, a)); }
public static ComplexF Asinh(ComplexF complex) { ComplexF result = ComplexF.Sqrt(ComplexF.Square(complex) + 1); result = ComplexF.Log(complex + result); return result; }
/// <summary> /// Multiplies two complex numbers. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="b">A <see cref="ComplexF"/> instance.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the result.</returns> public static ComplexF operator*(ComplexF a, ComplexF b) { return(ComplexF.Multiply(a, b)); }
/// <summary> /// Divides a scalar by a complex. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> instance.</param> /// <param name="scalar">A single-precision floating-point value.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the result.</returns> public static ComplexF Divide(float scalar, ComplexF complex) { if ((complex.Real == 0) || (complex.Imaginary == 0)) { throw new DivideByZeroException(); } return new ComplexF( scalar / complex.Real, scalar / complex.Imaginary); }
/// <summary> /// Multiplies a complex by a scalar. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the result.</returns> public static ComplexF operator*(ComplexF a, float s) { return(ComplexF.Multiply(a, s)); }
/// <summary> /// Divides a complex by a scalar and put the result into another complex number. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> instance.</param> /// <param name="scalar">A single-precision floating-point value.</param> /// <param name="result">A <see cref="ComplexF"/> instance to hold the result.</param> public static void Divide(ComplexF complex, float scalar, ref ComplexF result) { if (scalar == 0) { throw new DivideByZeroException(); } result.Real = complex.Real / scalar; result.Imaginary = complex.Imaginary / scalar; }
/// <summary> /// Divides a complex by a complex. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="b">A <see cref="ComplexF"/> instance.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the result.</returns> public static ComplexF operator/(ComplexF a, ComplexF b) { return(ComplexF.Divide(a, b)); }
/// <summary> /// Negates a complex number. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> instance.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the negated values.</returns> public static ComplexF Negate(ComplexF complex) { return new ComplexF(-complex.Real, -complex.Imaginary); }
/// <summary> /// Divides a complex by a scalar. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the result.</returns> public static ComplexF operator/(ComplexF a, float s) { return(ComplexF.Divide(a, s)); }
/// <summary> /// Tests whether two complex numbers are approximately equal given a tolerance value. /// </summary> /// <param name="left">A <see cref="ComplexF"/> instance.</param> /// <param name="right">A <see cref="ComplexF"/> instance.</param> /// <param name="tolerance">The tolerance value used to test approximate equality.</param> /// <returns><see langword="true"/> if the two vectors are approximately equal; otherwise, <see langword="false"/>.</returns> public static bool ApproxEqual(ComplexF left, ComplexF right, float tolerance) { return ( (System.Math.Abs(left.Real - right.Real) <= tolerance) && (System.Math.Abs(left.Imaginary - right.Imaginary) <= tolerance) ); }
/// <summary> /// Divides a scalar by a complex. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the result.</returns> public static ComplexF operator/(float s, ComplexF a) { return(ComplexF.Divide(s, a)); }
/// <summary> /// Adds two complex numbers. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="b">A <see cref="ComplexF"/> instance.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the sum.</returns> public static ComplexF Add(ComplexF a, ComplexF b) { return(new ComplexF(a.Real + b.Real, a.Imaginary + b.Imaginary)); }
/// <summary> /// Calculates the exponential of a specified complex number. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> instance.</param> /// <returns>The exponential of the complex number given in <paramref name="complex"/>.</returns> public static ComplexF Exp(ComplexF complex) { ComplexF result = ComplexF.Zero; float r = (float)System.Math.Exp(complex.Real); result.Real = r * (float)System.Math.Cos(complex.Imaginary); result.Imaginary = r * (float)System.Math.Sin(complex.Imaginary); return result; }
/// <summary> /// Adds a complex number and a scalar. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the sum.</returns> public static ComplexF Add(ComplexF a, float s) { return(new ComplexF(a.Real + s, a.Imaginary)); }
/// <summary> /// Calculates the square of the specified complex number. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> instance.</param> /// <returns>The square of the given complex number.</returns> public static ComplexF Square(ComplexF complex) { if (complex.IsReal) { return new ComplexF(complex.Real * complex.Real, 0.0f); } float real = complex.Real; float imag = complex.Imaginary; return new ComplexF(real * real - imag * imag, 2.0f * real * imag); }
/// <summary> /// Adds two complex numbers and put the result in the third complex number. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="b">A <see cref="ComplexF"/> instance.</param> /// <param name="result">A <see cref="ComplexF"/> instance to hold the result.</param> public static void Add(ComplexF a, ComplexF b, ComplexF result) { result.Real = a.Real + b.Real; result.Imaginary = a.Imaginary + b.Imaginary; }
/// <summary> /// Calculates the tangent of the specified complex number. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> instance.</param> /// <returns>The tangent of <paramref name="complex"/>.</returns> public static ComplexF Tan(ComplexF complex) { ComplexF result = ComplexF.Zero; if (complex.IsReal) { result.Real = (float)System.Math.Tan(complex.Real); result.Imaginary = 0.0f; } else { float cosr = (float)System.Math.Cos(complex.Real); float sinhi = (float)System.Math.Sinh(complex.Imaginary); float denom = cosr * cosr + sinhi * sinhi; result.Real = (float)System.Math.Sin(complex.Real) * cosr / denom; result.Imaginary = sinhi * (float)System.Math.Cosh(complex.Imaginary) / denom; } return result; }
/// <summary> /// Adds a complex number and a scalar and put the result into another complex. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="s">A scalar.</param> /// <param name="result">A <see cref="ComplexF"/> instance to hold the result.</param> public static void Add(ComplexF a, float s, ComplexF result) { result.Real = a.Real + s; result.Imaginary = a.Imaginary; }
public static ComplexF Asin(ComplexF complex) { ComplexF result = 1 - ComplexF.Square(complex); result = ComplexF.Sqrt(result); result = result + (ComplexF.I * complex); result = ComplexF.Log(result); result = -ComplexF.I * result; return result; }
/// <summary> /// Subtracts a complex from a complex. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="b">A <see cref="ComplexF"/> instance.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the difference.</returns> public static ComplexF Subtract(ComplexF a, ComplexF b) { return(new ComplexF(a.Real - b.Real, a.Imaginary - b.Imaginary)); }
public static ComplexF Atan(ComplexF complex) { ComplexF tmp = new ComplexF(-complex.Imaginary, complex.Real); return (new ComplexF(0.0f, 0.5f)) * (ComplexF.Log(1.0f - tmp) - ComplexF.Log(1.0f + tmp)); }
/// <summary> /// Subtracts a scalar from a complex. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the difference.</returns> public static ComplexF Subtract(ComplexF a, float s) { return(new ComplexF(a.Real - s, a.Imaginary)); }
public static ComplexF Acsc(ComplexF complex) { ComplexF inverse = 1 / complex; return (-ComplexF.I) * ComplexF.Log(ComplexF.I * inverse + ComplexF.Sqrt(1 - ComplexF.Square(inverse))); }
/// <summary> /// Multiplies a complex by a scalar and put the result into another complex number. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> instance.</param> /// <param name="scalar">A single-precision floating-point value.</param> /// <param name="result">A <see cref="ComplexF"/> instance to hold the result.</param> public static void Multiply(ComplexF complex, float scalar, ref ComplexF result) { result.Real = complex.Real * scalar; result.Imaginary = complex.Imaginary * scalar; }
/// <summary> /// Calculates the hyperbolic tangent of the specified complex number. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> instance.</param> /// <returns>Returns the hyperbolic tangent of the specified complex number.</returns> public static ComplexF Tanh(ComplexF complex) { if (complex.IsReal) { return new ComplexF((float)System.Math.Tanh(complex.Real), 0.0f); } float cosi = (float)System.Math.Cos(complex.Imaginary); float sinhr = (float)System.Math.Sinh(complex.Real); float denom = (cosi * cosi) + (sinhr * sinhr); return new ComplexF( (sinhr * (float)System.Math.Cosh(complex.Real)) / denom, (cosi * (float)System.Math.Sin(complex.Imaginary)) / denom ); }
/// <summary> /// Divides a complex by a complex. /// </summary> /// <param name="left">A <see cref="ComplexF"/> instance.</param> /// <param name="right">A <see cref="ComplexF"/> instance.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the result.</returns> /// <remarks>See http://mathworld.wolfram.com/ComplexFivision.html for further details.</remarks> public static ComplexF Divide(ComplexF left, ComplexF right) { float x = left.Real, y = left.Imaginary; float u = right.Real, v = right.Imaginary; float modulusSquared = u * u + v * v; if (modulusSquared == 0) { throw new DivideByZeroException(); } float invModulusSquared = 1 / modulusSquared; return new ComplexF( (x * u + y * v) * invModulusSquared, (y * u - x * v) * invModulusSquared); }
/// <summary> /// Calculates the hyperbolic cosecant of the specified complex number. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> instance.</param> /// <returns>Returns the hyperbolic cosecant of the specified complex number.</returns> public static ComplexF Csch(ComplexF complex) { if (complex.IsReal) { return new ComplexF((float)MathFunctions.Csch((double)complex.Real), 0.0f); } ComplexF exp = ComplexF.Exp(complex); return (2 * exp) / (ComplexF.Square(exp) - 1); }
/// <summary> /// Divides a complex by a scalar. /// </summary> /// <param name="complex">A <see cref="ComplexF"/> instance.</param> /// <param name="scalar">A single-precision floating-point value.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the result.</returns> public static ComplexF Divide(ComplexF complex, float scalar) { if (scalar == 0) { throw new DivideByZeroException(); } return new ComplexF( complex.Real / scalar, complex.Imaginary / scalar); }
public static ComplexF Acosh(ComplexF complex) { ComplexF result = ComplexF.Sqrt(complex - 1) * ComplexF.Sqrt(complex + 1); result = complex + result; result = ComplexF.Log(result); return result; }
/// <summary> /// Subtracts a complex from a scalar. /// </summary> /// <param name="a">A <see cref="ComplexF"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="ComplexF"/> instance containing the difference.</returns> public static ComplexF Subtract(float s, ComplexF a) { return(new ComplexF(s - a.Real, a.Imaginary)); }