public void Theta2ComplexTest() { var data = new[] { new Complex(-0.712045573932278, 1.30561516966583), new Complex(0.0115779438837883, 0.00215513498962569), new Complex(-1.02921651633888, -0.55663233114557), new Complex(0.0251305156397967, -0.0159972042786677), new Complex(-0.270601468194827, -0.958161202750493), new Complex(0.212623597863526, -0.480192562215063), new Complex(2.06182432952114, 0.605868394894129), new Complex(-0.018128943757431, 0.175402508876567), new Complex(-0.0161641166929001, 1.12406115610682), new Complex(0.0974889810203627, -0.317370944403016), }; var ans = new[] { "0.9510034016694605+0.7818307996124119 i", "0.4318298974220141-0.4811293513824665 i", "-3.491983713766145-1.639180977911250 i", "-0.4606794630399191-1.0510325356860531 i", "0.141664390294264-1.839493486453470 i", }; for (int i = 0; i < data.Length; i += 2) { var z = data[i]; var q = data[i + 1]; var th = Theta.θ2(z, q); var ex = Parse(ans[i / 2]); var err = th - ex; Assert.IsTrue(Complex.Abs(err) < 1e-14); var tf = Theta.θ2ComplexForNome(q); th = tf(z); err = th - ex; Assert.IsTrue(Complex.Abs(err) < 1e-14); } }
public void ThetasAtZeroTest() { Complex th; double ex = 0.0; th = Theta.θ1(Complex.Zero, (Complex)(.5)); Assert.AreEqual(0, th.Imaginary); Assert.AreEqual(ex, th.Real); th = Theta.θ1(Complex.Zero, .5); Assert.AreEqual(0, th.Imaginary); Assert.AreEqual(ex, th.Real); th = Theta.θ1(0, .5); Assert.AreEqual(0, th.Imaginary); Assert.AreEqual(ex, th.Real); th = Theta.θ1ComplexForNome(.5)(0); Assert.AreEqual(0, th.Imaginary); Assert.AreEqual(ex, th.Real); th = Theta.θ1DoubleForNome(.5)(0); Assert.AreEqual(0, th.Imaginary); Assert.AreEqual(ex, th.Real); ex = 2.12893125051303; th = Theta.θ2(Complex.Zero, (Complex)(.5)); Assert.AreEqual(0, th.Imaginary); Assert.IsTrue(Math.Abs(ex - th.Real) < 1e-14); th = Theta.θ2(Complex.Zero, .5); Assert.AreEqual(0, th.Imaginary); Assert.IsTrue(Math.Abs(ex - th.Real) < 1e-14); th = Theta.θ2(0, .5); Assert.AreEqual(0, th.Imaginary); Assert.IsTrue(Math.Abs(ex - th.Real) < 1e-14); th = Theta.θ2ComplexForNome(.5)(0); Assert.AreEqual(0, th.Imaginary); Assert.IsTrue(Math.Abs(ex - th.Real) < 1e-14); th = Theta.θ2DoubleForNome(.5)(0); Assert.AreEqual(0, th.Imaginary); Assert.IsTrue(Math.Abs(ex - th.Real) < 1e-14); ex = 2.12893682721188; th = Theta.θ3(Complex.Zero, (Complex)(.5)); Assert.AreEqual(0, th.Imaginary); Assert.IsTrue(Math.Abs(ex - th.Real) < 1e-14); th = Theta.θ3(Complex.Zero, .5); Assert.AreEqual(0, th.Imaginary); Assert.IsTrue(Math.Abs(ex - th.Real) < 1e-14); th = Theta.θ3(0, .5); Assert.AreEqual(0, th.Imaginary); Assert.IsTrue(Math.Abs(ex - th.Real) < 1e-14); th = Theta.θ3ComplexForNome(.5)(0); Assert.AreEqual(0, th.Imaginary); Assert.IsTrue(Math.Abs(ex - th.Real) < 1e-14); th = Theta.θ3DoubleForNome(.5)(0); Assert.AreEqual(0, th.Imaginary); Assert.IsTrue(Math.Abs(ex - th.Real) < 1e-14); ex = 0.121124208002581; th = Theta.θ4(Complex.Zero, (Complex)(.5)); Assert.AreEqual(0, th.Imaginary); Assert.IsTrue(Math.Abs(ex - th.Real) < 1e-14); th = Theta.θ4(Complex.Zero, .5); Assert.AreEqual(0, th.Imaginary); Assert.IsTrue(Math.Abs(ex - th.Real) < 1e-14); th = Theta.θ4(0, .5); Assert.AreEqual(0, th.Imaginary); Assert.IsTrue(Math.Abs(ex - th.Real) < 1e-14); th = Theta.θ4ComplexForNome(.5)(0); Assert.AreEqual(0, th.Imaginary); Assert.IsTrue(Math.Abs(ex - th.Real) < 1e-14); th = Theta.θ4DoubleForNome(.5)(0); Assert.AreEqual(0, th.Imaginary); Assert.IsTrue(Math.Abs(ex - th.Real) < 1e-14); }