コード例 #1
0
ファイル: cmath.cs プロジェクト: Siyy/DynamicLanguageRuntime
        //asin(x) = ln( x + (x*x +1)^1/2)
        public static Complex asinh(object x)
        {
            Complex num = GetComplexNum(x);

            if (num.IsZero())
            {
                // preserve -0.0 imag component
                return(MathUtils.MakeImaginary(num.Imaginary()));
            }

            Complex recip = 1 / num;

            return(log(num) + log(1 + sqrt(recip * recip + 1)));
        }
コード例 #2
0
ファイル: cmath.cs プロジェクト: Siyy/DynamicLanguageRuntime
        //ln(re^iO) = ln(r) + iO
        public static Complex log(object x)
        {
            Complex num = GetComplexNum(x);

            if (num.IsZero())
            {
                throw PythonOps.ValueError("math domain error");
            }

            double r, theta;

            r     = num.Abs();
            theta = GetAngle(num);

            return(new Complex(Math.Log(r), theta));
        }