Browse Source

RootFinding: migrate message strings to resources

v2
Christoph Ruegg 14 years ago
parent
commit
8742c92578
  1. 18
      src/Numerics/Properties/Resources.Designer.cs
  2. 14
      src/Numerics/Properties/Resources.resx
  3. 3
      src/Numerics/RootFinding/BrentRootFinder.cs
  4. 13
      src/Numerics/RootFinding/RootFinder.cs

18
src/Numerics/Properties/Resources.Designer.cs

@ -60,6 +60,15 @@ namespace MathNet.Numerics.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to The accuracy couldn&apos;t be reached with the specified number of iterations..
/// </summary>
public static string AccuracyNotReached {
get {
return ResourceManager.GetString("AccuracyNotReached", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The array arguments must have the same length..
/// </summary>
@ -744,6 +753,15 @@ namespace MathNet.Numerics.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to The algorithm ended without root in the range..
/// </summary>
public static string RootNotFound {
get {
return ResourceManager.GetString("RootNotFound", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The number of rows must greater than or equal to the number of columns..
/// </summary>

14
src/Numerics/Properties/Resources.resx

@ -369,10 +369,16 @@
<data name="TooManyElements" xml:space="preserve">
<value>We only support sparse matrix with less than int.MaxValue elements.</value>
</data>
<data name="Interpolation_Initialize_SamplePointsNotStrictlyAscendingOrder">
<value xml:space="preserve">Sample points should be sorted in strictly ascending order</value>
<data name="Interpolation_Initialize_SamplePointsNotStrictlyAscendingOrder" xml:space="preserve">
<value>Sample points should be sorted in strictly ascending order</value>
</data>
<data name="Interpolation_Initialize_SamplePointsNotUnique">
<value xml:space="preserve">All sample points should be unique.</value>
<data name="Interpolation_Initialize_SamplePointsNotUnique" xml:space="preserve">
<value>All sample points should be unique.</value>
</data>
<data name="AccuracyNotReached" xml:space="preserve">
<value>The accuracy couldn't be reached with the specified number of iterations.</value>
</data>
<data name="RootNotFound" xml:space="preserve">
<value>The algorithm ended without root in the range.</value>
</data>
</root>

3
src/Numerics/RootFinding/BrentRootFinder.cs

@ -1,4 +1,5 @@
using System;
using MathNet.Numerics.Properties;
namespace MathNet.Numerics.RootFinding
{
@ -108,7 +109,7 @@ namespace MathNet.Numerics.RootFinding
}
// The algorithm has exceeded the number of iterations allowed
throw new RootFinderException(ACCURACY_NOT_REACHED, i, new Range(XMin, XMax), Math.Abs(xMid));
throw new RootFinderException(Resources.AccuracyNotReached, i, new Range(XMin, XMax), Math.Abs(xMid));
}
}
}

13
src/Numerics/RootFinding/RootFinder.cs

@ -1,4 +1,5 @@
using System;
using MathNet.Numerics.Properties;
namespace MathNet.Numerics.RootFinding
{
@ -41,13 +42,7 @@ namespace MathNet.Numerics.RootFinding
}
public abstract class RootFinder
{
protected const string INVALID_RANGE="Invalid range while finding root";
protected const string ACCURACY_NOT_REACHED = "The accuracy couldn't be reached with the specified number of iterations";
protected const string ROOT_NOT_FOUND = "The algorithm ended without root in the range";
protected const string ROOT_NOT_BRACKETED = "The algorithm could not start because the root seemed not to be bracketed";
protected const string INVALID_ALGORITHM = "This algorithm is not able to solve this equation";
protected const double DOUBLE_ACCURACY = 9.99200722162641E-16;
protected const double DOUBLE_ACCURACY = 9.99200722162641E-16;
private const int DEFAULT_MAX_ITERATIONS = 30;
private const double DEFAULT_ACCURACY = 1e-8;
@ -122,7 +117,7 @@ namespace MathNet.Numerics.RootFinding
{
if (xmin >= xmax)
{
throw new RootFinderException(INVALID_RANGE, 0, new Range(xmin, xmax), 0.0);
throw new RootFinderException(string.Format(Resources.ArgumentOutOfRangeGreater,"xmax","xmin"), 0, new Range(xmin, xmax), 0.0);
}
double fmin = _func(xmin);
@ -144,7 +139,7 @@ namespace MathNet.Numerics.RootFinding
}
}
throw new RootFinderException(ROOT_NOT_FOUND, i, new Range(fmin, fmax), 0.0);
throw new RootFinderException(Resources.RootNotFound, i, new Range(fmin, fmax), 0.0);
}
/// <summary>Prototype algorithm for solving the equation f(x)=0.</summary>

Loading…
Cancel
Save