daily update on 20230205 by nitload youmu
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
public static unsafe partial class Math
|
||||
{
|
||||
|
||||
|
||||
public static unsafe float ACos(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;
|
||||
}/**/
|
||||
|
||||
v = sign * v * 90 / piby2;
|
||||
|
||||
return 90-v;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ namespace StgSharp
|
||||
public static unsafe partial class Math
|
||||
{
|
||||
|
||||
const float
|
||||
private const float
|
||||
piby2_tail = 7.5497894159e-08f, /* 0x33a22168 */
|
||||
hpiby2_head = 7.8539812565e-01f, /* 0x3f490fda */
|
||||
piby2 = 1.5707963705e+00f; /* 0x3fc90fdb */
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
public static unsafe partial class Math
|
||||
{
|
||||
|
||||
public const float E = 2.718281828f;
|
||||
/// <summary>
|
||||
/// Get the value of E ^ x;
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <returns></returns>
|
||||
public static unsafe float Exp(float x)
|
||||
{
|
||||
if (x == 1)
|
||||
{
|
||||
return E;
|
||||
}
|
||||
if (x == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool sign = false;
|
||||
if (x<0)
|
||||
{
|
||||
sign = true;
|
||||
x = -x;
|
||||
}
|
||||
|
||||
float z = x , t;
|
||||
if (x<0.5f)
|
||||
{
|
||||
t = 1.0f + x * (
|
||||
1.0f + x * (
|
||||
0.5f + x * (
|
||||
0.1666666667f + x * (
|
||||
0.0416666666667f + x *
|
||||
8.333333333e-3f))));
|
||||
}
|
||||
else
|
||||
{
|
||||
uint zBit = *(uint*)&z;
|
||||
uint zBitAbs = zBit & 0b_0111_1111_1111_1111_1111_1111_1111_1111;
|
||||
uint uintm = (zBitAbs >> 23);
|
||||
int m = (*(int*)&uintm) - 126;
|
||||
|
||||
|
||||
uint nBit = (zBitAbs & 0b_0000_0000_0111_1111_1111_1111_1111_1111)
|
||||
+ 0b_0011_1111_0000_0000_0000_0000_0000_0000;
|
||||
float n = *(float*)&nBit - 1;
|
||||
|
||||
t = 2.718281828f + n * (
|
||||
2.718281828f + n * (
|
||||
1.359140914f + n * (
|
||||
0.4530469714f + n * (
|
||||
0.1132617429f + n *
|
||||
0.02265234857f))));
|
||||
|
||||
for (int i = 0; i < m; i++)
|
||||
{
|
||||
t = t * t;
|
||||
}
|
||||
}
|
||||
|
||||
if (sign)
|
||||
{
|
||||
t = 1 / t;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -12,6 +12,13 @@
|
||||
<returns></returns>
|
||||
<exception cref="T:System.ArgumentException"></exception>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Exp(System.Single)">
|
||||
<summary>
|
||||
Get the value of E ^ x;
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.GetBits32(System.Single)">
|
||||
<summary>
|
||||
Get the bits of a float number
|
||||
|
||||
@@ -1 +1 @@
|
||||
d6533ff9d6a5f9bebff84d6c130d7f9b4e85612a
|
||||
57d2afd7a707b689bdeb3640509f8f39355cee04
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -12,6 +12,13 @@
|
||||
<returns></returns>
|
||||
<exception cref="T:System.ArgumentException"></exception>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Exp(System.Single)">
|
||||
<summary>
|
||||
Get the value of E ^ x;
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.GetBits32(System.Single)">
|
||||
<summary>
|
||||
Get the bits of a float number
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -12,7 +12,7 @@ internal class Program
|
||||
/**/
|
||||
|
||||
/*
|
||||
float test = StgSharp.Math.Pow(4.0f,0.125f);
|
||||
float test = StgSharp.Math.ACos(0.5f);
|
||||
Console.WriteLine(test);
|
||||
/**/
|
||||
|
||||
@@ -26,7 +26,7 @@ internal class Program
|
||||
stopwatch.Start(); // 开始监视代码运行时间
|
||||
for (float i = 2; i < time; i++)
|
||||
{
|
||||
a = StgSharp.Math.Pow(i, i);
|
||||
a = StgSharp.Math.ACos(i/500000-1);
|
||||
}
|
||||
stopwatch.Stop(); // 停止监视
|
||||
TimeSpan timespan = stopwatch.Elapsed; // 获取当前实例测量得出的总时间
|
||||
@@ -40,7 +40,7 @@ internal class Program
|
||||
stopwatch1.Start();
|
||||
for (float i = 2; i < time2; i++)
|
||||
{
|
||||
b = System.MathF.Pow(i, i);
|
||||
b = System.MathF.Acos(i / 500000 - 1);
|
||||
}
|
||||
stopwatch1.Stop();
|
||||
timespan = stopwatch1.Elapsed;
|
||||
@@ -51,14 +51,14 @@ internal class Program
|
||||
/**/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
//精度测试
|
||||
double accuracy = 0;
|
||||
for (float i = -10f; i < 2000f; i += 0.01f)
|
||||
for (float i = -10f; i < 200f; i += 0.01f)
|
||||
{
|
||||
|
||||
double r1 = StgSharp.Math.Pow(2,i);
|
||||
double r2 = System.Math.Pow(2,i);
|
||||
double r1 = StgSharp.Math.ACos(i/100);
|
||||
double r2 = 180*System.Math.Acos(i/100)/3.1415926;
|
||||
double ac = ( System.Math.Max(r1,r2)- System.Math.Min(r1, r2) ) / r2;
|
||||
if (ac>accuracy)
|
||||
{
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -12,6 +12,13 @@
|
||||
<returns></returns>
|
||||
<exception cref="T:System.ArgumentException"></exception>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Exp(System.Single)">
|
||||
<summary>
|
||||
Get the value of E ^ x;
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.GetBits32(System.Single)">
|
||||
<summary>
|
||||
Get the bits of a float number
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user