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 Theta2ComplexAtZeroTest() { var data = new[] { new Complex(0.0115779438837883, 0.00215513498962569), new Complex(0.0251305156397967, -0.0159972042786677), new Complex(0.212623597863526, -0.480192562215063), new Complex(-0.018128943757431, 0.175402508876567), new Complex(0.0974889810203627, -0.317370944403016), }; var ans = new[] { "0.6582370796109659+0.0303389984653170 i", "0.8227835878337571-0.1180651209669994 i", "1.252099829145631-0.757243748784380 i", "1.1514971709760006+0.5030378061113643 i", "1.2808167514270764-0.5228813837190602 i", }; for (int i = 0; i < data.Length; i++) { var q = data[i]; var th = Theta.θ2(0, q); var ex = Parse(ans[i]); var err = th - ex; Assert.IsTrue(Complex.Abs(err) < 1e-15); } }
public void Theta2ComplexDoubleTest() { var data = new[] { -0.712045573932278, 1.30561516966583, 0.0115779438837883, -1.02921651633888, -0.55663233114557, 0.0251305156397967, -0.270601468194827, -0.958161202750493, 0.212623597863526, 2.06182432952114, 0.605868394894129, -0.018128943757431, -0.0161641166929001, 1.12406115610682, 0.0974889810203627, }; var ans = new[] { "0.982419608291746+0.734637332793804 i", "0.47435925857122-0.39980828620516 i", "2.3339170647049-0.80428867268903 i", "0.004025373680221-0.5849390348420 i", "2.05576743007898+0.0323625056143800 i", }; for (int i = 0; i < data.Length; i += 3) { var z = new Complex(data[i], data[i + 1]); var q = data[i + 2]; var th = Theta.θ2(z, q); var ex = Parse(ans[i / 3]); var err = th - ex; Assert.IsTrue(Complex.Abs(err) < 1e-13); } }
public void Theta2DoubleTest() { var data = new[] { -0.712045573932278, 0.0115779438837883, 0.496601444431198, -1.02921651633888, 0.0251305156397967, 0.409986239688389, -0.270601468194827, 0.212623597863526, 1.35096326526392, 2.06182432952114, 0.018128943757431, -0.3458068199639, -0.0161641166929001, 0.0974889810203627, 1.128018761735100, }; for (int i = 0; i < data.Length; i += 3) { var z = data[i]; var q = data[i + 1]; var th = Theta.θ2(z, q); var ex = data[i + 2]; var err = th - ex; Assert.IsTrue(Complex.Abs(err) < 1e-14); var tf = Theta.θ2DoubleForNome(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); }