示例#1
0
        public static Complex Div(Complex com1, Complex com2)
        {
            if (Math.Abs(com2.real * com2.real + com2.imaginary + com2.imaginary) < double.Epsilon)
            {
                var obj = new Event(com1, com2);
                DivisionByZero?.Invoke(obj);
                return(new Complex());
            }
            Complex res = new Complex();

            res.real = (com1.real * com2.real + com1.imaginary * com2.imaginary) /
                       (com2.real * com2.real + com2.imaginary * com2.imaginary);
            res.imaginary = (com1.imaginary * com2.real - com1.real * com2.imaginary) /
                            (com2.real * com2.real + com2.imaginary * com2.imaginary);
            return(res);
        }
示例#2
0
        public static Complex Pow(Complex com, double deg)
        {
            Complex res    = new Complex();
            var     module = Module(com);

            if (com.real == 0)
            {
                var obj = new Event(new Complex(0, com.imaginary), new Complex(com.real, 0));
                DivisionByZero?.Invoke(obj);
                throw new Exception("Деление на ноль при вычислении аргумента");
            }

            var arg = Math.Atan(com.imaginary / com.real);

            res.real      = Math.Pow(module, deg) * Math.Cos(deg * arg);
            res.imaginary = Math.Pow(module, deg) * Math.Sin(deg * arg);
            return(res);
        }
示例#3
0
        public static Complex[] Sqrt(Complex com, double deg)
        {
            if (deg < 0.0001)
            {
                var obj = new Event(new Complex(1, 0), new Complex(deg, 0));
                DivisionByZero?.Invoke(obj);
                throw new Exception("Деление степени на ноль");
            }

            Complex[] res = new Complex[(int)deg];
            //Complex obj = new Complex();
            var module = Module(com);
            var arg    = Math.Atan(com.imaginary / com.real);

            for (int k = 0; k < deg; k++)
            {
                res[k] = new Complex(Math.Pow(module, 1 / deg) * Math.Cos((arg + 2 * Math.PI * k) / deg),
                                     Math.Pow(module, 1 / deg) * Math.Sin((arg + 2 * Math.PI * k) / deg));

                //res.Add(obj);
            }
            return(res);
        }