Beispiel #1
0
        public void JacobiMultiComplexTest()
        {
            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[]
            {
                .82872474670,
                .95465479750,
                .41588039490,
                .79913716820,
                .22263345920,
            };

            var cn_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",
            };

            var sn_ans = new[] {
                "0.011577520035845973+0.002154873907338315 i",
                "0.02513162775967239-0.01598866500104887 i",
                "1.0366906460437097-0.0928117050540744 i",
                "-0.9833652385779392+0.0168760678403997 i",
                "0.8497782949947773+0.1722870976144199 i",
            };

            var dn_ans = new[] {
                "0.9999463821545492-0.0000206762130171 i",
                "0.9998206008771541+0.0003836693444763 i",
                "0.7479880904783000+0.0534965402190790 i",
                "0.4777309286723279+0.0277602955990134 i",
                "0.9203769973939489-0.0354146592336434 i",
            };

            for (int i = 0; i < z.Length; i++)
            {
                var mt = Jacobi.Multi(z[i], m[i]);
                var ex = Parse(cn_ans[i]);
                Assert.IsTrue(Complex.Abs(mt.cn - ex) < 1e-15);
                ex = Parse(sn_ans[i]);
                Assert.IsTrue(Complex.Abs(mt.sn - ex) < 1e-15);
                ex = Parse(dn_ans[i]);
                Assert.IsTrue(Complex.Abs(mt.dn - ex) < 1e-15);
                var f   = Jacobi.MultiComplex(m[i]);
                var mtf = f(z[i]);
                Assert.AreEqual(mt.sn, mtf.sn);
                Assert.AreEqual(mt.cn, mtf.cn);
                Assert.AreEqual(mt.dn, mtf.dn);
            }
        }
Beispiel #2
0
 public void JacobiMultiDoubleTest()
 {
     for (int i = 0; i < jacobiData.Length; i += 5)
     {
         var z     = jacobiData[i];
         var m     = jacobiData[i + 1];
         var cn    = jacobiData[i + 2];
         var sn    = jacobiData[i + 3];
         var dn    = jacobiData[i + 4];
         var multi = Jacobi.Multi(z, m);
         Assert.IsTrue(Math.Abs(cn - multi.cn) < 1e-14);
         Assert.IsTrue(Math.Abs(sn - multi.sn) < 1e-14);
         Assert.IsTrue(Math.Abs(dn - multi.dn) < 1e-14);
         var fm = Jacobi.MultiDouble(m);
         var m2 = fm(z);
         Assert.AreEqual(multi.cn, m2.cn);
         Assert.AreEqual(multi.sn, m2.sn);
         Assert.AreEqual(multi.dn, m2.dn);
     }
 }