Example #1
0
        public void Run()
        {
            var a = new Complex(5.0, 6.0);
            var b = new Complex(-3.0, 4.0);

            Console.WriteLine("a            = " + a);
            Console.WriteLine("b            = " + b);
            Console.WriteLine("Re(a)        = " + a.Re());
            Console.WriteLine("Im(a)        = " + a.Im());
            Console.WriteLine("b + a        = " + b.Plus(a));
            Console.WriteLine("a - b        = " + a.Minus(b));
            Console.WriteLine("a * b        = " + a.Times(b));
            Console.WriteLine("b * a        = " + b.Times(a));
            Console.WriteLine("a / b        = " + a.Divides(b));
            Console.WriteLine("(a / b) * b  = " + a.Divides(b).Times(b));
            Console.WriteLine("conj(a)      = " + a.Conjugate());
            Console.WriteLine("|a|          = " + a.Abs());
            Console.WriteLine("tan(a)       = " + a.Tan());

            Console.ReadLine();
        }
Example #2
0
        // sample client for testing
        public static void test()
        {
            Complex a = new Complex(5.0, 6.0);
            Complex b = new Complex(-3.0, 4.0);

            System.Diagnostics.Debug.WriteLine("a            = " + a);
            System.Diagnostics.Debug.WriteLine("b            = " + b);
            System.Diagnostics.Debug.WriteLine("Re(a)        = " + a.Re);
            System.Diagnostics.Debug.WriteLine("Im(a)        = " + a.Im);
            System.Diagnostics.Debug.WriteLine("b + a        = " + b.Plus(a));
            System.Diagnostics.Debug.WriteLine("a - b        = " + a.Minus(b));
            System.Diagnostics.Debug.WriteLine("a * b        = " + a.Times(b));
            System.Diagnostics.Debug.WriteLine("b * a        = " + b.Times(a));
            System.Diagnostics.Debug.WriteLine("a / b        = " + a.Divides(b));
            System.Diagnostics.Debug.WriteLine("(a / b) * b  = " + a.Divides(b).Times(b));
            System.Diagnostics.Debug.WriteLine("conj(a)      = " + a.Conjugate());
            System.Diagnostics.Debug.WriteLine("|a|          = " + a.Abs());
            System.Diagnostics.Debug.WriteLine("tan(a)       = " + a.Tan());
        }