//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDivideMultiply()
        public virtual void testDivideMultiply()
        {
            assertComplexEquals(ComplexMathUtils.multiply(ComplexMathUtils.divide(Z1, Z2), Z2), Z1);
            assertComplexEquals(ComplexMathUtils.multiply(ComplexMathUtils.divide(Z1, X), X), Z1);
            assertComplexEquals(ComplexMathUtils.multiply(ComplexMathUtils.divide(X, Z1), Z1), X_C);
            assertComplexEquals(ComplexMathUtils.multiply(X, Z1), ComplexMathUtils.multiply(Z1, X));
        }
Exemplo n.º 2
0
        public static ComplexNumber tanh(ComplexNumber z)
        {
            ComplexNumber z2 = ComplexMathUtils.exp(z);
            ComplexNumber z3 = ComplexMathUtils.exp(ComplexMathUtils.multiply(z, -1));

            return(ComplexMathUtils.divide(ComplexMathUtils.subtract(z2, z3), ComplexMathUtils.add(z2, z3)));
        }
        public static ComplexNumber pow(ComplexNumber z, double x)
        {
            double mod  = ComplexMathUtils.mod(z);
            double arg  = ComplexMathUtils.arg(z);
            double mult = Math.Pow(mod, x);

            return(new ComplexNumber(mult * Math.Cos(x * arg), mult * Math.Sin(x * arg)));
        }
Exemplo n.º 4
0
        public static ComplexNumber atan(ComplexNumber z)
        {
            ArgChecker.notNull(z, "z");
            ComplexNumber iZ   = ComplexMathUtils.multiply(z, I);
            ComplexNumber half = new ComplexNumber(0, 0.5);

            return(ComplexMathUtils.multiply(half, ComplexMathUtils.log(ComplexMathUtils.divide(ComplexMathUtils.subtract(1, iZ), ComplexMathUtils.add(1, iZ)))));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testPower()
        public virtual void testPower()
        {
            assertComplexEquals(ComplexMathUtils.pow(Z1, 0), new ComplexNumber(1, 0));
            assertComplexEquals(ComplexMathUtils.pow(X, new ComplexNumber(0, 0)), new ComplexNumber(1, 0));
            assertComplexEquals(ComplexMathUtils.sqrt(ComplexMathUtils.pow(Z1, 2)), Z1);
            assertComplexEquals(ComplexMathUtils.sqrt(ComplexMathUtils.pow(Z2, 2)), Z2);
            assertComplexEquals(ComplexMathUtils.pow(ComplexMathUtils.pow(Z1, 1.0 / 3), 3), Z1);
            assertComplexEquals(ComplexMathUtils.pow(ComplexMathUtils.pow(X, ComplexMathUtils.inverse(Z2)), Z2), new ComplexNumber(X, 0));
            assertComplexEquals(ComplexMathUtils.pow(ComplexMathUtils.pow(Z1, ComplexMathUtils.inverse(Z2)), Z2), Z1);
        }
        public static ComplexNumber pow(ComplexNumber z1, ComplexNumber z2)
        {
            ArgChecker.notNull(z1, "z1");
            ArgChecker.notNull(z2, "z2");
            double mod   = ComplexMathUtils.mod(z1);
            double arg   = ComplexMathUtils.arg(z1);
            double mult  = Math.Pow(mod, z2.Real) * Math.Exp(-z2.Imaginary * arg);
            double theta = z2.Real * arg + z2.Imaginary * Math.Log(mod);

            return(new ComplexNumber(mult * Math.Cos(theta), mult * Math.Sin(theta)));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSqrt()
        public virtual void testSqrt()
        {
            ComplexNumber z1 = new ComplexNumber(3, -2);
            ComplexNumber z2 = new ComplexNumber(-3, 4);
            ComplexNumber z3 = new ComplexNumber(-3, -4);

            ComplexNumber rZ1 = ComplexMathUtils.sqrt(z1);
            ComplexNumber rZ2 = ComplexMathUtils.sqrt(z2);
            ComplexNumber rZ3 = ComplexMathUtils.sqrt(z3);

            assertComplexEquals(ComplexMathUtils.pow(z1, 0.5), rZ1);
            assertComplexEquals(ComplexMathUtils.pow(z2, 0.5), rZ2);
            assertComplexEquals(ComplexMathUtils.pow(z3, 0.5), rZ3);

            assertComplexEquals(z1, ComplexMathUtils.square(rZ1));
            assertComplexEquals(z2, ComplexMathUtils.square(rZ2));
            assertComplexEquals(z3, ComplexMathUtils.square(rZ3));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testModulus()
        public virtual void testModulus()
        {
            assertEquals(Math.Sqrt(V * V + W * W), ComplexMathUtils.mod(Z1), EPS);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testInverse()
        public virtual void testInverse()
        {
            assertComplexEquals(ComplexMathUtils.inverse(ComplexMathUtils.inverse(Z1)), Z1);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testExpLn()
        public virtual void testExpLn()
        {
            assertComplexEquals(ComplexMathUtils.log(ComplexMathUtils.exp(Z1)), Z1);
            //TODO test principal value
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testNull()
        public virtual void testNull()
        {
            try
            {
                ComplexMathUtils.add(null, Z1);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.add(Z1, null);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.add(X, null);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.add(null, X);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.arg(null);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.conjugate(null);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.divide(null, Z1);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.divide(Z1, null);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.divide(X, null);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.divide(null, X);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.exp(null);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.inverse(null);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.log(null);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.mod(null);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.multiply(null, Z1);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.multiply(Z1, null);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.multiply(X, (ComplexNumber)null);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.multiply(null, X);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.pow(null, Z1);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.pow(Z1, null);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.pow(X, null);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.pow(null, X);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.sqrt(null);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.subtract(null, Z1);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.subtract(Z1, null);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.subtract(X, null);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
            try
            {
                ComplexMathUtils.subtract(null, X);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (System.ArgumentException e)
            {
                assertStackTraceElement(e.StackTrace);
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testConjugate()
        public virtual void testConjugate()
        {
            assertComplexEquals(ComplexMathUtils.conjugate(ComplexMathUtils.conjugate(Z1)), Z1);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testAddSubtract()
        public virtual void testAddSubtract()
        {
            assertComplexEquals(ComplexMathUtils.subtract(ComplexMathUtils.add(Z1, Z2), Z2), Z1);
            assertComplexEquals(ComplexMathUtils.subtract(ComplexMathUtils.add(Z1, X), X), Z1);
            assertComplexEquals(ComplexMathUtils.subtract(ComplexMathUtils.add(X, Z1), Z1), X_C);
        }
Exemplo n.º 14
0
 public static ComplexNumber atanh(ComplexNumber z)
 {
     ArgChecker.notNull(z, "z");
     return(ComplexMathUtils.multiply(0.5, ComplexMathUtils.log(ComplexMathUtils.divide(ComplexMathUtils.add(1, z), ComplexMathUtils.subtract(1, z)))));
 }
Exemplo n.º 15
0
 public static ComplexNumber asinh(ComplexNumber z)
 {
     ArgChecker.notNull(z, "z");
     return(ComplexMathUtils.log(ComplexMathUtils.add(z, ComplexMathUtils.sqrt(ComplexMathUtils.add(ComplexMathUtils.multiply(z, z), 1)))));
 }
Exemplo n.º 16
0
 public static ComplexNumber asin(ComplexNumber z)
 {
     ArgChecker.notNull(z, "z");
     return(ComplexMathUtils.multiply(NEGATIVE_I, ComplexMathUtils.log(ComplexMathUtils.add(ComplexMathUtils.multiply(I, z), ComplexMathUtils.sqrt(ComplexMathUtils.subtract(1, ComplexMathUtils.multiply(z, z)))))));
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testArg()
        public virtual void testArg()
        {
            assertEquals(Math.Atan2(W, V), ComplexMathUtils.arg(Z1), EPS);
        }
Exemplo n.º 18
0
        public static ComplexNumber tan(ComplexNumber z)
        {
            ComplexNumber b = ComplexMathUtils.exp(ComplexMathUtils.multiply(ComplexMathUtils.multiply(I, 2), z));

            return(ComplexMathUtils.divide(ComplexMathUtils.subtract(b, 1), ComplexMathUtils.multiply(I, ComplexMathUtils.add(b, 1))));
        }