public void ComplexFaddeevaDawson () {
     foreach (double x in TestUtilities.GenerateRealValues(1.0E-4,1.0E4,10)) {
         Complex w = AdvancedComplexMath.Faddeeva(x);
         double F = AdvancedMath.Dawson(x);
         Console.WriteLine("x={0} F={1} w={2}", x, F, w);
         Assert.IsTrue(TestUtilities.IsNearlyEqual(w.Re, Math.Exp(-x * x)));
         Assert.IsTrue(TestUtilities.IsNearlyEqual(w.Im, (2.0/Math.Sqrt(Math.PI)) * AdvancedMath.Dawson(x)));
     }
 }
 public void ComplexFaddeevaConjugation()
 {
     foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-4, 1.0E4, 50))
     {
         if (z.Im * z.Im > Math.Log(Double.MaxValue / 10.0))
         {
             continue;                                                 // large imaginary values blow up
         }
         Assert.IsTrue(TestUtilities.IsNearlyEqual(AdvancedComplexMath.Faddeeva(z.Conjugate), AdvancedComplexMath.Faddeeva(-z).Conjugate));
     }
 }
 public void ComplexErfFaddevaAgreement () {
     foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-1, 1.0E2, 16)) {
         Complex w = AdvancedComplexMath.Faddeeva(z);
         Complex erf = AdvancedComplexMath.Erf(-ComplexMath.I * z);
         Complex erfc = 1.0 - erf;
         Complex f = ComplexMath.Exp(z * z);
         Console.WriteLine("z={0} w={1} erf={2} erfc={3} f={4} w'={5} erf'={6}", z, w, erf, erfc, f, erfc / f, 1.0 - f * w);
         if (Double.IsInfinity(f.Re) || Double.IsInfinity(f.Im) || f == 0.0) continue;
         //Console.WriteLine("{0} {1}", TestUtilities.IsNearlyEqual(w, erfc / f), TestUtilities.IsNearlyEqual(erf, 1.0 - f * w));
         Assert.IsTrue(TestUtilities.IsNearlyEqual(
             erf, 1.0 - f * w
         ));
     }
 }
 public void ComplexFaddeevaSpecialCase()
 {
     Assert.IsTrue(AdvancedComplexMath.Faddeeva(0.0) == 1.0);
 }