Пример #1
0
        public void Theta1ComplexTest()
        {
            var data = new[]
            {
                new Complex(0.325809816971265, 0.370161570985216), new Complex(-0.554674516560841, 0.499945368673331), new Complex(-1.93056857428662, 2.34534826872622), new Complex(-0.1472793517103625, 0.1560224176074929),
                new Complex(0.198956036583271, -1.87317433564776), new Complex(0.000948623894881476, -0.0231214497788391), new Complex(-0.413480618291979, -2.501046888987470), new Complex(0.2310770688461198, -1.0933062123454492),
                new Complex(0.383535878655032, -0.123381469441342), new Complex(-0.0410955986444651, 0.0539153508370558), new Complex(0.3880648652198836, 0.1080708332301739), new Complex(0.3119095691176429, 0.1661628828111056),
                new Complex(1.42936113058871, 1.01544618991625), new Complex(0.0159107820654157, 0.0511556824774055), new Complex(1.333570576905667, 0.614655026222637), new Complex(1.0997563008807847, 0.1208498036545937),
                new Complex(-1.01814545441105, 2.53426831012354), new Complex(-0.000747703469610204, 0.00024075059847843), new Complex(-2.089398894953623, -0.338003060204557), new Complex(-2.031668534521739, -0.493468543237303),
            };

            for (int i = 0; i < data.Length; i += 4)
            {
                var z   = data[i];
                var q   = data[i + 1];
                var th  = Theta.θ1(z, q);
                var err = th - data[i + 2];
                Assert.IsTrue(Complex.Abs(err) < 1e-14);
                var cfn = Theta.θ1ComplexForNome(q);
                th  = cfn(z);
                err = th - data[i + 2];
                Assert.IsTrue(Complex.Abs(err) < 1e-14);
                th  = Theta.θ1(z, q.Real);
                err = th - data[i + 3];
                Assert.IsTrue(Complex.Abs(err) < 1e-15);
            }
        }
Пример #2
0
        public void Theta1DoubleTest()
        {
            var data = new[]
            {
                .12478414350, .82872474670, .0000590523,
                -.32903686210, .95465479750, .0000000045,
                -.32701981860, .41588039490, -0.2933109256,
                .08385962364, .79913716820, 0.000176717,
                1.4888543850, .22263345920, 1.4354035775,
            };

            for (int i = 0; i < data.Length; i += 3)
            {
                var t = Theta.θ1(data[i], data[i + 1]);
                var e = data[i + 2];
                Assert.IsTrue(Math.Abs(t - e) < 1e-10);
                var dfn = Theta.θ1DoubleForNome(data[i + 1]);
                t = dfn(data[i]);
                Assert.IsTrue(Math.Abs(t - e) < 1e-10);
            }
        }
Пример #3
0
        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);
        }