diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/ResidualStopCriterium.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/ResidualStopCriterium.cs
index ee442ea4..9b706210 100644
--- a/src/Numerics/LinearAlgebra/Complex/Solvers/ResidualStopCriterium.cs
+++ b/src/Numerics/LinearAlgebra/Complex/Solvers/ResidualStopCriterium.cs
@@ -211,14 +211,24 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "residualVector");
}
+
// Store the infinity norms of both the solution and residual vectors
// These values will be used to calculate the relative drop in residuals
// later on.
var residualNorm = residualVector.InfinityNorm();
+
+ // This is criterium 1 from Templates for the solution of linear systems.
+ // The problem with this criterium is that it's not limiting enough. For now
+ // we won't use it. Later on we might get back to it.
+ // return mMaximumResidual * (System.Math.Abs(mMatrixNorm) * System.Math.Abs(solutionNorm) + System.Math.Abs(mVectorNorm));
+
+ // For now use criterium 2 from Templates for the solution of linear systems. See page 60.
+
// Check the residuals by calculating:
// ||r_i|| <= stop_tol * ||b||
- var stopCriterium = ComputeStopCriterium(sourceVector.InfinityNorm());
+ var stopCriterium = _maximum * sourceVector.InfinityNorm();
+
// First check that we have real numbers not NaN's.
// NaN's can occur when the iterative process diverges so we
@@ -232,8 +242,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers
// ||r_i|| <= stop_tol * ||b||
// Stop the calculation if it's clearly smaller than the tolerance
- var decimalMagnitude = Math.Abs(stopCriterium.Magnitude()) + 1;
- if (residualNorm.IsSmallerDecimal(stopCriterium, decimalMagnitude))
+ if (residualNorm < stopCriterium)
{
if (_lastIteration <= iterationNumber)
{
@@ -251,22 +260,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers
return _status;
}
- ///
- /// Calculate stop criterium
- ///
- /// Solution vector norm
- /// Criterium value
- double ComputeStopCriterium(double solutionNorm)
- {
- // This is criterium 1 from Templates for the solution of linear systems.
- // The problem with this criterium is that it's not limiting enough. For now
- // we won't use it. Later on we might get back to it.
- // return mMaximumResidual * (System.Math.Abs(mMatrixNorm) * System.Math.Abs(solutionNorm) + System.Math.Abs(mVectorNorm));
-
- // For now use criterium 2 from Templates for the solution of linear systems. See page 60.
- return _maximum*Math.Abs(solutionNorm);
- }
-
///
/// Gets the current calculation status.
///
diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/ResidualStopCriterium.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/ResidualStopCriterium.cs
index 7f402be0..91535fde 100644
--- a/src/Numerics/LinearAlgebra/Complex32/Solvers/ResidualStopCriterium.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/ResidualStopCriterium.cs
@@ -206,19 +206,29 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "residualVector");
}
+
// Store the infinity norms of both the solution and residual vectors
// These values will be used to calculate the relative drop in residuals
// later on.
- var residualNorm = (float) residualVector.InfinityNorm();
+ var residualNorm = residualVector.InfinityNorm();
+
+
+ // This is criterium 1 from Templates for the solution of linear systems.
+ // The problem with this criterium is that it's not limiting enough. For now
+ // we won't use it. Later on we might get back to it.
+ // return mMaximumResidual * (System.Math.Abs(mMatrixNorm) * System.Math.Abs(solutionNorm) + System.Math.Abs(mVectorNorm));
+
+ // For now use criterium 2 from Templates for the solution of linear systems. See page 60.
// Check the residuals by calculating:
// ||r_i|| <= stop_tol * ||b||
- var stopCriterium = ComputeStopCriterium((float) sourceVector.InfinityNorm());
+ var stopCriterium = _maximum * sourceVector.InfinityNorm();
+
// First check that we have real numbers not NaN's.
// NaN's can occur when the iterative process diverges so we
// stop if that is the case.
- if (float.IsNaN(stopCriterium) || float.IsNaN(residualNorm))
+ if (double.IsNaN(stopCriterium) || double.IsNaN(residualNorm))
{
_iterationCount = 0;
_status = IterationStatus.Diverged;
@@ -227,8 +237,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers
// ||r_i|| <= stop_tol * ||b||
// Stop the calculation if it's clearly smaller than the tolerance
- var decimalMagnitude = Math.Abs(stopCriterium.Magnitude()) + 1;
- if (residualNorm.IsSmallerDecimal(stopCriterium, decimalMagnitude))
+ if (residualNorm < stopCriterium)
{
if (_lastIteration <= iterationNumber)
{
@@ -246,22 +255,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers
return _status;
}
- ///
- /// Calculate stop criterium
- ///
- /// Solution vector norm
- /// Criterium value
- float ComputeStopCriterium(float solutionNorm)
- {
- // This is criterium 1 from Templates for the solution of linear systems.
- // The problem with this criterium is that it's not limiting enough. For now
- // we won't use it. Later on we might get back to it.
- // return mMaximumResidual * (System.Math.Abs(mMatrixNorm) * System.Math.Abs(solutionNorm) + System.Math.Abs(mVectorNorm));
-
- // For now use criterium 2 from Templates for the solution of linear systems. See page 60.
- return _maximum*Math.Abs(solutionNorm);
- }
-
///
/// Gets the current calculation status.
///
diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/ResidualStopCriterium.cs b/src/Numerics/LinearAlgebra/Double/Solvers/ResidualStopCriterium.cs
index 4ebce201..4093f4ac 100644
--- a/src/Numerics/LinearAlgebra/Double/Solvers/ResidualStopCriterium.cs
+++ b/src/Numerics/LinearAlgebra/Double/Solvers/ResidualStopCriterium.cs
@@ -204,14 +204,24 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "residualVector");
}
+
// Store the infinity norms of both the solution and residual vectors
// These values will be used to calculate the relative drop in residuals
// later on.
var residualNorm = residualVector.InfinityNorm();
+
+ // This is criterium 1 from Templates for the solution of linear systems.
+ // The problem with this criterium is that it's not limiting enough. For now
+ // we won't use it. Later on we might get back to it.
+ // return mMaximumResidual * (System.Math.Abs(mMatrixNorm) * System.Math.Abs(solutionNorm) + System.Math.Abs(mVectorNorm));
+
+ // For now use criterium 2 from Templates for the solution of linear systems. See page 60.
+
// Check the residuals by calculating:
// ||r_i|| <= stop_tol * ||b||
- var stopCriterium = ComputeStopCriterium(sourceVector.InfinityNorm());
+ var stopCriterium = _maximum * sourceVector.InfinityNorm();
+
// First check that we have real numbers not NaN's.
// NaN's can occur when the iterative process diverges so we
@@ -225,8 +235,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers
// ||r_i|| <= stop_tol * ||b||
// Stop the calculation if it's clearly smaller than the tolerance
- var decimalMagnitude = Math.Abs(stopCriterium.Magnitude()) + 1;
- if (residualNorm.IsSmallerDecimal(stopCriterium, decimalMagnitude))
+ if (residualNorm < stopCriterium)
{
if (_lastIteration <= iterationNumber)
{
@@ -244,22 +253,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers
return _status;
}
- ///
- /// Calculate stop criterium
- ///
- /// Solution vector norm
- /// Criterium value
- double ComputeStopCriterium(double solutionNorm)
- {
- // This is criterium 1 from Templates for the solution of linear systems.
- // The problem with this criterium is that it's not limiting enough. For now
- // we won't use it. Later on we might get back to it.
- // return mMaximumResidual * (System.Math.Abs(mMatrixNorm) * System.Math.Abs(solutionNorm) + System.Math.Abs(mVectorNorm));
-
- // For now use criterium 2 from Templates for the solution of linear systems. See page 60.
- return _maximum*Math.Abs(solutionNorm);
- }
-
///
/// Gets the current calculation status.
///
diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/ResidualStopCriterium.cs b/src/Numerics/LinearAlgebra/Single/Solvers/ResidualStopCriterium.cs
index ed3dc421..a6f5b042 100644
--- a/src/Numerics/LinearAlgebra/Single/Solvers/ResidualStopCriterium.cs
+++ b/src/Numerics/LinearAlgebra/Single/Solvers/ResidualStopCriterium.cs
@@ -204,19 +204,29 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "residualVector");
}
+
// Store the infinity norms of both the solution and residual vectors
// These values will be used to calculate the relative drop in residuals
// later on.
- var residualNorm = (float) residualVector.InfinityNorm();
+ var residualNorm = residualVector.InfinityNorm();
+
+
+ // This is criterium 1 from Templates for the solution of linear systems.
+ // The problem with this criterium is that it's not limiting enough. For now
+ // we won't use it. Later on we might get back to it.
+ // return mMaximumResidual * (System.Math.Abs(mMatrixNorm) * System.Math.Abs(solutionNorm) + System.Math.Abs(mVectorNorm));
+
+ // For now use criterium 2 from Templates for the solution of linear systems. See page 60.
// Check the residuals by calculating:
// ||r_i|| <= stop_tol * ||b||
- var stopCriterium = ComputeStopCriterium((float) sourceVector.InfinityNorm());
+ var stopCriterium = _maximum*sourceVector.InfinityNorm();
+
// First check that we have real numbers not NaN's.
// NaN's can occur when the iterative process diverges so we
// stop if that is the case.
- if (float.IsNaN(stopCriterium) || float.IsNaN(residualNorm))
+ if (double.IsNaN(stopCriterium) || double.IsNaN(residualNorm))
{
_iterationCount = 0;
_status = IterationStatus.Diverged;
@@ -225,8 +235,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers
// ||r_i|| <= stop_tol * ||b||
// Stop the calculation if it's clearly smaller than the tolerance
- var decimalMagnitude = Math.Abs(stopCriterium.Magnitude()) + 1;
- if (residualNorm.IsSmallerDecimal(stopCriterium, decimalMagnitude))
+ if (residualNorm < stopCriterium)
{
if (_lastIteration <= iterationNumber)
{
@@ -244,22 +253,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers
return _status;
}
- ///
- /// Calculate stop criterium
- ///
- /// Solution vector norm
- /// Criterium value
- float ComputeStopCriterium(float solutionNorm)
- {
- // This is criterium 1 from Templates for the solution of linear systems.
- // The problem with this criterium is that it's not limiting enough. For now
- // we won't use it. Later on we might get back to it.
- // return mMaximumResidual * (System.Math.Abs(mMatrixNorm) * System.Math.Abs(solutionNorm) + System.Math.Abs(mVectorNorm));
-
- // For now use criterium 2 from Templates for the solution of linear systems. See page 60.
- return _maximum*Math.Abs(solutionNorm);
- }
-
///
/// Gets the current calculation status.
///
diff --git a/src/Numerics/Numerics.csproj b/src/Numerics/Numerics.csproj
index bbd56164..d5ef82b2 100644
--- a/src/Numerics/Numerics.csproj
+++ b/src/Numerics/Numerics.csproj
@@ -86,6 +86,7 @@
+
diff --git a/src/Numerics/Precision.Comparison.cs b/src/Numerics/Precision.Comparison.cs
new file mode 100644
index 00000000..0d2319d7
--- /dev/null
+++ b/src/Numerics/Precision.Comparison.cs
@@ -0,0 +1,679 @@
+//
+// Math.NET Numerics, part of the Math.NET Project
+// http://numerics.mathdotnet.com
+// http://github.com/mathnet/mathnet-numerics
+// http://mathnetnumerics.codeplex.com
+//
+// Copyright (c) 2009-2013 Math.NET
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace MathNet.Numerics
+{
+ public static partial class Precision
+ {
+ ///
+ /// Compares two doubles and determines which double is bigger.
+ /// a < b -> -1; a ~= b (almost equal according to parameter) -> 0; a > b -> +1.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The absolute accuracy required for being almost equal.
+ public static int CompareTo(this double a, double b, double maximumAbsoluteError)
+ {
+ // NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (double.IsNaN(a) || double.IsNaN(b))
+ {
+ return a.CompareTo(b);
+ }
+
+ // If A or B are infinity (positive or negative) then
+ // only return true if first is smaller
+ if (double.IsInfinity(a) || double.IsInfinity(b))
+ {
+ return a.CompareTo(b);
+ }
+
+ // If the numbers are equal to within the number of decimal places
+ // then there's technically no difference
+ if (AlmostEqual(a, b, maximumAbsoluteError))
+ {
+ return 0;
+ }
+
+ // The numbers differ by more than the decimal places, so
+ // we can check the normal way to see if the first is
+ // larger than the second.
+ return a.CompareTo(b);
+ }
+
+ ///
+ /// Compares two doubles and determines which double is bigger.
+ /// a < b -> -1; a ~= b (almost equal according to parameter) -> 0; a > b -> +1.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The number of decimal places on which the values must be compared. Must be 1 or larger.
+ public static int CompareTo(this double a, double b, int decimalPlaces)
+ {
+ // NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (double.IsNaN(a) || double.IsNaN(b))
+ {
+ return a.CompareTo(b);
+ }
+
+ // If A or B are infinity (positive or negative) then
+ // only return true if first is smaller
+ if (double.IsInfinity(a) || double.IsInfinity(b))
+ {
+ return a.CompareTo(b);
+ }
+
+ // If the numbers are equal to within the number of decimal places
+ // then there's technically no difference
+ if (AlmostEqual(a, b, decimalPlaces))
+ {
+ return 0;
+ }
+
+ // The numbers differ by more than the decimal places, so
+ // we can check the normal way to see if the first is
+ // larger than the second.
+ return a.CompareTo(b);
+ }
+
+ ///
+ /// Compares two doubles and determines which double is bigger.
+ /// a < b -> -1; a ~= b (almost equal according to parameter) -> 0; a > b -> +1.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The relative accuracy required for being almost equal.
+ public static int CompareToRelative(this double a, double b, double maximumError)
+ {
+ // NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (double.IsNaN(a) || double.IsNaN(b))
+ {
+ return a.CompareTo(b);
+ }
+
+ // If A or B are infinity (positive or negative) then
+ // only return true if first is smaller
+ if (double.IsInfinity(a) || double.IsInfinity(b))
+ {
+ return a.CompareTo(b);
+ }
+
+ // If the numbers are equal to within the number of decimal places
+ // then there's technically no difference
+ if (AlmostEqualRelative(a, b, maximumError))
+ {
+ return 0;
+ }
+
+ // The numbers differ by more than the decimal places, so
+ // we can check the normal way to see if the first is
+ // larger than the second.
+ return a.CompareTo(b);
+ }
+
+ ///
+ /// Compares two doubles and determines which double is bigger.
+ /// a < b -> -1; a ~= b (almost equal according to parameter) -> 0; a > b -> +1.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The number of decimal places on which the values must be compared. Must be 1 or larger.
+ public static int CompareToRelative(this double a, double b, int decimalPlaces)
+ {
+ // NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (double.IsNaN(a) || double.IsNaN(b))
+ {
+ return a.CompareTo(b);
+ }
+
+ // If A or B are infinity (positive or negative) then
+ // only return true if first is smaller
+ if (double.IsInfinity(a) || double.IsInfinity(b))
+ {
+ return a.CompareTo(b);
+ }
+
+ // If the numbers are equal to within the number of decimal places
+ // then there's technically no difference
+ if (AlmostEqualRelative(a, b, decimalPlaces))
+ {
+ return 0;
+ }
+
+ // The numbers differ by more than the decimal places, so
+ // we can check the normal way to see if the first is
+ // larger than the second.
+ return a.CompareTo(b);
+ }
+
+ ///
+ /// Compares two doubles and determines which double is bigger.
+ /// a < b -> -1; a ~= b (almost equal according to parameter) -> 0; a > b -> +1.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The maximum error in terms of Units in Last Place (ulps), i.e. the maximum number of decimals that may be different. Must be 1 or larger.
+ public static int CompareToNumbersBetween(this double a, double b, long maxNumbersBetween)
+ {
+ // NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (double.IsNaN(a) || double.IsNaN(b))
+ {
+ return a.CompareTo(b);
+ }
+
+ // If A or B are infinity (positive or negative) then
+ // only return true if first is smaller
+ if (double.IsInfinity(a) || double.IsInfinity(b))
+ {
+ return a.CompareTo(b);
+ }
+
+ // If the numbers are equal to within the tolerance then
+ // there's technically no difference
+ if (AlmostEqualNumbersBetween(a, b, maxNumbersBetween))
+ {
+ return 0;
+ }
+
+ return a.CompareTo(b);
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is larger than the second
+ /// value to within the specified number of decimal places or not.
+ ///
+ ///
+ ///
+ /// The values are equal if the difference between the two numbers is smaller than 10^(-numberOfDecimalPlaces). We divide by
+ /// two so that we have half the range on each side of the numbers, e.g. if == 2, then 0.01 will equal between
+ /// 0.005 and 0.015, but not 0.02 and not 0.00
+ ///
+ ///
+ /// The first value.
+ /// The second value.
+ /// The number of decimal places.
+ /// true if the first value is larger than the second value; otherwise false.
+ public static bool IsLarger(this double a, double b, int decimalPlaces)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (double.IsNaN(a) || double.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareTo(a, b, decimalPlaces) > 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is larger than the second
+ /// value to within the specified number of decimal places or not.
+ ///
+ ///
+ ///
+ /// The values are equal if the difference between the two numbers is smaller than 10^(-numberOfDecimalPlaces). We divide by
+ /// two so that we have half the range on each side of the numbers, e.g. if == 2, then 0.01 will equal between
+ /// 0.005 and 0.015, but not 0.02 and not 0.00
+ ///
+ ///
+ /// The first value.
+ /// The second value.
+ /// The number of decimal places.
+ /// true if the first value is larger than the second value; otherwise false.
+ public static bool IsLarger(this float a, float b, int decimalPlaces)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (float.IsNaN(a) || float.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareTo(a, b, decimalPlaces) > 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is larger than the second
+ /// value to within the specified number of decimal places or not.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The absolute accuracy required for being almost equal.
+ /// true if the first value is larger than the second value; otherwise false.
+ public static bool IsLarger(this double a, double b, double maximumAbsoluteError)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (double.IsNaN(a) || double.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareTo(a, b, maximumAbsoluteError) > 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is larger than the second
+ /// value to within the specified number of decimal places or not.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The absolute accuracy required for being almost equal.
+ /// true if the first value is larger than the second value; otherwise false.
+ public static bool IsLarger(this float a, float b, double maximumAbsoluteError)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (float.IsNaN(a) || float.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareTo(a, b, maximumAbsoluteError) > 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is larger than the second
+ /// value to within the specified number of decimal places or not.
+ ///
+ ///
+ ///
+ /// The values are equal if the difference between the two numbers is smaller than 10^(-numberOfDecimalPlaces). We divide by
+ /// two so that we have half the range on each side of the numbers, e.g. if == 2, then 0.01 will equal between
+ /// 0.005 and 0.015, but not 0.02 and not 0.00
+ ///
+ ///
+ /// The first value.
+ /// The second value.
+ /// The number of decimal places.
+ /// true if the first value is larger than the second value; otherwise false.
+ public static bool IsLargerRelative(this double a, double b, int decimalPlaces)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (double.IsNaN(a) || double.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareToRelative(a, b, decimalPlaces) > 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is larger than the second
+ /// value to within the specified number of decimal places or not.
+ ///
+ ///
+ ///
+ /// The values are equal if the difference between the two numbers is smaller than 10^(-numberOfDecimalPlaces). We divide by
+ /// two so that we have half the range on each side of the numbers, e.g. if == 2, then 0.01 will equal between
+ /// 0.005 and 0.015, but not 0.02 and not 0.00
+ ///
+ ///
+ /// The first value.
+ /// The second value.
+ /// The number of decimal places.
+ /// true if the first value is larger than the second value; otherwise false.
+ public static bool IsLargerRelative(this float a, float b, int decimalPlaces)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (float.IsNaN(a) || float.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareToRelative(a, b, decimalPlaces) > 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is larger than the second
+ /// value to within the specified number of decimal places or not.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The relative accuracy required for being almost equal.
+ /// true if the first value is larger than the second value; otherwise false.
+ public static bool IsLargerRelative(this double a, double b, double maximumError)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (double.IsNaN(a) || double.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareToRelative(a, b, maximumError) > 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is larger than the second
+ /// value to within the specified number of decimal places or not.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The relative accuracy required for being almost equal.
+ /// true if the first value is larger than the second value; otherwise false.
+ public static bool IsLargerRelative(this float a, float b, double maximumError)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (float.IsNaN(a) || float.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareToRelative(a, b, maximumError) > 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is larger than the second
+ /// value to within the tolerance or not. Equality comparison is based on the binary representation.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The maximum number of floating point values for which the two values are considered equal. Must be 1 or larger.
+ /// true if the first value is larger than the second value; otherwise false.
+ public static bool IsLargerNumbersBetween(this double a, double b, long maxNumbersBetween)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (double.IsNaN(a) || double.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareToNumbersBetween(a, b, maxNumbersBetween) > 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is larger than the second
+ /// value to within the tolerance or not. Equality comparison is based on the binary representation.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The maximum number of floating point values for which the two values are considered equal. Must be 1 or larger.
+ /// true if the first value is larger than the second value; otherwise false.
+ public static bool IsLargerNumbersBetween(this float a, float b, long maxNumbersBetween)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (float.IsNaN(a) || float.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareToNumbersBetween(a, b, maxNumbersBetween) > 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is smaller than the second
+ /// value to within the specified number of decimal places or not.
+ ///
+ ///
+ ///
+ /// The values are equal if the difference between the two numbers is smaller than 10^(-numberOfDecimalPlaces). We divide by
+ /// two so that we have half the range on each side of thg. if == 2, then 0.01 will equal between
+ /// 0.005 and 0.015, but not 0.02 and not 0.00
+ ///
+ ///
+ /// The first value.
+ /// The second value.
+ /// The number of decimal places.
+ /// true if the first value is smaller than the second value; otherwise false.
+ public static bool IsSmaller(this double a, double b, int decimalPlaces)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (double.IsNaN(a) || double.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareTo(a, b, decimalPlaces) < 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is smaller than the second
+ /// value to within the specified number of decimal places or not.
+ ///
+ ///
+ ///
+ /// The values are equal if the difference between the two numbers is smaller than 10^(-numberOfDecimalPlaces). We divide by
+ /// two so that we have half the range on each side of thg. if == 2, then 0.01 will equal between
+ /// 0.005 and 0.015, but not 0.02 and not 0.00
+ ///
+ ///
+ /// The first value.
+ /// The second value.
+ /// The number of decimal places.
+ /// true if the first value is smaller than the second value; otherwise false.
+ public static bool IsSmaller(this float a, float b, int decimalPlaces)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (float.IsNaN(a) || float.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareTo(a, b, decimalPlaces) < 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is smaller than the second
+ /// value to within the specified number of decimal places or not.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The absolute accuracy required for being almost equal.
+ /// true if the first value is smaller than the second value; otherwise false.
+ public static bool IsSmaller(this double a, double b, double maximumAbsoluteError)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (double.IsNaN(a) || double.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareTo(a, b, maximumAbsoluteError) < 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is smaller than the second
+ /// value to within the specified number of decimal places or not.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The absolute accuracy required for being almost equal.
+ /// true if the first value is smaller than the second value; otherwise false.
+ public static bool IsSmaller(this float a, float b, double maximumAbsoluteError)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (float.IsNaN(a) || float.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareTo(a, b, maximumAbsoluteError) < 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is smaller than the second
+ /// value to within the specified number of decimal places or not.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The number of decimal places.
+ /// true if the first value is smaller than the second value; otherwise false.
+ public static bool IsSmallerRelative(this double a, double b, int decimalPlaces)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (double.IsNaN(a) || double.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareToRelative(a, b, decimalPlaces) < 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is smaller than the second
+ /// value to within the specified number of decimal places or not.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The number of decimal places.
+ /// true if the first value is smaller than the second value; otherwise false.
+ public static bool IsSmallerRelative(this float a, float b, int decimalPlaces)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (float.IsNaN(a) || float.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareToRelative(a, b, decimalPlaces) < 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is smaller than the second
+ /// value to within the specified number of decimal places or not.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The relative accuracy required for being almost equal.
+ /// true if the first value is smaller than the second value; otherwise false.
+ public static bool IsSmallerRelative(this double a, double b, double maximumError)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (double.IsNaN(a) || double.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareToRelative(a, b, maximumError) < 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is smaller than the second
+ /// value to within the specified number of decimal places or not.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The relative accuracy required for being almost equal.
+ /// true if the first value is smaller than the second value; otherwise false.
+ public static bool IsSmallerRelative(this float a, float b, double maximumError)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (float.IsNaN(a) || float.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareToRelative(a, b, maximumError) < 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is smaller than the second
+ /// value to within the tolerance or not. Equality comparison is based on the binary representation.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The maximum number of floating point values for which the two values are considered equal. Must be 1 or larger.
+ /// true if the first value is smaller than the second value; otherwise false.
+ public static bool IsSmallerNumbersBetween(this double a, double b, long maxNumbersBetween)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (double.IsNaN(a) || double.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareToNumbersBetween(a, b, maxNumbersBetween) < 0;
+ }
+
+ ///
+ /// Compares two doubles and determines if the first value is smaller than the second
+ /// value to within the tolerance or not. Equality comparison is based on the binary representation.
+ ///
+ /// The first value.
+ /// The second value.
+ /// The maximum number of floating point values for which the two values are considered equal. Must be 1 or larger.
+ /// true if the first value is smaller than the second value; otherwise false.
+ public static bool IsSmallerNumbersBetween(this float a, float b, long maxNumbersBetween)
+ {
+ // If A or B are a NAN, return false. NANs are equal to nothing,
+ // not even themselves, and thus they're not bigger or
+ // smaller than anything either
+ if (float.IsNaN(a) || float.IsNaN(b))
+ {
+ return false;
+ }
+
+ return CompareToNumbersBetween(a, b, maxNumbersBetween) < 0;
+ }
+ }
+}
diff --git a/src/Numerics/Precision.Equality.cs b/src/Numerics/Precision.Equality.cs
index bca92d37..e36945bf 100644
--- a/src/Numerics/Precision.Equality.cs
+++ b/src/Numerics/Precision.Equality.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2010 Math.NET
+// Copyright (c) 2009-2013 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -32,10 +32,6 @@ using System;
using System.Collections.Generic;
using MathNet.Numerics.LinearAlgebra;
-#if PORTABLE
-using System.Runtime.InteropServices;
-#endif
-
namespace MathNet.Numerics
{
diff --git a/src/Numerics/Precision.cs b/src/Numerics/Precision.cs
index 5e06f718..2b42b104 100644
--- a/src/Numerics/Precision.cs
+++ b/src/Numerics/Precision.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2010 Math.NET
+// Copyright (c) 2009-2013 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -36,11 +36,6 @@ using System.Runtime.InteropServices;
namespace MathNet.Numerics
{
-
-#if !NOSYSNUMERICS
- using Complex = System.Numerics.Complex;
-#endif
-
///
/// Support Interface for Precision Operations (like AlmostEquals).
///
@@ -710,311 +705,6 @@ namespace MathNet.Numerics
return (a >= b) ? (ulong) (intA - intB) : (ulong) (intB - intA);
}
- ///
- /// Compares two doubles and determines if the first value is larger than the second
- /// value to within the tolerance or not. Equality comparison is based on the binary representation.
- ///
- /// The first value.
- /// The second value.
- /// The maximum number of floating point values for which the two values are considered equal. Must be 1 or larger.
- /// true if the first value is larger than the second value; otherwise false.
- public static bool IsLarger(this double a, double b, long maxNumbersBetween)
- {
- // If A or B are a NAN, return false. NANs are equal to nothing,
- // not even themselves, and thus they're not bigger or
- // smaller than anything either
- if (double.IsNaN(a) || double.IsNaN(b))
- {
- return false;
- }
-
- return CompareTo(a, b, maxNumbersBetween) > 0;
- }
-
- ///
- /// Compares two doubles and determines if the first value is larger than the second
- /// value to within the tolerance or not. Equality comparison is based on the binary representation.
- ///
- /// The first value.
- /// The second value.
- /// The maximum number of floating point values for which the two values are considered equal. Must be 1 or larger.
- /// true if the first value is larger than the second value; otherwise false.
- public static bool IsLarger(this float a, float b, long maxNumbersBetween)
- {
- // If A or B are a NAN, return false. NANs are equal to nothing,
- // not even themselves, and thus they're not bigger or
- // smaller than anything either
- if (float.IsNaN(a) || float.IsNaN(b))
- {
- return false;
- }
-
- return CompareTo(a, b, maxNumbersBetween) > 0;
- }
-
- ///
- /// Compares two doubles and determines if the first value is larger than the second
- /// value to within the specified number of decimal places or not.
- ///
- ///
- ///
- /// The values are equal if the difference between the two numbers is smaller than 10^(-numberOfDecimalPlaces). We divide by
- /// two so that we have half the range on each side of the numbers, e.g. if == 2, then 0.01 will equal between
- /// 0.005 and 0.015, but not 0.02 and not 0.00
- ///
- ///
- /// The first value.
- /// The second value.
- /// The number of decimal places.
- /// true if the first value is larger than the second value; otherwise false.
- public static bool IsLargerDecimal(this double a, double b, int decimalPlaces)
- {
- // If A or B are a NAN, return false. NANs are equal to nothing,
- // not even themselves, and thus they're not bigger or
- // smaller than anything either
- if (double.IsNaN(a) || double.IsNaN(b))
- {
- return false;
- }
-
- return CompareToDecimal(a, b, decimalPlaces) > 0;
- }
-
- ///
- /// Compares two doubles and determines if the first value is larger than the second
- /// value to within the specified number of decimal places or not.
- ///
- ///
- ///
- /// The values are equal if the difference between the two numbers is smaller than 10^(-numberOfDecimalPlaces). We divide by
- /// two so that we have half the range on each side of the numbers, e.g. if == 2, then 0.01 will equal between
- /// 0.005 and 0.015, but not 0.02 and not 0.00
- ///
- ///
- /// The first value.
- /// The second value.
- /// The number of decimal places.
- /// true if the first value is larger than the second value; otherwise false.
- public static bool IsLargerDecimal(this float a, float b, int decimalPlaces)
- {
- // If A or B are a NAN, return false. NANs are equal to nothing,
- // not even themselves, and thus they're not bigger or
- // smaller than anything either
- if (float.IsNaN(a) || float.IsNaN(b))
- {
- return false;
- }
-
- return CompareToDecimal(a, b, decimalPlaces) > 0;
- }
-
- ///
- /// Compares two doubles and determines if the first value is smaller than the second
- /// value to within the tolerance or not. Equality comparison is based on the binary representation.
- ///
- /// The first value.
- /// The second value.
- /// The maximum number of floating point values for which the two values are considered equal. Must be 1 or larger.
- /// true if the first value is smaller than the second value; otherwise false.
- public static bool IsSmaller(this double a, double b, long maxNumbersBetween)
- {
- // If A or B are a NAN, return false. NANs are equal to nothing,
- // not even themselves, and thus they're not bigger or
- // smaller than anything either
- if (double.IsNaN(a) || double.IsNaN(b))
- {
- return false;
- }
-
- return CompareTo(a, b, maxNumbersBetween) < 0;
- }
-
- ///
- /// Compares two floats and determines if the first value is smaller than the second
- /// value to within the tolerance or not. Equality comparison is based on the binary representation.
- ///
- /// The first value.
- /// The second value.
- /// The maximum number of floating point values for which the two values are considered equal. Must be 1 or larger.
- /// true if the first value is smaller than the second value; otherwise false.
- public static bool IsSmaller(this float a, float b, long maxNumbersBetween)
- {
- // If A or B are a NAN, return false. NANs are equal to nothing,
- // not even themselves, and thus they're not bigger or
- // smaller than anything either
- if (float.IsNaN(a) || float.IsNaN(b))
- {
- return false;
- }
-
- return CompareTo(a, b, maxNumbersBetween) < 0;
- }
-
- ///
- /// Compares two doubles and determines if the first value is smaller than the second
- /// value to within the specified number of decimal places or not.
- ///
- ///
- ///
- /// The values are equal if the difference between the two numbers is smaller than 10^(-numberOfDecimalPlaces). We divide by
- /// two so that we have half the range on each side of thg. if == 2, then 0.01 will equal between
- /// 0.005 and 0.015, but not 0.02 and not 0.00
- ///
- ///
- /// The first value.
- /// The second value.
- /// The number of decimal places.
- /// true if the first value is smaller than the second value; otherwise false.
- public static bool IsSmallerDecimal(this double a, double b, int decimalPlaces)
- {
- // If A or B are a NAN, return false. NANs are equal to nothing,
- // not even themselves, and thus they're not bigger or
- // smaller than anything either
- if (double.IsNaN(a) || double.IsNaN(b))
- {
- return false;
- }
-
- return CompareToDecimal(a, b, decimalPlaces) < 0;
- }
-
- ///
- /// Compares two floats and determines if the first value is smaller than the second
- /// value to within the specified number of decimal places or not.
- ///
- ///
- ///
- /// The values are equal if the difference between the two numbers is smaller than 10^(-numberOfDecimalPlaces). We divide by
- /// two so that we have half the range on each side of thg. if == 2, then 0.01 will equal between
- /// 0.005 and 0.015, but not 0.02 and not 0.00
- ///
- ///
- /// The first value.
- /// The second value.
- /// The number of decimal places.
- /// true if the first value is smaller than the second value; otherwise false.
- public static bool IsSmallerDecimal(this float a, float b, int decimalPlaces)
- {
- // If A or B are a NAN, return false. NANs are equal to nothing,
- // not even themselves, and thus they're not bigger or
- // smaller than anything either
- if (float.IsNaN(a) || float.IsNaN(b))
- {
- return false;
- }
-
- return CompareToDecimal(a, b, decimalPlaces) < 0;
- }
-
- ///
- /// Compares two doubles and determines which double is bigger.
- ///
- /// The first value.
- /// The second value.
- /// The maximum error in terms of Units in Last Place (ulps), i.e. the maximum number of decimals that may be different. Must be 1 or larger.
- ///
- ///
- ///
- /// Return value
- /// Meaning
- ///
- /// -
- /// -1
- /// is smaller than by more than the tolerance.
- ///
- /// -
- /// 0
- /// is equal to within the tolerance.
- ///
- /// -
- /// 1
- /// is bigger than by more than the tolerance.
- ///
- ///
- ///
- public static int CompareTo(this double a, double b, long maxNumbersBetween)
- {
- // If A or B are a NAN, return false. NANs are equal to nothing,
- // not even themselves, and thus they're not bigger or
- // smaller than anything either
- if (double.IsNaN(a) || double.IsNaN(b))
- {
- return a.CompareTo(b);
- }
-
- // If A or B are infinity (positive or negative) then
- // only return true if first is smaller
- if (double.IsInfinity(a) || double.IsInfinity(b))
- {
- return a.CompareTo(b);
- }
-
- // If the numbers are equal to within the tolerance then
- // there's technically no difference
- if (AlmostEqualNumbersBetween(a, b, maxNumbersBetween))
- {
- return 0;
- }
-
- return a.CompareTo(b);
- }
-
- ///
- /// Compares two doubles and determines which double is bigger.
- ///
- /// The first value.
- /// The second value.
- /// The number of decimal places on which the values must be compared. Must be 1 or larger.
- ///
- ///
- ///
- /// Return value
- /// Meaning
- ///
- /// -
- /// -1
- /// is smaller than by more than a magnitude equal to .
- ///
- /// -
- /// 0
- /// is equal to within a magnitude equal to .
- ///
- /// -
- /// 1
- /// is bigger than by more than a magnitude equal to .
- ///
- ///
- ///
- public static int CompareToDecimal(this double a, double b, int decimalPlaces)
- {
- // If A or B are a NAN, return false. NANs are equal to nothing,
- // not even themselves, and thus they're not bigger or
- // smaller than anything either
- if (double.IsNaN(a) || double.IsNaN(b))
- {
- return a.CompareTo(b);
- }
-
- // If A or B are infinity (positive or negative) then
- // only return true if first is smaller
- if (double.IsInfinity(a) || double.IsInfinity(b))
- {
- return a.CompareTo(b);
- }
-
- // If the numbers are equal to within the number of decimal places
- // then there's technically no difference
- if (AlmostEqualRelative(a, b, decimalPlaces))
- {
- return 0;
- }
-
- // The numbers differ by more than the decimal places, so
- // we can check the normal way to see if the first is
- // larger than the second.
- return a.CompareTo(b);
- }
-
///
/// Evaluates the minimum distance to the next distinguishable number near the argument value.
///
diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs
index 22bce1c4..4c56dcc1 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs
@@ -121,7 +121,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
@@ -164,7 +164,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
@@ -240,7 +240,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs
index 80f39fec..d42cfb59 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs
@@ -121,7 +121,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
@@ -165,7 +165,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
@@ -242,7 +242,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs
index 3e449020..aebdb20b 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs
@@ -121,7 +121,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
@@ -165,7 +165,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
@@ -242,7 +242,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs
index 7b1cc04f..76e99531 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs
@@ -121,7 +121,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
@@ -165,7 +165,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
@@ -242,7 +242,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs
index aa135033..02b5af58 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs
@@ -117,7 +117,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
@@ -161,7 +161,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
@@ -238,11 +238,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
-#if !PORTABLE
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
-#else
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary * 10.0f, 1), "#05-" + i);
-#endif
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs
index ae53a8d6..60dc5ed8 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs
@@ -117,7 +117,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
@@ -161,7 +161,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
@@ -238,7 +238,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs
index bda0250d..0f862bbb 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs
@@ -117,7 +117,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
@@ -161,7 +161,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
@@ -238,7 +238,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs
index d7f66342..1d61041c 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs
@@ -117,7 +117,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
@@ -161,7 +161,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
@@ -238,7 +238,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(1e-4f, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, (y[i] - z[i]).Magnitude, "#05-" + i);
}
}
diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs
index 5d9ddf10..4148ffda 100644
--- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs
+++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs
@@ -115,7 +115,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
@@ -159,7 +159,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
@@ -236,11 +236,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
-#if !PORTABLE
- Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
-#else
- Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary * 100.0, 1), "#05-" + i);
-#endif
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs
index 43df5e8d..4a09ac00 100644
--- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs
+++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs
@@ -115,7 +115,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
@@ -159,7 +159,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
@@ -236,11 +236,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
-#if !PORTABLE
- Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
-#else
- Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary * 100.0, 1), "#05-" + i);
-#endif
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs
index 6416b6bc..b6873103 100644
--- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs
+++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs
@@ -115,7 +115,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
@@ -159,7 +159,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
@@ -236,11 +236,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
-#if !PORTABLE
- Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
-#else
- Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary * 100.0, 1), "#05-" + i);
-#endif
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs
index 69cf7d64..ef3b247a 100644
--- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs
+++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs
@@ -115,7 +115,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
@@ -159,7 +159,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
@@ -236,7 +236,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs
index ec038b05..10e62832 100644
--- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs
+++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs
@@ -115,7 +115,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
@@ -159,7 +159,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
@@ -236,7 +236,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs
index 23fc3a1d..b1f44dcf 100644
--- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs
+++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs
@@ -115,7 +115,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
@@ -159,7 +159,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
@@ -236,7 +236,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs
index b44326af..7d2952e1 100644
--- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs
+++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs
@@ -116,7 +116,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
@@ -160,7 +160,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
@@ -251,7 +251,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#04-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
return;
diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs
index 9b65f26b..2606c7b2 100644
--- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs
+++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs
@@ -115,7 +115,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
@@ -159,7 +159,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue((y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
@@ -236,7 +236,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
// Now compare the vectors
for (var i = 0; i < y.Count; i++)
{
- Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i);
+ Assert.GreaterOrEqual(ConvergenceBoundary, Math.Abs(y[i] - z[i]), "#05-" + i);
}
}
diff --git a/src/UnitTests/PrecisionTest.cs b/src/UnitTests/PrecisionTest.cs
index 024f32a4..604dfa10 100644
--- a/src/UnitTests/PrecisionTest.cs
+++ b/src/UnitTests/PrecisionTest.cs
@@ -787,53 +787,53 @@ namespace MathNet.Numerics.UnitTests
public void IsLargerWithMaxNumbersBetween()
{
// compare zero and negative zero
- Assert.IsFalse(Precision.IsLarger(0, -0, 1));
+ Assert.IsFalse(Precision.IsLargerNumbersBetween(0, -0, 1));
// compare two nearby numbers
- Assert.IsFalse(1.0.IsLarger(1.0 + (3 * _doublePrecision), 1));
- Assert.IsFalse(1.0.IsLarger(1.0 + _doublePrecision, 1));
- Assert.IsFalse(1.0.IsLarger(1.0 - _doublePrecision, 1));
- Assert.IsTrue(1.0.IsLarger(1.0 - (3 * _doublePrecision), 1));
+ Assert.IsFalse(1.0.IsLargerNumbersBetween(1.0 + (3 * _doublePrecision), 1));
+ Assert.IsFalse(1.0.IsLargerNumbersBetween(1.0 + _doublePrecision, 1));
+ Assert.IsFalse(1.0.IsLargerNumbersBetween(1.0 - _doublePrecision, 1));
+ Assert.IsTrue(1.0.IsLargerNumbersBetween(1.0 - (3 * _doublePrecision), 1));
// compare with the two numbers reversed in compare order
- Assert.IsTrue((1.0 + (3 * _doublePrecision)).IsLarger(1.0, 1));
- Assert.IsFalse((1.0 + _doublePrecision).IsLarger(1.0, 1));
- Assert.IsFalse((1.0 - _doublePrecision).IsLarger(1.0, 1));
- Assert.IsFalse((1.0 - (3 * _doublePrecision)).IsLarger(1.0, 1));
+ Assert.IsTrue((1.0 + (3 * _doublePrecision)).IsLargerNumbersBetween(1.0, 1));
+ Assert.IsFalse((1.0 + _doublePrecision).IsLargerNumbersBetween(1.0, 1));
+ Assert.IsFalse((1.0 - _doublePrecision).IsLargerNumbersBetween(1.0, 1));
+ Assert.IsFalse((1.0 - (3 * _doublePrecision)).IsLargerNumbersBetween(1.0, 1));
// compare two slightly more different numbers
- Assert.IsFalse(1.0.IsLarger(1.0 + (10 * _doublePrecision), 1));
- Assert.IsFalse(1.0.IsLarger(1.0 + (10 * _doublePrecision), 10));
- Assert.IsFalse(1.0.IsLarger(1.0 - (10 * _doublePrecision), 10));
- Assert.IsTrue(1.0.IsLarger(1.0 - (10 * _doublePrecision), 1));
+ Assert.IsFalse(1.0.IsLargerNumbersBetween(1.0 + (10 * _doublePrecision), 1));
+ Assert.IsFalse(1.0.IsLargerNumbersBetween(1.0 + (10 * _doublePrecision), 10));
+ Assert.IsFalse(1.0.IsLargerNumbersBetween(1.0 - (10 * _doublePrecision), 10));
+ Assert.IsTrue(1.0.IsLargerNumbersBetween(1.0 - (10 * _doublePrecision), 1));
// compare different numbers
- Assert.IsTrue(2.0.IsLarger(1.0, 1));
- Assert.IsFalse(1.0.IsLarger(2.0, 1));
+ Assert.IsTrue(2.0.IsLargerNumbersBetween(1.0, 1));
+ Assert.IsFalse(1.0.IsLargerNumbersBetween(2.0, 1));
// compare different numbers with large tolerance
- Assert.IsFalse(1.0.IsLarger(1.0 + (1e5 * _doublePrecision), 1));
- Assert.IsFalse(1.0.IsLarger(1.0 - (1e5 * _doublePrecision), 200000));
- Assert.IsTrue(1.0.IsLarger(1.0 - (1e5 * _doublePrecision), 1));
+ Assert.IsFalse(1.0.IsLargerNumbersBetween(1.0 + (1e5 * _doublePrecision), 1));
+ Assert.IsFalse(1.0.IsLargerNumbersBetween(1.0 - (1e5 * _doublePrecision), 200000));
+ Assert.IsTrue(1.0.IsLargerNumbersBetween(1.0 - (1e5 * _doublePrecision), 1));
// compare inf & inf
- Assert.IsFalse(double.PositiveInfinity.IsLarger(double.PositiveInfinity, 1));
- Assert.IsFalse(double.NegativeInfinity.IsLarger(double.NegativeInfinity, 1));
+ Assert.IsFalse(double.PositiveInfinity.IsLargerNumbersBetween(double.PositiveInfinity, 1));
+ Assert.IsFalse(double.NegativeInfinity.IsLargerNumbersBetween(double.NegativeInfinity, 1));
// compare -inf and inf
- Assert.IsTrue(double.PositiveInfinity.IsLarger(double.NegativeInfinity, 1));
- Assert.IsFalse(double.NegativeInfinity.IsLarger(double.PositiveInfinity, 1));
+ Assert.IsTrue(double.PositiveInfinity.IsLargerNumbersBetween(double.NegativeInfinity, 1));
+ Assert.IsFalse(double.NegativeInfinity.IsLargerNumbersBetween(double.PositiveInfinity, 1));
// compare inf and non-inf
- Assert.IsTrue(double.PositiveInfinity.IsLarger(1.0, 1));
- Assert.IsFalse(1.0.IsLarger(double.PositiveInfinity, 1));
+ Assert.IsTrue(double.PositiveInfinity.IsLargerNumbersBetween(1.0, 1));
+ Assert.IsFalse(1.0.IsLargerNumbersBetween(double.PositiveInfinity, 1));
- Assert.IsFalse(double.NegativeInfinity.IsLarger(1.0, 1));
- Assert.IsTrue(1.0.IsLarger(double.NegativeInfinity, 1));
+ Assert.IsFalse(double.NegativeInfinity.IsLargerNumbersBetween(1.0, 1));
+ Assert.IsTrue(1.0.IsLargerNumbersBetween(double.NegativeInfinity, 1));
// compare tiny numbers with opposite signs
- Assert.IsTrue(double.Epsilon.IsLarger(-double.Epsilon, 1));
- Assert.IsFalse((-double.Epsilon).IsLarger(double.Epsilon, 1));
+ Assert.IsTrue(double.Epsilon.IsLargerNumbersBetween(-double.Epsilon, 1));
+ Assert.IsFalse((-double.Epsilon).IsLargerNumbersBetween(double.Epsilon, 1));
}
///
@@ -842,39 +842,44 @@ namespace MathNet.Numerics.UnitTests
[Test]
public void IsLargerWithDecimalPlaces()
{
- Assert.IsFalse(Precision.IsLargerDecimal(1, double.NaN, 2));
- Assert.IsFalse(double.NaN.IsLargerDecimal(2, 2));
- Assert.IsFalse(double.NaN.IsLargerDecimal(double.NaN, 2));
+ Assert.IsFalse(Precision.IsLarger(1, double.NaN, 2));
+ Assert.IsFalse(double.NaN.IsLarger(2, 2));
+ Assert.IsFalse(double.NaN.IsLarger(double.NaN, 2));
- Assert.IsFalse(double.NegativeInfinity.IsLargerDecimal(2, 2));
- Assert.IsTrue(Precision.IsLargerDecimal(1, double.NegativeInfinity, 2));
+ Assert.IsFalse(double.NegativeInfinity.IsLarger(2, 2));
+ Assert.IsTrue(Precision.IsLarger(1, double.NegativeInfinity, 2));
- Assert.IsTrue(double.PositiveInfinity.IsLargerDecimal(2, 2));
- Assert.IsFalse(Precision.IsLargerDecimal(1, double.PositiveInfinity, 2));
+ Assert.IsTrue(double.PositiveInfinity.IsLarger(2, 2));
+ Assert.IsFalse(Precision.IsLarger(1, double.PositiveInfinity, 2));
- Assert.IsFalse(double.NegativeInfinity.IsLargerDecimal(double.PositiveInfinity, 2));
- Assert.IsTrue(double.PositiveInfinity.IsLargerDecimal(double.NegativeInfinity, 2));
+ Assert.IsFalse(double.NegativeInfinity.IsLarger(double.PositiveInfinity, 2));
+ Assert.IsTrue(double.PositiveInfinity.IsLarger(double.NegativeInfinity, 2));
- Assert.IsFalse(double.PositiveInfinity.IsLargerDecimal(double.PositiveInfinity, 2));
- Assert.IsFalse(double.NegativeInfinity.IsLargerDecimal(double.NegativeInfinity, 2));
+ Assert.IsFalse(double.PositiveInfinity.IsLarger(double.PositiveInfinity, 2));
+ Assert.IsFalse(double.NegativeInfinity.IsLarger(double.NegativeInfinity, 2));
- Assert.IsFalse(1.0.IsLargerDecimal(1.006, 2));
- Assert.IsFalse(1.0.IsLargerDecimal(1.004, 2));
- Assert.IsFalse(1.0.IsLargerDecimal(0.996, 2));
- Assert.IsTrue(1.0.IsLargerDecimal(0.994, 2));
+ Assert.IsFalse(1.0.IsLarger(1.006, 2));
+ Assert.IsFalse(1.0.IsLarger(1.004, 2));
+ Assert.IsFalse(1.0.IsLarger(0.996, 2));
+ Assert.IsTrue(1.0.IsLarger(0.994, 2));
- Assert.IsFalse(100.0.IsLargerDecimal(100.6, 2));
- Assert.IsFalse(100.0.IsLargerDecimal(100.4, 2));
- Assert.IsFalse(100.0.IsLargerDecimal(99.6, 2));
- Assert.IsTrue(100.0.IsLargerDecimal(99.4, 2));
+ Assert.IsFalse(1.0.IsLargerRelative(1.006, 2));
+ Assert.IsFalse(1.0.IsLargerRelative(1.004, 2));
+ Assert.IsFalse(1.0.IsLargerRelative(0.996, 2));
+ Assert.IsTrue(1.0.IsLargerRelative(0.994, 2));
+
+ Assert.IsFalse(100.0.IsLargerRelative(100.6, 2));
+ Assert.IsFalse(100.0.IsLargerRelative(100.4, 2));
+ Assert.IsFalse(100.0.IsLargerRelative(99.6, 2));
+ Assert.IsTrue(100.0.IsLargerRelative(99.4, 2));
var max = 0.4 * Math.Pow(10, _doublePrecision.Magnitude());
- Assert.IsFalse(0.0.IsLargerDecimal(max, -_doublePrecision.Magnitude()));
- Assert.IsFalse(0.0.IsLargerDecimal(-max, -_doublePrecision.Magnitude()));
+ Assert.IsFalse(0.0.IsLarger(max, -_doublePrecision.Magnitude()));
+ Assert.IsFalse(0.0.IsLarger(-max, -_doublePrecision.Magnitude()));
max = 0.6 * Math.Pow(10, _doublePrecision.Magnitude());
- Assert.IsFalse(0.0.IsLargerDecimal(max, -_doublePrecision.Magnitude()));
- Assert.IsTrue(0.0.IsLargerDecimal(-max, -_doublePrecision.Magnitude()));
+ Assert.IsFalse(0.0.IsLarger(max, -_doublePrecision.Magnitude()));
+ Assert.IsTrue(0.0.IsLarger(-max, -_doublePrecision.Magnitude()));
}
///
@@ -884,53 +889,53 @@ namespace MathNet.Numerics.UnitTests
public void IsSmallerWithMaxNumbersBetween()
{
// compare zero and negative zero
- Assert.IsFalse(Precision.IsSmaller(0, -0, 1));
+ Assert.IsFalse(Precision.IsSmallerNumbersBetween(0, -0, 1));
// compare two nearby numbers
- Assert.IsTrue(1.0.IsSmaller(1.0 + (3 * _doublePrecision), 1));
- Assert.IsFalse(1.0.IsSmaller(1.0 + _doublePrecision, 1));
- Assert.IsFalse(1.0.IsSmaller(1.0 - _doublePrecision, 1));
- Assert.IsFalse(1.0.IsSmaller(1.0 - (3 * _doublePrecision), 1));
+ Assert.IsTrue(1.0.IsSmallerNumbersBetween(1.0 + (3 * _doublePrecision), 1));
+ Assert.IsFalse(1.0.IsSmallerNumbersBetween(1.0 + _doublePrecision, 1));
+ Assert.IsFalse(1.0.IsSmallerNumbersBetween(1.0 - _doublePrecision, 1));
+ Assert.IsFalse(1.0.IsSmallerNumbersBetween(1.0 - (3 * _doublePrecision), 1));
// compare with the two numbers reversed in compare order
- Assert.IsFalse((1.0 + (3 * _doublePrecision)).IsSmaller(1.0, 1));
- Assert.IsFalse((1.0 + _doublePrecision).IsSmaller(1.0, 1));
- Assert.IsFalse((1.0 - _doublePrecision).IsSmaller(1.0, 1));
- Assert.IsTrue((1.0 - (3 * _doublePrecision)).IsSmaller(1.0, 1));
+ Assert.IsFalse((1.0 + (3 * _doublePrecision)).IsSmallerNumbersBetween(1.0, 1));
+ Assert.IsFalse((1.0 + _doublePrecision).IsSmallerNumbersBetween(1.0, 1));
+ Assert.IsFalse((1.0 - _doublePrecision).IsSmallerNumbersBetween(1.0, 1));
+ Assert.IsTrue((1.0 - (3 * _doublePrecision)).IsSmallerNumbersBetween(1.0, 1));
// compare two slightly more different numbers
- Assert.IsTrue(1.0.IsSmaller(1.0 + (10 * _doublePrecision), 1));
- Assert.IsFalse(1.0.IsSmaller(1.0 + (10 * _doublePrecision), 10));
- Assert.IsFalse(1.0.IsSmaller(1.0 - (10 * _doublePrecision), 10));
- Assert.IsFalse(1.0.IsSmaller(1.0 - (10 * _doublePrecision), 1));
+ Assert.IsTrue(1.0.IsSmallerNumbersBetween(1.0 + (10 * _doublePrecision), 1));
+ Assert.IsFalse(1.0.IsSmallerNumbersBetween(1.0 + (10 * _doublePrecision), 10));
+ Assert.IsFalse(1.0.IsSmallerNumbersBetween(1.0 - (10 * _doublePrecision), 10));
+ Assert.IsFalse(1.0.IsSmallerNumbersBetween(1.0 - (10 * _doublePrecision), 1));
// compare different numbers
- Assert.IsFalse(2.0.IsSmaller(1.0, 1));
- Assert.IsTrue(1.0.IsSmaller(2.0, 1));
+ Assert.IsFalse(2.0.IsSmallerNumbersBetween(1.0, 1));
+ Assert.IsTrue(1.0.IsSmallerNumbersBetween(2.0, 1));
// compare different numbers with large tolerance
- Assert.IsTrue(1.0.IsSmaller(1.0 + (1e5 * _doublePrecision), 1));
- Assert.IsFalse(1.0.IsSmaller(1.0 - (1e5 * _doublePrecision), 200000));
- Assert.IsFalse(1.0.IsSmaller(1.0 - (1e5 * _doublePrecision), 1));
+ Assert.IsTrue(1.0.IsSmallerNumbersBetween(1.0 + (1e5 * _doublePrecision), 1));
+ Assert.IsFalse(1.0.IsSmallerNumbersBetween(1.0 - (1e5 * _doublePrecision), 200000));
+ Assert.IsFalse(1.0.IsSmallerNumbersBetween(1.0 - (1e5 * _doublePrecision), 1));
// compare inf & inf
- Assert.IsFalse(double.PositiveInfinity.IsSmaller(double.PositiveInfinity, 1));
- Assert.IsFalse(double.NegativeInfinity.IsSmaller(double.NegativeInfinity, 1));
+ Assert.IsFalse(double.PositiveInfinity.IsSmallerNumbersBetween(double.PositiveInfinity, 1));
+ Assert.IsFalse(double.NegativeInfinity.IsSmallerNumbersBetween(double.NegativeInfinity, 1));
// compare -inf and inf
- Assert.IsFalse(double.PositiveInfinity.IsSmaller(double.NegativeInfinity, 1));
- Assert.IsTrue(double.NegativeInfinity.IsSmaller(double.PositiveInfinity, 1));
+ Assert.IsFalse(double.PositiveInfinity.IsSmallerNumbersBetween(double.NegativeInfinity, 1));
+ Assert.IsTrue(double.NegativeInfinity.IsSmallerNumbersBetween(double.PositiveInfinity, 1));
// compare inf and non-inf
- Assert.IsFalse(double.PositiveInfinity.IsSmaller(1.0, 1));
- Assert.IsTrue(1.0.IsSmaller(double.PositiveInfinity, 1));
+ Assert.IsFalse(double.PositiveInfinity.IsSmallerNumbersBetween(1.0, 1));
+ Assert.IsTrue(1.0.IsSmallerNumbersBetween(double.PositiveInfinity, 1));
- Assert.IsTrue(double.NegativeInfinity.IsSmaller(1.0, 1));
- Assert.IsFalse(1.0.IsSmaller(double.NegativeInfinity, 1));
+ Assert.IsTrue(double.NegativeInfinity.IsSmallerNumbersBetween(1.0, 1));
+ Assert.IsFalse(1.0.IsSmallerNumbersBetween(double.NegativeInfinity, 1));
// compare tiny numbers with opposite signs
- Assert.IsFalse(double.Epsilon.IsSmaller(-double.Epsilon, 1));
- Assert.IsTrue((-double.Epsilon).IsSmaller(double.Epsilon, 1));
+ Assert.IsFalse(double.Epsilon.IsSmallerNumbersBetween(-double.Epsilon, 1));
+ Assert.IsTrue((-double.Epsilon).IsSmallerNumbersBetween(double.Epsilon, 1));
}
///
@@ -939,39 +944,44 @@ namespace MathNet.Numerics.UnitTests
[Test]
public void IsSmallerWithDecimalPlaces()
{
- Assert.IsFalse(Precision.IsSmallerDecimal(1, double.NaN, 2));
- Assert.IsFalse(double.NaN.IsSmallerDecimal(2, 2));
- Assert.IsFalse(double.NaN.IsSmallerDecimal(double.NaN, 2));
+ Assert.IsFalse(Precision.IsSmaller(1, double.NaN, 2));
+ Assert.IsFalse(double.NaN.IsSmaller(2, 2));
+ Assert.IsFalse(double.NaN.IsSmaller(double.NaN, 2));
+
+ Assert.IsTrue(double.NegativeInfinity.IsSmaller(2, 2));
+ Assert.IsFalse(Precision.IsSmaller(1, double.NegativeInfinity, 2));
- Assert.IsTrue(double.NegativeInfinity.IsSmallerDecimal(2, 2));
- Assert.IsFalse(Precision.IsSmallerDecimal(1, double.NegativeInfinity, 2));
+ Assert.IsFalse(double.PositiveInfinity.IsSmaller(2, 2));
+ Assert.IsTrue(Precision.IsSmaller(1, double.PositiveInfinity, 2));
- Assert.IsFalse(double.PositiveInfinity.IsSmallerDecimal(2, 2));
- Assert.IsTrue(Precision.IsSmallerDecimal(1, double.PositiveInfinity, 2));
+ Assert.IsTrue(double.NegativeInfinity.IsSmaller(double.PositiveInfinity, 2));
+ Assert.IsFalse(double.PositiveInfinity.IsSmaller(double.NegativeInfinity, 2));
- Assert.IsTrue(double.NegativeInfinity.IsSmallerDecimal(double.PositiveInfinity, 2));
- Assert.IsFalse(double.PositiveInfinity.IsSmallerDecimal(double.NegativeInfinity, 2));
+ Assert.IsFalse(double.PositiveInfinity.IsSmaller(double.PositiveInfinity, 2));
+ Assert.IsFalse(double.NegativeInfinity.IsSmaller(double.NegativeInfinity, 2));
- Assert.IsFalse(double.PositiveInfinity.IsSmallerDecimal(double.PositiveInfinity, 2));
- Assert.IsFalse(double.NegativeInfinity.IsSmallerDecimal(double.NegativeInfinity, 2));
+ Assert.IsTrue(1.0.IsSmaller(1.006, 2));
+ Assert.IsFalse(1.0.IsSmaller(1.004, 2));
+ Assert.IsFalse(1.0.IsSmaller(0.996, 2));
+ Assert.IsFalse(1.0.IsSmaller(0.994, 2));
- Assert.IsTrue(1.0.IsSmallerDecimal(1.006, 2));
- Assert.IsFalse(1.0.IsSmallerDecimal(1.004, 2));
- Assert.IsFalse(1.0.IsSmallerDecimal(0.996, 2));
- Assert.IsFalse(1.0.IsSmallerDecimal(0.994, 2));
+ Assert.IsTrue(1.0.IsSmallerRelative(1.006, 2));
+ Assert.IsFalse(1.0.IsSmallerRelative(1.004, 2));
+ Assert.IsFalse(1.0.IsSmallerRelative(0.996, 2));
+ Assert.IsFalse(1.0.IsSmallerRelative(0.994, 2));
- Assert.IsTrue(100.0.IsSmallerDecimal(100.6, 2));
- Assert.IsFalse(100.0.IsSmallerDecimal(100.4, 2));
- Assert.IsFalse(100.0.IsSmallerDecimal(99.6, 2));
- Assert.IsFalse(100.0.IsSmallerDecimal(99.4, 2));
+ Assert.IsTrue(100.0.IsSmallerRelative(100.6, 2));
+ Assert.IsFalse(100.0.IsSmallerRelative(100.4, 2));
+ Assert.IsFalse(100.0.IsSmallerRelative(99.6, 2));
+ Assert.IsFalse(100.0.IsSmallerRelative(99.4, 2));
var max = 0.4 * Math.Pow(10, _doublePrecision.Magnitude());
- Assert.IsFalse(0.0.IsSmallerDecimal(max, -_doublePrecision.Magnitude()));
- Assert.IsFalse(0.0.IsSmallerDecimal(-max, -_doublePrecision.Magnitude()));
+ Assert.IsFalse(0.0.IsSmaller(max, -_doublePrecision.Magnitude()));
+ Assert.IsFalse(0.0.IsSmaller(-max, -_doublePrecision.Magnitude()));
max = 0.6 * Math.Pow(10, _doublePrecision.Magnitude());
- Assert.IsTrue(0.0.IsSmallerDecimal(max, -_doublePrecision.Magnitude()));
- Assert.IsFalse(0.0.IsSmallerDecimal(-max, -_doublePrecision.Magnitude()));
+ Assert.IsTrue(0.0.IsSmaller(max, -_doublePrecision.Magnitude()));
+ Assert.IsFalse(0.0.IsSmaller(-max, -_doublePrecision.Magnitude()));
}
///
@@ -981,7 +991,7 @@ namespace MathNet.Numerics.UnitTests
public void CompareToWithMaxNumbersBetweenWithNegativeNumberThrows()
{
const double Value = 10.0;
- Assert.Throws(() => Value.CompareTo(Value, -1));
+ Assert.Throws(() => Value.CompareToNumbersBetween(Value, -1));
}
///
@@ -991,7 +1001,7 @@ namespace MathNet.Numerics.UnitTests
public void CompareToWithMaxNumbersBetweenWithZeroNumberThrows()
{
const double Value = 10.0;
- Assert.Throws(() => Value.CompareTo(Value, 0));
+ Assert.Throws(() => Value.CompareToNumbersBetween(Value, 0));
}
///
@@ -1000,17 +1010,17 @@ namespace MathNet.Numerics.UnitTests
[Test]
public void CompareToWithMaxNumbersBetweenWithInfinityValue()
{
- Assert.AreEqual(0, double.PositiveInfinity.CompareTo(double.PositiveInfinity, 1));
- Assert.AreEqual(0, double.NegativeInfinity.CompareTo(double.NegativeInfinity, 1));
+ Assert.AreEqual(0, double.PositiveInfinity.CompareToNumbersBetween(double.PositiveInfinity, 1));
+ Assert.AreEqual(0, double.NegativeInfinity.CompareToNumbersBetween(double.NegativeInfinity, 1));
- Assert.AreEqual(1, double.PositiveInfinity.CompareTo(double.NegativeInfinity, 1));
- Assert.AreEqual(-1, double.NegativeInfinity.CompareTo(double.PositiveInfinity, 1));
+ Assert.AreEqual(1, double.PositiveInfinity.CompareToNumbersBetween(double.NegativeInfinity, 1));
+ Assert.AreEqual(-1, double.NegativeInfinity.CompareToNumbersBetween(double.PositiveInfinity, 1));
- Assert.AreEqual(-1, Precision.CompareTo(1, double.PositiveInfinity, 1));
- Assert.AreEqual(1, double.PositiveInfinity.CompareTo(1, 1));
+ Assert.AreEqual(-1, Precision.CompareToNumbersBetween(1, double.PositiveInfinity, 1));
+ Assert.AreEqual(1, double.PositiveInfinity.CompareToNumbersBetween(1, 1));
- Assert.AreEqual(1, Precision.CompareTo(1, double.NegativeInfinity, 1));
- Assert.AreEqual(-1, double.NegativeInfinity.CompareTo(1, 1));
+ Assert.AreEqual(1, Precision.CompareToNumbersBetween(1, double.NegativeInfinity, 1));
+ Assert.AreEqual(-1, double.NegativeInfinity.CompareToNumbersBetween(1, 1));
}
///
@@ -1020,9 +1030,9 @@ namespace MathNet.Numerics.UnitTests
public void CompareToWithMaxNumbersBetweenWithNaNValue()
{
// compare nan & not-nan
- Assert.AreEqual(1, Precision.CompareTo(1, double.NaN, 1));
- Assert.AreEqual(0, double.NaN.CompareTo(double.NaN, 1));
- Assert.AreEqual(-1, double.NaN.CompareTo(1, 1));
+ Assert.AreEqual(1, Precision.CompareToNumbersBetween(1, double.NaN, 1));
+ Assert.AreEqual(0, double.NaN.CompareToNumbersBetween(double.NaN, 1));
+ Assert.AreEqual(-1, double.NaN.CompareToNumbersBetween(1, 1));
}
///
@@ -1031,8 +1041,8 @@ namespace MathNet.Numerics.UnitTests
[Test]
public void CompareToWithMaxNumbersBetweenForValuesThatOverFlowALong()
{
- Assert.AreEqual(1, 2.0.CompareTo(-2.0, 1));
- Assert.AreEqual(-1, (-2.0).CompareTo(2.0, 1));
+ Assert.AreEqual(1, 2.0.CompareToNumbersBetween(-2.0, 1));
+ Assert.AreEqual(-1, (-2.0).CompareToNumbersBetween(2.0, 1));
}
///
@@ -1042,53 +1052,53 @@ namespace MathNet.Numerics.UnitTests
public void CompareToWithMaxNumbersBetween()
{
// compare zero and negative zero
- Assert.AreEqual(0, Precision.CompareTo(0, -0, 1));
+ Assert.AreEqual(0, Precision.CompareToNumbersBetween(0, -0, 1));
// compare two nearby numbers
- Assert.AreEqual(-1, 1.0.CompareTo(1.0 + (3 * _doublePrecision), 1));
- Assert.AreEqual(0, 1.0.CompareTo(1.0 + _doublePrecision, 1));
- Assert.AreEqual(0, 1.0.CompareTo(1.0 - _doublePrecision, 1));
- Assert.AreEqual(1, 1.0.CompareTo(1.0 - (3 * _doublePrecision), 1));
+ Assert.AreEqual(-1, 1.0.CompareToNumbersBetween(1.0 + (3 * _doublePrecision), 1));
+ Assert.AreEqual(0, 1.0.CompareToNumbersBetween(1.0 + _doublePrecision, 1));
+ Assert.AreEqual(0, 1.0.CompareToNumbersBetween(1.0 - _doublePrecision, 1));
+ Assert.AreEqual(1, 1.0.CompareToNumbersBetween(1.0 - (3 * _doublePrecision), 1));
// compare with the two numbers reversed in compare order
- Assert.AreEqual(1, (1.0 + (3 * _doublePrecision)).CompareTo(1.0, 1));
- Assert.AreEqual(0, (1.0 + _doublePrecision).CompareTo(1.0, 1));
- Assert.AreEqual(0, (1.0 - _doublePrecision).CompareTo(1.0, 1));
- Assert.AreEqual(-1, (1.0 - (3 * _doublePrecision)).CompareTo(1.0, 1));
+ Assert.AreEqual(1, (1.0 + (3 * _doublePrecision)).CompareToNumbersBetween(1.0, 1));
+ Assert.AreEqual(0, (1.0 + _doublePrecision).CompareToNumbersBetween(1.0, 1));
+ Assert.AreEqual(0, (1.0 - _doublePrecision).CompareToNumbersBetween(1.0, 1));
+ Assert.AreEqual(-1, (1.0 - (3 * _doublePrecision)).CompareToNumbersBetween(1.0, 1));
// compare two slightly more different numbers
- Assert.AreEqual(-1, 1.0.CompareTo(1.0 + (10 * _doublePrecision), 1));
- Assert.AreEqual(0, 1.0.CompareTo(1.0 + (10 * _doublePrecision), 10));
- Assert.AreEqual(0, 1.0.CompareTo(1.0 - (10 * _doublePrecision), 10));
- Assert.AreEqual(1, 1.0.CompareTo(1.0 - (10 * _doublePrecision), 1));
+ Assert.AreEqual(-1, 1.0.CompareToNumbersBetween(1.0 + (10 * _doublePrecision), 1));
+ Assert.AreEqual(0, 1.0.CompareToNumbersBetween(1.0 + (10 * _doublePrecision), 10));
+ Assert.AreEqual(0, 1.0.CompareToNumbersBetween(1.0 - (10 * _doublePrecision), 10));
+ Assert.AreEqual(1, 1.0.CompareToNumbersBetween(1.0 - (10 * _doublePrecision), 1));
// compare different numbers
- Assert.AreEqual(1, 2.0.CompareTo(1.0, 1));
- Assert.AreEqual(-1, 1.0.CompareTo(2.0, 1));
+ Assert.AreEqual(1, 2.0.CompareToNumbersBetween(1.0, 1));
+ Assert.AreEqual(-1, 1.0.CompareToNumbersBetween(2.0, 1));
// compare different numbers with large tolerance
- Assert.AreEqual(-1, 1.0.CompareTo(1.0 + (1e5 * _doublePrecision), 1));
- Assert.AreEqual(0, 1.0.CompareTo(1.0 - (1e5 * _doublePrecision), 200000));
- Assert.AreEqual(1, 1.0.CompareTo(1.0 - (1e5 * _doublePrecision), 1));
+ Assert.AreEqual(-1, 1.0.CompareToNumbersBetween(1.0 + (1e5 * _doublePrecision), 1));
+ Assert.AreEqual(0, 1.0.CompareToNumbersBetween(1.0 - (1e5 * _doublePrecision), 200000));
+ Assert.AreEqual(1, 1.0.CompareToNumbersBetween(1.0 - (1e5 * _doublePrecision), 1));
// compare inf & inf
- Assert.AreEqual(0, double.PositiveInfinity.CompareTo(double.PositiveInfinity, 1));
- Assert.AreEqual(0, double.NegativeInfinity.CompareTo(double.NegativeInfinity, 1));
+ Assert.AreEqual(0, double.PositiveInfinity.CompareToNumbersBetween(double.PositiveInfinity, 1));
+ Assert.AreEqual(0, double.NegativeInfinity.CompareToNumbersBetween(double.NegativeInfinity, 1));
// compare -inf and inf
- Assert.AreEqual(1, double.PositiveInfinity.CompareTo(double.NegativeInfinity, 1));
- Assert.AreEqual(-1, double.NegativeInfinity.CompareTo(double.PositiveInfinity, 1));
+ Assert.AreEqual(1, double.PositiveInfinity.CompareToNumbersBetween(double.NegativeInfinity, 1));
+ Assert.AreEqual(-1, double.NegativeInfinity.CompareToNumbersBetween(double.PositiveInfinity, 1));
// compare inf and non-inf
- Assert.AreEqual(1, double.PositiveInfinity.CompareTo(1.0, 1));
- Assert.AreEqual(-1, 1.0.CompareTo(double.PositiveInfinity, 1));
+ Assert.AreEqual(1, double.PositiveInfinity.CompareToNumbersBetween(1.0, 1));
+ Assert.AreEqual(-1, 1.0.CompareToNumbersBetween(double.PositiveInfinity, 1));
- Assert.AreEqual(-1, double.NegativeInfinity.CompareTo(1.0, 1));
- Assert.AreEqual(1, 1.0.CompareTo(double.NegativeInfinity, 1));
+ Assert.AreEqual(-1, double.NegativeInfinity.CompareToNumbersBetween(1.0, 1));
+ Assert.AreEqual(1, 1.0.CompareToNumbersBetween(double.NegativeInfinity, 1));
// compare tiny numbers with opposite signs
- Assert.AreEqual(1, double.Epsilon.CompareTo(-double.Epsilon, 1));
- Assert.AreEqual(-1, (-double.Epsilon).CompareTo(double.Epsilon, 1));
+ Assert.AreEqual(1, double.Epsilon.CompareToNumbersBetween(-double.Epsilon, 1));
+ Assert.AreEqual(-1, (-double.Epsilon).CompareToNumbersBetween(double.Epsilon, 1));
}
///
@@ -1098,50 +1108,50 @@ namespace MathNet.Numerics.UnitTests
public void CompareToWithDecimalPlaces()
{
// compare zero and negative zero
- Assert.AreEqual(0, Precision.CompareToDecimal(0, -0, 1));
- Assert.AreEqual(0, Precision.CompareToDecimal(0, -0, Precision.DoubleDecimalPlaces));
- Assert.AreEqual(0, Precision.CompareToDecimal(0, -0, Precision.SingleDecimalPlaces));
+ Assert.AreEqual(0, Precision.CompareTo(0, -0, 1));
+ Assert.AreEqual(0, Precision.CompareTo(0, -0, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(0, Precision.CompareTo(0, -0, Precision.SingleDecimalPlaces));
// compare two nearby numbers
- Assert.AreEqual(-1, 1.0.CompareToDecimal(1.0 + 10*_doublePrecision, Precision.DoubleDecimalPlaces));
- Assert.AreEqual(0, 1.0.CompareToDecimal(1.0 + _doublePrecision, Precision.DoubleDecimalPlaces));
- Assert.AreEqual(0, 1.0.CompareToDecimal(1.0 - _doublePrecision, Precision.DoubleDecimalPlaces));
- Assert.AreEqual(1, 1.0.CompareToDecimal(1.0 - 10*_doublePrecision, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(-1, 1.0.CompareTo(1.0 + 10*_doublePrecision, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(0, 1.0.CompareTo(1.0 + _doublePrecision, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(0, 1.0.CompareTo(1.0 - _doublePrecision, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(1, 1.0.CompareTo(1.0 - 10*_doublePrecision, Precision.DoubleDecimalPlaces));
// compare with the two numbers reversed in compare order
- Assert.AreEqual(1, (1.0 + 10*_doublePrecision).CompareToDecimal(1.0, Precision.DoubleDecimalPlaces));
- Assert.AreEqual(0, (1.0 + _doublePrecision).CompareToDecimal(1.0, Precision.DoubleDecimalPlaces));
- Assert.AreEqual(0, (1.0 - _doublePrecision).CompareToDecimal(1.0, Precision.DoubleDecimalPlaces));
- Assert.AreEqual(-1, (1.0 - 10*_doublePrecision).CompareToDecimal(1.0, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(1, (1.0 + 10*_doublePrecision).CompareTo(1.0, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(0, (1.0 + _doublePrecision).CompareTo(1.0, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(0, (1.0 - _doublePrecision).CompareTo(1.0, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(-1, (1.0 - 10*_doublePrecision).CompareTo(1.0, Precision.DoubleDecimalPlaces));
// compare two slightly more different numbers
- Assert.AreEqual(-1, 1.0.CompareToDecimal(1.0 + (50*_doublePrecision), Precision.DoubleDecimalPlaces));
- Assert.AreEqual(0, 1.0.CompareToDecimal(1.0 + (50*_doublePrecision), Precision.DoubleDecimalPlaces - 2));
- Assert.AreEqual(0, 1.0.CompareToDecimal(1.0 - (50*_doublePrecision), Precision.DoubleDecimalPlaces - 2));
- Assert.AreEqual(1, 1.0.CompareToDecimal(1.0 - (50*_doublePrecision), Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(-1, 1.0.CompareTo(1.0 + (50*_doublePrecision), Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(0, 1.0.CompareTo(1.0 + (50*_doublePrecision), Precision.DoubleDecimalPlaces - 2));
+ Assert.AreEqual(0, 1.0.CompareTo(1.0 - (50*_doublePrecision), Precision.DoubleDecimalPlaces - 2));
+ Assert.AreEqual(1, 1.0.CompareTo(1.0 - (50*_doublePrecision), Precision.DoubleDecimalPlaces));
// compare different numbers
- Assert.AreEqual(1, 2.0.CompareToDecimal(1.0, Precision.DoubleDecimalPlaces));
- Assert.AreEqual(-1, 1.0.CompareToDecimal(2.0, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(1, 2.0.CompareTo(1.0, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(-1, 1.0.CompareTo(2.0, Precision.DoubleDecimalPlaces));
// compare different numbers with large tolerance
- Assert.AreEqual(-1, 1.0.CompareToDecimal(1.0 + (1e5 * _doublePrecision), Precision.DoubleDecimalPlaces));
- Assert.AreEqual(0, 1.0.CompareToDecimal(1.0 - (1e5 * _doublePrecision), 10));
- Assert.AreEqual(1, 1.0.CompareToDecimal(1.0 - (1e5 * _doublePrecision), Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(-1, 1.0.CompareTo(1.0 + (1e5 * _doublePrecision), Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(0, 1.0.CompareTo(1.0 - (1e5 * _doublePrecision), 10));
+ Assert.AreEqual(1, 1.0.CompareTo(1.0 - (1e5 * _doublePrecision), Precision.DoubleDecimalPlaces));
// compare inf & inf
- Assert.AreEqual(0, double.PositiveInfinity.CompareToDecimal(double.PositiveInfinity, Precision.DoubleDecimalPlaces));
- Assert.AreEqual(0, double.NegativeInfinity.CompareToDecimal(double.NegativeInfinity, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(0, double.PositiveInfinity.CompareTo(double.PositiveInfinity, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(0, double.NegativeInfinity.CompareTo(double.NegativeInfinity, Precision.DoubleDecimalPlaces));
// compare -inf and inf
- Assert.AreEqual(1, double.PositiveInfinity.CompareToDecimal(double.NegativeInfinity, Precision.DoubleDecimalPlaces));
- Assert.AreEqual(-1, double.NegativeInfinity.CompareToDecimal(double.PositiveInfinity, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(1, double.PositiveInfinity.CompareTo(double.NegativeInfinity, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(-1, double.NegativeInfinity.CompareTo(double.PositiveInfinity, Precision.DoubleDecimalPlaces));
// compare inf and non-inf
- Assert.AreEqual(1, double.PositiveInfinity.CompareToDecimal(1.0, Precision.DoubleDecimalPlaces));
- Assert.AreEqual(-1, 1.0.CompareToDecimal(double.PositiveInfinity, Precision.DoubleDecimalPlaces));
- Assert.AreEqual(-1, double.NegativeInfinity.CompareToDecimal(1.0, Precision.DoubleDecimalPlaces));
- Assert.AreEqual(1, 1.0.CompareToDecimal(double.NegativeInfinity, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(1, double.PositiveInfinity.CompareTo(1.0, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(-1, 1.0.CompareTo(double.PositiveInfinity, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(-1, double.NegativeInfinity.CompareTo(1.0, Precision.DoubleDecimalPlaces));
+ Assert.AreEqual(1, 1.0.CompareTo(double.NegativeInfinity, Precision.DoubleDecimalPlaces));
}
}
}