Ejemplo n.º 1
0
        public void Atan()
        {
            Complex      cd1 = new Complex(1.1, -2.2);
            Complex      cd2 = new Complex(0, -2.2);
            Complex      cd3 = new Complex(1.1, 0);
            Complex      cd4 = new Complex(-1.1, 2.2);
            ComplexFloat cf1 = new ComplexFloat(1.1f, -2.2f);
            ComplexFloat cf2 = new ComplexFloat(0, -2.2f);
            ComplexFloat cf3 = new ComplexFloat(1.1f, 0);
            ComplexFloat cf4 = new ComplexFloat(-1.1f, 2.2f);

            Complex cdt = ComplexMath.Atan(cd1);

            Assert.AreEqual(cdt.Real, 1.365, TOLERENCE);
            Assert.AreEqual(cdt.Imag, -0.366, TOLERENCE);

            cdt = ComplexMath.Atan(cd2);
            Assert.AreEqual(cdt.Real, -1.5708, TOLERENCE);
            Assert.AreEqual(cdt.Imag, -0.490415, TOLERENCE);

            cdt = ComplexMath.Atan(cd3);
            Assert.AreEqual(cdt.Real, 0.833, TOLERENCE);
            Assert.AreEqual(cdt.Imag, 0, TOLERENCE);

            cdt = ComplexMath.Atan(cd4);
            Assert.AreEqual(cdt.Real, -1.365, TOLERENCE);
            Assert.AreEqual(cdt.Imag, 0.366, TOLERENCE);

            ComplexFloat cft = ComplexMath.Atan(cf1);

            Assert.AreEqual(cft.Real, 1.365, TOLERENCE);
            Assert.AreEqual(cft.Imag, -0.366, TOLERENCE);

            cft = ComplexMath.Atan(cf2);
            Assert.AreEqual(cft.Real, -1.571, TOLERENCE);
            Assert.AreEqual(cft.Imag, -0.490, TOLERENCE);

            cft = ComplexMath.Atan(cf3);
            Assert.AreEqual(cft.Real, 0.833, TOLERENCE);
            Assert.AreEqual(cft.Imag, 0, TOLERENCE);

            cft = ComplexMath.Atan(cf4);
            Assert.AreEqual(cft.Real, -1.365, TOLERENCE);
            Assert.AreEqual(cft.Imag, 0.366, TOLERENCE);
        }