Browse Source

Fix a negative-zero issue in complex numbers; make all portable tests pass

optimization-1
Christoph Ruegg 13 years ago
parent
commit
024570b9e6
  1. 3
      src/Numerics/Complex32.cs
  2. 3
      src/Numerics/Complex64.cs
  3. 2
      src/UnitTests/LinearAlgebraTests/Complex/Factorization/QRTests.cs

3
src/Numerics/Complex32.cs

@ -169,8 +169,9 @@ namespace MathNet.Numerics
/// <returns>The phase or argument of this <c>Complex32</c></returns>
public float Phase
{
// NOTE: the special case for negative real numbers fixes negative-zero value behavior. Do not remove.
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
get { return (float)Math.Atan2(_imag, _real); }
get { return _imag == 0f && _real < 0f ? (float)Constants.Pi : (float)Math.Atan2(_imag, _real); }
}
/// <summary>

3
src/Numerics/Complex64.cs

@ -162,8 +162,9 @@ namespace MathNet.Numerics
/// <returns>The phase or argument of this <c>Complex</c></returns>
public double Phase
{
// NOTE: the special case for negative real numbers fixes negative-zero value behavior. Do not remove.
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
get { return Math.Atan2(_imag, _real); }
get { return _imag == 0d && _real < 0d ? Constants.Pi : Math.Atan2(_imag, _real); }
}
/// <summary>

2
src/UnitTests/LinearAlgebraTests/Complex/Factorization/QRTests.cs

@ -707,7 +707,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization
for (var i = 0; i < vectorX.Count; i++)
{
AssertHelpers.AlmostEqual(test[i], vectorX[i], 9);
AssertHelpers.AlmostEqualAbsolute(test[i], vectorX[i], 9);
}
// Make sure A didn't change.

Loading…
Cancel
Save