diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/09623af6-e9dc-4965-9c60-43ed5fd6c80f.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/09623af6-e9dc-4965-9c60-43ed5fd6c80f.vsidx new file mode 100644 index 00000000..50643be2 Binary files /dev/null and b/源代码/.Net/.vs/StgSharp/FileContentIndex/09623af6-e9dc-4965-9c60-43ed5fd6c80f.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 new file mode 100644 index 00000000..c3a84f1e Binary files /dev/null and b/源代码/.Net/.vs/StgSharp/FileContentIndex/28df5e33-198f-4e38-a231-d6aa35d5c0a4.vsidx differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/3527821b-cf30-4a7f-8830-13da7b13bb36.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/3527821b-cf30-4a7f-8830-13da7b13bb36.vsidx deleted file mode 100644 index 38b22b83..00000000 Binary files a/源代码/.Net/.vs/StgSharp/FileContentIndex/3527821b-cf30-4a7f-8830-13da7b13bb36.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 new file mode 100644 index 00000000..af653297 Binary files /dev/null and b/源代码/.Net/.vs/StgSharp/FileContentIndex/3fc62930-1055-4b79-8829-37d9ba47c2af.vsidx differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/444ccc36-99b0-40c9-ae55-d3e84d10bc98.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/444ccc36-99b0-40c9-ae55-d3e84d10bc98.vsidx deleted file mode 100644 index f9976564..00000000 Binary files a/源代码/.Net/.vs/StgSharp/FileContentIndex/444ccc36-99b0-40c9-ae55-d3e84d10bc98.vsidx and /dev/null 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 new file mode 100644 index 00000000..e7d29428 Binary files /dev/null and b/源代码/.Net/.vs/StgSharp/FileContentIndex/88d57b05-8cbd-4b0e-b695-81f1dfe9b942.vsidx differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/b04ebd94-63d0-47f0-9c17-c1befe7f3c7e.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/b04ebd94-63d0-47f0-9c17-c1befe7f3c7e.vsidx deleted file mode 100644 index cc479817..00000000 Binary files a/源代码/.Net/.vs/StgSharp/FileContentIndex/b04ebd94-63d0-47f0-9c17-c1befe7f3c7e.vsidx and /dev/null differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/d0f7b73f-18c1-4f4a-b8a1-12a5f7b34034.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/d0f7b73f-18c1-4f4a-b8a1-12a5f7b34034.vsidx deleted file mode 100644 index c397e0ad..00000000 Binary files a/源代码/.Net/.vs/StgSharp/FileContentIndex/d0f7b73f-18c1-4f4a-b8a1-12a5f7b34034.vsidx and /dev/null differ diff --git a/源代码/.Net/.vs/StgSharp/v17/.suo b/源代码/.Net/.vs/StgSharp/v17/.suo index 42847c4f..387aa838 100644 Binary files a/源代码/.Net/.vs/StgSharp/v17/.suo and b/源代码/.Net/.vs/StgSharp/v17/.suo differ diff --git a/源代码/.Net/StgSharp/Math/Cos.cs b/源代码/.Net/StgSharp/Math/Cos.cs new file mode 100644 index 00000000..0ea99d07 --- /dev/null +++ b/源代码/.Net/StgSharp/Math/Cos.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace StgSharp +{ + public static partial class Math + { + + public static float Cos(float x) + { + float refer = x / 360.0f; + refer -= (int)refer; + + refer *= 40; + int a = (int)refer; //大分度,查表 + refer -= a; //小分度,拟合 + + float refer2 = refer * refer; + + + return -sinData[a] * (0.1570796327f * refer - 6.459640975e-4f * refer * refer2) + + cosData[a] * (1 - 0.0123370055f * refer2 + 2.536695709e-5f * refer2 * refer2); + } + } +} diff --git a/源代码/.Net/StgSharp/Math/Log.cs b/源代码/.Net/StgSharp/Math/Log.cs index 659a7a9e..1b1bf56c 100644 --- a/源代码/.Net/StgSharp/Math/Log.cs +++ b/源代码/.Net/StgSharp/Math/Log.cs @@ -39,7 +39,10 @@ namespace StgSharp /// public unsafe static float Log(float x) { - + if (x<0) + { + throw new ArgumentException(); + } uint input = *(uint*)&x; uint f = input; @@ -62,6 +65,13 @@ namespace StgSharp result + logArray[order]; } - + + + public static float Log(float x, float y) + { + return Log(x)/Log(y); + } + + } } diff --git a/源代码/.Net/StgSharp/Math/Sin.cs b/源代码/.Net/StgSharp/Math/Sin.cs index 5fba4d94..24753133 100644 --- a/源代码/.Net/StgSharp/Math/Sin.cs +++ b/源代码/.Net/StgSharp/Math/Sin.cs @@ -6,6 +6,47 @@ namespace StgSharp { public static partial class Math { + private static readonly float[] sinData = + { + 0f, 0.15643446239373f, 0.309016989278255f, 0.453990492577218f, 0.587785243621462f, + 0.707106771713121f, 0.80901698492516f, 0.891006515673128f, 0.951056509671091f, 0.987688336822657f, + 1f, 0.987688345205947f, 0.951056526231247f, 0.891006540002384f, 0.80901701642445f, + 0.707106809606826f, 0.587785286976515f, 0.453990540326073f, 0.309017040245177f, 0.156434515323744f, + 5.35897931701074E-08f, -0.156434409463716f, -0.309016938311333f, -0.453990444828362f, -0.587785200266408f, + -0.707106733819413f, -0.809016953425868f, -0.891006491343869f, -0.951056493110931f, -0.987688328439363f, + -0.999999999999997f, -0.987688353589235f, -0.951056542791401f, -0.891006564331638f, -0.809017047923737f, + -0.70710684750053f, -0.587785330331566f, -0.453990588074927f, -0.309017091212098f, -0.156434568253757f, + + }; + private static readonly float[] cosData = + { + 1f, 0.987688341014302f, 0.951056517951169f, 0.891006527837756f, 0.809017000674805f, + 0.707106790659974f, 0.587785265298989f, 0.453990516451646f, 0.309017014761716f, 0.156434488858737f, + 2.67948965850537E-08f, -0.156434435928723f, -0.309016963794794f, -0.453990468702791f, -0.587785221943935f, + -0.707106752766267f, -0.809016969175515f, -0.891006503508499f, -0.951056501391011f, -0.98768833263101f, + -0.999999999999999f, -0.987688349397591f, -0.951056534511324f, -0.891006552167012f, -0.809017032174094f, + -0.707106828553679f, -0.587785308654041f, -0.4539905642005f, -0.309017065728638f, -0.156434541788751f, + -8.03846893110719E-08f, 0.156434382998709f, 0.309016912827872f, 0.453990420953934f, 0.58778517858888f, + 0.707106714872559f, 0.809016937676222f, 0.891006479179238f, 0.951056484830851f, 0.987688324247716f, + + + }; + + public static unsafe float Sin(float x) + { + float refer = x / 360.0f; + refer -= (int)refer; + + refer *= 40; + int a = (int)refer; //大分度,查表 + refer -= a; //小分度,拟合 + + float refer2 = refer * refer; + + + return sinData[a]*(1 - 0.0123370055f * refer2 + 2.536695709e-5f * refer2 * refer2 ) + + cosData[a] * (0.1570796327f * refer - 6.459640975e-4f * refer * refer2); + } } } diff --git a/源代码/.Net/StgSharp/Math/Tan.cs b/源代码/.Net/StgSharp/Math/Tan.cs new file mode 100644 index 00000000..ccea7a1b --- /dev/null +++ b/源代码/.Net/StgSharp/Math/Tan.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace StgSharp +{ + public static partial class Math + { + + public static float Tan(float x) + { + float refer = x / 360.0f; + refer -= (int)refer; + + refer *= 40; + int a = (int)refer; //大分度,查表 + refer -= a; //小分度,拟合 + + float refer2 = refer * refer; + + float sin = (0.1570796327f * refer - 6.459640975e-4f * refer * refer2); + float cos = (1 - 0.0123370055f * refer2 + 2.536695709e-5f * refer2 * refer2); + + return ( sinData[a] * cos + cosData[a] * sin ) + / ( cosData[a] * cos - sinData[a] * sin ); + } + } +} diff --git a/源代码/.Net/StgSharp/bin/Debug/netstandard2.1/StgSharp.dll b/源代码/.Net/StgSharp/bin/Debug/netstandard2.1/StgSharp.dll index 9f9e90af..9912dbf5 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 afe20f70..bb912343 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/obj/Debug/netstandard2.1/StgSharp.csproj.CoreCompileInputs.cache b/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.csproj.CoreCompileInputs.cache index 1061b93d..4a5142b4 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 @@ -9f6c1da9ad577916e70408e10ff0292581a33dcb +db0ba6dd25ed071a0f5414145ab29a83438c6530 diff --git a/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.dll b/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/StgSharp.dll index 9f9e90af..9912dbf5 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 afe20f70..bb912343 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/ref/StgSharp.dll b/源代码/.Net/StgSharp/obj/Debug/netstandard2.1/ref/StgSharp.dll index 42ae5a46..d22f663a 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 42ae5a46..d22f663a 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 c1e6ff65..18a335e1 100644 --- a/源代码/.Net/StgSharpDebug/Program.cs +++ b/源代码/.Net/StgSharpDebug/Program.cs @@ -11,14 +11,12 @@ internal class Program Console.WriteLine(cc/2); /**/ + /* - float aa = 261.2776027f; - uint bb = *(uint*)&aa; - Console.WriteLine(Convert.ToString(bb,toBase:2)); - Console.WriteLine(StgSharp.Math.Log(3.5f)); + Console.WriteLine(StgSharp.Math.Sin(1.06f)); /**/ - + /* for (int wasd = 0; wasd < 100; wasd++) { float time = 1000000; @@ -27,7 +25,7 @@ internal class Program stopwatch.Start(); // 开始监视代码运行时间 for (float i = 2; i < time; i++) { - a = StgSharp.Math.Log(i); + a = StgSharp.Math.Tan(i); } stopwatch.Stop(); // 停止监视 TimeSpan timespan = stopwatch.Elapsed; // 获取当前实例测量得出的总时间 @@ -41,7 +39,7 @@ internal class Program stopwatch1.Start(); for (double i = 2; i < time2; i++) { - b = System.Math.Log(i); + b = System.Math.Tan(i); } stopwatch1.Stop(); timespan = stopwatch1.Elapsed; @@ -51,13 +49,13 @@ internal class Program } /**/ - /* + double accuracy = 0; - for (float i = 1.001f; i < 4; i += 0.001f) + for (float i = 1f; i < 4000000; i += 1f) { - double r1 = StgSharp.Math.Log(i); - double r2 = System.Math.Log(i); - double ac = ( System.Math.Max(r1,r2)- System.Math.Min(r1, r2) ) / System.Math.Max(r1, r2); + double r1 = StgSharp.Math.Sin(i); + double r2 = System.Math.Sin(i * ( 2 * System.Math.PI) / 360); + double ac = ( System.Math.Max(r1,r2)- System.Math.Min(r1, r2) ) / r2; if (ac>accuracy) { accuracy = ac; @@ -70,6 +68,8 @@ internal class Program } Console.WriteLine(accuracy); /**/ + + } diff --git a/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharp.dll b/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharp.dll index 9f9e90af..9912dbf5 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 afe20f70..bb912343 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/StgSharpDebug.dll b/源代码/.Net/StgSharpDebug/bin/Debug/net6.0/StgSharpDebug.dll index 28328832..ce7b097b 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 8e292bdc..9bace438 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 a1e21241..5e402412 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 28328832..ce7b097b 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 8e292bdc..9bace438 100644 Binary files a/源代码/.Net/StgSharpDebug/obj/Debug/net6.0/StgSharpDebug.pdb and b/源代码/.Net/StgSharpDebug/obj/Debug/net6.0/StgSharpDebug.pdb differ