diff --git a/src/Managed/Integration/Algorithms/DoubleExponentialTransformation.cs b/src/Managed/Integration/Algorithms/DoubleExponentialTransformation.cs index cd6dc683..f9af64ca 100644 --- a/src/Managed/Integration/Algorithms/DoubleExponentialTransformation.cs +++ b/src/Managed/Integration/Algorithms/DoubleExponentialTransformation.cs @@ -37,14 +37,11 @@ namespace MathNet.Numerics.Integration.Algorithms /// public class DoubleExponentialTransformation { - private const int NumberOfMaximumLevels = 10; - - private readonly NewtonCotesTrapeziumRule _trapezium = new NewtonCotesTrapeziumRule(); - private IEnumerable _levelAbcissas; - private IEnumerable _levelWeights; - #region Precomputed Abcissas and Weights + /// + /// Precomputed abscissa vector per level. + /// private static readonly double[][] PrecomputedAbscissas = new[] { @@ -264,6 +261,9 @@ namespace MathNet.Numerics.Integration.Algorithms } }; + /// + /// Precomputed weight vector per level. + /// private static readonly double[][] PrecomputedWeights = new[] { @@ -485,9 +485,35 @@ namespace MathNet.Numerics.Integration.Algorithms #endregion + /// + /// Maximum number of iterations, until the asked + /// maximum error is (likely to be) satisfied. + /// + private const int NumberOfMaximumLevels = 10; + + /// + /// Internal Trapezium Rule. + /// + private readonly NewtonCotesTrapeziumRule _trapezium = new NewtonCotesTrapeziumRule(); + + /// + /// Abscissa vector per level provider. + /// + private IEnumerable _levelAbcissas; + + /// + /// Weight vector per level provider. + /// + private IEnumerable _levelWeights; + /// /// Approximate the integral by the double exponential transformation /// + /// The analytic smooth function to integrate. + /// Where the interval starts, inclusive and finite. + /// Where the interval stops, inclusive and finite. + /// The expected relative accuracy of the approximation. + /// Approximation of the finite integral in the given interval. public double Integrate( Func f, double intervalBegin, @@ -510,6 +536,10 @@ namespace MathNet.Numerics.Integration.Algorithms targetRelativeError); } + /// + /// Abscissa vector per level provider. + /// + /// Level Enumerator. private static IEnumerable ProvideLevelAbcissas() { for (int i = 0; i < NumberOfMaximumLevels; i++) @@ -518,6 +548,10 @@ namespace MathNet.Numerics.Integration.Algorithms } } + /// + /// Weight vector per level provider. + /// + /// Level Enumerator. private static IEnumerable ProvideLevelWeights() { for (int i = 0; i < NumberOfMaximumLevels; i++) @@ -526,6 +560,11 @@ namespace MathNet.Numerics.Integration.Algorithms } } + /// + /// Compute the abscissa vector for a single level. + /// + /// The level to evaluate the abscissa vector for. + /// Abscissa Vector. private static double[] EvaluateAbcissas(int level) { if (level < PrecomputedAbscissas.Length) @@ -550,6 +589,11 @@ namespace MathNet.Numerics.Integration.Algorithms return abcissas; } + /// + /// Compute the weight vector for a single level. + /// + /// The level to evaluate the weight vector for. + /// Weight Vector. private static double[] EvaluateWeights(int level) { if (level < PrecomputedWeights.Length) diff --git a/src/Managed/Integration/Algorithms/NewtonCotesTrapeziumRule.cs b/src/Managed/Integration/Algorithms/NewtonCotesTrapeziumRule.cs index fb467bcc..d989f58d 100644 --- a/src/Managed/Integration/Algorithms/NewtonCotesTrapeziumRule.cs +++ b/src/Managed/Integration/Algorithms/NewtonCotesTrapeziumRule.cs @@ -46,7 +46,7 @@ namespace MathNet.Numerics.Integration.Algorithms /// The analytic smooth function to integrate. /// Where the interval starts, inclusive and finite. /// Where the interval stops, inclusive and finite. - /// approximation of the area in the given interval. + /// Approximation of the finite integral in the given interval. public double IntegrateTwoPoint( Func f, double intervalBegin, @@ -62,7 +62,7 @@ namespace MathNet.Numerics.Integration.Algorithms /// Where the interval starts, inclusive and finite. /// Where the interval stops, inclusive and finite. /// Number of composite subdivision partitions. - /// approximation of the area in the given interval. + /// Approximation of the finite integral in the given interval. public double IntegrateComposite( Func f, double intervalBegin, @@ -95,7 +95,7 @@ namespace MathNet.Numerics.Integration.Algorithms /// Where the interval starts, inclusive and finite. /// Where the interval stops, inclusive and finite. /// The expected relative accuracy of the approximation. - /// approximation of the area in the given interval. + /// Approximation of the finite integral in the given interval. public double IntegrateAdaptive( Func f, double intervalBegin, @@ -137,7 +137,7 @@ namespace MathNet.Numerics.Integration.Algorithms /// Weight vector per level provider. /// First Level Step /// The expected relative accuracy of the approximation. - /// approximation of the area in the given interval. + /// Approximation of the finite integral in the given interval. public double IntegrateAdaptiveTransformedOdd( Func f, double intervalBegin, diff --git a/src/Managed/Integration/Algorithms/SimpsonRule.cs b/src/Managed/Integration/Algorithms/SimpsonRule.cs index 57776f59..98982b8a 100644 --- a/src/Managed/Integration/Algorithms/SimpsonRule.cs +++ b/src/Managed/Integration/Algorithms/SimpsonRule.cs @@ -43,7 +43,7 @@ namespace MathNet.Numerics.Integration.Algorithms /// The analytic smooth function to integrate. /// Where the interval starts, inclusive and finite. /// Where the interval stops, inclusive and finite. - /// approximation of the area in the given interval. + /// Approximation of the finite integral in the given interval. public double IntegrateThreePoint( Func f, double intervalBegin, @@ -60,7 +60,7 @@ namespace MathNet.Numerics.Integration.Algorithms /// Where the interval starts, inclusive and finite. /// Where the interval stops, inclusive and finite. /// Even number of composite subdivision partitions. - /// approximation of the area in the given interval. + /// Approximation of the finite integral in the given interval. public double IntegrateComposite( Func f, double intervalBegin, diff --git a/src/Managed/Integration/Integrate.cs b/src/Managed/Integration/Integrate.cs index afb9fa3f..87dbd3e0 100644 --- a/src/Managed/Integration/Integrate.cs +++ b/src/Managed/Integration/Integrate.cs @@ -36,7 +36,10 @@ namespace MathNet.Numerics.Integration /// public static class Integrate { - static readonly DoubleExponentialTransformation Det = new DoubleExponentialTransformation(); + /// + /// Shared internal DET algorithm. + /// + private static readonly DoubleExponentialTransformation Det = new DoubleExponentialTransformation(); /// /// Approximation of the definite interval of an analytic smooth function on a closed interval. @@ -45,9 +48,8 @@ namespace MathNet.Numerics.Integration /// Where the interval starts, inclusive and finite. /// Where the interval stops, inclusive and finite. /// The expected relative accuracy of the approximation. - public static - double - OnClosedInterval( + /// Approximation of the finite integral in the given interval. + public static double OnClosedInterval( Func f, double intervalBegin, double intervalEnd, @@ -66,9 +68,8 @@ namespace MathNet.Numerics.Integration /// The analytic smooth function to integrate. /// Where the interval starts, inclusive and finite. /// Where the interval stops, inclusive and finite. - public static - double - OnClosedInterval( + /// Approximation of the finite integral in the given interval. + public static double OnClosedInterval( Func f, double intervalBegin, double intervalEnd) diff --git a/src/Managed/NumberTheory/IntegerTheory.cs b/src/Managed/NumberTheory/IntegerTheory.cs index 5fe6926e..f801b5c2 100644 --- a/src/Managed/NumberTheory/IntegerTheory.cs +++ b/src/Managed/NumberTheory/IntegerTheory.cs @@ -38,6 +38,7 @@ namespace MathNet.Numerics.NumberTheory /// /// Find out whether the provided 32 bit integer is an even number. /// + /// The number to very whether it's even. /// True if and only if it is an even number. public static bool IsEven(this int number) { @@ -47,6 +48,7 @@ namespace MathNet.Numerics.NumberTheory /// /// Find out whether the provided 64 bit integer is an even number. /// + /// The number to very whether it's even. /// True if and only if it is an even number. public static bool IsEven(this long number) { @@ -56,6 +58,7 @@ namespace MathNet.Numerics.NumberTheory /// /// Find out whether the provided 32 bit integer is an odd number. /// + /// The number to very whether it's odd. /// True if and only if it is an odd number. public static bool IsOdd(this int number) { @@ -65,6 +68,7 @@ namespace MathNet.Numerics.NumberTheory /// /// Find out whether the provided 64 bit integer is an odd number. /// + /// The number to very whether it's odd. /// True if and only if it is an odd number. public static bool IsOdd(this long number) { @@ -74,6 +78,7 @@ namespace MathNet.Numerics.NumberTheory /// /// Find out whether the provided 32 bit integer is a perfect square, i.e. a square of an integer. /// + /// The number to very whether it's a perfect square. /// True if and only if it is a perfect square. public static bool IsPerfectSquare(int number) { @@ -100,6 +105,7 @@ namespace MathNet.Numerics.NumberTheory /// /// Find out whether the provided 64 bit integer is a perfect square, i.e. a square of an integer. /// + /// The number to very whether it's a perfect square. /// True if and only if it is a perfect square. public static bool IsPerfectSquare(long number) { diff --git a/src/Managed/SpecialFunctions.cs b/src/Managed/SpecialFunctions.cs index e00efb83..d8bcc487 100644 --- a/src/Managed/SpecialFunctions.cs +++ b/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;