Esempio n. 1
0
        public static __ct__[] Csqrt(this __ct__ number)
        {
            __ct__ res0 = __ct__.CreateRadial(Sqrt(number.Norm), number.Argument / 2);
            __ct__ res1 = __ct__.CreateRadial(Sqrt(number.Norm), number.Argument / 2 + (__ft__)Constant.Pi);

            return(new __ct__[2] {
                res0, res1
            });
        }
Esempio n. 2
0
 public static __ct__ Power(this __ct__ number, __ft__ exponent)
 {
     if (number.IsZero)
     {
         return(__ct__.Zero);
     }
     else
     {
         __ft__ r   = number.Norm;
         __ft__ phi = number.Argument;
         return(__ct__.CreateRadial(Pow(r, exponent), exponent * phi));
     }
 }
Esempio n. 3
0
 public static __ct__ Tan(this __ct__ x)
 {
     if (x == __ct__.PositiveInfinityI)
     {
         return(__ct__.I);
     }
     else if (x == __ct__.NegativeInfinityI)
     {
         return(-__ct__.I);
     }
     else
     {
         return(Sin(x) / Cos(x));
     }
 }
Esempio n. 4
0
        public static __ct__[] Root(this __ct__ number, int n)
        {
            __ct__[] values = new __ct__[n];

            __ft__ invN = 1 / (__ft__)n;
            __ft__ phi  = number.Argument / n;
            __ft__ dphi = __cast__Constant.PiTimesTwo * invN;
            __ft__ r    = Pow(number.Norm, invN);

            for (int i = 0; i < n; i++)
            {
                values[i] = __ct__.CreateRadial(r, phi + dphi * i);
            }

            return(values);
        }
Esempio n. 5
0
 public static __ct__ Sqrt(this __ct__ x)
 {
     if (x.Imag == 0)
     {
         if (x.Real < 0)
         {
             return(new __ct__(0, Sqrt(-x.Real)));
         }
         else
         {
             return(new __ct__(Sqrt(x.Real), 0));
         }
     }
     else
     {
         var a = x.Norm;
         var b = x + a;
         return(a.Sqrt() * (b / b.Norm));
     }
 }
Esempio n. 6
0
        public static __ct__ Power(this __ct__ number, __ct__ exponent)
        {
            if (number.IsZero)
            {
                return(__ct__.Zero);
            }
            else if (exponent.IsZero)
            {
                return(__ct__.One);
            }
            else
            {
                __ft__ r   = number.Norm;
                __ft__ phi = number.Argument;

                __ft__ a = exponent.Real;
                __ft__ b = exponent.Imag;

                return(__ct__.CreateRadial(Exp(Log(r) * a - b * phi), a * phi + b * Log(r)));
            }
        }
Esempio n. 7
0
        public static __ct__ Power(this __ft__ number, __ct__ exponent)
        {
            if (number == 0)
            {
                return(__ct__.Zero);
            }
            else
            {
                __ft__ a = exponent.Real;
                __ft__ b = exponent.Imag;

                if (number < 0)
                {
                    var phi = __cast__Constant.Pi;
                    return(__ct__.CreateRadial(Exp(Log(-number) * a - b * phi), a * phi + b * Log(-number)));
                }
                else
                {
                    return(__ct__.CreateRadial(Pow(number, a), b * Log(number)));
                }
            }
        }
Esempio n. 8
0
 public static __ct__ Atanh(this __ct__ x)
 {
     if (x == __ct__.Zero)
     {
         return(__ct__.Zero);
     }
     else if (x == __ct__.One)
     {
         return(__ct__.PositiveInfinity);
     }
     else if (x == __ct__.PositiveInfinity)
     {
         return(new __ct__(0, -__cast__Constant.PiHalf));
     }
     else if (x == __ct__.I)
     {
         return(new __ct__(0, __cast__Constant.PiQuarter));
     }
     else
     {
         return(__half__ * (Log(1 + x) - Log(1 - x)));
     }
 }
Esempio n. 9
0
 public static __ct__ Atan(this __ct__ x)
 {
     if (x == __ct__.I)
     {
         return(__ct__.PositiveInfinityI);
     }
     else if (x == -__ct__.I)
     {
         return(__ct__.NegativeInfinityI);
     }
     else if (x == __ct__.PositiveInfinity)
     {
         return(new __ct__(__cast__Constant.PiHalf));
     }
     else if (x == __ct__.NegativeInfinity)
     {
         return(new __ct__(-__cast__Constant.PiHalf));
     }
     else
     {
         return(new __ct__(0, __half__) * Log((__ct__.I + x) / (__ct__.I - x)));
     }
 }
Esempio n. 10
0
 public static __ct__ Acosh(this __ct__ x)
 => Log(x + Sqrt(x * x - 1));
Esempio n. 11
0
        public static __ct__ Sinh(this __ct__ x)
        {
            var sin = Sin(new __ct__(-x.Imag, x.Real));

            return(new __ct__(sin.Imag, -sin.Real));
        }
Esempio n. 12
0
 public static __ct__ Conjugated(__ct__ c)
 => c.Conjugated;
Esempio n. 13
0
 public static __ft__ NormSquared(__ct__ c)
 => c.NormSquared;
Esempio n. 14
0
 public static __ct__ Log10(this __ct__ x)
 => Log(x, 10);
Esempio n. 15
0
 public static __ct__ Log(this __ct__ x)
 => new __ct__(Log(x.Norm), x.Argument);
Esempio n. 16
0
        public static __ct__ Tanh(this __ct__ x)
        {
            var tan = Tan(new __ct__(-x.Imag, x.Real));

            return(new __ct__(tan.Imag, -tan.Real));
        }
Esempio n. 17
0
        public static __ct__ Acos(this __ct__ x)
        {
            var t = Log(new __ct__(-x.Imag, x.Real) + Sqrt(1 - x * x));

            return(new __ct__(-t.Imag + __cast__Constant.PiHalf, t.Real));
        }
Esempio n. 18
0
 public static __ct__ Pow(this __ft__ number, __ct__ exponent)
 => Power(number, exponent);
Esempio n. 19
0
 public static __ft__ Norm(__ct__ c)
 => c.Norm;
Esempio n. 20
0
 public static __ft__ Argument(__ct__ c)
 => c.Argument;
Esempio n. 21
0
 public static __ct__ Exp(this __ct__ x)
 => new __ct__(Cos(x.Imag), Sin(x.Imag)) * Exp(x.Real);
Esempio n. 22
0
 public static __ct__ Cos(this __ct__ x)
 => (
     Exp(new __ct__(-x.Imag, x.Real)) +
     Exp(new __ct__(x.Imag, -x.Real))
     ) * __half__;
Esempio n. 23
0
 public static __ct__ Log(this __ct__ x, __ft__ basis)
 => x.Log() / basis.Log();
Esempio n. 24
0
 public static __ct__ Cosh(this __ct__ x)
 => Cos(new __ct__(-x.Imag, x.Real));
Esempio n. 25
0
 public static __ct__ Log2(this __ct__ x)
 => x.Log() * __cast__Constant.Ln2Inv;
Esempio n. 26
0
        public static __ct__ Asin(this __ct__ x)
        {
            var t = Log(new __ct__(-x.Imag, x.Real) + Sqrt(1 - x * x));

            return(new __ct__(t.Imag, -t.Real));
        }
Esempio n. 27
0
 public static __ct__ Cbrt(this __ct__ x)
 => __ct__.CreateRadial(Cbrt(x.Norm), x.Argument / 3);
Esempio n. 28
0
 public static __ct__ Asinh(this __ct__ x)
 => Log(x + Sqrt(1 + x * x));
Esempio n. 29
0
        public static __ct__ Sin(this __ct__ x)
        {
            var a = Exp(new __ct__(-x.Imag, x.Real)) - Exp(new __ct__(x.Imag, -x.Real));

            return(new __ct__(a.Imag, -a.Real) * __half__);
        }
Esempio n. 30
0
 public static bool IsFinite(this __ct__ v)
 => !(v.IsNaN || v.IsInfinity);