Browse Source

style cop

Signed-off-by: Christoph Ruegg <git@cdrnet.ch>
pull/2/head
Christoph Ruegg 17 years ago
parent
commit
9e01fe767f
  1. 56
      src/Managed/Integration/Algorithms/DoubleExponentialTransformation.cs
  2. 8
      src/Managed/Integration/Algorithms/NewtonCotesTrapeziumRule.cs
  3. 4
      src/Managed/Integration/Algorithms/SimpsonRule.cs
  4. 15
      src/Managed/Integration/Integrate.cs
  5. 6
      src/Managed/NumberTheory/IntegerTheory.cs
  6. 6
      src/Managed/SpecialFunctions.cs

56
src/Managed/Integration/Algorithms/DoubleExponentialTransformation.cs

@ -37,14 +37,11 @@ namespace MathNet.Numerics.Integration.Algorithms
/// </summary>
public class DoubleExponentialTransformation
{
private const int NumberOfMaximumLevels = 10;
private readonly NewtonCotesTrapeziumRule _trapezium = new NewtonCotesTrapeziumRule();
private IEnumerable<double[]> _levelAbcissas;
private IEnumerable<double[]> _levelWeights;
#region Precomputed Abcissas and Weights
/// <summary>
/// Precomputed abscissa vector per level.
/// </summary>
private static readonly double[][] PrecomputedAbscissas =
new[]
{
@ -264,6 +261,9 @@ namespace MathNet.Numerics.Integration.Algorithms
}
};
/// <summary>
/// Precomputed weight vector per level.
/// </summary>
private static readonly double[][] PrecomputedWeights =
new[]
{
@ -485,9 +485,35 @@ namespace MathNet.Numerics.Integration.Algorithms
#endregion
/// <summary>
/// Maximum number of iterations, until the asked
/// maximum error is (likely to be) satisfied.
/// </summary>
private const int NumberOfMaximumLevels = 10;
/// <summary>
/// Internal Trapezium Rule.
/// </summary>
private readonly NewtonCotesTrapeziumRule _trapezium = new NewtonCotesTrapeziumRule();
/// <summary>
/// Abscissa vector per level provider.
/// </summary>
private IEnumerable<double[]> _levelAbcissas;
/// <summary>
/// Weight vector per level provider.
/// </summary>
private IEnumerable<double[]> _levelWeights;
/// <summary>
/// Approximate the integral by the double exponential transformation
/// </summary>
/// <param name="f">The analytic smooth function to integrate.</param>
/// <param name="intervalBegin">Where the interval starts, inclusive and finite.</param>
/// <param name="intervalEnd">Where the interval stops, inclusive and finite.</param>
/// <param name="targetRelativeError">The expected relative accuracy of the approximation.</param>
/// <returns>Approximation of the finite integral in the given interval.</returns>
public double Integrate(
Func<double, double> f,
double intervalBegin,
@ -510,6 +536,10 @@ namespace MathNet.Numerics.Integration.Algorithms
targetRelativeError);
}
/// <summary>
/// Abscissa vector per level provider.
/// </summary>
/// <returns>Level Enumerator.</returns>
private static IEnumerable<double[]> ProvideLevelAbcissas()
{
for (int i = 0; i < NumberOfMaximumLevels; i++)
@ -518,6 +548,10 @@ namespace MathNet.Numerics.Integration.Algorithms
}
}
/// <summary>
/// Weight vector per level provider.
/// </summary>
/// <returns>Level Enumerator.</returns>
private static IEnumerable<double[]> ProvideLevelWeights()
{
for (int i = 0; i < NumberOfMaximumLevels; i++)
@ -526,6 +560,11 @@ namespace MathNet.Numerics.Integration.Algorithms
}
}
/// <summary>
/// Compute the abscissa vector for a single level.
/// </summary>
/// <param name="level">The level to evaluate the abscissa vector for.</param>
/// <returns>Abscissa Vector.</returns>
private static double[] EvaluateAbcissas(int level)
{
if (level < PrecomputedAbscissas.Length)
@ -550,6 +589,11 @@ namespace MathNet.Numerics.Integration.Algorithms
return abcissas;
}
/// <summary>
/// Compute the weight vector for a single level.
/// </summary>
/// <param name="level">The level to evaluate the weight vector for.</param>
/// <returns>Weight Vector.</returns>
private static double[] EvaluateWeights(int level)
{
if (level < PrecomputedWeights.Length)

8
src/Managed/Integration/Algorithms/NewtonCotesTrapeziumRule.cs

@ -46,7 +46,7 @@ namespace MathNet.Numerics.Integration.Algorithms
/// <param name="f">The analytic smooth function to integrate.</param>
/// <param name="intervalBegin">Where the interval starts, inclusive and finite.</param>
/// <param name="intervalEnd">Where the interval stops, inclusive and finite.</param>
/// <returns>approximation of the area in the given interval.</returns>
/// <returns>Approximation of the finite integral in the given interval.</returns>
public double IntegrateTwoPoint(
Func<double, double> f,
double intervalBegin,
@ -62,7 +62,7 @@ namespace MathNet.Numerics.Integration.Algorithms
/// <param name="intervalBegin">Where the interval starts, inclusive and finite.</param>
/// <param name="intervalEnd">Where the interval stops, inclusive and finite.</param>
/// <param name="numberOfPartitions">Number of composite subdivision partitions.</param>
/// <returns>approximation of the area in the given interval.</returns>
/// <returns>Approximation of the finite integral in the given interval.</returns>
public double IntegrateComposite(
Func<double, double> f,
double intervalBegin,
@ -95,7 +95,7 @@ namespace MathNet.Numerics.Integration.Algorithms
/// <param name="intervalBegin">Where the interval starts, inclusive and finite.</param>
/// <param name="intervalEnd">Where the interval stops, inclusive and finite.</param>
/// <param name="targetRelativeError">The expected relative accuracy of the approximation.</param>
/// <returns>approximation of the area in the given interval.</returns>
/// <returns>Approximation of the finite integral in the given interval.</returns>
public double IntegrateAdaptive(
Func<double, double> f,
double intervalBegin,
@ -137,7 +137,7 @@ namespace MathNet.Numerics.Integration.Algorithms
/// <param name="levelWeights">Weight vector per level provider.</param>
/// <param name="levelOneStep">First Level Step</param>
/// <param name="targetRelativeError">The expected relative accuracy of the approximation.</param>
/// <returns>approximation of the area in the given interval.</returns>
/// <returns>Approximation of the finite integral in the given interval.</returns>
public double IntegrateAdaptiveTransformedOdd(
Func<double, double> f,
double intervalBegin,

4
src/Managed/Integration/Algorithms/SimpsonRule.cs

@ -43,7 +43,7 @@ namespace MathNet.Numerics.Integration.Algorithms
/// <param name="f">The analytic smooth function to integrate.</param>
/// <param name="intervalBegin">Where the interval starts, inclusive and finite.</param>
/// <param name="intervalEnd">Where the interval stops, inclusive and finite.</param>
/// <returns>approximation of the area in the given interval.</returns>
/// <returns>Approximation of the finite integral in the given interval.</returns>
public double IntegrateThreePoint(
Func<double, double> f,
double intervalBegin,
@ -60,7 +60,7 @@ namespace MathNet.Numerics.Integration.Algorithms
/// <param name="intervalBegin">Where the interval starts, inclusive and finite.</param>
/// <param name="intervalEnd">Where the interval stops, inclusive and finite.</param>
/// <param name="numberOfPartitions">Even number of composite subdivision partitions.</param>
/// <returns>approximation of the area in the given interval.</returns>
/// <returns>Approximation of the finite integral in the given interval.</returns>
public double IntegrateComposite(
Func<double, double> f,
double intervalBegin,

15
src/Managed/Integration/Integrate.cs

@ -36,7 +36,10 @@ namespace MathNet.Numerics.Integration
/// </summary>
public static class Integrate
{
static readonly DoubleExponentialTransformation Det = new DoubleExponentialTransformation();
/// <summary>
/// Shared internal DET algorithm.
/// </summary>
private static readonly DoubleExponentialTransformation Det = new DoubleExponentialTransformation();
/// <summary>
/// Approximation of the definite interval of an analytic smooth function on a closed interval.
@ -45,9 +48,8 @@ namespace MathNet.Numerics.Integration
/// <param name="intervalBegin">Where the interval starts, inclusive and finite.</param>
/// <param name="intervalEnd">Where the interval stops, inclusive and finite.</param>
/// <param name="targetAbsoluteError">The expected relative accuracy of the approximation.</param>
public static
double
OnClosedInterval(
/// <returns>Approximation of the finite integral in the given interval.</returns>
public static double OnClosedInterval(
Func<double, double> f,
double intervalBegin,
double intervalEnd,
@ -66,9 +68,8 @@ namespace MathNet.Numerics.Integration
/// <param name="f">The analytic smooth function to integrate.</param>
/// <param name="intervalBegin">Where the interval starts, inclusive and finite.</param>
/// <param name="intervalEnd">Where the interval stops, inclusive and finite.</param>
public static
double
OnClosedInterval(
/// <returns>Approximation of the finite integral in the given interval.</returns>
public static double OnClosedInterval(
Func<double, double> f,
double intervalBegin,
double intervalEnd)

6
src/Managed/NumberTheory/IntegerTheory.cs

@ -38,6 +38,7 @@ namespace MathNet.Numerics.NumberTheory
/// <summary>
/// Find out whether the provided 32 bit integer is an even number.
/// </summary>
/// <param name="number">The number to very whether it's even.</param>
/// <returns>True if and only if it is an even number.</returns>
public static bool IsEven(this int number)
{
@ -47,6 +48,7 @@ namespace MathNet.Numerics.NumberTheory
/// <summary>
/// Find out whether the provided 64 bit integer is an even number.
/// </summary>
/// <param name="number">The number to very whether it's even.</param>
/// <returns>True if and only if it is an even number.</returns>
public static bool IsEven(this long number)
{
@ -56,6 +58,7 @@ namespace MathNet.Numerics.NumberTheory
/// <summary>
/// Find out whether the provided 32 bit integer is an odd number.
/// </summary>
/// <param name="number">The number to very whether it's odd.</param>
/// <returns>True if and only if it is an odd number.</returns>
public static bool IsOdd(this int number)
{
@ -65,6 +68,7 @@ namespace MathNet.Numerics.NumberTheory
/// <summary>
/// Find out whether the provided 64 bit integer is an odd number.
/// </summary>
/// <param name="number">The number to very whether it's odd.</param>
/// <returns>True if and only if it is an odd number.</returns>
public static bool IsOdd(this long number)
{
@ -74,6 +78,7 @@ namespace MathNet.Numerics.NumberTheory
/// <summary>
/// Find out whether the provided 32 bit integer is a perfect square, i.e. a square of an integer.
/// </summary>
/// <param name="number">The number to very whether it's a perfect square.</param>
/// <returns>True if and only if it is a perfect square.</returns>
public static bool IsPerfectSquare(int number)
{
@ -100,6 +105,7 @@ namespace MathNet.Numerics.NumberTheory
/// <summary>
/// Find out whether the provided 64 bit integer is a perfect square, i.e. a square of an integer.
/// </summary>
/// <param name="number">The number to very whether it's a perfect square.</param>
/// <returns>True if and only if it is a perfect square.</returns>
public static bool IsPerfectSquare(long number)
{

6
src/Managed/SpecialFunctions.cs

@ -47,13 +47,13 @@ namespace MathNet.Numerics
if (Math.Abs(a) > Math.Abs(b))
{
double r = b / a;
return Math.Abs(a) * Math.Sqrt(1 + r * r);
return Math.Abs(a) * Math.Sqrt(1 + (r * r));
}
if (b.AlmostZero())
if (!b.AlmostZero())
{
double r = a / b;
return Math.Abs(b) * Math.Sqrt(1 + r * r);
return Math.Abs(b) * Math.Sqrt(1 + (r * r));
}
return 0d;

Loading…
Cancel
Save