CultLib/packages/cultmath/src/CultMath
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Meta Vens fc9ce970b8 Fix erfinv's sign inversion at the domain edges
math.erfinv(1.0f) returned -infinity and erfinv(-1.0f) returned
+infinity: at value = +-1, w = -log((1-value)(1+value)) = -log(0) =
+infinity, the tail branch's leading coefficient is negative, and
`return p * value` delivered the inverted infinity. erf saturates to
exactly 1.0f at 5.543 sigma, so any interval edge beyond that reaches
this bug in ordinary use.

Guard both edges explicitly before the polynomial runs: erfinv(1) is
now +infinity, erfinv(-1) is -infinity, and anything strictly outside
[-1, 1] (including +-infinity) is NaN, which is the correct answer and
was already the fallthrough behavior. Documented the domain and the
edge behavior in a comment, matching the house style `sign` already
uses at math.cs:84. The approximation itself is unchanged.

Also recorded the true measured accuracy beside erf and erfinv: worst
absolute error 6.621e-7 and 5.066e-7 respectively, both inside the
2e-6 bar this package's tests pin.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 21:30:07 +02:00
..
BatchMath.cs Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
BatchMath.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
bool2.cs Generate every HLSL swizzle and mixed constructor; fix intrinsic types 2026-09-14 13:57:02 +02:00
bool2.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
bool3.cs Generate every HLSL swizzle and mixed constructor; fix intrinsic types 2026-09-14 13:57:02 +02:00
bool3.cs.meta Make CultMath HLSL-shaped: writable components, bool-vector comparisons 2026-09-14 13:29:59 +02:00
bool4.cs Generate every HLSL swizzle and mixed constructor; fix intrinsic types 2026-09-14 13:57:02 +02:00
bool4.cs.meta Make CultMath HLSL-shaped: writable components, bool-vector comparisons 2026-09-14 13:29:59 +02:00
Color32.cs Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
Color32.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
CultMath.asmdef Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
CultMath.asmdef.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
CultMath.csproj Add PCG integer hashes to CultMath and release 0.2.3 2026-09-14 18:19:53 +02:00
CultMath.csproj.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
CultMathTone.cs Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
CultMathTone.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
double2.cs Generate every HLSL swizzle and mixed constructor; fix intrinsic types 2026-09-14 13:57:02 +02:00
double2.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
double3.cs Generate every HLSL swizzle and mixed constructor; fix intrinsic types 2026-09-14 13:57:02 +02:00
double3.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
float2.cs Generate every HLSL swizzle and mixed constructor; fix intrinsic types 2026-09-14 13:57:02 +02:00
float2.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
float2x2.cs Document where matrix row writes are silently lost 2026-09-14 14:18:00 +02:00
float2x2.cs.meta Make CultMath HLSL-shaped: writable components, bool-vector comparisons 2026-09-14 13:29:59 +02:00
float3.cs Generate every HLSL swizzle and mixed constructor; fix intrinsic types 2026-09-14 13:57:02 +02:00
float3.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
float3x3.cs Document where matrix row writes are silently lost 2026-09-14 14:18:00 +02:00
float3x3.cs.meta Make CultMath HLSL-shaped: writable components, bool-vector comparisons 2026-09-14 13:29:59 +02:00
float4.cs Generate every HLSL swizzle and mixed constructor; fix intrinsic types 2026-09-14 13:57:02 +02:00
float4.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
int2.cs Generate every HLSL swizzle and mixed constructor; fix intrinsic types 2026-09-14 13:57:02 +02:00
int2.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
int3.cs Generate every HLSL swizzle and mixed constructor; fix intrinsic types 2026-09-14 13:57:02 +02:00
int3.cs.meta Make CultMath HLSL-shaped: writable components, bool-vector comparisons 2026-09-14 13:29:59 +02:00
int4.cs Generate every HLSL swizzle and mixed constructor; fix intrinsic types 2026-09-14 13:57:02 +02:00
int4.cs.meta Make CultMath HLSL-shaped: writable components, bool-vector comparisons 2026-09-14 13:29:59 +02:00
IsExternalInit.cs Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
IsExternalInit.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
math.cs Fix erfinv's sign inversion at the domain edges 2026-09-22 21:30:07 +02:00
math.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
quaternion.cs Make CultMath HLSL-shaped: writable components, bool-vector comparisons 2026-09-14 13:29:59 +02:00
quaternion.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
Random.cs Make CultMath HLSL-shaped: writable components, bool-vector comparisons 2026-09-14 13:29:59 +02:00
Random.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
rect.cs Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
rect.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
Swizzles.g.cs Add HLSL vector conversions, int clamp, and double frac to CultMath 2026-09-14 16:16:32 +02:00
Swizzles.g.cs.meta Generate every HLSL swizzle and mixed constructor; fix intrinsic types 2026-09-14 13:57:02 +02:00
UnscopedRefAttribute.cs Generate every HLSL swizzle and mixed constructor; fix intrinsic types 2026-09-14 13:57:02 +02:00
UnscopedRefAttribute.cs.meta Generate every HLSL swizzle and mixed constructor; fix intrinsic types 2026-09-14 13:57:02 +02:00
Voronoi.cs Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
Voronoi.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00