diff --git a/源代码/.Net/.vs/ProjectEvaluation/stgsharp.metadata.v5.1 b/源代码/.Net/.vs/ProjectEvaluation/stgsharp.metadata.v5.1 index 2a1ee97f..4a9b61ee 100644 Binary files a/源代码/.Net/.vs/ProjectEvaluation/stgsharp.metadata.v5.1 and b/源代码/.Net/.vs/ProjectEvaluation/stgsharp.metadata.v5.1 differ diff --git a/源代码/.Net/.vs/ProjectEvaluation/stgsharp.projects.v5.1 b/源代码/.Net/.vs/ProjectEvaluation/stgsharp.projects.v5.1 index c64ad54f..a77c3ae5 100644 Binary files a/源代码/.Net/.vs/ProjectEvaluation/stgsharp.projects.v5.1 and b/源代码/.Net/.vs/ProjectEvaluation/stgsharp.projects.v5.1 differ diff --git a/源代码/.Net/.vs/StgSharp/DesignTimeBuild/.dtbcache.v2 b/源代码/.Net/.vs/StgSharp/DesignTimeBuild/.dtbcache.v2 index 078037f8..370e2b8b 100644 Binary files a/源代码/.Net/.vs/StgSharp/DesignTimeBuild/.dtbcache.v2 and b/源代码/.Net/.vs/StgSharp/DesignTimeBuild/.dtbcache.v2 differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/09623af6-e9dc-4965-9c60-43ed5fd6c80f.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/09623af6-e9dc-4965-9c60-43ed5fd6c80f.vsidx deleted file mode 100644 index 50643be2..00000000 Binary files a/源代码/.Net/.vs/StgSharp/FileContentIndex/09623af6-e9dc-4965-9c60-43ed5fd6c80f.vsidx and /dev/null differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/0c69a35f-7728-42b6-9e97-9b5117b130de.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/0c69a35f-7728-42b6-9e97-9b5117b130de.vsidx new file mode 100644 index 00000000..e3f63dda Binary files /dev/null and b/源代码/.Net/.vs/StgSharp/FileContentIndex/0c69a35f-7728-42b6-9e97-9b5117b130de.vsidx differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/28df5e33-198f-4e38-a231-d6aa35d5c0a4.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/28df5e33-198f-4e38-a231-d6aa35d5c0a4.vsidx deleted file mode 100644 index c3a84f1e..00000000 Binary files a/源代码/.Net/.vs/StgSharp/FileContentIndex/28df5e33-198f-4e38-a231-d6aa35d5c0a4.vsidx and /dev/null differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/3fc62930-1055-4b79-8829-37d9ba47c2af.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/3fc62930-1055-4b79-8829-37d9ba47c2af.vsidx deleted file mode 100644 index af653297..00000000 Binary files a/源代码/.Net/.vs/StgSharp/FileContentIndex/3fc62930-1055-4b79-8829-37d9ba47c2af.vsidx and /dev/null differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/63c5d65f-bed4-45a2-aa5a-841441e3a7ef.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/63c5d65f-bed4-45a2-aa5a-841441e3a7ef.vsidx new file mode 100644 index 00000000..c59245f2 Binary files /dev/null and b/源代码/.Net/.vs/StgSharp/FileContentIndex/63c5d65f-bed4-45a2-aa5a-841441e3a7ef.vsidx differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/88d57b05-8cbd-4b0e-b695-81f1dfe9b942.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/88d57b05-8cbd-4b0e-b695-81f1dfe9b942.vsidx deleted file mode 100644 index e7d29428..00000000 Binary files a/源代码/.Net/.vs/StgSharp/FileContentIndex/88d57b05-8cbd-4b0e-b695-81f1dfe9b942.vsidx and /dev/null differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/8d903c73-8770-4bcc-a3e4-51d01a3f8bfe.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/8d903c73-8770-4bcc-a3e4-51d01a3f8bfe.vsidx new file mode 100644 index 00000000..a4569612 Binary files /dev/null and b/源代码/.Net/.vs/StgSharp/FileContentIndex/8d903c73-8770-4bcc-a3e4-51d01a3f8bfe.vsidx differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/9dde3049-e2a8-4228-9241-4e352944ddca.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/9dde3049-e2a8-4228-9241-4e352944ddca.vsidx new file mode 100644 index 00000000..6caa2d26 Binary files /dev/null and b/源代码/.Net/.vs/StgSharp/FileContentIndex/9dde3049-e2a8-4228-9241-4e352944ddca.vsidx differ diff --git a/源代码/.Net/.vs/StgSharp/v17/.futdcache.v2 b/源代码/.Net/.vs/StgSharp/v17/.futdcache.v2 index 4d40db45..00a6ccc0 100644 Binary files a/源代码/.Net/.vs/StgSharp/v17/.futdcache.v2 and b/源代码/.Net/.vs/StgSharp/v17/.futdcache.v2 differ diff --git a/源代码/.Net/.vs/StgSharp/v17/.suo b/源代码/.Net/.vs/StgSharp/v17/.suo index 387aa838..68856f92 100644 Binary files a/源代码/.Net/.vs/StgSharp/v17/.suo and b/源代码/.Net/.vs/StgSharp/v17/.suo differ diff --git a/源代码/.Net/StgSharp/Data/Union4.cs b/源代码/.Net/StgSharp/Data/Union4.cs new file mode 100644 index 00000000..e65e2a80 --- /dev/null +++ b/源代码/.Net/StgSharp/Data/Union4.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Runtime.InteropServices; +using System.Text; + +namespace StgSharp +{ + + //对4字节空间的联合体的C#实现 + [StructLayout(LayoutKind.Explicit, Size = 4)] + public struct Union4 + { + [FieldOffset(0)] + public byte b0; + [FieldOffset(1)] + public byte b1; + [FieldOffset(2)] + public byte b2; + [FieldOffset(3)] + public byte b3; + //得到对应的int值 + [FieldOffset(0)] + public uint i; + //得到对应的float值 + [FieldOffset(0)] + public float f; + + + public Union4(float x, uint y) + { + b0 = 0; + b1 = 0; + b2 = 0; + b3 = 0; + i = 0; + f = x; + y = i; + } + } + + + +} diff --git a/源代码/.Net/StgSharp/Data/Union8.cs b/源代码/.Net/StgSharp/Data/Union8.cs new file mode 100644 index 00000000..1b4d8022 --- /dev/null +++ b/源代码/.Net/StgSharp/Data/Union8.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Runtime.InteropServices; +using System.Text; + +namespace StgSharp +{ + //对8字节空间的联合体的C#实现 + [StructLayout(LayoutKind.Explicit, Size = 8)] + public struct Union8 + { + [FieldOffset(0)] + public byte b0; + [FieldOffset(1)] + public byte b1; + [FieldOffset(2)] + public byte b2; + [FieldOffset(3)] + public byte b3; + //得到对应的int值 + [FieldOffset(0)] + public int i1; + [FieldOffset(4)] + public int i2; + //得到对应的float值 + [FieldOffset(0)] + public double f; + } +} diff --git a/源代码/.Net/StgSharp/Math/ASin.cs b/源代码/.Net/StgSharp/Math/ASin.cs new file mode 100644 index 00000000..32d58b5b --- /dev/null +++ b/源代码/.Net/StgSharp/Math/ASin.cs @@ -0,0 +1,92 @@ + +// some of the code is rewritten from the AMD code: +// https://github.com/amd/aocl-libm-ose/blob/a43e092b03213eb0e129a1cc129900e6e4475778/src/ref/asinf.c + + +using System; +using System.Collections.Generic; +using System.Text; + +namespace StgSharp +{ + public static unsafe partial class Math + { + + const float + piby2_tail = 7.5497894159e-08f, /* 0x33a22168 */ + hpiby2_head = 7.8539812565e-01f, /* 0x3f490fda */ + piby2 = 1.5707963705e+00f; /* 0x3fc90fdb */ + + + /// + /// Reurns the value of ArcSin(x) + /// + /// + /// + /// + public static float ASin(float x ) + { + + int sign = 1; + float y ; + + if (x<0) + { + sign = -1; + y = -x; + } + else + { + y = x; + } + + if ( x>1) + { + throw new ArgumentException(); + } + + float r, s, u, v = 0.0f; + bool transform = (y >= 0.5f); + + if (transform) + { + r = 0.5f * (1.0f - y); + s = StgSharp.Math.Sqrt(r); + y = s; + } + else + { + r = y * y; + } + u= r * (0.184161606965100694821398249421F + + (-0.0565298683201845211985026327361F + + (-0.0133819288943925804214011424456F - + 0.00396137437848476485201154797087F * r) * r) * r) / + (1.10496961524520294485512696706F - + 0.836411276854206731913362287293F * r); + /**/ + + if (transform) + { + float c, s1, p, q; + uint us; + + us = *(uint*)&s; + uint uss = us & 0xffff0000; + s1 = *(float*)&uss; + + c = (r - s1 * s1) / (s + s1); + p = 2.0F * s * u - (piby2_tail - 2.0F * c); + q = hpiby2_head - 2.0F * s1; + v = hpiby2_head - (p - q); + } + else + { + v = y + y * u; + }/**/ + + return sign * v * 90 / piby2; + + } + } +} diff --git a/源代码/.Net/StgSharp/Math/GetBits32.cs b/源代码/.Net/StgSharp/Math/GetBits32.cs new file mode 100644 index 00000000..4a4a631b --- /dev/null +++ b/源代码/.Net/StgSharp/Math/GetBits32.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace StgSharp +{ + public static unsafe partial class Math + { + } +} diff --git a/源代码/.Net/StgSharp/Math/Sqrt.cs b/源代码/.Net/StgSharp/Math/Sqrt.cs index f4757e5e..f659604c 100644 --- a/源代码/.Net/StgSharp/Math/Sqrt.cs +++ b/源代码/.Net/StgSharp/Math/Sqrt.cs @@ -8,7 +8,6 @@ namespace StgSharp public static partial class Math { /*本方法将小数部分统一提升至2^16处后进行线性近似 - const uint sqmov = 0b_0100_0111_1000_0000_0000_0000_0000_0000; const float sqmov1 = 0.0015947f; const float sqmov2 = 156.7673435f; diff --git a/源代码/.Net/StgSharp/bin/Debug/netstandard2.1/StgSharp.dll b/源代码/.Net/StgSharp/bin/Debug/netstandard2.1/StgSharp.dll index 9912dbf5..36083c27 100644 Binary files a/源代码/.Net/StgSharp/bin/Debug/netstandard2.1/StgSharp.dll and b/源代码/.Net/StgSharp/bin/Debug/netstandard2.1/StgSharp.dll differ diff --git a/源代码/.Net/StgSharp/bin/Debug/netstandard2.1/StgSharp.pdb b/源代码/.Net/StgSharp/bin/Debug/netstandard2.1/StgSharp.pdb index bb912343..4bc2c5ce 100644 Binary files a/源代码/.Net/StgSharp/bin/Debug/netstandard2.1/StgSharp.pdb and b/源代码/.Net/StgSharp/bin/Debug/netstandard2.1/StgSharp.pdb differ diff --git a/源代码/.Net/StgSharp/bin/Debug/netstandard2.1/StgSharp.xml b/源代码/.Net/StgSharp/bin/Debug/netstandard2.1/StgSharp.xml index e1d3061b..35df1f26 100644 --- a/源代码/.Net/StgSharp/bin/Debug/netstandard2.1/StgSharp.xml +++ b/源代码/.Net/StgSharp/bin/Debug/netstandard2.1/StgSharp.xml @@ -4,6 +4,14 @@ StgSharp + + + Reurns the value of ArcSin(x) + + + + + diff --git a/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.csproj.CoreCompileInputs.cache b/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.csproj.CoreCompileInputs.cache index 4a5142b4..e48be026 100644 --- a/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.csproj.CoreCompileInputs.cache +++ b/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -db0ba6dd25ed071a0f5414145ab29a83438c6530 +b7317d4b12ba4162c78ad3d204d71202d31826dd diff --git a/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.dll b/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.dll index 9912dbf5..36083c27 100644 Binary files a/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.dll and b/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.dll differ diff --git a/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.pdb b/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.pdb index bb912343..4bc2c5ce 100644 Binary files a/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.pdb and b/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.pdb differ diff --git a/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.xml b/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.xml index e1d3061b..35df1f26 100644 --- a/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.xml +++ b/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.xml @@ -4,6 +4,14 @@ StgSharp + + + Reurns the value of ArcSin(x) + + + + + diff --git a/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/ref/StgSharp.dll b/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/ref/StgSharp.dll index d22f663a..5b3c7474 100644 Binary files a/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/ref/StgSharp.dll and b/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/ref/StgSharp.dll differ diff --git a/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/refint/StgSharp.dll b/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/refint/StgSharp.dll index d22f663a..5b3c7474 100644 Binary files a/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/refint/StgSharp.dll and b/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/refint/StgSharp.dll differ diff --git a/源代码/.Net/StgSharpDebug/Program.cs b/源代码/.Net/StgSharpDebug/Program.cs index 18a335e1..9c92ddc7 100644 --- a/源代码/.Net/StgSharpDebug/Program.cs +++ b/源代码/.Net/StgSharpDebug/Program.cs @@ -11,21 +11,21 @@ internal class Program Console.WriteLine(cc/2); /**/ - /* - Console.WriteLine(StgSharp.Math.Sin(1.06f)); + float test = StgSharp.Math.ASin(StgSharp.Math.Sqrt(3.0f) / 2); + Console.WriteLine(test); /**/ /* for (int wasd = 0; wasd < 100; wasd++) { float time = 1000000; - double a = 114514; + float a = 114514; System.Diagnostics.Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); // 开始监视代码运行时间 for (float i = 2; i < time; i++) { - a = StgSharp.Math.Tan(i); + a = StgSharp.Math.ASin(i/(time/2)-1); } stopwatch.Stop(); // 停止监视 TimeSpan timespan = stopwatch.Elapsed; // 获取当前实例测量得出的总时间 @@ -37,9 +37,9 @@ internal class Program double b = 114514; double time2 = time; stopwatch1.Start(); - for (double i = 2; i < time2; i++) + for (float i = 2; i < time2; i++) { - b = System.Math.Tan(i); + b = System.MathF.Asin(i / (time / 2) - 1); } stopwatch1.Stop(); timespan = stopwatch1.Elapsed; @@ -49,12 +49,13 @@ internal class Program } /**/ - + /* double accuracy = 0; - for (float i = 1f; i < 4000000; i += 1f) + for (float i = -1f; i < 1f; i += 0.000001f) { - double r1 = StgSharp.Math.Sin(i); - double r2 = System.Math.Sin(i * ( 2 * System.Math.PI) / 360); + + double r1 = StgSharp.Math.ASin(i); + double r2 = System.Math.Asin(i)*180/3.1415926; double ac = ( System.Math.Max(r1,r2)- System.Math.Min(r1, r2) ) / r2; if (ac>accuracy) { diff --git a/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharp.dll b/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharp.dll index 9912dbf5..36083c27 100644 Binary files a/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharp.dll and b/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharp.dll differ diff --git a/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharp.pdb b/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharp.pdb index bb912343..4bc2c5ce 100644 Binary files a/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharp.pdb and b/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharp.pdb differ diff --git a/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharp.xml b/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharp.xml index e1d3061b..35df1f26 100644 --- a/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharp.xml +++ b/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharp.xml @@ -4,6 +4,14 @@ StgSharp + + + Reurns the value of ArcSin(x) + + + + + diff --git a/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharpDebug.dll b/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharpDebug.dll index ce7b097b..52b3e595 100644 Binary files a/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharpDebug.dll and b/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharpDebug.dll differ diff --git a/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharpDebug.pdb b/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharpDebug.pdb index 9bace438..bd5bdf1f 100644 Binary files a/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharpDebug.pdb and b/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharpDebug.pdb differ diff --git a/源代码/.Net/StgSharpDebug/obj/Debug/net6.0/StgSharpDebug.csproj.AssemblyReference.cache b/源代码/.Net/StgSharpDebug/obj/Debug/net6.0/StgSharpDebug.csproj.AssemblyReference.cache index 5e402412..b795883a 100644 Binary files a/源代码/.Net/StgSharpDebug/obj/Debug/net6.0/StgSharpDebug.csproj.AssemblyReference.cache and b/源代码/.Net/StgSharpDebug/obj/Debug/net6.0/StgSharpDebug.csproj.AssemblyReference.cache differ diff --git a/源代码/.Net/StgSharpDebug/obj/Debug/net6.0/StgSharpDebug.dll b/源代码/.Net/StgSharpDebug/obj/Debug/net6.0/StgSharpDebug.dll index ce7b097b..52b3e595 100644 Binary files a/源代码/.Net/StgSharpDebug/obj/Debug/net6.0/StgSharpDebug.dll and b/源代码/.Net/StgSharpDebug/obj/Debug/net6.0/StgSharpDebug.dll differ diff --git a/源代码/.Net/StgSharpDebug/obj/Debug/net6.0/StgSharpDebug.pdb b/源代码/.Net/StgSharpDebug/obj/Debug/net6.0/StgSharpDebug.pdb index 9bace438..bd5bdf1f 100644 Binary files a/源代码/.Net/StgSharpDebug/obj/Debug/net6.0/StgSharpDebug.pdb and b/源代码/.Net/StgSharpDebug/obj/Debug/net6.0/StgSharpDebug.pdb differ