mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-26 13:18:47 +00:00
Improve accuracy of ComplexSqrt
This commit is contained in:
parent
e7e8d75fba
commit
70b3e9eff3
@ -19,7 +19,8 @@ public static class DoubleExtensions
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
public static Complex ComplexSqrt(this double value)
|
public static Complex ComplexSqrt(this double value)
|
||||||
{
|
{
|
||||||
return Complex.Sqrt(value);
|
double absoluteSqrt = Math.Abs(value).Sqrt();
|
||||||
|
return new Complex(absoluteSqrt, value >= 0 ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -19,7 +19,8 @@ public static class SingleExtensions
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
public static Complex ComplexSqrt(this float value)
|
public static Complex ComplexSqrt(this float value)
|
||||||
{
|
{
|
||||||
return Complex.Sqrt(value);
|
float absoluteSqrt = MathF.Abs(value).Sqrt();
|
||||||
|
return new Complex(absoluteSqrt, value >= 0 ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user