public static ComplexF Log(ComplexF a) { ComplexF result = ComplexF.Zero; if ((a.Real > 0.0f) && (a.Imaginary == 0.0f)) { result.Real = (float)System.Math.Log(a.Real); result.Imaginary = 0.0f; } else if (a.Real == 0.0f) { if (a.Imaginary > 0.0f) { result.Real = (float)System.Math.Log(a.Imaginary); result.Imaginary = (float)MathFunctions.HalfPI; } else { result.Real = (float)System.Math.Log(-(a.Imaginary)); result.Imaginary = (float)-MathFunctions.HalfPI; } } else { result.Real = (float)System.Math.Log(a.GetModulus()); result.Imaginary = (float)System.Math.Atan2(a.Imaginary, a.Real); } return(result); }
public static ComplexF Sqrt(ComplexF a) { ComplexF result = ComplexF.Zero; if ((a.Real == 0.0f) && (a.Imaginary == 0.0f)) { return(result); } else if (a.Imaginary == 0.0f) { result.Real = (float)((a.Real > 0) ? System.Math.Sqrt(a.Real) : System.Math.Sqrt(-a.Real)); result.Imaginary = 0.0f; } else { float modulus = a.GetModulus(); result.Real = (float)System.Math.Sqrt(0.5 * (modulus + a.Real)); result.Imaginary = (float)System.Math.Sqrt(0.5 * (modulus - a.Real)); if (a.Imaginary < 0.0) { result.Imaginary = -result.Imaginary; } } return(result); }
public static ComplexF Sqrt(ComplexF a) { ComplexF result = ComplexF.Zero; if ((a.Real == 0.0f) && (a.Imaginary == 0.0f)) { return result; } else if (a.Imaginary == 0.0f) { result.Real = (float)((a.Real > 0) ? System.Math.Sqrt(a.Real) : System.Math.Sqrt(-a.Real)); result.Imaginary = 0.0f; } else { float modulus = a.GetModulus(); result.Real = (float)System.Math.Sqrt(0.5 * (modulus + a.Real)); result.Imaginary= (float)System.Math.Sqrt(0.5 * (modulus - a.Real)); if (a.Imaginary < 0.0) result.Imaginary = -result.Imaginary; } return result; }
public static ComplexF Log(ComplexF a) { ComplexF result = ComplexF.Zero; if ((a.Real > 0.0f) && (a.Imaginary == 0.0f)) { result.Real = (float)System.Math.Log(a.Real); result.Imaginary = 0.0f; } else if (a.Real == 0.0f) { if (a.Imaginary > 0.0f) { result.Real = (float)System.Math.Log(a.Imaginary); result.Imaginary = (float)MathFunctions.HalfPI; } else { result.Real = (float)System.Math.Log(-(a.Imaginary)); result.Imaginary = (float)-MathFunctions.HalfPI; } } else { result.Real = (float)System.Math.Log(a.GetModulus()); result.Imaginary = (float)System.Math.Atan2(a.Imaginary, a.Real); } return result; }