Exemplo n.º 1
0
 public void ComplexLogExp()
 {
     foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-4, 1.0E4, 16))
     {
         Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Exp(ComplexMath.Log(z)), z));
     }
 }
Exemplo n.º 2
0
 public void ComplexLogSpecialValues()
 {
     Assert.IsTrue(ComplexMath.Log(Math.E) == Complex.One);
     Assert.IsTrue(ComplexMath.Log(1.0) == Complex.Zero);
     Assert.IsTrue(ComplexMath.Log(-1.0) == ComplexMath.I * Math.PI);
     Assert.IsTrue(ComplexMath.Log(ComplexMath.I) == ComplexMath.I * Math.PI / 2.0);
     Assert.IsTrue(ComplexMath.Log(-ComplexMath.I) == -ComplexMath.I * Math.PI / 2.0);
 }
Exemplo n.º 3
0
 public void ComplexLogSpecialCase()
 {
     Assert.IsTrue(ComplexMath.Log(Math.E) == 1);
     Assert.IsTrue(ComplexMath.Log(1.0) == 0.0);
     Assert.IsTrue(ComplexMath.Log(-1.0) == ComplexMath.I * Math.PI);
     Assert.IsTrue(ComplexMath.Log(ComplexMath.I) == ComplexMath.I * Math.PI / 2.0);
     Assert.IsTrue(ComplexMath.Log(-ComplexMath.I) == -ComplexMath.I * Math.PI / 2.0);
 }
 public void ComplexLogGammaRecurrance()
 {
     // Don't try for z << 1, because z + 1 won't retain enough digits to satisfy
     foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-2, 1.0E4, 24))
     {
         Assert.IsTrue(TestUtilities.IsNearlyEqual(
                           AdvancedComplexMath.LogGamma(z + 1.0),
                           AdvancedComplexMath.LogGamma(z) + ComplexMath.Log(z)
                           ));
     }
 }
Exemplo n.º 5
0
        public void ComplexRealAgreement()
        {
            foreach (double x in TestUtilities.GenerateRealValues(0.01, 1000.0, 8))
            {
                Assert.IsTrue(ComplexMath.Exp(x) == Math.Exp(x));
                Assert.IsTrue(ComplexMath.Log(x) == Math.Log(x));
                Assert.IsTrue(ComplexMath.Sqrt(x) == Math.Sqrt(x));

                Assert.IsTrue(ComplexMath.Abs(x) == Math.Abs(x));
                Assert.IsTrue(ComplexMath.Arg(x) == 0.0);
            }
        }
Exemplo n.º 6
0
 public void ComplexLogSum()
 {
     Complex[] z = TestUtilities.GenerateComplexValues(1.0E-4, 1.0E4, 10);
     for (int i = 0; i < z.Length; i++)
     {
         for (int j = 0; j < i; j++)
         {
             if (Math.Abs(ComplexMath.Arg(z[i]) + ComplexMath.Arg(z[j])) >= Math.PI)
             {
                 continue;
             }
             Console.WriteLine("{0} {1}", z[i], z[j]);
             Console.WriteLine("ln(z1) + ln(z2) = {0}", ComplexMath.Log(z[i]) + ComplexMath.Log(z[j]));
             Console.WriteLine("ln(z1*z2) = {0}", ComplexMath.Log(z[i] * z[j]));
             Assert.IsTrue(TestUtilities.IsSumNearlyEqual(ComplexMath.Log(z[i]), ComplexMath.Log(z[j]), ComplexMath.Log(z[i] * z[j])));
         }
     }
 }
        public void ComplexDiLogSymmetry()
        {
            foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-2, 1.0E2, 12))
            {
                Assert.IsTrue(TestUtilities.IsSumNearlyEqual(
                                  AdvancedComplexMath.DiLog(z), AdvancedComplexMath.DiLog(-z),
                                  AdvancedComplexMath.DiLog(z * z) / 2.0
                                  ));

                Assert.IsTrue(TestUtilities.IsNearlyEqual(
                                  -AdvancedComplexMath.DiLog(1.0 / z),
                                  AdvancedComplexMath.DiLog(z) + ComplexMath.Log(-z) * ComplexMath.Log(-z) / 2.0 + Math.PI * Math.PI / 6.0
                                  ));

                Assert.IsTrue(TestUtilities.IsNearlyEqual(
                                  -AdvancedComplexMath.DiLog(1.0 - z),
                                  AdvancedComplexMath.DiLog(z) + ComplexMath.Log(z) * ComplexMath.Log(1.0 - z) - Math.PI * Math.PI / 6.0
                                  ));
            }
        }
Exemplo n.º 8
0
 public void ComplexLogExtremeValues()
 {
     Assert.IsTrue(ComplexMath.Log(Double.MaxValue) == Math.Log(Double.MaxValue));
     Assert.IsTrue(Complex.IsNaN(ComplexMath.Log(Double.NaN)));
 }