Daily update on 20250618-051714 by Nitload Youmu. Additional Message : Brief support to collection operation in EXPRESS. A collection type added in core lib and compilestack.
Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
@@ -41,11 +41,17 @@ namespace StgSharp.Math
|
||||
piby2 = 1.5707963705e+00f; /* 0x3fc90fdb */
|
||||
|
||||
/// <summary>
|
||||
/// Reurns the value of ArcSin(x)
|
||||
/// Reurns the value of ArcSin(x)
|
||||
/// </summary>
|
||||
/// <param _name="x"> The sine value of the angle </param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
/// <param _label="x">
|
||||
/// The sine value of the angle
|
||||
/// </param>
|
||||
/// <returns>
|
||||
///
|
||||
/// </returns>
|
||||
/// <exception cref="ArgumentException">
|
||||
///
|
||||
/// </exception>
|
||||
public static float ASin( float x )
|
||||
{
|
||||
return MathF.Asin( x );
|
||||
|
||||
@@ -53,8 +53,7 @@ namespace StgSharp.Math
|
||||
return *( int* )a;
|
||||
}
|
||||
|
||||
internal static string GetListSeparator(
|
||||
IFormatProvider formatProvider )
|
||||
internal static string GetListSeparator( IFormatProvider formatProvider )
|
||||
{
|
||||
if( formatProvider is CultureInfo cultureInfo ) {
|
||||
return cultureInfo.TextInfo.ListSeparator;
|
||||
|
||||
@@ -42,7 +42,8 @@ namespace StgSharp.Math
|
||||
public static float MaxOf( params float[] stream )
|
||||
{
|
||||
float ret = stream[ 0 ];
|
||||
foreach( float num in stream ) {
|
||||
foreach( float num in stream )
|
||||
{
|
||||
if( ret < num ) {
|
||||
ret = num;
|
||||
}
|
||||
@@ -53,7 +54,8 @@ namespace StgSharp.Math
|
||||
public static float MinOf( params float[] stream )
|
||||
{
|
||||
float ret = stream[ 0 ];
|
||||
foreach( float num in stream ) {
|
||||
foreach( float num in stream )
|
||||
{
|
||||
if( ret > num ) {
|
||||
ret = num;
|
||||
}
|
||||
|
||||
@@ -47,16 +47,13 @@ namespace StgSharp.Math
|
||||
|
||||
[DllImport( "Kernel32.dll", EntryPoint = "VirtualAlloc" )]
|
||||
private static extern IntPtr VirtualAlloc(
|
||||
IntPtr address,
|
||||
int size,
|
||||
uint allocType,
|
||||
uint protect );
|
||||
IntPtr address,
|
||||
int size,
|
||||
uint allocType,
|
||||
uint protect );
|
||||
|
||||
[DllImport( "Kernel32.dll", EntryPoint = "VirtualFree" )]
|
||||
private static extern bool VirtualFree(
|
||||
IntPtr address,
|
||||
int size,
|
||||
uint freeType );
|
||||
private static extern bool VirtualFree( IntPtr address, int size, uint freeType );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,10 +36,14 @@ namespace StgSharp.Math
|
||||
public const float E = 2.718281828f;
|
||||
|
||||
/// <summary>
|
||||
/// Get the value of E ^ x;
|
||||
/// Get the value of E ^ x;
|
||||
/// </summary>
|
||||
/// <param _name="x"></param>
|
||||
/// <returns></returns>
|
||||
/// <param _label="x">
|
||||
///
|
||||
/// </param>
|
||||
/// <returns>
|
||||
///
|
||||
/// </returns>
|
||||
public static unsafe float Exp( float x )
|
||||
{
|
||||
if( x == 1 ) {
|
||||
@@ -50,15 +54,18 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
bool sign = false;
|
||||
if( x < 0 ) {
|
||||
if( x < 0 )
|
||||
{
|
||||
sign = true;
|
||||
x = -x;
|
||||
}
|
||||
|
||||
float z = x, t;
|
||||
if( x < 0.5f ) {
|
||||
if( x < 0.5f )
|
||||
{
|
||||
t = 1.0f + ( x * ( 1.0f + ( x * ( 0.5f + ( x * ( 0.1666666667f + ( x * ( 0.0416666666667f + ( x * 8.333333333e-3f ) ) ) ) ) ) ) ) );
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/*
|
||||
* define z = n * 2 ^ m
|
||||
* n is between 0 and 0.5
|
||||
|
||||
@@ -42,9 +42,11 @@ namespace StgSharp.Math
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param _name="x"></param>
|
||||
/// <param _label="x">
|
||||
///
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// Returns the value of ln(x).
|
||||
/// Returns the value of ln(x).
|
||||
/// </returns>
|
||||
public static unsafe float Log( float x )
|
||||
{
|
||||
|
||||
@@ -34,11 +34,17 @@ namespace StgSharp.Math
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// calculate the value of x^y
|
||||
/// calculate the value of x^y
|
||||
/// </summary>
|
||||
/// <param _name="x"></param>
|
||||
/// <param _name="y"></param>
|
||||
/// <returns> Returns the value of x^y </returns>
|
||||
/// <param _label="x">
|
||||
///
|
||||
/// </param>
|
||||
/// <param _label="y">
|
||||
///
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// Returns the value of x^y
|
||||
/// </returns>
|
||||
public static unsafe float Pow( float x, float y )
|
||||
{
|
||||
/*
|
||||
@@ -67,14 +73,17 @@ namespace StgSharp.Math
|
||||
z = Scaler.Log( x ) * y;
|
||||
|
||||
bool sign = false;
|
||||
if( z < 0 ) {
|
||||
if( z < 0 )
|
||||
{
|
||||
sign = true;
|
||||
z = -z;
|
||||
}
|
||||
|
||||
if( z < 0.5f ) {
|
||||
if( z < 0.5f )
|
||||
{
|
||||
t = 1.0f + ( z * ( 1.0f + ( z * ( 0.5f + ( z * ( 0.1666666667f + ( z * ( 0.0416666666667f + ( z * 8.333333333e-3f ) ) ) ) ) ) ) ) );
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
uint zBit = *( uint* )&z;
|
||||
uint zBitAbs = zBit & 0b_0111_1111_1111_1111_1111_1111_1111_1111;
|
||||
uint uintm = zBitAbs >> 23;
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
@@ -56,9 +55,11 @@ namespace StgSharp.Math
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// returns a random float number between 0 and 1.
|
||||
/// returns a random float number between 0 and 1.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns>
|
||||
///
|
||||
/// </returns>
|
||||
public static unsafe float LowProceisionRandom()
|
||||
{
|
||||
float seed = currentSeed;
|
||||
@@ -75,7 +76,8 @@ namespace StgSharp.Math
|
||||
sample2 *= 1000000;
|
||||
|
||||
float result = sample2 - ( ( int )sample2 );
|
||||
if( result == 0 ) {
|
||||
if( result == 0 )
|
||||
{
|
||||
currentSeed = sample2 + 0.1f;
|
||||
result = Scaler.LowProceisionRandom();
|
||||
}
|
||||
@@ -85,19 +87,21 @@ namespace StgSharp.Math
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns>
|
||||
///
|
||||
/// </returns>
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static T Random<T>() where T: struct, IConvertible, INumber<T>
|
||||
|
||||
{
|
||||
if( randomSeed == null ) {
|
||||
if( randomSeed == null )
|
||||
{
|
||||
randomSeed = new byte[64];
|
||||
string originSeed =
|
||||
( $"{((Assembly.GetEntryAssembly() == null) ? (Assembly.GetAssembly(typeof(StgSharp))!) :
|
||||
( $"{((Assembly.GetEntryAssembly() == null) ? (Assembly.GetAssembly(typeof(World))!) :
|
||||
Assembly.GetEntryAssembly())}" ) + ( $"{DateTime.UtcNow.ToString("o")}" );
|
||||
using( SHA256 sha = SHA256.Create() ) {
|
||||
randomSeed = sha.ComputeHash(
|
||||
Encoding.UTF8.GetBytes( originSeed ) );
|
||||
randomSeed = sha.ComputeHash( Encoding.UTF8.GetBytes( originSeed ) );
|
||||
}
|
||||
}
|
||||
using( SHA256 sha = SHA256.Create() ) {
|
||||
@@ -109,9 +113,11 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a random seed in int value.
|
||||
/// Generates a random seed in int value.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns>
|
||||
///
|
||||
/// </returns>
|
||||
public static unsafe int RandomSeed()
|
||||
{
|
||||
float seedValue1 = LowProceisionRandom();
|
||||
|
||||
@@ -47,9 +47,9 @@ namespace StgSharp.Math
|
||||
* 在进一步简化操作后,计算精度达到0.5%,速度约为.Net库函数的3倍
|
||||
*/
|
||||
|
||||
if( x < 0 ) {
|
||||
throw new ArgumentOutOfRangeException(
|
||||
"Input is smaller than zero!" );
|
||||
if( x < 0 )
|
||||
{
|
||||
throw new ArgumentOutOfRangeException( "Input is smaller than zero!" );
|
||||
}
|
||||
if( x == 0 ) {
|
||||
return 0;
|
||||
@@ -60,7 +60,8 @@ namespace StgSharp.Math
|
||||
* 故不考虑正负号
|
||||
*/
|
||||
|
||||
if( x < 0 ) {
|
||||
if( x < 0 )
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
if( x <= 1e-12 ) {
|
||||
|
||||
@@ -47,8 +47,8 @@ namespace StgSharp.Math
|
||||
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 ) );
|
||||
return ( ( sinData[ a ] * cos ) + ( cosData[ a ] * sin ) ) / ( ( cosData[ a ] * cos ) - ( sinData[
|
||||
a ] * sin ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user