public void AsinUnnormalValueTest() { MultiPrecision <Pow2.N8>[] vs = new MultiPrecision <Pow2.N8>[] { MultiPrecision <Pow2.N8> .NaN, MultiPrecision <Pow2.N8> .BitDecrement(-1), MultiPrecision <Pow2.N8> .BitIncrement(1), MultiPrecision <Pow2.N8> .PositiveInfinity, MultiPrecision <Pow2.N8> .NegativeInfinity, }; foreach (MultiPrecision <Pow2.N8> v in vs) { MultiPrecision <Pow2.N8> y = MultiPrecision <Pow2.N8> .Asin(v); Assert.IsTrue(y.IsNaN); } }
public void AsinTest() { for (Int64 i = -99; i <= 99; i++) { MultiPrecision <Pow2.N8> x = (MultiPrecision <Pow2.N8>)i / 100; MultiPrecision <Pow2.N8> y = MultiPrecision <Pow2.N8> .Asin(x); Console.WriteLine(x); Console.WriteLine(y); TestTool.Tolerance(Math.Asin((double)x), y); } Assert.IsTrue(MultiPrecision <Pow2.N8> .NearlyEqualBits( MultiPrecision <Pow2.N8> .PI / 4, MultiPrecision <Pow2.N8> .Asin(MultiPrecision <Pow2.N8> .Sqrt2 / 2), 1)); Assert.IsTrue(MultiPrecision <Pow2.N16> .NearlyEqualBits( MultiPrecision <Pow2.N16> .PI / 4, MultiPrecision <Pow2.N16> .Asin(MultiPrecision <Pow2.N16> .Sqrt2 / 2), 1)); }
public void AsinBorderTest() { MultiPrecision <Pow2.N8>[] borders_n8 = new MultiPrecision <Pow2.N8>[] { -MultiPrecision <Pow2.N8> .Ldexp(MultiPrecision <Pow2.N8> .Sqrt2, int.MinValue / 2), -MultiPrecision <Pow2.N8> .Ldexp(MultiPrecision <Pow2.N8> .Sqrt2, -1), 0, MultiPrecision <Pow2.N8> .Ldexp(MultiPrecision <Pow2.N8> .Sqrt2, -1), MultiPrecision <Pow2.N8> .Ldexp(MultiPrecision <Pow2.N8> .Sqrt2, int.MinValue / 2), }; 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> .Asin(x); Console.WriteLine(x); Console.WriteLine(x.ToHexcode()); Console.WriteLine(y); Console.WriteLine(y.ToHexcode()); Console.Write("\n"); TestTool.Tolerance(Math.Asin((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> .Ldexp(MultiPrecision <Pow2.N16> .Sqrt2, int.MinValue / 2), -MultiPrecision <Pow2.N16> .Ldexp(MultiPrecision <Pow2.N16> .Sqrt2, -1), 0, MultiPrecision <Pow2.N16> .Ldexp(MultiPrecision <Pow2.N16> .Sqrt2, -1), MultiPrecision <Pow2.N16> .Ldexp(MultiPrecision <Pow2.N16> .Sqrt2, int.MinValue / 2), }; 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> .Asin(x); Console.WriteLine(x); Console.WriteLine(x.ToHexcode()); Console.WriteLine(y); Console.WriteLine(y.ToHexcode()); Console.Write("\n"); TestTool.Tolerance(Math.Asin((double)x), y); ys.Add(y); } if (b != 0) { TestTool.NearlyNeighbors(ys, 2); } TestTool.SmoothnessSatisfied(ys, 1); TestTool.MonotonicitySatisfied(ys); Console.Write("\n"); } }