public void JacobiCnDoubleArgTest() { for (int i = 0; i < jacobiData.Length; i += 5) { var z = jacobiData[i]; var m = jacobiData[i + 1]; var ex = jacobiData[i + 2]; var cn = Jacobi.cn(z, m); var err = Math.Abs(ex - cn) / Math.Abs(ex); Assert.IsTrue(err < 1e-15); var f = Jacobi.cnDouble(m); var cn2 = f(z); Assert.AreEqual(cn, cn2); } }
public void JacobiCnComplexArgTest() { var z = new[] { new Complex(0.0115779438837883, 0.00215513498962569), new Complex(0.0251305156397967, -0.0159972042786677), new Complex(2.12623597863526, 0.480192562215063), new Complex(-1.8128943757431, 0.175402508876567), new Complex(0.974889810203627, 0.317370944403016), }; var m = new[] { .8287247467, .9546547975, .4158803949, .7991371682, .2226334592, }; var ans = new[] { "0.9999353004739177-0.0000249497100713 i", "0.9998120824513089+0.0004018967006233 i", "-0.2620696287961345-0.3671429875904256 i", "0.2003469806496059+0.0828329851756354 i", "0.6050679400137476-0.2419659452739375 i", }; for (int i = 0; i < z.Length; i++) { var cn = Jacobi.cn(z[i], m[i]); var ex = Parse(ans[i]); Assert.IsTrue(Complex.Abs(cn - ex) < 1e-15); var cc = Jacobi.cnComplex(m[i]); cn = cc(z[i]); Assert.IsTrue(Complex.Abs(cn - ex) < 1e-15); } }