Ejemplo 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
            });
        }
Ejemplo 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));
     }
 }
Ejemplo 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));
     }
 }
Ejemplo 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);
        }
Ejemplo 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));
     }
 }
Ejemplo 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)));
            }
        }
Ejemplo 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)));
                }
            }
        }
Ejemplo 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)));
     }
 }
Ejemplo 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)));
     }
 }
Ejemplo n.º 10
0
 public static __ct__ Acosh(this __ct__ x)
 => Log(x + Sqrt(x * x - 1));
Ejemplo 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));
        }
Ejemplo n.º 12
0
 public static __ct__ Conjugated(__ct__ c)
 => c.Conjugated;
Ejemplo n.º 13
0
 public static __ft__ NormSquared(__ct__ c)
 => c.NormSquared;
Ejemplo n.º 14
0
 public static __ct__ Log10(this __ct__ x)
 => Log(x, 10);
Ejemplo n.º 15
0
 public static __ct__ Log(this __ct__ x)
 => new __ct__(Log(x.Norm), x.Argument);
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo n.º 18
0
 public static __ct__ Pow(this __ft__ number, __ct__ exponent)
 => Power(number, exponent);
Ejemplo n.º 19
0
 public static __ft__ Norm(__ct__ c)
 => c.Norm;
Ejemplo n.º 20
0
 public static __ft__ Argument(__ct__ c)
 => c.Argument;
Ejemplo n.º 21
0
 public static __ct__ Exp(this __ct__ x)
 => new __ct__(Cos(x.Imag), Sin(x.Imag)) * Exp(x.Real);
Ejemplo 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__;
Ejemplo n.º 23
0
 public static __ct__ Log(this __ct__ x, __ft__ basis)
 => x.Log() / basis.Log();
Ejemplo n.º 24
0
 public static __ct__ Cosh(this __ct__ x)
 => Cos(new __ct__(-x.Imag, x.Real));
Ejemplo n.º 25
0
 public static __ct__ Log2(this __ct__ x)
 => x.Log() * __cast__Constant.Ln2Inv;
Ejemplo 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));
        }
Ejemplo n.º 27
0
 public static __ct__ Cbrt(this __ct__ x)
 => __ct__.CreateRadial(Cbrt(x.Norm), x.Argument / 3);
Ejemplo n.º 28
0
 public static __ct__ Asinh(this __ct__ x)
 => Log(x + Sqrt(1 + x * x));
Ejemplo 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__);
        }
Ejemplo n.º 30
0
 public static bool IsFinite(this __ct__ v)
 => !(v.IsNaN || v.IsInfinity);