public void AtanTest() { foreach (MultiPrecision <Pow2.N8> x in TestTool.AllRangeSet <Pow2.N8>()) { MultiPrecision <Pow2.N8> y = MultiPrecision <Pow2.N8> .Atan(x); Console.WriteLine(x); Console.WriteLine(y); TestTool.Tolerance(Math.Atan((double)x), y); } Assert.IsTrue(MultiPrecision <Pow2.N8> .NearlyEqualBits( MultiPrecision <Pow2.N8> .PI / 4, MultiPrecision <Pow2.N8> .Atan(1), 1)); Assert.IsTrue(MultiPrecision <Pow2.N16> .NearlyEqualBits( MultiPrecision <Pow2.N16> .PI / 4, MultiPrecision <Pow2.N16> .Atan(1), 1)); }
public void AtanUnnormalValueTest() { MultiPrecision <Pow2.N8> y = MultiPrecision <Pow2.N8> .Atan(MultiPrecision <Pow2.N8> .NaN); Assert.IsTrue(y.IsNaN); }
public void AtanBorderTest() { MultiPrecision <Pow2.N8>[] borders_n8 = new MultiPrecision <Pow2.N8>[] { MultiPrecision <Pow2.N8> .NegativeInfinity, -2, -1, -MultiPrecision <Pow2.N8> .Ldexp(1, int.MinValue / 2), 0, +MultiPrecision <Pow2.N8> .Ldexp(1, int.MinValue / 2), 1, 2, MultiPrecision <Pow2.N8> .PositiveInfinity }; foreach (MultiPrecision <Pow2.N8> b in borders_n8) { List <MultiPrecision <Pow2.N8> > ys = new(); foreach (MultiPrecision <Pow2.N8> x in TestTool.EnumerateNeighbor(b)) { MultiPrecision <Pow2.N8> y = MultiPrecision <Pow2.N8> .Atan(x); Console.WriteLine(x); Console.WriteLine(x.ToHexcode()); Console.WriteLine(y); Console.WriteLine(y.ToHexcode()); Console.Write("\n"); TestTool.Tolerance(Math.Atan((double)x), y); ys.Add(y); } if (b != 0) { TestTool.NearlyNeighbors(ys, 2); } TestTool.SmoothnessSatisfied(ys, 1); TestTool.MonotonicitySatisfied(ys); Console.Write("\n"); } MultiPrecision <Pow2.N16>[] borders_n16 = new MultiPrecision <Pow2.N16>[] { MultiPrecision <Pow2.N16> .NegativeInfinity, -2, -1, -MultiPrecision <Pow2.N16> .Ldexp(1, int.MinValue / 2), 0, +MultiPrecision <Pow2.N16> .Ldexp(1, int.MinValue / 2), 1, 2, MultiPrecision <Pow2.N16> .PositiveInfinity }; foreach (MultiPrecision <Pow2.N16> b in borders_n16) { List <MultiPrecision <Pow2.N16> > ys = new(); foreach (MultiPrecision <Pow2.N16> x in TestTool.EnumerateNeighbor(b)) { MultiPrecision <Pow2.N16> y = MultiPrecision <Pow2.N16> .Atan(x); Console.WriteLine(x); Console.WriteLine(x.ToHexcode()); Console.WriteLine(y); Console.WriteLine(y.ToHexcode()); Console.Write("\n"); TestTool.Tolerance(Math.Atan((double)x), y); ys.Add(y); } if (b != 0) { TestTool.NearlyNeighbors(ys, 2); } TestTool.SmoothnessSatisfied(ys, 1); TestTool.MonotonicitySatisfied(ys); Console.Write("\n"); } }