diff --git a/.gitattributes b/.gitattributes
index bcf2ae8f..2a674dba 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -6,6 +6,7 @@
*.csdef text
*.xml text
*.js text
+*.ps1 text
*.csproj text merge=union
*.fsproj text merge=union
diff --git a/MathNet.Numerics.sln.DotSettings b/MathNet.Numerics.sln.DotSettings
index 76dcc889..857c5d9e 100644
--- a/MathNet.Numerics.sln.DotSettings
+++ b/MathNet.Numerics.sln.DotSettings
@@ -47,7 +47,19 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
</copyright>
CDF
+ DFT
+ FFT
+ LU
+ MAE
+ MC
+ MCMC
+ MSE
+ QR
+ SAD
SAS
SPSS
+ SSD
+ TFQMR
+ WH
<data />
<data><IncludeFilters /><ExcludeFilters /></data>
\ No newline at end of file
diff --git a/src/Numerics/ArrayExtensions.cs b/src/Numerics/ArrayExtensions.cs
index 47bf5fc6..dbf885f6 100644
--- a/src/Numerics/ArrayExtensions.cs
+++ b/src/Numerics/ArrayExtensions.cs
@@ -28,9 +28,10 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
namespace MathNet.Numerics
{
- using System;
#if !NOSYSNUMERICS
using Complex = System.Numerics.Complex;
diff --git a/src/Numerics/Constants.cs b/src/Numerics/Constants.cs
index 745af170..ef7734d1 100644
--- a/src/Numerics/Constants.cs
+++ b/src/Numerics/Constants.cs
@@ -76,15 +76,15 @@ namespace MathNet.Numerics
/// The number pi
public const double Pi = 3.1415926535897932384626433832795028841971693993751d;
- /// The number 2*pi
+ /// The number pi*2
public const double Pi2 = 6.2831853071795864769252867665590057683943387987502d;
- /// The number 1/pi
- public const double OneOverPi = 0.31830988618379067153776752674502872406891929148091d;
-
/// The number pi/2
public const double PiOver2 = 1.5707963267948966192313216916397514420985846996876d;
+ /// The number pi*3/2
+ public const double Pi3Over2 = 4.71238898038468985769396507491925432629575409906266d;
+
/// The number pi/4
public const double PiOver4 = 0.78539816339744830961566084581987572104929234984378d;
diff --git a/src/Numerics/Distributions/Continuous/Beta.cs b/src/Numerics/Distributions/Continuous/Beta.cs
index 245f9701..b7f1e95e 100644
--- a/src/Numerics/Distributions/Continuous/Beta.cs
+++ b/src/Numerics/Distributions/Continuous/Beta.cs
@@ -105,12 +105,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double a, double b)
{
- if (a < 0.0 || b < 0.0 || Double.IsNaN(a) || Double.IsNaN(b))
- {
- return false;
- }
-
- return true;
+ return a >= 0.0 && b >= 0.0;
}
///
diff --git a/src/Numerics/Distributions/Continuous/Cauchy.cs b/src/Numerics/Distributions/Continuous/Cauchy.cs
index d3197e23..9f6213c4 100644
--- a/src/Numerics/Distributions/Continuous/Cauchy.cs
+++ b/src/Numerics/Distributions/Continuous/Cauchy.cs
@@ -108,17 +108,7 @@ namespace MathNet.Numerics.Distributions
/// True when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double location, double scale)
{
- if (scale <= 0)
- {
- return false;
- }
-
- if (Double.IsNaN(location) || Double.IsNaN(scale))
- {
- return false;
- }
-
- return true;
+ return scale > 0.0 && !Double.IsNaN(location);
}
///
diff --git a/src/Numerics/Distributions/Continuous/Chi.cs b/src/Numerics/Distributions/Continuous/Chi.cs
index b4b75f8c..0a915c06 100644
--- a/src/Numerics/Distributions/Continuous/Chi.cs
+++ b/src/Numerics/Distributions/Continuous/Chi.cs
@@ -97,12 +97,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double dof)
{
- if (dof <= 0 || Double.IsNaN(dof))
- {
- return false;
- }
-
- return true;
+ return dof > 0.0;
}
///
diff --git a/src/Numerics/Distributions/Continuous/ContinuousUniform.cs b/src/Numerics/Distributions/Continuous/ContinuousUniform.cs
index 97c84210..b5048a33 100644
--- a/src/Numerics/Distributions/Continuous/ContinuousUniform.cs
+++ b/src/Numerics/Distributions/Continuous/ContinuousUniform.cs
@@ -109,17 +109,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double lower, double upper)
{
- if (upper < lower)
- {
- return false;
- }
-
- if (Double.IsNaN(upper) || Double.IsNaN(lower))
- {
- return false;
- }
-
- return true;
+ return upper >= lower && !Double.IsNaN(upper) && !Double.IsNaN(lower);
}
///
diff --git a/src/Numerics/Distributions/Continuous/Erlang.cs b/src/Numerics/Distributions/Continuous/Erlang.cs
index 16c51057..73b38b90 100644
--- a/src/Numerics/Distributions/Continuous/Erlang.cs
+++ b/src/Numerics/Distributions/Continuous/Erlang.cs
@@ -129,12 +129,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double shape, double invScale)
{
- if (shape < 0.0 || invScale < 0.0 || Double.IsNaN(shape) || Double.IsNaN(invScale))
- {
- return false;
- }
-
- return true;
+ return shape >= 0.0 && invScale >= 0.0;
}
///
diff --git a/src/Numerics/Distributions/Continuous/Exponential.cs b/src/Numerics/Distributions/Continuous/Exponential.cs
index 6bdb7fd6..b95017d1 100644
--- a/src/Numerics/Distributions/Continuous/Exponential.cs
+++ b/src/Numerics/Distributions/Continuous/Exponential.cs
@@ -94,17 +94,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double lambda)
{
- if (lambda < 0)
- {
- return false;
- }
-
- if (Double.IsNaN(lambda))
- {
- return false;
- }
-
- return true;
+ return lambda >= 0.0;
}
///
diff --git a/src/Numerics/Distributions/Continuous/FisherSnedecor.cs b/src/Numerics/Distributions/Continuous/FisherSnedecor.cs
index ddcfd74f..d1ea2039 100644
--- a/src/Numerics/Distributions/Continuous/FisherSnedecor.cs
+++ b/src/Numerics/Distributions/Continuous/FisherSnedecor.cs
@@ -103,17 +103,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double d1, double d2)
{
- if (d1 <= 0 || d2 <= 0)
- {
- return false;
- }
-
- if (Double.IsNaN(d1) || Double.IsNaN(d2))
- {
- return false;
- }
-
- return true;
+ return d1 > 0.0 && d2 > 0.0;
}
///
diff --git a/src/Numerics/Distributions/Continuous/Gamma.cs b/src/Numerics/Distributions/Continuous/Gamma.cs
index 7d445739..9dec6982 100644
--- a/src/Numerics/Distributions/Continuous/Gamma.cs
+++ b/src/Numerics/Distributions/Continuous/Gamma.cs
@@ -128,12 +128,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double shape, double invScale)
{
- if (shape < 0.0 || invScale < 0.0 || Double.IsNaN(shape) || Double.IsNaN(invScale))
- {
- return false;
- }
-
- return true;
+ return shape >= 0.0 && invScale >= 0.0;
}
///
diff --git a/src/Numerics/Distributions/Continuous/InverseGamma.cs b/src/Numerics/Distributions/Continuous/InverseGamma.cs
index b6bbda07..246a3240 100644
--- a/src/Numerics/Distributions/Continuous/InverseGamma.cs
+++ b/src/Numerics/Distributions/Continuous/InverseGamma.cs
@@ -104,26 +104,12 @@ namespace MathNet.Numerics.Distributions
///
/// Checks whether the parameters of the distribution are valid.
///
- ///
- /// The shape (alpha) parameter of the inverse Gamma distribution.
- ///
- ///
- /// The scale (beta) parameter of the inverse Gamma distribution.
- ///
+ /// The shape (alpha) parameter of the inverse Gamma distribution.
+ /// The scale (beta) parameter of the inverse Gamma distribution.
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double shape, double scale)
{
- if (shape <= 0 || scale <= 0)
- {
- return false;
- }
-
- if (Double.IsNaN(shape) || Double.IsNaN(scale))
- {
- return false;
- }
-
- return true;
+ return shape > 0.0 && scale > 0.0;
}
///
diff --git a/src/Numerics/Distributions/Continuous/Laplace.cs b/src/Numerics/Distributions/Continuous/Laplace.cs
index 4d0be04a..e88855fe 100644
--- a/src/Numerics/Distributions/Continuous/Laplace.cs
+++ b/src/Numerics/Distributions/Continuous/Laplace.cs
@@ -129,17 +129,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double location, double scale)
{
- if (scale <= 0)
- {
- return false;
- }
-
- if (Double.IsNaN(location) || Double.IsNaN(scale))
- {
- return false;
- }
-
- return true;
+ return scale > 0.0 && !Double.IsNaN(location);
}
///
diff --git a/src/Numerics/Distributions/Continuous/LogNormal.cs b/src/Numerics/Distributions/Continuous/LogNormal.cs
index 1aec37d0..227b758b 100644
--- a/src/Numerics/Distributions/Continuous/LogNormal.cs
+++ b/src/Numerics/Distributions/Continuous/LogNormal.cs
@@ -125,12 +125,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double mu, double sigma)
{
- if (sigma < 0.0 || Double.IsNaN(mu) || Double.IsNaN(mu) || Double.IsNaN(sigma))
- {
- return false;
- }
-
- return true;
+ return sigma >= 0.0 && !Double.IsNaN(mu) && !Double.IsNaN(mu);
}
///
diff --git a/src/Numerics/Distributions/Continuous/Normal.cs b/src/Numerics/Distributions/Continuous/Normal.cs
index b0d88988..5dcf90cf 100644
--- a/src/Numerics/Distributions/Continuous/Normal.cs
+++ b/src/Numerics/Distributions/Continuous/Normal.cs
@@ -166,12 +166,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double mean, double stddev)
{
- if (stddev < 0.0 || Double.IsNaN(mean) || Double.IsNaN(stddev))
- {
- return false;
- }
-
- return true;
+ return stddev >= 0.0 && !Double.IsNaN(mean);
}
///
diff --git a/src/Numerics/Distributions/Continuous/Pareto.cs b/src/Numerics/Distributions/Continuous/Pareto.cs
index f7932cb2..092c62c8 100644
--- a/src/Numerics/Distributions/Continuous/Pareto.cs
+++ b/src/Numerics/Distributions/Continuous/Pareto.cs
@@ -108,17 +108,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double scale, double shape)
{
- if (scale <= 0 || shape <= 0)
- {
- return false;
- }
-
- if (Double.IsNaN(scale) || Double.IsNaN(shape))
- {
- return false;
- }
-
- return true;
+ return scale > 0.0 && shape > 0.0;
}
///
diff --git a/src/Numerics/Distributions/Continuous/Rayleigh.cs b/src/Numerics/Distributions/Continuous/Rayleigh.cs
index a7c29470..85bc03db 100644
--- a/src/Numerics/Distributions/Continuous/Rayleigh.cs
+++ b/src/Numerics/Distributions/Continuous/Rayleigh.cs
@@ -99,17 +99,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double scale)
{
- if (scale <= 0)
- {
- return false;
- }
-
- if (Double.IsNaN(scale))
- {
- return false;
- }
-
- return true;
+ return scale > 0.0;
}
///
diff --git a/src/Numerics/Distributions/Continuous/Stable.cs b/src/Numerics/Distributions/Continuous/Stable.cs
index 9e83926c..18cdf781 100644
--- a/src/Numerics/Distributions/Continuous/Stable.cs
+++ b/src/Numerics/Distributions/Continuous/Stable.cs
@@ -126,27 +126,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double alpha, double beta, double scale, double location)
{
- if (alpha <= 0 || alpha > 2)
- {
- return false;
- }
-
- if (beta < -1 || beta > 1)
- {
- return false;
- }
-
- if (scale <= 0)
- {
- return false;
- }
-
- if (Double.IsNaN(alpha) || Double.IsNaN(beta) || Double.IsNaN(scale) || Double.IsNaN(location))
- {
- return false;
- }
-
- return true;
+ return alpha > 0.0 && alpha <= 2.0 && beta >= -1.0 && beta <= 1.0 && scale > 0.0 && !Double.IsNaN(location);
}
///
diff --git a/src/Numerics/Distributions/Continuous/StudentT.cs b/src/Numerics/Distributions/Continuous/StudentT.cs
index de726169..0ca0ae24 100644
--- a/src/Numerics/Distributions/Continuous/StudentT.cs
+++ b/src/Numerics/Distributions/Continuous/StudentT.cs
@@ -129,12 +129,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double location, double scale, double dof)
{
- if (scale <= 0.0 || dof <= 0.0 || Double.IsNaN(scale) || Double.IsNaN(location) || Double.IsNaN(dof))
- {
- return false;
- }
-
- return true;
+ return scale > 0.0 && dof > 0.0 && !Double.IsNaN(location);
}
///
diff --git a/src/Numerics/Distributions/Continuous/Weibull.cs b/src/Numerics/Distributions/Continuous/Weibull.cs
index 34bad113..f5fbbe20 100644
--- a/src/Numerics/Distributions/Continuous/Weibull.cs
+++ b/src/Numerics/Distributions/Continuous/Weibull.cs
@@ -111,12 +111,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters positive valid floating point numbers, false otherwise.
static bool IsValidParameterSet(double shape, double scale)
{
- if (shape <= 0.0 || scale <= 0.0 || Double.IsNaN(shape) || Double.IsNaN(scale))
- {
- return false;
- }
-
- return true;
+ return shape > 0.0 && scale > 0.0;
}
///
diff --git a/src/Numerics/Distributions/Discrete/Bernoulli.cs b/src/Numerics/Distributions/Discrete/Bernoulli.cs
index 3811f8d0..7f2ee52d 100644
--- a/src/Numerics/Distributions/Discrete/Bernoulli.cs
+++ b/src/Numerics/Distributions/Discrete/Bernoulli.cs
@@ -91,12 +91,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double p)
{
- if (p >= 0.0 && p <= 1.0)
- {
- return true;
- }
-
- return false;
+ return p >= 0.0 && p <= 1.0;
}
///
diff --git a/src/Numerics/Distributions/Discrete/Binomial.cs b/src/Numerics/Distributions/Discrete/Binomial.cs
index b1ff288b..fed6eb37 100644
--- a/src/Numerics/Distributions/Discrete/Binomial.cs
+++ b/src/Numerics/Distributions/Discrete/Binomial.cs
@@ -101,17 +101,7 @@ namespace MathNet.Numerics.Distributions
/// false is not in the interval [0.0,1.0] or is negative, true otherwise.
static bool IsValidParameterSet(double p, int n)
{
- if (p < 0.0 || p > 1.0 || Double.IsNaN(p))
- {
- return false;
- }
-
- if (n < 0)
- {
- return false;
- }
-
- return true;
+ return p >= 0.0 && p <= 1.0 && n >= 0;
}
///
diff --git a/src/Numerics/Distributions/Discrete/ConwayMaxwellPoisson.cs b/src/Numerics/Distributions/Discrete/ConwayMaxwellPoisson.cs
index c341fb01..b771b8cf 100644
--- a/src/Numerics/Distributions/Discrete/ConwayMaxwellPoisson.cs
+++ b/src/Numerics/Distributions/Discrete/ConwayMaxwellPoisson.cs
@@ -132,17 +132,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double lambda, double nu)
{
- if (lambda <= 0.0)
- {
- return false;
- }
-
- if (nu < 0.0)
- {
- return false;
- }
-
- return true;
+ return lambda > 0.0 && nu >= 0.0;
}
///
diff --git a/src/Numerics/Distributions/Discrete/DiscreteUniform.cs b/src/Numerics/Distributions/Discrete/DiscreteUniform.cs
index cc6e37ab..74f4f5d8 100644
--- a/src/Numerics/Distributions/Discrete/DiscreteUniform.cs
+++ b/src/Numerics/Distributions/Discrete/DiscreteUniform.cs
@@ -99,12 +99,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(int lower, int upper)
{
- if (lower <= upper)
- {
- return true;
- }
-
- return false;
+ return lower <= upper;
}
///
diff --git a/src/Numerics/Distributions/Discrete/Geometric.cs b/src/Numerics/Distributions/Discrete/Geometric.cs
index c085eb38..6167a290 100644
--- a/src/Numerics/Distributions/Discrete/Geometric.cs
+++ b/src/Numerics/Distributions/Discrete/Geometric.cs
@@ -97,12 +97,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double p)
{
- if (p >= 0.0 && p <= 1.0)
- {
- return true;
- }
-
- return false;
+ return p >= 0.0 && p <= 1.0;
}
///
diff --git a/src/Numerics/Distributions/Discrete/Hypergeometric.cs b/src/Numerics/Distributions/Discrete/Hypergeometric.cs
index c54cdbab..76d41578 100644
--- a/src/Numerics/Distributions/Discrete/Hypergeometric.cs
+++ b/src/Numerics/Distributions/Discrete/Hypergeometric.cs
@@ -122,17 +122,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(int population, int success, int draws)
{
- if (population < 0 || success < 0 || draws < 0)
- {
- return false;
- }
-
- if (success > population || draws > population)
- {
- return false;
- }
-
- return true;
+ return population >= 0 && success >= 0 && draws >= 0 && (success <= population && draws <= population);
}
///
diff --git a/src/Numerics/Distributions/Discrete/NegativeBinomial.cs b/src/Numerics/Distributions/Discrete/NegativeBinomial.cs
index 31b731ba..1ed3c658 100644
--- a/src/Numerics/Distributions/Discrete/NegativeBinomial.cs
+++ b/src/Numerics/Distributions/Discrete/NegativeBinomial.cs
@@ -124,17 +124,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double r, double p)
{
- if (r < 0.0 || Double.IsNaN(r))
- {
- return false;
- }
-
- if (p < 0.0 || p > 1.0 || Double.IsNaN(p))
- {
- return false;
- }
-
- return true;
+ return r >= 0.0 && p >= 0.0 && p <= 1.0;
}
///
diff --git a/src/Numerics/Distributions/Discrete/Zipf.cs b/src/Numerics/Distributions/Discrete/Zipf.cs
index 48f40bff..7d859342 100644
--- a/src/Numerics/Distributions/Discrete/Zipf.cs
+++ b/src/Numerics/Distributions/Discrete/Zipf.cs
@@ -106,12 +106,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double s, int n)
{
- if (n <= 0 || s <= 0 || Double.IsNaN(s))
- {
- return false;
- }
-
- return true;
+ return n > 0 && s > 0.0;
}
///
@@ -180,8 +175,9 @@ namespace MathNet.Numerics.Distributions
throw new NotSupportedException();
}
- var generalHarmonicsNS = SpecialFunctions.GeneralHarmonic(_n, _s);
- return (SpecialFunctions.GeneralHarmonic(_n, _s - 2)*SpecialFunctions.GeneralHarmonic(_n, _s)) - (Math.Pow(SpecialFunctions.GeneralHarmonic(_n, _s - 1), 2)/(generalHarmonicsNS*generalHarmonicsNS));
+ var ghns = SpecialFunctions.GeneralHarmonic(_n, _s);
+ return (SpecialFunctions.GeneralHarmonic(_n, _s - 2)*SpecialFunctions.GeneralHarmonic(_n, _s))
+ - (Math.Pow(SpecialFunctions.GeneralHarmonic(_n, _s - 1), 2)/(ghns*ghns));
}
}
diff --git a/src/Numerics/Distributions/Multivariate/InverseWishart.cs b/src/Numerics/Distributions/Multivariate/InverseWishart.cs
index 7f77efac..ce95ab23 100644
--- a/src/Numerics/Distributions/Multivariate/InverseWishart.cs
+++ b/src/Numerics/Distributions/Multivariate/InverseWishart.cs
@@ -136,12 +136,7 @@ namespace MathNet.Numerics.Distributions
}
}
- if (nu <= 0.0 || Double.IsNaN(nu))
- {
- return false;
- }
-
- return true;
+ return nu > 0.0;
}
///
diff --git a/src/Numerics/Distributions/Multivariate/NormalGamma.cs b/src/Numerics/Distributions/Multivariate/NormalGamma.cs
index 87505126..c2d5f137 100644
--- a/src/Numerics/Distributions/Multivariate/NormalGamma.cs
+++ b/src/Numerics/Distributions/Multivariate/NormalGamma.cs
@@ -159,14 +159,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double meanLocation, double meanScale, double precShape, double precInvScale)
{
- if (meanScale <= 0.0 || precShape <= 0.0 || precInvScale <= 0.0
- || Double.IsNaN(meanLocation) || Double.IsNaN(meanScale) || Double.IsNaN(precShape)
- || Double.IsNaN(precInvScale))
- {
- return false;
- }
-
- return true;
+ return (meanScale > 0.0) && (precShape > 0.0) && (precInvScale > 0.0) && !Double.IsNaN(meanLocation);
}
///
diff --git a/src/Numerics/Financial/AbsoluteReturnMeasures.cs b/src/Numerics/Financial/AbsoluteReturnMeasures.cs
index f86311b9..abd38630 100644
--- a/src/Numerics/Financial/AbsoluteReturnMeasures.cs
+++ b/src/Numerics/Financial/AbsoluteReturnMeasures.cs
@@ -40,8 +40,6 @@ namespace MathNet.Numerics.Financial
///
/// Compound Monthly Return or Geometric Return or Annualized Return
///
- ///
- ///
public static double CompoundMonthlyReturn(this IEnumerable data)
{
if (data == null)
@@ -58,7 +56,7 @@ namespace MathNet.Numerics.Financial
{
compoundReturn *= (1 + item);
}
- return Math.Pow(compoundReturn, 1.0 / (double)samples) - 1.0;
+ return Math.Pow(compoundReturn, 1.0 / samples) - 1.0;
}
///
@@ -66,8 +64,6 @@ namespace MathNet.Numerics.Financial
/// This is a simple average (arithmetic mean) of the periods with a gain. It is calculated by summing the returns for gain periods (return 0)
/// and then dividing the total by the number of gain periods.
///
- ///
- ///
/// http://www.offshore-library.com/kb/statistics.php
public static double GainMean(this IEnumerable data)
{
@@ -85,8 +81,6 @@ namespace MathNet.Numerics.Financial
/// This is a simple average (arithmetic mean) of the periods with a loss. It is calculated by summing the returns for loss periods (return < 0)
/// and then dividing the total by the number of loss periods.
///
- ///
- ///
/// http://www.offshore-library.com/kb/statistics.php
public static double LossMean(this IEnumerable data)
{
diff --git a/src/Numerics/Financial/AbsoluteRiskMeasures.cs b/src/Numerics/Financial/AbsoluteRiskMeasures.cs
index 2db55192..560aecdc 100644
--- a/src/Numerics/Financial/AbsoluteRiskMeasures.cs
+++ b/src/Numerics/Financial/AbsoluteRiskMeasures.cs
@@ -49,8 +49,6 @@ namespace MathNet.Numerics.Financial
/// and measures the variation of only the gain periods around the gain mean. Measures the volatility of upside performance.
/// © Copyright 1996, 1999 Gary L.Gastineau. First Edition. © 1992 Swiss Bank Corporation.
///
- ///
- ///
public static double GainStandardDeviation(this IEnumerable data)
{
if (data == null)
@@ -66,8 +64,6 @@ namespace MathNet.Numerics.Financial
/// Similar to standard deviation, except this statistic calculates an average (mean) return for only the periods with a loss and then
/// measures the variation of only the losing periods around this loss mean. This statistic measures the volatility of downside performance.
///
- ///
- ///
/// http://www.offshore-library.com/kb/statistics.php
public static double LossStandardDeviation(this IEnumerable data)
{
@@ -87,9 +83,6 @@ namespace MathNet.Numerics.Financial
/// 7%. (The loss standard deviation, on the other hand, would take only losing periods, calculate an average return for
/// the losing periods, and then measure the variation between each losing return and the losing return average).
///
- ///
- ///
- ///
public static double DownsideDeviation(this IEnumerable data, double minimalAcceptableReturn)
{
if (data == null)
@@ -105,8 +98,6 @@ namespace MathNet.Numerics.Financial
/// A measure of volatility in returns below the mean. It's similar to standard deviation, but it only
/// looks at periods where the investment return was less than average return.
///
- ///
- ///
public static double SemiDeviation(this IEnumerable data)
{
if (data == null)
@@ -123,8 +114,6 @@ namespace MathNet.Numerics.Financial
/// Measures a fund’s average gain in a gain period divided by the fund’s average loss in a losing
/// period. Periods can be monthly or quarterly depending on the data frequency.
///
- ///
- ///
public static double GainLossRatio(this IEnumerable data)
{
if (data == null)
diff --git a/src/Numerics/GlobalizationHelper.cs b/src/Numerics/GlobalizationHelper.cs
index 8e5b9068..21571e65 100644
--- a/src/Numerics/GlobalizationHelper.cs
+++ b/src/Numerics/GlobalizationHelper.cs
@@ -56,8 +56,8 @@ namespace MathNet.Numerics
}
return (formatProvider as CultureInfo)
- ?? (formatProvider.GetFormat(typeof(CultureInfo)) as CultureInfo)
- ?? CultureInfo.CurrentCulture;
+ ?? (formatProvider.GetFormat(typeof (CultureInfo)) as CultureInfo)
+ ?? CultureInfo.CurrentCulture;
}
///
@@ -84,8 +84,13 @@ namespace MathNet.Numerics
/// A instance.
internal static TextInfo GetTextInfo(this IFormatProvider formatProvider)
{
- return (formatProvider as TextInfo)
- ?? GetCultureInfo(formatProvider).TextInfo;
+ if (formatProvider == null)
+ {
+ return CultureInfo.CurrentCulture.TextInfo;
+ }
+
+ return (formatProvider.GetFormat(typeof (TextInfo)) as TextInfo)
+ ?? GetCultureInfo(formatProvider).TextInfo;
}
///
diff --git a/src/Numerics/IntegralTransforms/Algorithms/DiscreteFourierTransform.Bluestein.cs b/src/Numerics/IntegralTransforms/Algorithms/DiscreteFourierTransform.Bluestein.cs
index aa1a4ec1..47c8829a 100644
--- a/src/Numerics/IntegralTransforms/Algorithms/DiscreteFourierTransform.Bluestein.cs
+++ b/src/Numerics/IntegralTransforms/Algorithms/DiscreteFourierTransform.Bluestein.cs
@@ -73,8 +73,8 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
// Padding to power of two >= 2N–1 so we can apply Radix-2 FFT.
int m = ((n << 1) - 1).CeilingToPowerOfTwo();
- Complex[] b = new Complex[m];
- Complex[] a = new Complex[m];
+ var b = new Complex[m];
+ var a = new Complex[m];
CommonParallel.Invoke(
() =>
diff --git a/src/Numerics/IntegralTransforms/Transform.cs b/src/Numerics/IntegralTransforms/Transform.cs
index 0a2480f9..7fe56944 100644
--- a/src/Numerics/IntegralTransforms/Transform.cs
+++ b/src/Numerics/IntegralTransforms/Transform.cs
@@ -28,9 +28,10 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+using MathNet.Numerics.IntegralTransforms.Algorithms;
+
namespace MathNet.Numerics.IntegralTransforms
{
- using Algorithms;
#if !NOSYSNUMERICS
using Complex = System.Numerics.Complex;
@@ -41,10 +42,7 @@ namespace MathNet.Numerics.IntegralTransforms
///
public static class Transform
{
- ///
- /// Shared internal DET algorithm.
- ///
- private static readonly DiscreteFourierTransform _dft = new DiscreteFourierTransform();
+ private static readonly DiscreteFourierTransform DFT = new DiscreteFourierTransform();
///
/// Applies the forward Fast Fourier Transform (FFT) to arbitrary-length sample vectors.
@@ -52,7 +50,7 @@ namespace MathNet.Numerics.IntegralTransforms
/// Sample vector, where the FFT is evaluated in place.
public static void FourierForward(Complex[] samples)
{
- _dft.BluesteinForward(samples, FourierOptions.Default);
+ DFT.BluesteinForward(samples, FourierOptions.Default);
}
///
@@ -62,7 +60,7 @@ namespace MathNet.Numerics.IntegralTransforms
/// Fourier Transform Convention Options.
public static void FourierForward(Complex[] samples, FourierOptions options)
{
- _dft.BluesteinForward(samples, options);
+ DFT.BluesteinForward(samples, options);
}
///
@@ -71,7 +69,7 @@ namespace MathNet.Numerics.IntegralTransforms
/// Sample vector, where the FFT is evaluated in place.
public static void FourierInverse(Complex[] samples)
{
- _dft.BluesteinInverse(samples, FourierOptions.Default);
+ DFT.BluesteinInverse(samples, FourierOptions.Default);
}
///
@@ -81,7 +79,7 @@ namespace MathNet.Numerics.IntegralTransforms
/// Fourier Transform Convention Options.
public static void FourierInverse(Complex[] samples, FourierOptions options)
{
- _dft.BluesteinInverse(samples, options);
+ DFT.BluesteinInverse(samples, options);
}
}
}
diff --git a/src/Numerics/Integration/DoubleExponentialTransformation.cs b/src/Numerics/Integration/DoubleExponentialTransformation.cs
index 4ab6c256..4a490b55 100644
--- a/src/Numerics/Integration/DoubleExponentialTransformation.cs
+++ b/src/Numerics/Integration/DoubleExponentialTransformation.cs
@@ -119,7 +119,7 @@ namespace MathNet.Numerics.Integration
int length = level == 0 ? 4 : (3 << (level - 1));
double t = 0;
- double[] abcissas = new double[length];
+ var abcissas = new double[length];
for (int i = 0; i < abcissas.Length; i++)
{
double arg = offset + t;
@@ -148,7 +148,7 @@ namespace MathNet.Numerics.Integration
int length = level == 0 ? 4 : (3 << (level - 1));
double t = 0;
- double[] weights = new double[length];
+ var weights = new double[length];
for (int i = 0; i < weights.Length; i++)
{
double arg = offset + t;
@@ -158,7 +158,6 @@ namespace MathNet.Numerics.Integration
double abcissa = Math.Tanh(Constants.PiOver2*Math.Sinh(arg));
weights[i] = Constants.PiOver2*(1 - (abcissa*abcissa))*Math.Cosh(arg);
}
-
return weights;
}
diff --git a/src/Numerics/Interpolation/BulirschStoerRationalInterpolation.cs b/src/Numerics/Interpolation/BulirschStoerRationalInterpolation.cs
index cc36a6ca..efce88a4 100644
--- a/src/Numerics/Interpolation/BulirschStoerRationalInterpolation.cs
+++ b/src/Numerics/Interpolation/BulirschStoerRationalInterpolation.cs
@@ -127,11 +127,11 @@ namespace MathNet.Numerics.Interpolation
/// Interpolated value x(t).
public double Interpolate(double t)
{
- const double Tiny = 1.0e-25;
+ const double tiny = 1.0e-25;
int n = _points.Count;
- double[] c = new double[n];
- double[] d = new double[n];
+ var c = new double[n];
+ var d = new double[n];
int nearestIndex = 0;
double nearestDistance = Math.Abs(t - _points[0]);
@@ -151,7 +151,7 @@ namespace MathNet.Numerics.Interpolation
}
c[i] = _values[i];
- d[i] = _values[i] + Tiny;
+ d[i] = _values[i] + tiny;
}
double x = _values[nearestIndex];
diff --git a/src/Numerics/Interpolation/CubicSplineInterpolation.cs b/src/Numerics/Interpolation/CubicSplineInterpolation.cs
index 4d695d5d..725073ed 100644
--- a/src/Numerics/Interpolation/CubicSplineInterpolation.cs
+++ b/src/Numerics/Interpolation/CubicSplineInterpolation.cs
@@ -206,10 +206,10 @@ namespace MathNet.Numerics.Interpolation
rightBoundary = 0d;
}
- double[] a1 = new double[n];
- double[] a2 = new double[n];
- double[] a3 = new double[n];
- double[] b = new double[n];
+ var a1 = new double[n];
+ var a2 = new double[n];
+ var a3 = new double[n];
+ var b = new double[n];
// Left Boundary
switch (leftBoundaryCondition)
@@ -307,8 +307,6 @@ namespace MathNet.Numerics.Interpolation
/// The x-vector[n]
static double[] SolveTridiagonal(double[] a, double[] b, double[] c, double[] d)
{
- double[] x = new double[a.Length];
-
for (int k = 1; k < a.Length; k++)
{
double t = a[k]/b[k - 1];
@@ -316,6 +314,7 @@ namespace MathNet.Numerics.Interpolation
d[k] = d[k] - (t*d[k - 1]);
}
+ var x = new double[a.Length];
x[x.Length - 1] = d[d.Length - 1]/b[b.Length - 1];
for (int k = x.Length - 2; k >= 0; k--)
{
diff --git a/src/Numerics/Interpolation/FloaterHormannRationalInterpolation.cs b/src/Numerics/Interpolation/FloaterHormannRationalInterpolation.cs
index a6c40b0d..6ae1573e 100644
--- a/src/Numerics/Interpolation/FloaterHormannRationalInterpolation.cs
+++ b/src/Numerics/Interpolation/FloaterHormannRationalInterpolation.cs
@@ -173,15 +173,15 @@ namespace MathNet.Numerics.Interpolation
throw new ArgumentOutOfRangeException("order");
}
- double[] sortedWeights = new double[sampleValues.Count];
- double[] sortedPoints = new double[samplePoints.Count];
+ var sortedWeights = new double[sampleValues.Count];
+ var sortedPoints = new double[samplePoints.Count];
samplePoints.CopyTo(sortedPoints, 0);
// order: odd -> negative, even -> positive
double sign = ((order & 0x1) == 0x1) ? -1.0 : 1.0;
// init permutation vector
- int[] perm = new int[sortedWeights.Length];
+ var perm = new int[sortedWeights.Length];
for (int i = 0; i < perm.Length; i++)
{
perm[i] = i;
@@ -227,12 +227,11 @@ namespace MathNet.Numerics.Interpolation
}
// reorder back to original order, based on the permutation vector.
- double[] weights = new double[sortedWeights.Length];
+ var weights = new double[sortedWeights.Length];
for (int i = 0; i < weights.Length; i++)
{
weights[perm[i]] = sortedWeights[i];
}
-
return weights;
}
diff --git a/src/Numerics/Interpolation/LinearSplineInterpolation.cs b/src/Numerics/Interpolation/LinearSplineInterpolation.cs
index 5db1a084..7b413d80 100644
--- a/src/Numerics/Interpolation/LinearSplineInterpolation.cs
+++ b/src/Numerics/Interpolation/LinearSplineInterpolation.cs
@@ -129,8 +129,7 @@ namespace MathNet.Numerics.Interpolation
if (samplePoints[i] <= samplePoints[i - 1])
throw new ArgumentException(Resources.Interpolation_Initialize_SamplePointsNotStrictlyAscendingOrder, "samplePoints");
- double[] coefficients = new double[4*(samplePoints.Count - 1)];
-
+ var coefficients = new double[4*(samplePoints.Count - 1)];
for (int i = 0, j = 0; i < samplePoints.Count - 1; i++, j += 4)
{
coefficients[j] = sampleValues[i];
@@ -138,7 +137,6 @@ namespace MathNet.Numerics.Interpolation
coefficients[j + 2] = 0;
coefficients[j + 3] = 0;
}
-
return coefficients;
}
diff --git a/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs
index 8725c6f2..70f501ed 100644
--- a/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs
@@ -403,7 +403,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var diagResult = result as DiagonalMatrix;
if (diagResult == null)
{
- base.Multiply(scalar, result);
+ base.DoMultiply(scalar, result);
}
else
{
diff --git a/src/Numerics/LinearAlgebra/Complex/Factorization/DenseEvd.cs b/src/Numerics/LinearAlgebra/Complex/Factorization/DenseEvd.cs
index cfd97139..cf431695 100644
--- a/src/Numerics/LinearAlgebra/Complex/Factorization/DenseEvd.cs
+++ b/src/Numerics/LinearAlgebra/Complex/Factorization/DenseEvd.cs
@@ -235,7 +235,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
///
internal static void SymmetricDiagonalize(Complex[] dataEv, double[] d, double[] e, int order)
{
- const int Maxiter = 1000;
+ const int maxiter = 1000;
for (var i = 1; i < order; i++)
{
@@ -329,7 +329,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// Check for convergence. If too many iterations have been performed,
// throw exception that Convergence Failed
- if (iter >= Maxiter)
+ if (iter >= maxiter)
{
throw new NonConvergenceException();
}
diff --git a/src/Numerics/LinearAlgebra/Complex/Factorization/UserEvd.cs b/src/Numerics/LinearAlgebra/Complex/Factorization/UserEvd.cs
index e06969a6..7462eaca 100644
--- a/src/Numerics/LinearAlgebra/Complex/Factorization/UserEvd.cs
+++ b/src/Numerics/LinearAlgebra/Complex/Factorization/UserEvd.cs
@@ -255,7 +255,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
///
private void SymmetricDiagonalize(double[] d, double[] e, int order)
{
- const int Maxiter = 1000;
+ const int maxiter = 1000;
for (var i = 1; i < order; i++)
{
@@ -349,7 +349,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// Check for convergence. If too many iterations have been performed,
// throw exception that Convergence Failed
- if (iter >= Maxiter)
+ if (iter >= maxiter)
{
throw new NonConvergenceException();
}
diff --git a/src/Numerics/LinearAlgebra/Complex/Factorization/UserSvd.cs b/src/Numerics/LinearAlgebra/Complex/Factorization/UserSvd.cs
index ac3abff3..ce3ffdfd 100644
--- a/src/Numerics/LinearAlgebra/Complex/Factorization/UserSvd.cs
+++ b/src/Numerics/LinearAlgebra/Complex/Factorization/UserSvd.cs
@@ -79,14 +79,12 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
MatrixU = matrixCopy.CreateMatrix(matrixCopy.RowCount, matrixCopy.RowCount);
MatrixVT = matrixCopy.CreateMatrix(matrixCopy.ColumnCount, matrixCopy.ColumnCount);
- const int Maxiter = 1000;
+ const int maxiter = 1000;
var e = new Complex[matrixCopy.ColumnCount];
var work = new Complex[matrixCopy.RowCount];
int i, j;
int l, lp1;
- var cs = 0.0;
- var sn = 0.0;
Complex t;
var ncu = matrixCopy.RowCount;
@@ -360,7 +358,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
{
// Quit if all the singular values have been found. If too many iterations have been performed,
// throw exception that Convergence Failed
- if (iter >= Maxiter)
+ if (iter >= maxiter)
{
throw new NonConvergenceException();
}
@@ -433,6 +431,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// Perform the task indicated by kase.
int k;
double f;
+ double cs;
+ double sn;
switch (kase)
{
// Deflate negligible VectorS[m].
@@ -444,7 +444,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
{
k = m - 2 - kk + l;
t1 = VectorS[k].Real;
- Srotg(ref t1, ref f, ref cs, ref sn);
+ Srotg(ref t1, ref f, out cs, out sn);
VectorS[k] = t1;
if (k != l)
{
@@ -467,7 +467,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
for (k = l; k < m; k++)
{
t1 = VectorS[k].Real;
- Srotg(ref t1, ref f, ref cs, ref sn);
+ Srotg(ref t1, ref f, out cs, out sn);
VectorS[k] = t1;
f = -sn * e[k].Real;
e[k] = cs * e[k];
@@ -514,7 +514,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// Chase zeros.
for (k = l; k < m - 1; k++)
{
- Srotg(ref f, ref g, ref cs, ref sn);
+ Srotg(ref f, ref g, out cs, out sn);
if (k != l)
{
e[k - 1] = f;
@@ -529,7 +529,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
Csrot(MatrixVT, matrixCopy.ColumnCount, k, k + 1, cs, sn);
}
- Srotg(ref f, ref g, ref cs, ref sn);
+ Srotg(ref f, ref g, out cs, out sn);
VectorS[k] = f;
f = (cs * e[k].Real) + (sn * VectorS[k + 1].Real);
VectorS[k + 1] = (-sn * e[k]) + (cs * VectorS[k + 1]);
@@ -675,7 +675,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
/// Contains the parameter c associated with the Givens rotation
/// Contains the parameter s associated with the Givens rotation
/// This is equivalent to the DROTG LAPACK routine.
- private static void Srotg(ref double da, ref double db, ref double c, ref double s)
+ private static void Srotg(ref double da, ref double db, out double c, out double s)
{
double r, z;
diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/IlutpElementSorter.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/IlutpElementSorter.cs
index fbb0d12c..d0f8f48c 100644
--- a/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/IlutpElementSorter.cs
+++ b/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/IlutpElementSorter.cs
@@ -44,7 +44,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners
/// This sort algorithm is used to sort the columns in a sparse matrix based on
/// the value of the element on the diagonal of the matrix.
///
- internal class IlutpElementSorter
+ internal static class IlutpElementSorter
{
///
/// Sorts the elements of the vector in decreasing
diff --git a/src/Numerics/LinearAlgebra/Complex/SparseVector.cs b/src/Numerics/LinearAlgebra/Complex/SparseVector.cs
index 6e561899..4b0233c1 100644
--- a/src/Numerics/LinearAlgebra/Complex/SparseVector.cs
+++ b/src/Numerics/LinearAlgebra/Complex/SparseVector.cs
@@ -33,7 +33,6 @@ using MathNet.Numerics.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Linq;
namespace MathNet.Numerics.LinearAlgebra.Complex
{
diff --git a/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs
index ab0ad36c..2f16cd5d 100644
--- a/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs
@@ -398,7 +398,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var diagResult = result as DiagonalMatrix;
if (diagResult == null)
{
- base.Multiply(scalar, result);
+ base.DoMultiply(scalar, result);
}
else
{
diff --git a/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseEvd.cs b/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseEvd.cs
index ed6d739d..e37b77fa 100644
--- a/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseEvd.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseEvd.cs
@@ -228,7 +228,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
///
internal static void SymmetricDiagonalize(Numerics.Complex32[] dataEv, float[] d, float[] e, int order)
{
- const int Maxiter = 1000;
+ const int maxiter = 1000;
for (var i = 1; i < order; i++)
{
@@ -322,7 +322,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
// Check for convergence. If too many iterations have been performed,
// throw exception that Convergence Failed
- if (iter >= Maxiter)
+ if (iter >= maxiter)
{
throw new NonConvergenceException();
}
diff --git a/src/Numerics/LinearAlgebra/Complex32/Factorization/UserEvd.cs b/src/Numerics/LinearAlgebra/Complex32/Factorization/UserEvd.cs
index ed079547..9a911db0 100644
--- a/src/Numerics/LinearAlgebra/Complex32/Factorization/UserEvd.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/Factorization/UserEvd.cs
@@ -257,7 +257,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
///
private void SymmetricDiagonalize(float[] d, float[] e, int order)
{
- const int Maxiter = 1000;
+ const int maxiter = 1000;
for (var i = 1; i < order; i++)
{
@@ -351,7 +351,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
// Check for convergence. If too many iterations have been performed,
// throw exception that Convergence Failed
- if (iter >= Maxiter)
+ if (iter >= maxiter)
{
throw new NonConvergenceException();
}
diff --git a/src/Numerics/LinearAlgebra/Complex32/Factorization/UserSvd.cs b/src/Numerics/LinearAlgebra/Complex32/Factorization/UserSvd.cs
index d4fc405b..14319c3d 100644
--- a/src/Numerics/LinearAlgebra/Complex32/Factorization/UserSvd.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/Factorization/UserSvd.cs
@@ -74,14 +74,12 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
MatrixU = matrixCopy.CreateMatrix(matrixCopy.RowCount, matrixCopy.RowCount);
MatrixVT = matrixCopy.CreateMatrix(matrixCopy.ColumnCount, matrixCopy.ColumnCount);
- const int Maxiter = 1000;
+ const int maxiter = 1000;
var e = new Complex32[matrixCopy.ColumnCount];
var work = new Complex32[matrixCopy.RowCount];
int i, j;
int l, lp1;
- var cs = 0.0f;
- var sn = 0.0f;
Complex32 t;
var ncu = matrixCopy.RowCount;
@@ -355,7 +353,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
{
// Quit if all the singular values have been found. If too many iterations have been performed,
// throw exception that Convergence Failed
- if (iter >= Maxiter)
+ if (iter >= maxiter)
{
throw new NonConvergenceException();
}
@@ -428,6 +426,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
// Perform the task indicated by kase.
int k;
float f;
+ float sn;
+ float cs;
switch (kase)
{
// Deflate negligible VectorS[m].
@@ -439,7 +439,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
{
k = m - 2 - kk + l;
t1 = VectorS[k].Real;
- Srotg(ref t1, ref f, ref cs, ref sn);
+ Srotg(ref t1, ref f, out cs, out sn);
VectorS[k] = t1;
if (k != l)
{
@@ -462,7 +462,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
for (k = l; k < m; k++)
{
t1 = VectorS[k].Real;
- Srotg(ref t1, ref f, ref cs, ref sn);
+ Srotg(ref t1, ref f, out cs, out sn);
VectorS[k] = t1;
f = -sn * e[k].Real;
e[k] = cs * e[k];
@@ -509,7 +509,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
// Chase zeros.
for (k = l; k < m - 1; k++)
{
- Srotg(ref f, ref g, ref cs, ref sn);
+ Srotg(ref f, ref g, out cs, out sn);
if (k != l)
{
e[k - 1] = f;
@@ -524,7 +524,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
Csrot(MatrixVT, matrixCopy.ColumnCount, k, k + 1, cs, sn);
}
- Srotg(ref f, ref g, ref cs, ref sn);
+ Srotg(ref f, ref g, out cs, out sn);
VectorS[k] = f;
f = (cs * e[k].Real) + (sn * VectorS[k + 1].Real);
VectorS[k + 1] = (-sn * e[k]) + (cs * VectorS[k + 1]);
@@ -670,7 +670,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
/// Contains the parameter c associated with the Givens rotation
/// Contains the parameter s associated with the Givens rotation
/// This is equivalent to the DROTG LAPACK routine.
- private static void Srotg(ref float da, ref float db, ref float c, ref float s)
+ private static void Srotg(ref float da, ref float db, out float c, out float s)
{
float r, z;
diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/IlutpElementSorter.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/IlutpElementSorter.cs
index cf2ee5cc..76ba3a20 100644
--- a/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/IlutpElementSorter.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/IlutpElementSorter.cs
@@ -37,7 +37,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners
/// This sort algorithm is used to sort the columns in a sparse matrix based on
/// the value of the element on the diagonal of the matrix.
///
- internal class IlutpElementSorter
+ internal static class IlutpElementSorter
{
///
/// Sorts the elements of the vector in decreasing
diff --git a/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs b/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
index 5e57a58f..1b01469e 100644
--- a/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
@@ -33,7 +33,6 @@ using MathNet.Numerics.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Linq;
namespace MathNet.Numerics.LinearAlgebra.Complex32
{
diff --git a/src/Numerics/LinearAlgebra/Double/Factorization/UserEvd.cs b/src/Numerics/LinearAlgebra/Double/Factorization/UserEvd.cs
index 1b72ddc1..dcbf2c9d 100644
--- a/src/Numerics/LinearAlgebra/Double/Factorization/UserEvd.cs
+++ b/src/Numerics/LinearAlgebra/Double/Factorization/UserEvd.cs
@@ -297,7 +297,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
///
private void SymmetricDiagonalize(double[] d, double[] e, int order)
{
- const int Maxiter = 1000;
+ const int maxiter = 1000;
for (var i = 1; i < order; i++)
{
@@ -391,7 +391,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
// Check for convergence. If too many iterations have been performed,
// throw exception that Convergence Failed
- if (iter >= Maxiter)
+ if (iter >= maxiter)
{
throw new NonConvergenceException();
}
diff --git a/src/Numerics/LinearAlgebra/Double/Factorization/UserSvd.cs b/src/Numerics/LinearAlgebra/Double/Factorization/UserSvd.cs
index 9976d922..511f36e8 100644
--- a/src/Numerics/LinearAlgebra/Double/Factorization/UserSvd.cs
+++ b/src/Numerics/LinearAlgebra/Double/Factorization/UserSvd.cs
@@ -72,14 +72,12 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
MatrixU = matrixCopy.CreateMatrix(matrixCopy.RowCount, matrixCopy.RowCount);
MatrixVT = matrixCopy.CreateMatrix(matrixCopy.ColumnCount, matrixCopy.ColumnCount);
- const int Maxiter = 1000;
+ const int maxiter = 1000;
var e = new double[matrixCopy.ColumnCount];
var work = new double[matrixCopy.RowCount];
int i, j;
int l, lp1;
- var cs = 0.0;
- var sn = 0.0;
double t;
var ncu = matrixCopy.RowCount;
@@ -339,7 +337,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
{
// Quit if all the singular values have been found. If too many iterations have been performed,
// throw exception that Convergence Failed
- if (iter >= Maxiter)
+ if (iter >= maxiter)
{
throw new NonConvergenceException();
}
@@ -412,6 +410,8 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
// Perform the task indicated by kase.
int k;
double f;
+ double sn;
+ double cs;
switch (kase)
{
// Deflate negligible VectorS[m].
@@ -423,7 +423,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
{
k = m - 2 - kk + l;
t1 = VectorS[k];
- Drotg(ref t1, ref f, ref cs, ref sn);
+ Drotg(ref t1, ref f, out cs, out sn);
VectorS[k] = t1;
if (k != l)
{
@@ -446,7 +446,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
for (k = l; k < m; k++)
{
t1 = VectorS[k];
- Drotg(ref t1, ref f, ref cs, ref sn);
+ Drotg(ref t1, ref f, out cs, out sn);
VectorS[k] = t1;
f = -sn * e[k];
e[k] = cs * e[k];
@@ -492,7 +492,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
// Chase zeros.
for (k = l; k < m - 1; k++)
{
- Drotg(ref f, ref g, ref cs, ref sn);
+ Drotg(ref f, ref g, out cs, out sn);
if (k != l)
{
e[k - 1] = f;
@@ -507,7 +507,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
Drot(MatrixVT, matrixCopy.ColumnCount, k, k + 1, cs, sn);
}
- Drotg(ref f, ref g, ref cs, ref sn);
+ Drotg(ref f, ref g, out cs, out sn);
VectorS[k] = f;
f = (cs * e[k]) + (sn * VectorS[k + 1]);
VectorS[k + 1] = (-sn * e[k]) + (cs * VectorS[k + 1]);
@@ -653,7 +653,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
/// Contains the parameter c associated with the Givens rotation
/// Contains the parameter s associated with the Givens rotation
/// This is equivalent to the DROTG LAPACK routine.
- private static void Drotg(ref double da, ref double db, ref double c, ref double s)
+ private static void Drotg(ref double da, ref double db, out double c, out double s)
{
double r, z;
diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/IlutpElementSorter.cs b/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/IlutpElementSorter.cs
index 4371c911..3b5db00a 100644
--- a/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/IlutpElementSorter.cs
+++ b/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/IlutpElementSorter.cs
@@ -37,7 +37,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners
/// This sort algorithm is used to sort the columns in a sparse matrix based on
/// the value of the element on the diagonal of the matrix.
///
- internal class IlutpElementSorter
+ internal static class IlutpElementSorter
{
///
/// Sorts the elements of the vector in decreasing
diff --git a/src/Numerics/LinearAlgebra/Factorization/Cholesky.cs b/src/Numerics/LinearAlgebra/Factorization/Cholesky.cs
index 1f9a5179..7d3a5906 100644
--- a/src/Numerics/LinearAlgebra/Factorization/Cholesky.cs
+++ b/src/Numerics/LinearAlgebra/Factorization/Cholesky.cs
@@ -99,7 +99,7 @@ namespace MathNet.Numerics.LinearAlgebra.Factorization
return new LinearAlgebra.Complex32.Factorization.DenseCholesky(dense) as Cholesky;
}
- return new LinearAlgebra.Complex32.Factorization.UserCholesky(matrix as Matrix) as Cholesky;
+ return new LinearAlgebra.Complex32.Factorization.UserCholesky(matrix as Matrix) as Cholesky;
}
throw new NotSupportedException();
diff --git a/src/Numerics/LinearAlgebra/Factorization/Evd.cs b/src/Numerics/LinearAlgebra/Factorization/Evd.cs
index 3526f874..d07158ec 100644
--- a/src/Numerics/LinearAlgebra/Factorization/Evd.cs
+++ b/src/Numerics/LinearAlgebra/Factorization/Evd.cs
@@ -167,7 +167,7 @@ namespace MathNet.Numerics.LinearAlgebra.Factorization
return new LinearAlgebra.Complex32.Factorization.DenseEvd(dense) as Evd;
}
- return new LinearAlgebra.Complex32.Factorization.UserEvd(matrix as Matrix) as Evd;
+ return new LinearAlgebra.Complex32.Factorization.UserEvd(matrix as Matrix) as Evd;
}
throw new NotSupportedException();
diff --git a/src/Numerics/LinearAlgebra/Matrix.BCL.cs b/src/Numerics/LinearAlgebra/Matrix.BCL.cs
index 73601aca..aa8dfeff 100644
--- a/src/Numerics/LinearAlgebra/Matrix.BCL.cs
+++ b/src/Numerics/LinearAlgebra/Matrix.BCL.cs
@@ -213,7 +213,7 @@ namespace MathNet.Numerics.LinearAlgebra
///
public override sealed string ToString()
{
- return string.Concat(ToTypeString(), Environment.NewLine, ToMatrixString(Control.MaxToStringRows, Control.MaxToStringColumns, null));
+ return string.Concat(ToTypeString(), Environment.NewLine, ToMatrixString(Control.MaxToStringRows, Control.MaxToStringColumns));
}
///
diff --git a/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs
index 39a27225..30e30f97 100644
--- a/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs
@@ -397,7 +397,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var diagResult = result as DiagonalMatrix;
if (diagResult == null)
{
- base.Multiply(scalar, result);
+ base.DoMultiply(scalar, result);
}
else
{
diff --git a/src/Numerics/LinearAlgebra/Single/Factorization/DenseEvd.cs b/src/Numerics/LinearAlgebra/Single/Factorization/DenseEvd.cs
index 8301a2cc..450ec9a1 100644
--- a/src/Numerics/LinearAlgebra/Single/Factorization/DenseEvd.cs
+++ b/src/Numerics/LinearAlgebra/Single/Factorization/DenseEvd.cs
@@ -264,7 +264,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
///
internal static void SymmetricDiagonalize(float[] a, float[] d, float[] e, int order)
{
- const int Maxiter = 1000;
+ const int maxiter = 1000;
for (var i = 1; i < order; i++)
{
@@ -358,7 +358,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
// Check for convergence. If too many iterations have been performed,
// throw exception that Convergence Failed
- if (iter >= Maxiter)
+ if (iter >= maxiter)
{
throw new NonConvergenceException();
}
@@ -1038,7 +1038,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
var vi = (d[i] - p)*2.0f*q;
if ((vr == 0.0f) && (vi == 0.0f))
{
- vr = eps*norm*(float) (Math.Abs(w) + Math.Abs(q) + Math.Abs(x) + Math.Abs(y) + Math.Abs(z));
+ vr = eps*norm*(Math.Abs(w) + Math.Abs(q) + Math.Abs(x) + Math.Abs(y) + Math.Abs(z));
}
var res = Cdiv((x*r) - (z*ra) + (q*sa), (x*s) - (z*sa) - (q*ra), vr, vi);
diff --git a/src/Numerics/LinearAlgebra/Single/Factorization/UserEvd.cs b/src/Numerics/LinearAlgebra/Single/Factorization/UserEvd.cs
index 2cf90ab6..e78dc79e 100644
--- a/src/Numerics/LinearAlgebra/Single/Factorization/UserEvd.cs
+++ b/src/Numerics/LinearAlgebra/Single/Factorization/UserEvd.cs
@@ -296,7 +296,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
///
private void SymmetricDiagonalize(float[] d, float[] e, int order)
{
- const int Maxiter = 1000;
+ const int maxiter = 1000;
for (var i = 1; i < order; i++)
{
@@ -390,7 +390,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
// Check for convergence. If too many iterations have been performed,
// throw exception that Convergence Failed
- if (iter >= Maxiter)
+ if (iter >= maxiter)
{
throw new NonConvergenceException();
}
diff --git a/src/Numerics/LinearAlgebra/Single/Factorization/UserSvd.cs b/src/Numerics/LinearAlgebra/Single/Factorization/UserSvd.cs
index 37060291..9727bd1a 100644
--- a/src/Numerics/LinearAlgebra/Single/Factorization/UserSvd.cs
+++ b/src/Numerics/LinearAlgebra/Single/Factorization/UserSvd.cs
@@ -72,14 +72,12 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
MatrixU = matrixCopy.CreateMatrix(matrixCopy.RowCount, matrixCopy.RowCount);
MatrixVT = matrixCopy.CreateMatrix(matrixCopy.ColumnCount, matrixCopy.ColumnCount);
- const int Maxiter = 1000;
+ const int maxiter = 1000;
var e = new float[matrixCopy.ColumnCount];
var work = new float[matrixCopy.RowCount];
int i, j;
int l, lp1;
- var cs = 0.0f;
- var sn = 0.0f;
float t;
var ncu = matrixCopy.RowCount;
@@ -339,7 +337,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
{
// Quit if all the singular values have been found. If too many iterations have been performed,
// throw exception that Convergence Failed
- if (iter >= Maxiter)
+ if (iter >= maxiter)
{
throw new NonConvergenceException();
}
@@ -412,6 +410,8 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
// Perform the task indicated by kase.
int k;
float f;
+ float sn;
+ float cs;
switch (kase)
{
// Deflate negligible VectorS[m].
@@ -423,7 +423,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
{
k = m - 2 - kk + l;
t1 = VectorS[k];
- Drotg(ref t1, ref f, ref cs, ref sn);
+ Drotg(ref t1, ref f, out cs, out sn);
VectorS[k] = t1;
if (k != l)
{
@@ -446,7 +446,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
for (k = l; k < m; k++)
{
t1 = VectorS[k];
- Drotg(ref t1, ref f, ref cs, ref sn);
+ Drotg(ref t1, ref f, out cs, out sn);
VectorS[k] = t1;
f = -sn * e[k];
e[k] = cs * e[k];
@@ -492,7 +492,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
// Chase zeros.
for (k = l; k < m - 1; k++)
{
- Drotg(ref f, ref g, ref cs, ref sn);
+ Drotg(ref f, ref g, out cs, out sn);
if (k != l)
{
e[k - 1] = f;
@@ -507,7 +507,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
Drot(MatrixVT, matrixCopy.ColumnCount, k, k + 1, cs, sn);
}
- Drotg(ref f, ref g, ref cs, ref sn);
+ Drotg(ref f, ref g, out cs, out sn);
VectorS[k] = f;
f = (cs * e[k]) + (sn * VectorS[k + 1]);
VectorS[k + 1] = (-sn * e[k]) + (cs * VectorS[k + 1]);
@@ -653,7 +653,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
/// Contains the parameter c associated with the Givens rotation
/// Contains the parameter s associated with the Givens rotation
/// This is equivalent to the DROTG LAPACK routine.
- private static void Drotg(ref float da, ref float db, ref float c, ref float s)
+ private static void Drotg(ref float da, ref float db, out float c, out float s)
{
float r, z;
diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/IlutpElementSorter.cs b/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/IlutpElementSorter.cs
index ba66386e..e9b5e846 100644
--- a/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/IlutpElementSorter.cs
+++ b/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/IlutpElementSorter.cs
@@ -37,7 +37,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners
/// This sort algorithm is used to sort the columns in a sparse matrix based on
/// the value of the element on the diagonal of the matrix.
///
- internal class IlutpElementSorter
+ internal static class IlutpElementSorter
{
///
/// Sorts the elements of the vector in decreasing
diff --git a/src/Numerics/LinearAlgebra/Single/SparseMatrix.cs b/src/Numerics/LinearAlgebra/Single/SparseMatrix.cs
index a87f50ad..c4213988 100644
--- a/src/Numerics/LinearAlgebra/Single/SparseMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Single/SparseMatrix.cs
@@ -1116,9 +1116,9 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var lastRow = rowPointers.Length - 1;
- if (rowPointers[lastRow] < NonZerosCount)
+ if (rowPointers[lastRow] < valueCount)
{
- for (var index = rowPointers[lastRow]; index < NonZerosCount; index++)
+ for (var index = rowPointers[lastRow]; index < valueCount; index++)
{
yield return new Tuple(lastRow, columnIndices[index], values[index]);
}
diff --git a/src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs b/src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs
index 9c8527c1..8797bdb4 100644
--- a/src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs
+++ b/src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs
@@ -30,7 +30,6 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using MathNet.Numerics.Properties;
namespace MathNet.Numerics.LinearAlgebra.Storage
diff --git a/src/Numerics/LinearAlgebra/Vector.BCL.cs b/src/Numerics/LinearAlgebra/Vector.BCL.cs
index b58268ac..d3bb848a 100644
--- a/src/Numerics/LinearAlgebra/Vector.BCL.cs
+++ b/src/Numerics/LinearAlgebra/Vector.BCL.cs
@@ -336,7 +336,7 @@ namespace MathNet.Numerics.LinearAlgebra
///
public override sealed string ToString()
{
- return string.Concat(ToTypeString(), Environment.NewLine, ToVectorString(Control.MaxToStringRows, Control.MaxToStringColumns, null));
+ return string.Concat(ToTypeString(), Environment.NewLine, ToVectorString(Control.MaxToStringRows, Control.MaxToStringColumns));
}
///
diff --git a/src/Numerics/NumberTheory/IntegerTheory.cs b/src/Numerics/NumberTheory/IntegerTheory.cs
index c6f99235..993b7b26 100644
--- a/src/Numerics/NumberTheory/IntegerTheory.cs
+++ b/src/Numerics/NumberTheory/IntegerTheory.cs
@@ -111,8 +111,8 @@ namespace MathNet.Numerics.NumberTheory
return 0;
}
- const int MaxPowerOfTwo = 0x40000000;
- if (number > MaxPowerOfTwo)
+ const int maxPowerOfTwo = 0x40000000;
+ if (number > maxPowerOfTwo)
{
throw new ArgumentOutOfRangeException("number");
}
@@ -140,8 +140,8 @@ namespace MathNet.Numerics.NumberTheory
return 0;
}
- const long MaxPowerOfTwo = 0x4000000000000000;
- if (number > MaxPowerOfTwo)
+ const long maxPowerOfTwo = 0x4000000000000000;
+ if (number > maxPowerOfTwo)
{
throw new ArgumentOutOfRangeException("number");
}
diff --git a/src/Numerics/Providers/LinearAlgebra/ILinearAlgebraProvider.cs b/src/Numerics/Providers/LinearAlgebra/ILinearAlgebraProvider.cs
index a087911a..4443bdf2 100644
--- a/src/Numerics/Providers/LinearAlgebra/ILinearAlgebraProvider.cs
+++ b/src/Numerics/Providers/LinearAlgebra/ILinearAlgebraProvider.cs
@@ -100,7 +100,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
///
/// Interface to linear algebra algorithms that work off 1-D arrays.
///
- /// Supported data types are double, single, Complex, and Complex32.
+ /// Supported data types are Double, Single, Complex, and Complex32.
+ /// Supported data types are Double and Single, must correspond to T.
public interface ILinearAlgebraProvider
where T : struct
where TNorm : struct
diff --git a/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs
index f9111247..db67e7eb 100644
--- a/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs
+++ b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs
@@ -1689,12 +1689,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
if (a == null)
{
- throw new ArgumentNullException("q");
+ throw new ArgumentNullException("a");
}
if (work == null)
{
- throw new ArgumentNullException("q");
+ throw new ArgumentNullException("work");
}
if (a.Length != rowsA*columnsA)
@@ -2236,7 +2236,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
- const int Maxiter = 1000;
+ const int maxiter = 1000;
var e = new Complex[columnsA];
var v = new Complex[vt.Length];
@@ -2244,8 +2244,6 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
int i, j, l, lp1;
- var cs = 0.0;
- var sn = 0.0;
Complex t;
var ncu = rowsA;
@@ -2566,7 +2564,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
{
// Quit if all the singular values have been found.
// If too many iterations have been performed throw exception.
- if (iter >= Maxiter)
+ if (iter >= maxiter)
{
throw new NonConvergenceException();
}
@@ -2639,6 +2637,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
// Perform the task indicated by kase.
int k;
double f;
+ double cs;
+ double sn;
switch (kase)
{
// Deflate negligible s[m].
@@ -2650,7 +2650,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
{
k = m - 2 - kk + l;
t1 = stemp[k].Real;
- Drotg(ref t1, ref f, ref cs, ref sn);
+ Drotg(ref t1, ref f, out cs, out sn);
stemp[k] = t1;
if (k != l)
{
@@ -2679,7 +2679,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
for (k = l; k < m; k++)
{
t1 = stemp[k].Real;
- Drotg(ref t1, ref f, ref cs, ref sn);
+ Drotg(ref t1, ref f, out cs, out sn);
stemp[k] = t1;
f = -sn*e[k].Real;
e[k] = cs*e[k];
@@ -2731,7 +2731,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
// Chase zeros
for (k = l; k < m - 1; k++)
{
- Drotg(ref f, ref g, ref cs, ref sn);
+ Drotg(ref f, ref g, out cs, out sn);
if (k != l)
{
e[k - 1] = f;
@@ -2751,7 +2751,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
}
}
- Drotg(ref f, ref g, ref cs, ref sn);
+ Drotg(ref f, ref g, out cs, out sn);
stemp[k] = f;
f = (cs*e[k].Real) + (sn*stemp[k + 1].Real);
stemp[k + 1] = -(sn*e[k]) + (cs*stemp[k + 1]);
diff --git a/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs
index a231fa01..757bb555 100644
--- a/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs
+++ b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs
@@ -1687,12 +1687,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
if (a == null)
{
- throw new ArgumentNullException("q");
+ throw new ArgumentNullException("a");
}
if (work == null)
{
- throw new ArgumentNullException("q");
+ throw new ArgumentNullException("work");
}
if (a.Length != rowsA*columnsA)
@@ -2234,7 +2234,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
- const int Maxiter = 1000;
+ const int maxiter = 1000;
var e = new Complex32[columnsA];
var v = new Complex32[vt.Length];
@@ -2242,8 +2242,6 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
int i, j, l, lp1;
- var cs = 0.0f;
- var sn = 0.0f;
Complex32 t;
var ncu = rowsA;
@@ -2564,7 +2562,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
{
// Quit if all the singular values have been found.
// If too many iterations have been performed throw exception.
- if (iter >= Maxiter)
+ if (iter >= maxiter)
{
throw new NonConvergenceException();
}
@@ -2637,6 +2635,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
// Perform the task indicated by kase.
int k;
float f;
+ float sn;
+ float cs;
switch (kase)
{
// Deflate negligible s[m].
@@ -2648,7 +2648,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
{
k = m - 2 - kk + l;
t1 = stemp[k].Real;
- Drotg(ref t1, ref f, ref cs, ref sn);
+ Drotg(ref t1, ref f, out cs, out sn);
stemp[k] = t1;
if (k != l)
{
@@ -2677,7 +2677,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
for (k = l; k < m; k++)
{
t1 = stemp[k].Real;
- Drotg(ref t1, ref f, ref cs, ref sn);
+ Drotg(ref t1, ref f, out cs, out sn);
stemp[k] = t1;
f = -sn*e[k].Real;
e[k] = cs*e[k];
@@ -2729,7 +2729,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
// Chase zeros
for (k = l; k < m - 1; k++)
{
- Drotg(ref f, ref g, ref cs, ref sn);
+ Drotg(ref f, ref g, out cs, out sn);
if (k != l)
{
e[k - 1] = f;
@@ -2749,7 +2749,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
}
}
- Drotg(ref f, ref g, ref cs, ref sn);
+ Drotg(ref f, ref g, out cs, out sn);
stemp[k] = f;
f = (cs*e[k].Real) + (sn*stemp[k + 1].Real);
stemp[k + 1] = -(sn*e[k]) + (cs*stemp[k + 1]);
diff --git a/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs
index e9e6b0b0..87954a93 100644
--- a/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs
+++ b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs
@@ -1575,12 +1575,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
if (a == null)
{
- throw new ArgumentNullException("q");
+ throw new ArgumentNullException("a");
}
if (work == null)
{
- throw new ArgumentNullException("q");
+ throw new ArgumentNullException("work");
}
if (a.Length != rowsA*columnsA)
@@ -2122,7 +2122,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
- const int Maxiter = 1000;
+ const int maxiter = 1000;
var e = new double[columnsA];
var v = new double[vt.Length];
@@ -2130,8 +2130,6 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
int i, j, l, lp1;
- var cs = 0.0;
- var sn = 0.0;
double t;
var ncu = rowsA;
@@ -2454,7 +2452,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
{
// Quit if all the singular values have been found.
// If too many iterations have been performed throw exception.
- if (iter >= Maxiter)
+ if (iter >= maxiter)
{
throw new NonConvergenceException();
}
@@ -2527,6 +2525,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
// Perform the task indicated by kase.
int k;
double f;
+ double cs;
+ double sn;
switch (kase)
{
// Deflate negligible s[m].
@@ -2539,7 +2539,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
k = m - 2 - kk + l;
t1 = stemp[k];
- Drotg(ref t1, ref f, ref cs, ref sn);
+ Drotg(ref t1, ref f, out cs, out sn);
stemp[k] = t1;
if (k != l)
{
@@ -2568,7 +2568,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
for (k = l; k < m; k++)
{
t1 = stemp[k];
- Drotg(ref t1, ref f, ref cs, ref sn);
+ Drotg(ref t1, ref f, out cs, out sn);
stemp[k] = t1;
f = -sn*e[k];
e[k] = cs*e[k];
@@ -2621,7 +2621,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
// Chase zeros
for (k = l; k < m - 1; k++)
{
- Drotg(ref f, ref g, ref cs, ref sn);
+ Drotg(ref f, ref g, out cs, out sn);
if (k != l)
{
e[k - 1] = f;
@@ -2641,7 +2641,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
}
}
- Drotg(ref f, ref g, ref cs, ref sn);
+ Drotg(ref f, ref g, out cs, out sn);
stemp[k] = f;
f = (cs*e[k]) + (sn*stemp[k + 1]);
stemp[k + 1] = -(sn*e[k]) + (cs*stemp[k + 1]);
@@ -2752,7 +2752,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
/// Contains the parameter c associated with the Givens rotation
/// Contains the parameter s associated with the Givens rotation
/// This is equivalent to the DROTG LAPACK routine.
- static void Drotg(ref double da, ref double db, ref double c, ref double s)
+ static void Drotg(ref double da, ref double db, out double c, out double s)
{
double r, z;
diff --git a/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs
index 7a581001..ccdf6049 100644
--- a/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs
+++ b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs
@@ -1575,12 +1575,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
if (a == null)
{
- throw new ArgumentNullException("q");
+ throw new ArgumentNullException("a");
}
if (work == null)
{
- throw new ArgumentNullException("q");
+ throw new ArgumentNullException("work");
}
if (a.Length != rowsA*columnsA)
@@ -2122,7 +2122,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
- const int Maxiter = 1000;
+ const int maxiter = 1000;
var e = new float[columnsA];
var v = new float[vt.Length];
@@ -2130,8 +2130,6 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
int i, j, l, lp1;
- var cs = 0.0f;
- var sn = 0.0f;
float t;
var ncu = rowsA;
@@ -2456,7 +2454,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
{
// Quit if all the singular values have been found.
// If too many iterations have been performed throw exception.
- if (iter >= Maxiter)
+ if (iter >= maxiter)
{
throw new NonConvergenceException();
}
@@ -2529,6 +2527,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
// Perform the task indicated by kase.
int k;
float f;
+ float cs;
+ float sn;
switch (kase)
{
// Deflate negligible s[m].
@@ -2541,7 +2541,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
k = m - 2 - kk + l;
t1 = stemp[k];
- Drotg(ref t1, ref f, ref cs, ref sn);
+ Drotg(ref t1, ref f, out cs, out sn);
stemp[k] = t1;
if (k != l)
{
@@ -2570,7 +2570,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
for (k = l; k < m; k++)
{
t1 = stemp[k];
- Drotg(ref t1, ref f, ref cs, ref sn);
+ Drotg(ref t1, ref f, out cs, out sn);
stemp[k] = t1;
f = -sn*e[k];
e[k] = cs*e[k];
@@ -2623,7 +2623,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
// Chase zeros
for (k = l; k < m - 1; k++)
{
- Drotg(ref f, ref g, ref cs, ref sn);
+ Drotg(ref f, ref g, out cs, out sn);
if (k != l)
{
e[k - 1] = f;
@@ -2643,7 +2643,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
}
}
- Drotg(ref f, ref g, ref cs, ref sn);
+ Drotg(ref f, ref g, out cs, out sn);
stemp[k] = f;
f = (cs*e[k]) + (sn*stemp[k + 1]);
stemp[k + 1] = -(sn*e[k]) + (cs*stemp[k + 1]);
@@ -2754,7 +2754,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
/// Contains the parameter c associated with the Givens rotation
/// Contains the parameter s associated with the Givens rotation
/// This is equivalent to the DROTG LAPACK routine.
- static void Drotg(ref float da, ref float db, ref float c, ref float s)
+ static void Drotg(ref float da, ref float db, out float c, out float s)
{
float r, z;
diff --git a/src/Numerics/Random/AbstractRandomNumberGenerator.cs b/src/Numerics/Random/AbstractRandomNumberGenerator.cs
index 7d698eb0..f80dfd9a 100644
--- a/src/Numerics/Random/AbstractRandomNumberGenerator.cs
+++ b/src/Numerics/Random/AbstractRandomNumberGenerator.cs
@@ -28,10 +28,11 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+using MathNet.Numerics.Properties;
+
namespace MathNet.Numerics.Random
{
using System;
- using Properties;
///
/// Abstract class for random number generators. This class introduces a layer between
diff --git a/src/Numerics/Random/Mcg31m1.cs b/src/Numerics/Random/Mcg31m1.cs
index 5b9eec5c..93fd6ef6 100644
--- a/src/Numerics/Random/Mcg31m1.cs
+++ b/src/Numerics/Random/Mcg31m1.cs
@@ -28,18 +28,18 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
namespace MathNet.Numerics.Random
{
- using System;
-
///
/// Multiplicative congruential generator using a modulus of 2^31-1 and a multiplier of 1132489760.
///
- public partial class Mcg31m1 : AbstractRandomNumberGenerator
+ public class Mcg31m1 : AbstractRandomNumberGenerator
{
- private const ulong _modulus = 2147483647;
- private const ulong _multiplier = 1132489760;
- private const double _reciprocal = 1.0 / _modulus;
+ private const ulong Modulus = 2147483647;
+ private const ulong Multiplier = 1132489760;
+ private const double Reciprocal = 1.0 / Modulus;
private ulong _xn;
///
@@ -82,7 +82,7 @@ namespace MathNet.Numerics.Random
{
seed = 1;
}
- _xn = (uint) seed%_modulus;
+ _xn = (uint) seed%Modulus;
}
///
@@ -93,8 +93,8 @@ namespace MathNet.Numerics.Random
///
protected override double DoSample()
{
- double ret = _xn*_reciprocal;
- _xn = (_xn*_multiplier)%_modulus;
+ double ret = _xn*Reciprocal;
+ _xn = (_xn*Multiplier)%Modulus;
return ret;
}
}
diff --git a/src/Numerics/Random/Mcg59.cs b/src/Numerics/Random/Mcg59.cs
index 441caeb9..650c57dd 100644
--- a/src/Numerics/Random/Mcg59.cs
+++ b/src/Numerics/Random/Mcg59.cs
@@ -28,18 +28,18 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
namespace MathNet.Numerics.Random
{
- using System;
-
///
/// Multiplicative congruential generator using a modulus of 2^59 and a multiplier of 13^13.
///
- public partial class Mcg59 : AbstractRandomNumberGenerator
+ public class Mcg59 : AbstractRandomNumberGenerator
{
- private const double _reciprocal = 1.0 / _modulus;
- private const ulong _modulus = 576460752303423488;
- private const ulong _multiplier = 302875106592253;
+ private const double Reciprocal = 1.0 / Modulus;
+ private const ulong Modulus = 576460752303423488;
+ private const ulong Multiplier = 302875106592253;
private ulong _xn;
///
@@ -83,7 +83,7 @@ namespace MathNet.Numerics.Random
{
seed = 1;
}
- _xn = (uint) seed % _modulus;
+ _xn = (uint) seed % Modulus;
}
///
@@ -94,8 +94,8 @@ namespace MathNet.Numerics.Random
///
protected override double DoSample()
{
- double ret = _xn * _reciprocal;
- _xn = (_xn * _multiplier) % _modulus;
+ double ret = _xn * Reciprocal;
+ _xn = (_xn * Multiplier) % Modulus;
return ret;
}
}
diff --git a/src/Numerics/Random/MersenneTwister.cs b/src/Numerics/Random/MersenneTwister.cs
index 8c2a3cfe..ddff6188 100644
--- a/src/Numerics/Random/MersenneTwister.cs
+++ b/src/Numerics/Random/MersenneTwister.cs
@@ -66,10 +66,10 @@
email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
*/
+using System;
+
namespace MathNet.Numerics.Random
{
- using System;
-
///
/// Random number generator using Mersenne Twister 19937 algorithm.
///
@@ -78,37 +78,37 @@ namespace MathNet.Numerics.Random
///
/// Mersenne twister constant.
///
- private const uint _lower_mask = 0x7fffffff;
+ private const uint LowerMask = 0x7fffffff;
///
/// Mersenne twister constant.
///
- private const int _m = 397;
+ private const int M = 397;
///
/// Mersenne twister constant.
///
- private const uint _matrix_a = 0x9908b0df;
+ private const uint MatrixA = 0x9908b0df;
///
/// Mersenne twister constant.
///
- private const int _n = 624;
+ private const int N = 624;
///
/// Mersenne twister constant.
///
- private const double _reciprocal = 1.0/4294967296.0;
+ private const double Reciprocal = 1.0/4294967296.0;
///
/// Mersenne twister constant.
///
- private const uint _upper_mask = 0x80000000;
+ private const uint UpperMask = 0x80000000;
///
/// Mersenne twister constant.
///
- private static readonly uint[] _mag01 = {0x0U, _matrix_a};
+ private static readonly uint[] Mag01 = {0x0U, MatrixA};
///
/// Mersenne twister constant.
@@ -118,7 +118,7 @@ namespace MathNet.Numerics.Random
///
/// Mersenne twister constant.
///
- private int mti = _n + 1;
+ private int _mti = N + 1;
///
/// Initializes a new instance of the class using
@@ -183,14 +183,14 @@ namespace MathNet.Numerics.Random
private void init_genrand(uint s)
{
_mt[0] = s & 0xffffffff;
- for (mti = 1; mti < _n; mti++)
+ for (_mti = 1; _mti < N; _mti++)
{
- _mt[mti] = (1812433253*(_mt[mti - 1] ^ (_mt[mti - 1] >> 30)) + (uint) mti);
+ _mt[_mti] = (1812433253*(_mt[_mti - 1] ^ (_mt[_mti - 1] >> 30)) + (uint) _mti);
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
/* In the previous versions, MSBs of the seed affect */
/* only MSBs of the array _mt[]. */
/* 2002/01/09 modified by Makoto Matsumoto */
- _mt[mti] &= 0xffffffff;
+ _mt[_mti] &= 0xffffffff;
/* for >32 bit machines */
}
}
@@ -243,31 +243,31 @@ namespace MathNet.Numerics.Random
/* mag01[x] = x * MATRIX_A for x=0,1 */
- if (mti >= _n)
+ if (_mti >= N)
{
/* generate _n words at one time */
int kk;
- if (mti == _n + 1) /* if init_genrand() has not been called, */
+ if (_mti == N + 1) /* if init_genrand() has not been called, */
init_genrand(5489); /* a default initial seed is used */
- for (kk = 0; kk < _n - _m; kk++)
+ for (kk = 0; kk < N - M; kk++)
{
- y = (_mt[kk] & _upper_mask) | (_mt[kk + 1] & _lower_mask);
- _mt[kk] = _mt[kk + _m] ^ (y >> 1) ^ _mag01[y & 0x1];
+ y = (_mt[kk] & UpperMask) | (_mt[kk + 1] & LowerMask);
+ _mt[kk] = _mt[kk + M] ^ (y >> 1) ^ Mag01[y & 0x1];
}
- for (; kk < _n - 1; kk++)
+ for (; kk < N - 1; kk++)
{
- y = (_mt[kk] & _upper_mask) | (_mt[kk + 1] & _lower_mask);
- _mt[kk] = _mt[kk + (_m - _n)] ^ (y >> 1) ^ _mag01[y & 0x1];
+ y = (_mt[kk] & UpperMask) | (_mt[kk + 1] & LowerMask);
+ _mt[kk] = _mt[kk + (M - N)] ^ (y >> 1) ^ Mag01[y & 0x1];
}
- y = (_mt[_n - 1] & _upper_mask) | (_mt[0] & _lower_mask);
- _mt[_n - 1] = _mt[_m - 1] ^ (y >> 1) ^ _mag01[y & 0x1];
+ y = (_mt[N - 1] & UpperMask) | (_mt[0] & LowerMask);
+ _mt[N - 1] = _mt[M - 1] ^ (y >> 1) ^ Mag01[y & 0x1];
- mti = 0;
+ _mti = 0;
}
- y = _mt[mti++];
+ y = _mt[_mti++];
/* Tempering */
y ^= (y >> 11);
@@ -286,7 +286,7 @@ namespace MathNet.Numerics.Random
///
protected override double DoSample()
{
- return genrand_int32() * _reciprocal;
+ return genrand_int32() * Reciprocal;
}
/* ///
diff --git a/src/Numerics/Random/Mrg32k3a.cs b/src/Numerics/Random/Mrg32k3a.cs
index e6894526..b54812f2 100644
--- a/src/Numerics/Random/Mrg32k3a.cs
+++ b/src/Numerics/Random/Mrg32k3a.cs
@@ -28,16 +28,31 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
namespace MathNet.Numerics.Random
{
- using System;
-
///
/// A 32-bit combined multiple recursive generator with 2 components of order 3.
///
///Based off of P. L'Ecuyer, "Combined Multiple Recursive Random Number Generators," Operations Research, 44, 5 (1996), 816--822.
- public partial class Mrg32k3a : AbstractRandomNumberGenerator
+ public class Mrg32k3a : AbstractRandomNumberGenerator
{
+ private const double A12 = 1403580;
+ private const double A13 = 810728;
+ private const double A21 = 527612;
+ private const double A23 = 1370589;
+ private const double Modulus1 = 4294967087;
+ private const double Modulus2 = 4294944443;
+
+ private const double Reciprocal = 1.0 / Modulus1;
+ private double _xn1 = 1;
+ private double _xn2 = 1;
+ private double _xn3;
+ private double _yn1 = 1;
+ private double _yn2 = 1;
+ private double _yn3 = 1;
+
///
/// Initializes a new instance of the class using
/// the current time as the seed.
@@ -57,20 +72,6 @@ namespace MathNet.Numerics.Random
public Mrg32k3a(bool threadSafe) : this((int)DateTime.Now.Ticks, threadSafe)
{
}
- private const double _a12 = 1403580;
- private const double _a13 = 810728;
- private const double _a21 = 527612;
- private const double _a23 = 1370589;
- private const double _modulus1 = 4294967087;
- private const double _modulus2 = 4294944443;
-
- private const double _reciprocal = 1.0/_modulus1;
- private double _xn1 = 1;
- private double _xn2 = 1;
- private double _xn3;
- private double _yn1 = 1;
- private double _yn2 = 1;
- private double _yn3 = 1;
///
/// Initializes a new instance of the class.
@@ -106,20 +107,20 @@ namespace MathNet.Numerics.Random
///
protected override double DoSample()
{
- double xn = _a12*_xn2 - _a13*_xn3;
- double k = (long) (xn/_modulus1);
- xn -= k*_modulus1;
+ double xn = A12*_xn2 - A13*_xn3;
+ double k = (long) (xn/Modulus1);
+ xn -= k*Modulus1;
if (xn < 0)
{
- xn += _modulus1;
+ xn += Modulus1;
}
- double yn = _a21*_yn1 - _a23*_yn3;
- k = (long) (yn/_modulus2);
- yn -= k*_modulus2;
+ double yn = A21*_yn1 - A23*_yn3;
+ k = (long) (yn/Modulus2);
+ yn -= k*Modulus2;
if (yn < 0)
{
- yn += _modulus2;
+ yn += Modulus2;
}
_xn3 = _xn2;
_xn2 = _xn1;
@@ -130,9 +131,9 @@ namespace MathNet.Numerics.Random
if (xn <= yn)
{
- return (xn - yn + _modulus1)*_reciprocal;
+ return (xn - yn + Modulus1)*Reciprocal;
}
- return (xn - yn)*_reciprocal;
+ return (xn - yn)*Reciprocal;
}
}
}
\ No newline at end of file
diff --git a/src/Numerics/Random/Palf.cs b/src/Numerics/Random/Palf.cs
index 115c0066..01ff002a 100644
--- a/src/Numerics/Random/Palf.cs
+++ b/src/Numerics/Random/Palf.cs
@@ -28,12 +28,12 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+using MathNet.Numerics.Properties;
+using MathNet.Numerics.Threading;
+
namespace MathNet.Numerics.Random
{
- using System;
- using Properties;
- using Threading;
-
///
/// Represents a Parallel Additive Lagged Fibonacci pseudo-random number generator.
///
diff --git a/src/Numerics/Random/SystemCrypto.cs b/src/Numerics/Random/SystemCrypto.cs
index 4b85df0c..b9adca1f 100644
--- a/src/Numerics/Random/SystemCrypto.cs
+++ b/src/Numerics/Random/SystemCrypto.cs
@@ -29,18 +29,19 @@
//
#if !PORTABLE
+
+using System;
+using System.Security.Cryptography;
+
namespace MathNet.Numerics.Random
{
- using System;
- using System.Security.Cryptography;
-
///
/// A random number generator based on the class in the .NET library.
///
public class SystemCryptoRandomNumberGenerator : AbstractRandomNumberGenerator, IDisposable
{
- private const double mReciprocal = 1.0 / uint.MaxValue;
- private readonly RandomNumberGenerator mRandom;
+ private const double Reciprocal = 1.0 / uint.MaxValue;
+ private readonly RandomNumberGenerator _random;
///
/// Construct a new random number generator with a random seed.
@@ -49,7 +50,7 @@ namespace MathNet.Numerics.Random
/// to set whether the instance is thread safe.
public SystemCryptoRandomNumberGenerator(): this(new RNGCryptoServiceProvider(), Control.ThreadSafeRandomNumberGenerators)
{
- mRandom = new RNGCryptoServiceProvider();
+ _random = new RNGCryptoServiceProvider();
}
///
@@ -81,7 +82,7 @@ namespace MathNet.Numerics.Random
{
throw new ArgumentNullException("rng");
}
- mRandom = rng;
+ _random = rng;
}
@@ -93,15 +94,16 @@ namespace MathNet.Numerics.Random
///
protected override double DoSample()
{
- byte[] bytes = new byte[4];
- mRandom.GetBytes(bytes);
- return BitConverter.ToUInt32(bytes, 0) * mReciprocal;
+ var bytes = new byte[4];
+ _random.GetBytes(bytes);
+ return BitConverter.ToUInt32(bytes, 0) * Reciprocal;
}
public void Dispose()
{
- mRandom.Dispose();
+ _random.Dispose();
}
}
}
+
#endif
diff --git a/src/Numerics/Random/WH1982.cs b/src/Numerics/Random/WH1982.cs
index 8d7ad733..d4e410fd 100644
--- a/src/Numerics/Random/WH1982.cs
+++ b/src/Numerics/Random/WH1982.cs
@@ -28,10 +28,10 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
namespace MathNet.Numerics.Random
{
- using System;
-
///
/// Wichmann-Hill’s 1982 combined multiplicative congruential generator.
///
@@ -40,12 +40,12 @@ namespace MathNet.Numerics.Random
///
public class WH1982 : AbstractRandomNumberGenerator
{
- private const uint _modx = 30269;
- private const double _modx_recip = 1.0/_modx;
- private const uint _mody = 30307;
- private const double _mody_recip = 1.0/_mody;
- private const uint _modz = 30323;
- private const double _modz_recip = 1.0/_modz;
+ private const uint Modx = 30269;
+ private const double ModxRecip = 1.0/Modx;
+ private const uint Mody = 30307;
+ private const double ModyRecip = 1.0/Mody;
+ private const uint Modz = 30323;
+ private const double ModzRecip = 1.0/Modz;
private uint _xn;
private uint _yn = 1;
private uint _zn = 1;
@@ -92,7 +92,7 @@ namespace MathNet.Numerics.Random
{
seed = 1;
}
- _xn = (uint) seed%_modx;
+ _xn = (uint) seed%Modx;
}
///
@@ -103,11 +103,11 @@ namespace MathNet.Numerics.Random
///
protected override double DoSample()
{
- _xn = (171*_xn)%_modx;
- _yn = (172*_yn)%_mody;
- _zn = (170*_zn)%_modz;
+ _xn = (171*_xn)%Modx;
+ _yn = (172*_yn)%Mody;
+ _zn = (170*_zn)%Modz;
- double w = _xn*_modx_recip + _yn*_mody_recip + _zn*_modz_recip;
+ double w = _xn*ModxRecip + _yn*ModyRecip + _zn*ModzRecip;
w -= (int) w;
return w;
}
diff --git a/src/Numerics/Random/WH2006.cs b/src/Numerics/Random/WH2006.cs
index 3625d07b..94e5f27b 100644
--- a/src/Numerics/Random/WH2006.cs
+++ b/src/Numerics/Random/WH2006.cs
@@ -28,10 +28,10 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
namespace MathNet.Numerics.Random
{
- using System;
-
///
/// Wichmann-Hill’s 2006 combined multiplicative congruential generator.
///
@@ -40,14 +40,14 @@ namespace MathNet.Numerics.Random
///
public class WH2006 : AbstractRandomNumberGenerator
{
- private const uint _modw = 2147483123;
- private const double _modw_recip = 1.0/_modw;
- private const uint _modx = 2147483579;
- private const double _modx_recip = 1.0/_modx;
- private const uint _mody = 2147483543;
- private const double _mody_recip = 1.0/_mody;
- private const uint _modz = 2147483423;
- private const double _modz_recip = 1.0/_modz;
+ private const uint Modw = 2147483123;
+ private const double ModwRecip = 1.0/Modw;
+ private const uint Modx = 2147483579;
+ private const double ModxRecip = 1.0/Modx;
+ private const uint Mody = 2147483543;
+ private const double ModyRecip = 1.0/Mody;
+ private const uint Modz = 2147483423;
+ private const double ModzRecip = 1.0/Modz;
private ulong _wn = 1;
private ulong _xn;
private ulong _yn = 1;
@@ -95,7 +95,7 @@ namespace MathNet.Numerics.Random
{
seed = 1;
}
- _xn = (uint) seed%_modx;
+ _xn = (uint) seed%Modx;
}
///
@@ -106,12 +106,12 @@ namespace MathNet.Numerics.Random
///
protected override double DoSample()
{
- _xn = 11600*_xn%_modx;
- _yn = 47003*_yn%_mody;
- _zn = 23000*_zn%_modz;
- _wn = 33000*_wn%_modw;
+ _xn = 11600*_xn%Modx;
+ _yn = 47003*_yn%Mody;
+ _zn = 23000*_zn%Modz;
+ _wn = 33000*_wn%Modw;
- double u = _xn*_modx_recip + _yn*_mody_recip + _zn*_modz_recip + _wn*_modw_recip;
+ double u = _xn*ModxRecip + _yn*ModyRecip + _zn*ModzRecip + _wn*ModwRecip;
u -= (int) u;
return u;
}
diff --git a/src/Numerics/Random/Xorshift.cs b/src/Numerics/Random/Xorshift.cs
index b21fbda0..da38207c 100644
--- a/src/Numerics/Random/Xorshift.cs
+++ b/src/Numerics/Random/Xorshift.cs
@@ -29,11 +29,10 @@
//
using MathNet.Numerics.Properties;
+using System;
namespace MathNet.Numerics.Random
{
- using System;
-
///
/// Implements a multiply-with-carry Xorshift pseudo random number generator (RNG) specified in Marsaglia, George. (2003). Xorshift RNGs.
/// Xn = a * Xn−3 + c mod 2^32
@@ -41,6 +40,56 @@ namespace MathNet.Numerics.Random
///
public class Xorshift : AbstractRandomNumberGenerator
{
+ ///
+ /// The default value for X1.
+ ///
+ private const uint YSeed = 362436069;
+
+ ///
+ /// The default value for X2.
+ ///
+ private const uint ZSeed = 77465321;
+
+ ///
+ /// The default value for the multiplier.
+ ///
+ private const uint ASeed = 916905990;
+
+ ///
+ /// The default value for the carry over.
+ ///
+ private const uint CSeed = 13579;
+
+ ///
+ /// The multiplier to compute a double-precision floating point number [0, 1)
+ ///
+ private const double UlongToDoubleMultiplier = 1.0 / (uint.MaxValue + 1.0);
+
+ ///
+ /// Seed or last but three unsigned random number.
+ ///
+ private ulong _x;
+
+ ///
+ /// Last but two unsigned random number.
+ ///
+ private ulong _y;
+
+ ///
+ /// Last but one unsigned random number.
+ ///
+ private ulong _z;
+
+ ///
+ /// The value of the carry over.
+ ///
+ private ulong _c;
+
+ ///
+ /// The multiplier.
+ ///
+ private readonly ulong _a;
+
///
/// Initializes a new instance of the class using
/// the current time as the seed.
@@ -202,56 +251,6 @@ namespace MathNet.Numerics.Random
_c = (ulong)c;
}
- ///
- /// The default value for X1.
- ///
- private const uint YSeed = 362436069;
-
- ///
- /// The default value for X2.
- ///
- private const uint ZSeed = 77465321;
-
- ///
- /// The default value for the multiplier.
- ///
- private const uint ASeed = 916905990;
-
- ///
- /// The default value for the carry over.
- ///
- private const uint CSeed = 13579;
-
- ///
- /// The multiplier to compute a double-precision floating point number [0, 1)
- ///
- private const double UlongToDoubleMultiplier = 1.0 / (uint.MaxValue + 1.0);
-
- ///
- /// Seed or last but three unsigned random number.
- ///
- private ulong _x;
-
- ///
- /// Last but two unsigned random number.
- ///
- private ulong _y;
-
- ///
- /// Last but one unsigned random number.
- ///
- private ulong _z;
-
- ///
- /// The value of the carry over.
- ///
- private ulong _c;
-
- ///
- /// The multiplier.
- ///
- private readonly ulong _a;
-
///
/// Returns a random number between 0.0 and 1.0.
///
diff --git a/src/Numerics/RootFinding/Broyden.cs b/src/Numerics/RootFinding/Broyden.cs
index 41131c9b..1ebec75e 100644
--- a/src/Numerics/RootFinding/Broyden.cs
+++ b/src/Numerics/RootFinding/Broyden.cs
@@ -117,8 +117,8 @@ namespace MathNet.Numerics.RootFinding
/// Helper method to calculate an approxiamtion of the Jacobian.
///
/// The function.
- /// The argument.
- ///
+ /// The argument (initial guess).
+ /// The result (of initial guess).
static Matrix CalculateApproximateJacobian(Func f, double[] x0, double[] y0)
{
int dim = x0.Length;
diff --git a/src/Numerics/SpecialFunctions/Beta.cs b/src/Numerics/SpecialFunctions/Beta.cs
index c96dfd93..c0ae018c 100644
--- a/src/Numerics/SpecialFunctions/Beta.cs
+++ b/src/Numerics/SpecialFunctions/Beta.cs
@@ -121,7 +121,7 @@ namespace MathNet.Numerics
var symmetryTransformation = x >= (a + 1.0) / (a + b + 2.0);
/* Continued fraction representation */
- const int MaxIterations = 100;
+ const int maxIterations = 100;
var eps = Precision.DoubleMachinePrecision;
var fpmin = 0.0.Increment() / eps;
@@ -147,7 +147,7 @@ namespace MathNet.Numerics
d = 1.0 / d;
var h = d;
- for (int m = 1, m2 = 2; m <= MaxIterations; m++, m2 += 2)
+ for (int m = 1, m2 = 2; m <= maxIterations; m++, m2 += 2)
{
var aa = m * (b - m) * x / ((qam + m2) * (a + m2));
d = 1.0 + (aa * d);
diff --git a/src/Numerics/SpecialFunctions/Erf.cs b/src/Numerics/SpecialFunctions/Erf.cs
index 3ee142c0..6db5855c 100644
--- a/src/Numerics/SpecialFunctions/Erf.cs
+++ b/src/Numerics/SpecialFunctions/Erf.cs
@@ -115,6 +115,7 @@ namespace MathNet.Numerics
return ErfImp(x, true);
}
+
///Calculates the inverse error function evaluated at z.
/// The inverse error function evaluated at given value.
///
@@ -165,7 +166,7 @@ namespace MathNet.Numerics
/// Where to evaluate the error function.
/// Whether to compute 1 - the error function.
/// the error function.
- private static double ErfImp(double z, bool invert)
+ static double ErfImp(double z, bool invert)
{
if (z < 0)
{
@@ -196,15 +197,15 @@ namespace MathNet.Numerics
//
if (z < 1e-10)
{
- result = (z * 1.125) + (z * 0.003379167095512573896158903121545171688);
+ result = (z*1.125) + (z*0.003379167095512573896158903121545171688);
}
else
{
// Worst case absolute error found: 6.688618532e-21
- double[] n = new[] { 0.00337916709551257388990745, -0.00073695653048167948530905, -0.374732337392919607868241, 0.0817442448733587196071743, -0.0421089319936548595203468, 0.0070165709512095756344528, -0.00495091255982435110337458, 0.000871646599037922480317225 };
- double[] d = new[] { 1, -0.218088218087924645390535, 0.412542972725442099083918, -0.0841891147873106755410271, 0.0655338856400241519690695, -0.0120019604454941768171266, 0.00408165558926174048329689, -0.000615900721557769691924509 };
+ double[] nc = {0.00337916709551257388990745, -0.00073695653048167948530905, -0.374732337392919607868241, 0.0817442448733587196071743, -0.0421089319936548595203468, 0.0070165709512095756344528, -0.00495091255982435110337458, 0.000871646599037922480317225};
+ double[] dc = {1, -0.218088218087924645390535, 0.412542972725442099083918, -0.0841891147873106755410271, 0.0655338856400241519690695, -0.0120019604454941768171266, 0.00408165558926174048329689, -0.000615900721557769691924509};
- result = (z * 1.125) + (z * Evaluate.Polynomial(z, n) / Evaluate.Polynomial(z, d));
+ result = (z*1.125) + (z*Evaluate.Polynomial(z, nc)/Evaluate.Polynomial(z, dc));
}
}
else if ((z < 110) || ((z < 110) && invert))
@@ -217,110 +218,110 @@ namespace MathNet.Numerics
if (z < 0.75)
{
// Worst case absolute error found: 5.582813374e-21
- double[] n = new[] { -0.0361790390718262471360258, 0.292251883444882683221149, 0.281447041797604512774415, 0.125610208862766947294894, 0.0274135028268930549240776, 0.00250839672168065762786937 };
- double[] d = new[] { 1, 1.8545005897903486499845, 1.43575803037831418074962, 0.582827658753036572454135, 0.124810476932949746447682, 0.0113724176546353285778481 };
- r = Evaluate.Polynomial(z - 0.5, n) / Evaluate.Polynomial(z - 0.5, d);
+ double[] nc = {-0.0361790390718262471360258, 0.292251883444882683221149, 0.281447041797604512774415, 0.125610208862766947294894, 0.0274135028268930549240776, 0.00250839672168065762786937};
+ double[] dc = {1, 1.8545005897903486499845, 1.43575803037831418074962, 0.582827658753036572454135, 0.124810476932949746447682, 0.0113724176546353285778481};
+ r = Evaluate.Polynomial(z - 0.5, nc)/Evaluate.Polynomial(z - 0.5, dc);
b = 0.3440242112F;
}
else if (z < 1.25)
{
// Worst case absolute error found: 4.01854729e-21
- double[] n = new[] { -0.0397876892611136856954425, 0.153165212467878293257683, 0.191260295600936245503129, 0.10276327061989304213645, 0.029637090615738836726027, 0.0046093486780275489468812, 0.000307607820348680180548455 };
- double[] d = new[] { 1, 1.95520072987627704987886, 1.64762317199384860109595, 0.768238607022126250082483, 0.209793185936509782784315, 0.0319569316899913392596356, 0.00213363160895785378615014 };
- r = Evaluate.Polynomial(z - 0.75, n) / Evaluate.Polynomial(z - 0.75, d);
+ double[] nc = {-0.0397876892611136856954425, 0.153165212467878293257683, 0.191260295600936245503129, 0.10276327061989304213645, 0.029637090615738836726027, 0.0046093486780275489468812, 0.000307607820348680180548455};
+ double[] dc = {1, 1.95520072987627704987886, 1.64762317199384860109595, 0.768238607022126250082483, 0.209793185936509782784315, 0.0319569316899913392596356, 0.00213363160895785378615014};
+ r = Evaluate.Polynomial(z - 0.75, nc)/Evaluate.Polynomial(z - 0.75, dc);
b = 0.419990927F;
}
else if (z < 2.25)
{
// Worst case absolute error found: 2.866005373e-21
- double[] n = new[] { -0.0300838560557949717328341, 0.0538578829844454508530552, 0.0726211541651914182692959, 0.0367628469888049348429018, 0.00964629015572527529605267, 0.00133453480075291076745275, 0.778087599782504251917881e-4 };
- double[] d = new[] { 1, 1.75967098147167528287343, 1.32883571437961120556307, 0.552528596508757581287907, 0.133793056941332861912279, 0.0179509645176280768640766, 0.00104712440019937356634038, -0.106640381820357337177643e-7 };
- r = Evaluate.Polynomial(z - 1.25, n) / Evaluate.Polynomial(z - 1.25, d);
+ double[] nc = {-0.0300838560557949717328341, 0.0538578829844454508530552, 0.0726211541651914182692959, 0.0367628469888049348429018, 0.00964629015572527529605267, 0.00133453480075291076745275, 0.778087599782504251917881e-4};
+ double[] dc = {1, 1.75967098147167528287343, 1.32883571437961120556307, 0.552528596508757581287907, 0.133793056941332861912279, 0.0179509645176280768640766, 0.00104712440019937356634038, -0.106640381820357337177643e-7};
+ r = Evaluate.Polynomial(z - 1.25, nc)/Evaluate.Polynomial(z - 1.25, dc);
b = 0.4898625016F;
}
else if (z < 3.5)
{
// Worst case absolute error found: 1.045355789e-21
- double[] n = new[] { -0.0117907570137227847827732, 0.014262132090538809896674, 0.0202234435902960820020765, 0.00930668299990432009042239, 0.00213357802422065994322516, 0.00025022987386460102395382, 0.120534912219588189822126e-4 };
- double[] d = new[] { 1, 1.50376225203620482047419, 0.965397786204462896346934, 0.339265230476796681555511, 0.0689740649541569716897427, 0.00771060262491768307365526, 0.000371421101531069302990367 };
- r = Evaluate.Polynomial(z - 2.25, n) / Evaluate.Polynomial(z - 2.25, d);
+ double[] nc = {-0.0117907570137227847827732, 0.014262132090538809896674, 0.0202234435902960820020765, 0.00930668299990432009042239, 0.00213357802422065994322516, 0.00025022987386460102395382, 0.120534912219588189822126e-4};
+ double[] dc = {1, 1.50376225203620482047419, 0.965397786204462896346934, 0.339265230476796681555511, 0.0689740649541569716897427, 0.00771060262491768307365526, 0.000371421101531069302990367};
+ r = Evaluate.Polynomial(z - 2.25, nc)/Evaluate.Polynomial(z - 2.25, dc);
b = 0.5317370892F;
}
else if (z < 5.25)
{
// Worst case absolute error found: 8.300028706e-22
- double[] n = new[] { -0.00546954795538729307482955, 0.00404190278731707110245394, 0.0054963369553161170521356, 0.00212616472603945399437862, 0.000394984014495083900689956, 0.365565477064442377259271e-4, 0.135485897109932323253786e-5 };
- double[] d = new[] { 1, 1.21019697773630784832251, 0.620914668221143886601045, 0.173038430661142762569515, 0.0276550813773432047594539, 0.00240625974424309709745382, 0.891811817251336577241006e-4, -0.465528836283382684461025e-11 };
- r = Evaluate.Polynomial(z - 3.5, n) / Evaluate.Polynomial(z - 3.5, d);
+ double[] nc = {-0.00546954795538729307482955, 0.00404190278731707110245394, 0.0054963369553161170521356, 0.00212616472603945399437862, 0.000394984014495083900689956, 0.365565477064442377259271e-4, 0.135485897109932323253786e-5};
+ double[] dc = {1, 1.21019697773630784832251, 0.620914668221143886601045, 0.173038430661142762569515, 0.0276550813773432047594539, 0.00240625974424309709745382, 0.891811817251336577241006e-4, -0.465528836283382684461025e-11};
+ r = Evaluate.Polynomial(z - 3.5, nc)/Evaluate.Polynomial(z - 3.5, dc);
b = 0.5489973426F;
}
else if (z < 8)
{
// Worst case absolute error found: 1.700157534e-21
- double[] n = new[] { -0.00270722535905778347999196, 0.0013187563425029400461378, 0.00119925933261002333923989, 0.00027849619811344664248235, 0.267822988218331849989363e-4, 0.923043672315028197865066e-6 };
- double[] d = new[] { 1, 0.814632808543141591118279, 0.268901665856299542168425, 0.0449877216103041118694989, 0.00381759663320248459168994, 0.000131571897888596914350697, 0.404815359675764138445257e-11 };
- r = Evaluate.Polynomial(z - 5.25, n) / Evaluate.Polynomial(z - 5.25, d);
+ double[] nc = {-0.00270722535905778347999196, 0.0013187563425029400461378, 0.00119925933261002333923989, 0.00027849619811344664248235, 0.267822988218331849989363e-4, 0.923043672315028197865066e-6};
+ double[] dc = {1, 0.814632808543141591118279, 0.268901665856299542168425, 0.0449877216103041118694989, 0.00381759663320248459168994, 0.000131571897888596914350697, 0.404815359675764138445257e-11};
+ r = Evaluate.Polynomial(z - 5.25, nc)/Evaluate.Polynomial(z - 5.25, dc);
b = 0.5571740866F;
}
else if (z < 11.5)
{
// Worst case absolute error found: 3.002278011e-22
- double[] n = new[] { -0.00109946720691742196814323, 0.000406425442750422675169153, 0.000274499489416900707787024, 0.465293770646659383436343e-4, 0.320955425395767463401993e-5, 0.778286018145020892261936e-7 };
- double[] d = new[] { 1, 0.588173710611846046373373, 0.139363331289409746077541, 0.0166329340417083678763028, 0.00100023921310234908642639, 0.24254837521587225125068e-4 };
- r = Evaluate.Polynomial(z - 8, n) / Evaluate.Polynomial(z - 8, d);
+ double[] nc = {-0.00109946720691742196814323, 0.000406425442750422675169153, 0.000274499489416900707787024, 0.465293770646659383436343e-4, 0.320955425395767463401993e-5, 0.778286018145020892261936e-7};
+ double[] dc = {1, 0.588173710611846046373373, 0.139363331289409746077541, 0.0166329340417083678763028, 0.00100023921310234908642639, 0.24254837521587225125068e-4};
+ r = Evaluate.Polynomial(z - 8, nc)/Evaluate.Polynomial(z - 8, dc);
b = 0.5609807968F;
}
else if (z < 17)
{
// Worst case absolute error found: 6.741114695e-21
- double[] n = new[] { -0.00056907993601094962855594, 0.000169498540373762264416984, 0.518472354581100890120501e-4, 0.382819312231928859704678e-5, 0.824989931281894431781794e-7 };
- double[] d = new[] { 1, 0.339637250051139347430323, 0.043472647870310663055044, 0.00248549335224637114641629, 0.535633305337152900549536e-4, -0.117490944405459578783846e-12 };
- r = Evaluate.Polynomial(z - 11.5, n) / Evaluate.Polynomial(z - 11.5, d);
+ double[] nc = {-0.00056907993601094962855594, 0.000169498540373762264416984, 0.518472354581100890120501e-4, 0.382819312231928859704678e-5, 0.824989931281894431781794e-7};
+ double[] dc = {1, 0.339637250051139347430323, 0.043472647870310663055044, 0.00248549335224637114641629, 0.535633305337152900549536e-4, -0.117490944405459578783846e-12};
+ r = Evaluate.Polynomial(z - 11.5, nc)/Evaluate.Polynomial(z - 11.5, dc);
b = 0.5626493692F;
}
else if (z < 24)
{
// Worst case absolute error found: 7.802346984e-22
- double[] n = new[] { -0.000241313599483991337479091, 0.574224975202501512365975e-4, 0.115998962927383778460557e-4, 0.581762134402593739370875e-6, 0.853971555085673614607418e-8 };
- double[] d = new[] { 1, 0.233044138299687841018015, 0.0204186940546440312625597, 0.000797185647564398289151125, 0.117019281670172327758019e-4 };
- r = Evaluate.Polynomial(z - 17, n) / Evaluate.Polynomial(z - 17, d);
+ double[] nc = {-0.000241313599483991337479091, 0.574224975202501512365975e-4, 0.115998962927383778460557e-4, 0.581762134402593739370875e-6, 0.853971555085673614607418e-8};
+ double[] dc = {1, 0.233044138299687841018015, 0.0204186940546440312625597, 0.000797185647564398289151125, 0.117019281670172327758019e-4};
+ r = Evaluate.Polynomial(z - 17, nc)/Evaluate.Polynomial(z - 17, dc);
b = 0.5634598136F;
}
else if (z < 38)
{
// Worst case absolute error found: 2.414228989e-22
- double[] n = new[] { -0.000146674699277760365803642, 0.162666552112280519955647e-4, 0.269116248509165239294897e-5, 0.979584479468091935086972e-7, 0.101994647625723465722285e-8 };
- double[] d = new[] { 1, 0.165907812944847226546036, 0.0103361716191505884359634, 0.000286593026373868366935721, 0.298401570840900340874568e-5 };
- r = Evaluate.Polynomial(z - 24, n) / Evaluate.Polynomial(z - 24, d);
+ double[] nc = {-0.000146674699277760365803642, 0.162666552112280519955647e-4, 0.269116248509165239294897e-5, 0.979584479468091935086972e-7, 0.101994647625723465722285e-8};
+ double[] dc = {1, 0.165907812944847226546036, 0.0103361716191505884359634, 0.000286593026373868366935721, 0.298401570840900340874568e-5};
+ r = Evaluate.Polynomial(z - 24, nc)/Evaluate.Polynomial(z - 24, dc);
b = 0.5638477802F;
}
else if (z < 60)
{
// Worst case absolute error found: 5.896543869e-24
- double[] n = new[] { -0.583905797629771786720406e-4, 0.412510325105496173512992e-5, 0.431790922420250949096906e-6, 0.993365155590013193345569e-8, 0.653480510020104699270084e-10 };
- double[] d = new[] { 1, 0.105077086072039915406159, 0.00414278428675475620830226, 0.726338754644523769144108e-4, 0.477818471047398785369849e-6 };
- r = Evaluate.Polynomial(z - 38, n) / Evaluate.Polynomial(z - 38, d);
+ double[] nc = {-0.583905797629771786720406e-4, 0.412510325105496173512992e-5, 0.431790922420250949096906e-6, 0.993365155590013193345569e-8, 0.653480510020104699270084e-10};
+ double[] dc = {1, 0.105077086072039915406159, 0.00414278428675475620830226, 0.726338754644523769144108e-4, 0.477818471047398785369849e-6};
+ r = Evaluate.Polynomial(z - 38, nc)/Evaluate.Polynomial(z - 38, dc);
b = 0.5640528202F;
}
else if (z < 85)
{
// Worst case absolute error found: 3.080612264e-21
- double[] n = new[] { -0.196457797609229579459841e-4, 0.157243887666800692441195e-5, 0.543902511192700878690335e-7, 0.317472492369117710852685e-9 };
- double[] d = new[] { 1, 0.052803989240957632204885, 0.000926876069151753290378112, 0.541011723226630257077328e-5, 0.535093845803642394908747e-15 };
- r = Evaluate.Polynomial(z - 60, n) / Evaluate.Polynomial(z - 60, d);
+ double[] nc = {-0.196457797609229579459841e-4, 0.157243887666800692441195e-5, 0.543902511192700878690335e-7, 0.317472492369117710852685e-9};
+ double[] dc = {1, 0.052803989240957632204885, 0.000926876069151753290378112, 0.541011723226630257077328e-5, 0.535093845803642394908747e-15};
+ r = Evaluate.Polynomial(z - 60, nc)/Evaluate.Polynomial(z - 60, dc);
b = 0.5641309023F;
}
else
{
// Worst case absolute error found: 8.094633491e-22
- double[] n = new[] { -0.789224703978722689089794e-5, 0.622088451660986955124162e-6, 0.145728445676882396797184e-7, 0.603715505542715364529243e-10 };
- double[] d = new[] { 1, 0.0375328846356293715248719, 0.000467919535974625308126054, 0.193847039275845656900547e-5 };
- r = Evaluate.Polynomial(z - 85, n) / Evaluate.Polynomial(z - 85, d);
+ double[] nc = {-0.789224703978722689089794e-5, 0.622088451660986955124162e-6, 0.145728445676882396797184e-7, 0.603715505542715364529243e-10};
+ double[] dc = {1, 0.0375328846356293715248719, 0.000467919535974625308126054, 0.193847039275845656900547e-5};
+ r = Evaluate.Polynomial(z - 85, nc)/Evaluate.Polynomial(z - 85, dc);
b = 0.5641584396F;
}
- double g = Math.Exp(-z * z) / z;
- result = (g * b) + (g * r);
+ double g = Math.Exp(-z*z)/z;
+ result = (g*b) + (g*r);
}
else
{
@@ -387,7 +388,7 @@ namespace MathNet.Numerics
/// Second intermediate parameter.
/// Third intermediate parameter.
/// the inverse error function.
- private static double ErfInvImpl(double p, double q, double s)
+ static double ErfInvImpl(double p, double q, double s)
{
double result;
@@ -405,12 +406,12 @@ namespace MathNet.Numerics
// long double: Max error found: 1.017064e-20
// Maximum Deviation Found (actual error term at infinite precision) 8.030e-21
//
- const float Y = 0.0891314744949340820313f;
- double[] P = new[] { -0.000508781949658280665617, -0.00836874819741736770379, 0.0334806625409744615033, -0.0126926147662974029034, -0.0365637971411762664006, 0.0219878681111168899165, 0.00822687874676915743155, -0.00538772965071242932965 };
- double[] Q = new[] { 1, -0.970005043303290640362, -1.56574558234175846809, 1.56221558398423026363, 0.662328840472002992063, -0.71228902341542847553, -0.0527396382340099713954, 0.0795283687341571680018, -0.00233393759374190016776, 0.000886216390456424707504 };
- double g = p * (p + 10);
- double r = Evaluate.Polynomial(p, P) / Evaluate.Polynomial(p, Q);
- result = (g * Y) + (g * r);
+ const float y = 0.0891314744949340820313f;
+ double[] nc = {-0.000508781949658280665617, -0.00836874819741736770379, 0.0334806625409744615033, -0.0126926147662974029034, -0.0365637971411762664006, 0.0219878681111168899165, 0.00822687874676915743155, -0.00538772965071242932965};
+ double[] dc = {1, -0.970005043303290640362, -1.56574558234175846809, 1.56221558398423026363, 0.662328840472002992063, -0.71228902341542847553, -0.0527396382340099713954, 0.0795283687341571680018, -0.00233393759374190016776, 0.000886216390456424707504};
+ double g = p*(p + 10);
+ double r = Evaluate.Polynomial(p, nc)/Evaluate.Polynomial(p, dc);
+ result = (g*y) + (g*r);
}
else if (q >= 0.25)
{
@@ -426,13 +427,13 @@ namespace MathNet.Numerics
// long double : Max error found: 6.084616e-20
// Maximum Deviation Found (error term) 4.811e-20
//
- const float Y = 2.249481201171875f;
- double[] P = new[] { -0.202433508355938759655, 0.105264680699391713268, 8.37050328343119927838, 17.6447298408374015486, -18.8510648058714251895, -44.6382324441786960818, 17.445385985570866523, 21.1294655448340526258, -3.67192254707729348546 };
- double[] Q = new[] { 1, 6.24264124854247537712, 3.9713437953343869095, -28.6608180499800029974, -20.1432634680485188801, 48.5609213108739935468, 10.8268667355460159008, -22.6436933413139721736, 1.72114765761200282724 };
- double g = Math.Sqrt(-2 * Math.Log(q));
+ const float y = 2.249481201171875f;
+ double[] nc = {-0.202433508355938759655, 0.105264680699391713268, 8.37050328343119927838, 17.6447298408374015486, -18.8510648058714251895, -44.6382324441786960818, 17.445385985570866523, 21.1294655448340526258, -3.67192254707729348546};
+ double[] dc = {1, 6.24264124854247537712, 3.9713437953343869095, -28.6608180499800029974, -20.1432634680485188801, 48.5609213108739935468, 10.8268667355460159008, -22.6436933413139721736, 1.72114765761200282724};
+ double g = Math.Sqrt(-2*Math.Log(q));
double xs = q - 0.25;
- double r = Evaluate.Polynomial(xs, P) / Evaluate.Polynomial(xs, Q);
- result = g / (Y + r);
+ double r = Evaluate.Polynomial(xs, nc)/Evaluate.Polynomial(xs, dc);
+ result = g/(y + r);
}
else
{
@@ -459,56 +460,56 @@ namespace MathNet.Numerics
if (x < 3)
{
// Max error found: 1.089051e-20
- const float Y = 0.807220458984375f;
- double[] P = new[] { -0.131102781679951906451, -0.163794047193317060787, 0.117030156341995252019, 0.387079738972604337464, 0.337785538912035898924, 0.142869534408157156766, 0.0290157910005329060432, 0.00214558995388805277169, -0.679465575181126350155e-6, 0.285225331782217055858e-7, -0.681149956853776992068e-9 };
- double[] Q = new[] { 1, 3.46625407242567245975, 5.38168345707006855425, 4.77846592945843778382, 2.59301921623620271374, 0.848854343457902036425, 0.152264338295331783612, 0.01105924229346489121 };
+ const float y = 0.807220458984375f;
+ double[] nc = {-0.131102781679951906451, -0.163794047193317060787, 0.117030156341995252019, 0.387079738972604337464, 0.337785538912035898924, 0.142869534408157156766, 0.0290157910005329060432, 0.00214558995388805277169, -0.679465575181126350155e-6, 0.285225331782217055858e-7, -0.681149956853776992068e-9};
+ double[] dc = {1, 3.46625407242567245975, 5.38168345707006855425, 4.77846592945843778382, 2.59301921623620271374, 0.848854343457902036425, 0.152264338295331783612, 0.01105924229346489121};
double xs = x - 1.125;
- double R = Evaluate.Polynomial(xs, P) / Evaluate.Polynomial(xs, Q);
- result = (Y * x) + (R * x);
+ double r = Evaluate.Polynomial(xs, nc)/Evaluate.Polynomial(xs, dc);
+ result = (y*x) + (r*x);
}
else if (x < 6)
{
// Max error found: 8.389174e-21
- const float Y = 0.93995571136474609375f;
- double[] P = new[] { -0.0350353787183177984712, -0.00222426529213447927281, 0.0185573306514231072324, 0.00950804701325919603619, 0.00187123492819559223345, 0.000157544617424960554631, 0.460469890584317994083e-5, -0.230404776911882601748e-9, 0.266339227425782031962e-11 };
- double[] Q = new[] { 1, 1.3653349817554063097, 0.762059164553623404043, 0.220091105764131249824, 0.0341589143670947727934, 0.00263861676657015992959, 0.764675292302794483503e-4 };
+ const float y = 0.93995571136474609375f;
+ double[] nc = {-0.0350353787183177984712, -0.00222426529213447927281, 0.0185573306514231072324, 0.00950804701325919603619, 0.00187123492819559223345, 0.000157544617424960554631, 0.460469890584317994083e-5, -0.230404776911882601748e-9, 0.266339227425782031962e-11};
+ double[] dc = {1, 1.3653349817554063097, 0.762059164553623404043, 0.220091105764131249824, 0.0341589143670947727934, 0.00263861676657015992959, 0.764675292302794483503e-4};
double xs = x - 3;
- double R = Evaluate.Polynomial(xs, P) / Evaluate.Polynomial(xs, Q);
- result = (Y * x) + (R * x);
+ double r = Evaluate.Polynomial(xs, nc)/Evaluate.Polynomial(xs, dc);
+ result = (y*x) + (r*x);
}
else if (x < 18)
{
// Max error found: 1.481312e-19
- const float Y = 0.98362827301025390625f;
- double[] P = new[] { -0.0167431005076633737133, -0.00112951438745580278863, 0.00105628862152492910091, 0.000209386317487588078668, 0.149624783758342370182e-4, 0.449696789927706453732e-6, 0.462596163522878599135e-8, -0.281128735628831791805e-13, 0.99055709973310326855e-16 };
- double[] Q = new[] { 1, 0.591429344886417493481, 0.138151865749083321638, 0.0160746087093676504695, 0.000964011807005165528527, 0.275335474764726041141e-4, 0.282243172016108031869e-6 };
+ const float y = 0.98362827301025390625f;
+ double[] nc = {-0.0167431005076633737133, -0.00112951438745580278863, 0.00105628862152492910091, 0.000209386317487588078668, 0.149624783758342370182e-4, 0.449696789927706453732e-6, 0.462596163522878599135e-8, -0.281128735628831791805e-13, 0.99055709973310326855e-16};
+ double[] dc = {1, 0.591429344886417493481, 0.138151865749083321638, 0.0160746087093676504695, 0.000964011807005165528527, 0.275335474764726041141e-4, 0.282243172016108031869e-6};
double xs = x - 6;
- double R = Evaluate.Polynomial(xs, P) / Evaluate.Polynomial(xs, Q);
- result = (Y * x) + (R * x);
+ double r = Evaluate.Polynomial(xs, nc)/Evaluate.Polynomial(xs, dc);
+ result = (y*x) + (r*x);
}
else if (x < 44)
{
// Max error found: 5.697761e-20
- const float Y = 0.99714565277099609375f;
- double[] P = new[] { -0.0024978212791898131227, -0.779190719229053954292e-5, 0.254723037413027451751e-4, 0.162397777342510920873e-5, 0.396341011304801168516e-7, 0.411632831190944208473e-9, 0.145596286718675035587e-11, -0.116765012397184275695e-17 };
- double[] Q = new[] { 1, 0.207123112214422517181, 0.0169410838120975906478, 0.000690538265622684595676, 0.145007359818232637924e-4, 0.144437756628144157666e-6, 0.509761276599778486139e-9 };
+ const float y = 0.99714565277099609375f;
+ double[] nc = {-0.0024978212791898131227, -0.779190719229053954292e-5, 0.254723037413027451751e-4, 0.162397777342510920873e-5, 0.396341011304801168516e-7, 0.411632831190944208473e-9, 0.145596286718675035587e-11, -0.116765012397184275695e-17};
+ double[] dc = {1, 0.207123112214422517181, 0.0169410838120975906478, 0.000690538265622684595676, 0.145007359818232637924e-4, 0.144437756628144157666e-6, 0.509761276599778486139e-9};
double xs = x - 18;
- double R = Evaluate.Polynomial(xs, P) / Evaluate.Polynomial(xs, Q);
- result = (Y * x) + (R * x);
+ double r = Evaluate.Polynomial(xs, nc)/Evaluate.Polynomial(xs, dc);
+ result = (y*x) + (r*x);
}
else
{
// Max error found: 1.279746e-20
- const float Y = 0.99941349029541015625f;
- double[] P = new[] { -0.000539042911019078575891, -0.28398759004727721098e-6, 0.899465114892291446442e-6, 0.229345859265920864296e-7, 0.225561444863500149219e-9, 0.947846627503022684216e-12, 0.135880130108924861008e-14, -0.348890393399948882918e-21 };
- double[] Q = new[] { 1, 0.0845746234001899436914, 0.00282092984726264681981, 0.468292921940894236786e-4, 0.399968812193862100054e-6, 0.161809290887904476097e-8, 0.231558608310259605225e-11 };
+ const float y = 0.99941349029541015625f;
+ double[] nc = {-0.000539042911019078575891, -0.28398759004727721098e-6, 0.899465114892291446442e-6, 0.229345859265920864296e-7, 0.225561444863500149219e-9, 0.947846627503022684216e-12, 0.135880130108924861008e-14, -0.348890393399948882918e-21};
+ double[] dc = {1, 0.0845746234001899436914, 0.00282092984726264681981, 0.468292921940894236786e-4, 0.399968812193862100054e-6, 0.161809290887904476097e-8, 0.231558608310259605225e-11};
double xs = x - 44;
- double R = Evaluate.Polynomial(xs, P) / Evaluate.Polynomial(xs, Q);
- result = (Y * x) + (R * x);
+ double r = Evaluate.Polynomial(xs, nc)/Evaluate.Polynomial(xs, dc);
+ result = (y*x) + (r*x);
}
}
- return s * result;
+ return s*result;
}
}
}
diff --git a/src/Numerics/SpecialFunctions/Factorial.cs b/src/Numerics/SpecialFunctions/Factorial.cs
index fecdf339..be858c46 100644
--- a/src/Numerics/SpecialFunctions/Factorial.cs
+++ b/src/Numerics/SpecialFunctions/Factorial.cs
@@ -38,7 +38,7 @@ namespace MathNet.Numerics
public partial class SpecialFunctions
{
private const int FactorialMaxArgument = 170;
- private static double[] factorialCache;
+ private static double[] _factorialCache;
///
/// Initializes static members of the SpecialFunctions class.
@@ -50,11 +50,11 @@ namespace MathNet.Numerics
private static void InitializeFactorial()
{
- factorialCache = new double[FactorialMaxArgument + 1];
- factorialCache[0] = 1.0;
- for (int i = 1; i < factorialCache.Length; i++)
+ _factorialCache = new double[FactorialMaxArgument + 1];
+ _factorialCache[0] = 1.0;
+ for (int i = 1; i < _factorialCache.Length; i++)
{
- factorialCache[i] = factorialCache[i - 1] * i;
+ _factorialCache[i] = _factorialCache[i - 1] * i;
}
}
@@ -77,9 +77,9 @@ namespace MathNet.Numerics
throw new ArgumentOutOfRangeException("x", Resources.ArgumentPositive);
}
- if (x < factorialCache.Length)
+ if (x < _factorialCache.Length)
{
- return factorialCache[x];
+ return _factorialCache[x];
}
return Double.PositiveInfinity;
@@ -101,9 +101,9 @@ namespace MathNet.Numerics
return 0d;
}
- if (x < factorialCache.Length)
+ if (x < _factorialCache.Length)
{
- return Math.Log(factorialCache[x]);
+ return Math.Log(_factorialCache[x]);
}
return GammaLn(x + 1.0);
diff --git a/src/Numerics/SpecialFunctions/Gamma.cs b/src/Numerics/SpecialFunctions/Gamma.cs
index 91307084..c5c21d46 100644
--- a/src/Numerics/SpecialFunctions/Gamma.cs
+++ b/src/Numerics/SpecialFunctions/Gamma.cs
@@ -44,31 +44,30 @@ namespace MathNet.Numerics
///
/// The order of the approximation.
///
- private const int Gamma_n = 10;
+ private const int GammaN = 10;
///
/// Auxiliary variable when evaluating the function.
///
- private const double Gamma_r = 10.900511;
+ private const double GammaR = 10.900511;
///
/// Polynomial coefficients for the approximation.
///
- private static readonly double[] Gamma_dk =
- new[]
- {
- 2.48574089138753565546e-5,
- 1.05142378581721974210,
- -3.45687097222016235469,
- 4.51227709466894823700,
- -2.98285225323576655721,
- 1.05639711577126713077,
- -1.95428773191645869583e-1,
- 1.70970543404441224307e-2,
- -5.71926117404305781283e-4,
- 4.63399473359905636708e-6,
- -2.71994908488607703910e-9
- };
+ static readonly double[] GammaDk =
+ {
+ 2.48574089138753565546e-5,
+ 1.05142378581721974210,
+ -3.45687097222016235469,
+ 4.51227709466894823700,
+ -2.98285225323576655721,
+ 1.05639711577126713077,
+ -1.95428773191645869583e-1,
+ 1.70970543404441224307e-2,
+ -5.71926117404305781283e-4,
+ 4.63399473359905636708e-6,
+ -2.71994908488607703910e-9
+ };
///
/// Computes the logarithm of the Gamma function.
@@ -86,29 +85,29 @@ namespace MathNet.Numerics
{
if (z < 0.5)
{
- double s = Gamma_dk[0];
- for (int i = 1; i <= Gamma_n; i++)
+ double s = GammaDk[0];
+ for (int i = 1; i <= GammaN; i++)
{
- s += Gamma_dk[i] / (i - z);
+ s += GammaDk[i] / (i - z);
}
return Constants.LnPi
- Math.Log(Math.Sin(Math.PI * z))
- Math.Log(s)
- Constants.LogTwoSqrtEOverPi
- - ((0.5 - z) * Math.Log((0.5 - z + Gamma_r) / Math.E));
+ - ((0.5 - z) * Math.Log((0.5 - z + GammaR) / Math.E));
}
else
{
- double s = Gamma_dk[0];
- for (int i = 1; i <= Gamma_n; i++)
+ double s = GammaDk[0];
+ for (int i = 1; i <= GammaN; i++)
{
- s += Gamma_dk[i] / (z + i - 1.0);
+ s += GammaDk[i] / (z + i - 1.0);
}
return Math.Log(s)
+ Constants.LogTwoSqrtEOverPi
- + ((z - 0.5) * Math.Log((z - 0.5 + Gamma_r) / Math.E));
+ + ((z - 0.5) * Math.Log((z - 0.5 + GammaR) / Math.E));
}
}
@@ -130,26 +129,26 @@ namespace MathNet.Numerics
{
if (z < 0.5)
{
- double s = Gamma_dk[0];
- for (int i = 1; i <= Gamma_n; i++)
+ double s = GammaDk[0];
+ for (int i = 1; i <= GammaN; i++)
{
- s += Gamma_dk[i] / (i - z);
+ s += GammaDk[i] / (i - z);
}
return Math.PI / (Math.Sin(Math.PI * z)
* s
* Constants.TwoSqrtEOverPi
- * Math.Pow((0.5 - z + Gamma_r) / Math.E, 0.5 - z));
+ * Math.Pow((0.5 - z + GammaR) / Math.E, 0.5 - z));
}
else
{
- double s = Gamma_dk[0];
- for (int i = 1; i <= Gamma_n; i++)
+ double s = GammaDk[0];
+ for (int i = 1; i <= GammaN; i++)
{
- s += Gamma_dk[i] / (z + i - 1.0);
+ s += GammaDk[i] / (z + i - 1.0);
}
- return s * Constants.TwoSqrtEOverPi * Math.Pow((z - 0.5 + Gamma_r) / Math.E, z - 0.5);
+ return s * Constants.TwoSqrtEOverPi * Math.Pow((z - 0.5 + GammaR) / Math.E, z - 0.5);
}
}
@@ -162,9 +161,9 @@ namespace MathNet.Numerics
/// The upper incomplete regularized gamma function.
public static double GammaUpperRegularized(double a, double x)
{
- const double Epsilon = 0.000000000000001;
- const double BigNumber = 4503599627370496.0;
- const double BigNumberInverse = 2.22044604925031308085e-16;
+ const double epsilon = 0.000000000000001;
+ const double big = 4503599627370496.0;
+ const double bigInv = 2.22044604925031308085e-16;
if (x <= 0d || a <= 0d)
{
@@ -216,15 +215,15 @@ namespace MathNet.Numerics
qkm2 = qkm1;
qkm1 = qk;
- if (Math.Abs(pk) > BigNumber)
+ if (Math.Abs(pk) > big)
{
- pkm2 = pkm2 * BigNumberInverse;
- pkm1 = pkm1 * BigNumberInverse;
- qkm2 = qkm2 * BigNumberInverse;
- qkm1 = qkm1 * BigNumberInverse;
+ pkm2 = pkm2 * bigInv;
+ pkm1 = pkm1 * bigInv;
+ qkm2 = qkm2 * bigInv;
+ qkm1 = qkm1 * bigInv;
}
}
- while (t > Epsilon);
+ while (t > epsilon);
return ans * ax;
}
@@ -262,9 +261,9 @@ namespace MathNet.Numerics
/// The lower incomplete gamma function.
public static double GammaLowerRegularized(double a, double x)
{
- const double Epsilon = 0.000000000000001;
- const double BigNumber = 4503599627370496.0;
- const double BigNumberInverse = 2.22044604925031308085e-16;
+ const double epsilon = 0.000000000000001;
+ const double big = 4503599627370496.0;
+ const double bigInv = 2.22044604925031308085e-16;
if (a < 0d || x < 0d)
{
@@ -305,7 +304,7 @@ namespace MathNet.Numerics
c2 = c2 * x / r2;
ans2 += c2;
}
- while ((c2 / ans2) > Epsilon);
+ while ((c2 / ans2) > epsilon);
return Math.Exp(ax) * ans2 / a;
}
@@ -351,15 +350,15 @@ namespace MathNet.Numerics
q2 = q;
// normalize fraction when the numerator becomes large
- if (Math.Abs(p) > BigNumber)
+ if (Math.Abs(p) > big)
{
- p3 *= BigNumberInverse;
- p2 *= BigNumberInverse;
- q3 *= BigNumberInverse;
- q2 *= BigNumberInverse;
+ p3 *= bigInv;
+ p2 *= bigInv;
+ q3 *= bigInv;
+ q2 *= bigInv;
}
}
- while (error > Epsilon);
+ while (error > epsilon);
return 1d - (Math.Exp(ax) * ans);
}
@@ -378,15 +377,15 @@ namespace MathNet.Numerics
/// The value of the DiGamma function at .
public static double DiGamma(double x)
{
- const double C = 12.0;
- const double D1 = -0.57721566490153286;
- const double D2 = 1.6449340668482264365;
- const double S = 1e-6;
- const double S3 = 1.0 / 12.0;
- const double S4 = 1.0 / 120.0;
- const double S5 = 1.0 / 252.0;
- const double S6 = 1.0 / 240.0;
- const double S7 = 1.0 / 132.0;
+ const double c = 12.0;
+ const double d1 = -0.57721566490153286;
+ const double d2 = 1.6449340668482264365;
+ const double s = 1e-6;
+ const double s3 = 1.0 / 12.0;
+ const double s4 = 1.0 / 120.0;
+ const double s5 = 1.0 / 252.0;
+ const double s6 = 1.0 / 240.0;
+ const double s7 = 1.0 / 132.0;
if (Double.IsNegativeInfinity(x) || Double.IsNaN(x))
{
@@ -405,25 +404,25 @@ namespace MathNet.Numerics
return DiGamma(1.0 - x) + (Math.PI / Math.Tan(-Math.PI * x));
}
- if (x <= S)
+ if (x <= s)
{
- return D1 - (1 / x) + (D2 * x);
+ return d1 - (1 / x) + (d2 * x);
}
double result = 0;
- while (x < C)
+ while (x < c)
{
result -= 1 / x;
x++;
}
- if (x >= C)
+ if (x >= c)
{
var r = 1 / x;
result += Math.Log(x) - (0.5 * r);
r *= r;
- result -= r * (S3 - (r * (S4 - (r * (S5 - (r * (S6 - (r * S7))))))));
+ result -= r * (s3 - (r * (s4 - (r * (s5 - (r * (s6 - (r * s7))))))));
}
return result;
diff --git a/src/Numerics/SpecialFunctions/ModifiedStruve.cs b/src/Numerics/SpecialFunctions/ModifiedStruve.cs
index 504c5357..5984a59b 100644
--- a/src/Numerics/SpecialFunctions/ModifiedStruve.cs
+++ b/src/Numerics/SpecialFunctions/ModifiedStruve.cs
@@ -59,7 +59,6 @@ namespace MathNet.Numerics
/// Returns the modified Struve function of order 0.
///
/// The value to compute the function of.
- ///
public static double StruveL0(double x)
{
//*********************************************************************72
@@ -159,9 +158,6 @@ namespace MathNet.Numerics
return -StruveL0(-x);
}
- const double LNR2PI = 0.91893853320467274178;
- const double TWOBPI = 0.63661977236758134308;
-
double[] ARL0 = new double[28];
ARL0[0] = 0.42127458349979924863;
ARL0[1] = -0.33859536391220612188;
@@ -237,36 +233,36 @@ namespace MathNet.Numerics
AI0ML0[23] = 0.16e-18;
// MACHINE-DEPENDENT VALUES (Suitable for IEEE-arithmetic machines)
- const int NTERM1 = 25; const int NTERM2 = 14; const int NTERM3 = 21;
- const double XLOW = 4.4703484e-8; const double XMAX = 1.797693e308;
- const double XHIGH1 = 5.1982303e8; const double XHIGH2 = 2.5220158e17;
+ const int nterm1 = 25; const int nterm2 = 14; const int nterm3 = 21;
+ const double xlow = 4.4703484e-8; const double xmax = 1.797693e308;
+ const double xhigh1 = 5.1982303e8; const double xhigh2 = 2.5220158e17;
// Code for |xvalue| <= 16
if (x <= 16.0)
{
- if (x < XLOW)
+ if (x < xlow)
{
- return TWOBPI * x;
+ return Constants.TwoInvPi * x;
}
double T = (4.0 * x - 24.0) / (x + 24.0);
- return TWOBPI * x * Evaluate.ChebyshevSum(NTERM1, ARL0, T) * Math.Exp(x);
+ return Constants.TwoInvPi * x * Evaluate.ChebyshevSum(nterm1, ARL0, T) * Math.Exp(x);
}
// Code for |xvalue| > 16
double ch1;
- if (x > XHIGH2)
+ if (x > xhigh2)
{
ch1 = 1.0;
}
else
{
double T = (x - 28.0) / (4.0 - x);
- ch1 = Evaluate.ChebyshevSum(NTERM2, ARL0AS, T);
+ ch1 = Evaluate.ChebyshevSum(nterm2, ARL0AS, T);
}
double ch2;
- if (x > XHIGH1)
+ if (x > xhigh1)
{
ch2 = 1.0;
}
@@ -274,23 +270,22 @@ namespace MathNet.Numerics
{
double xsq = x * x;
double T = (800.0 - xsq) / (288.0 + xsq);
- ch2 = Evaluate.ChebyshevSum(NTERM3, AI0ML0, T);
+ ch2 = Evaluate.ChebyshevSum(nterm3, AI0ML0, T);
}
- double test = Math.Log(ch1) - LNR2PI - Math.Log(x) / 2.0 + x;
- if (test > Math.Log(XMAX))
+ double test = Math.Log(ch1) - Constants.LogSqrt2Pi - Math.Log(x) / 2.0 + x;
+ if (test > Math.Log(xmax))
{
throw new ArithmeticException("ERROR IN MISCFUN FUNCTION STRVL0: ARGUMENT CAUSES OVERFLOW");
}
- return Math.Exp(test) - TWOBPI * ch2 / x;
+ return Math.Exp(test) - Constants.TwoInvPi * ch2 / x;
}
///
/// Returns the modified Struve function of order 1.
///
/// The value to compute the function of.
- ///
public static double StruveL1(double x)
{
//*********************************************************************72
@@ -395,10 +390,6 @@ namespace MathNet.Numerics
return StruveL1(-x);
}
- const double LNR2PI = 0.91893853320467274178;
- const double PI3BY2 = 4.71238898038468985769;
- const double TWOBPI = 0.63661977236758134308;
-
double[] ARL1 = new double[27];
ARL1[0] = 0.38996027351229538208;
ARL1[1] = -0.33658096101975749366;
@@ -476,42 +467,42 @@ namespace MathNet.Numerics
AI1ML1[25] = -0.1e-19;
// MACHINE-DEPENDENT VALUES (Suitable for IEEE-arithmetic machines)
- const int NTERM1 = 24; const int NTERM2 = 13; const int NTERM3 = 22;
- const double XLOW1 = 5.7711949e-8; const double XLOW2 = 3.3354714e-154; const double XMAX = 1.797693e308;
- const double XHIGH1 = 5.19823025e8; const double XHIGH2 = 2.7021597e17;
+ const int nterm1 = 24; const int nterm2 = 13; const int nterm3 = 22;
+ const double xlow1 = 5.7711949e-8; const double xlow2 = 3.3354714e-154; const double xmax = 1.797693e308;
+ const double xhigh1 = 5.19823025e8; const double xhigh2 = 2.7021597e17;
// CODE FOR |x| <= 16
if (x <= 16.0)
{
- if (x <= XLOW2)
+ if (x <= xlow2)
{
return 0.0;
}
double xsq = x * x;
- if (x < XLOW1)
+ if (x < xlow1)
{
- return xsq / PI3BY2;
+ return xsq / Constants.Pi3Over2;
}
double t = (4.0 * x - 24.0) / (x + 24.0);
- return xsq * Evaluate.ChebyshevSum(NTERM1, ARL1, t) * Math.Exp(x) / PI3BY2;
+ return xsq * Evaluate.ChebyshevSum(nterm1, ARL1, t) * Math.Exp(x) / Constants.Pi3Over2;
}
// CODE FOR |x| > 16
double ch1;
- if (x > XHIGH2)
+ if (x > xhigh2)
{
ch1 = 1.0;
}
else
{
double t = (x - 30.0) / (2.0 - x);
- ch1 = Evaluate.ChebyshevSum(NTERM2, ARL1AS, t);
+ ch1 = Evaluate.ChebyshevSum(nterm2, ARL1AS, t);
}
double ch2;
- if (x > XHIGH1)
+ if (x > xhigh1)
{
ch2 = 1.0;
}
@@ -519,23 +510,22 @@ namespace MathNet.Numerics
{
double xsq = x * x;
double t = (800.0 - xsq) / (288.0 + xsq);
- ch2 = Evaluate.ChebyshevSum(NTERM3, AI1ML1, t);
+ ch2 = Evaluate.ChebyshevSum(nterm3, AI1ML1, t);
}
- double test = Math.Log(ch1) - LNR2PI - Math.Log(x) / 2.0 + x;
- if (test > Math.Log(XMAX))
+ double test = Math.Log(ch1) - Constants.LogSqrt2Pi - Math.Log(x) / 2.0 + x;
+ if (test > Math.Log(xmax))
{
throw new ArithmeticException("ERROR IN MISCFUN FUNCTION STRVL1: ARGUMENT CAUSES OVERFLOW");
}
- return Math.Exp(test) - TWOBPI * ch2;
+ return Math.Exp(test) - Constants.TwoInvPi * ch2;
}
///
/// Returns the difference between the Bessel I0 and Struve L0 functions.
///
/// The value to compute the function of.
- ///
public static double BesselI0MStruveL0(double x)
{
// TODO: way off for large x (e.g. 100) - needs direct approximation
@@ -546,7 +536,6 @@ namespace MathNet.Numerics
/// Returns the difference between the Bessel I1 and Struve L1 functions.
///
/// The value to compute the function of.
- ///
public static double BesselI1MStruveL1(double x)
{
// TODO: way off for large x (e.g. 100) - needs direct approximation
diff --git a/src/Numerics/Statistics/ArrayStatistics.cs b/src/Numerics/Statistics/ArrayStatistics.cs
index 88c01362..454cb303 100644
--- a/src/Numerics/Statistics/ArrayStatistics.cs
+++ b/src/Numerics/Statistics/ArrayStatistics.cs
@@ -368,6 +368,10 @@ namespace MathNet.Numerics.Statistics
///
/// Sample array, no sorting is assumed. Will be reordered.
/// Quantile selector, between 0.0 and 1.0 (inclusive)
+ /// a-parameter
+ /// b-parameter
+ /// c-parameter
+ /// d-parameter
public static double QuantileCustomInplace(double[] data, double tau, double a, double b, double c, double d)
{
if (data == null) throw new ArgumentNullException("data");
diff --git a/src/Numerics/Statistics/Correlation.cs b/src/Numerics/Statistics/Correlation.cs
index 25ba78ae..11566965 100644
--- a/src/Numerics/Statistics/Correlation.cs
+++ b/src/Numerics/Statistics/Correlation.cs
@@ -64,13 +64,13 @@ namespace MathNet.Numerics.Statistics
{
throw new ArgumentOutOfRangeException("dataB", "Datasets dataA and dataB need to have the same length. dataB is shorter.");
}
- double Acurrent = ieA.Current;
- double Bcurrent = ieB.Current;
+ double currentA = ieA.Current;
+ double currentB = ieB.Current;
- double deltaA = Acurrent - meanA;
+ double deltaA = currentA - meanA;
double scaleDeltaA = deltaA / ++n;
- double deltaB = Bcurrent - meanB;
+ double deltaB = currentB - meanB;
double scaleDeltaB = deltaB / n;
meanA += scaleDeltaA;
diff --git a/src/Numerics/Statistics/DescriptiveStatistics.cs b/src/Numerics/Statistics/DescriptiveStatistics.cs
index e80dedf5..fb21c5b4 100644
--- a/src/Numerics/Statistics/DescriptiveStatistics.cs
+++ b/src/Numerics/Statistics/DescriptiveStatistics.cs
@@ -80,7 +80,7 @@ namespace MathNet.Numerics.Statistics
if (increasedAccuracy)
{
- ComputeHA(data);
+ ComputeDecimal(data);
}
else
{
@@ -109,7 +109,7 @@ namespace MathNet.Numerics.Statistics
if (increasedAccuracy)
{
- ComputeHA(data);
+ ComputeDecimal(data);
}
else
{
@@ -184,15 +184,15 @@ namespace MathNet.Numerics.Statistics
{
double delta = xi - mean;
double scaleDelta = delta / ++n;
- double scaleDeltaSQR = scaleDelta * scaleDelta;
+ double scaleDeltaSqr = scaleDelta * scaleDelta;
double tmpDelta = delta * (n - 1);
mean += scaleDelta;
- kurtosis += tmpDelta * scaleDelta * scaleDeltaSQR * (n * n - 3 * n + 3)
- + 6 * scaleDeltaSQR * variance - 4 * scaleDelta * skewness;
+ kurtosis += tmpDelta * scaleDelta * scaleDeltaSqr * (n * n - 3 * n + 3)
+ + 6 * scaleDeltaSqr * variance - 4 * scaleDelta * skewness;
- skewness += tmpDelta * scaleDeltaSQR * (n - 2) - 3 * scaleDelta * variance;
+ skewness += tmpDelta * scaleDeltaSqr * (n - 2) - 3 * scaleDelta * variance;
variance += tmpDelta * scaleDelta;
if (minimum > xi) { minimum = xi; }
@@ -222,15 +222,15 @@ namespace MathNet.Numerics.Statistics
{
double delta = xi.Value - mean;
double scaleDelta = delta / ++n;
- double scaleDeltaSQR = scaleDelta * scaleDelta;
+ double scaleDeltaSqr = scaleDelta * scaleDelta;
double tmpDelta = delta * (n - 1);
mean += scaleDelta;
- kurtosis += tmpDelta * scaleDelta * scaleDeltaSQR * (n * n - 3 * n + 3)
- + 6 * scaleDeltaSQR * variance - 4 * scaleDelta * skewness;
+ kurtosis += tmpDelta * scaleDelta * scaleDeltaSqr * (n * n - 3 * n + 3)
+ + 6 * scaleDeltaSqr * variance - 4 * scaleDelta * skewness;
- skewness += tmpDelta * scaleDeltaSQR * (n - 2) - 3 * scaleDelta * variance;
+ skewness += tmpDelta * scaleDeltaSqr * (n - 2) - 3 * scaleDelta * variance;
variance += tmpDelta * scaleDelta;
if (minimum > xi) { minimum = xi.Value; }
if (maximum < xi) { maximum = xi.Value; }
@@ -245,7 +245,7 @@ namespace MathNet.Numerics.Statistics
/// Computes descriptive statistics from a stream of data values using high accuracy.
///
/// A sequence of datapoints.
- private void ComputeHA(IEnumerable data)
+ private void ComputeDecimal(IEnumerable data)
{
decimal mean = 0;
decimal variance = 0;
@@ -280,7 +280,7 @@ namespace MathNet.Numerics.Statistics
/// Computes descriptive statistics from a stream of nullable data values using high accuracy.
///
/// A sequence of datapoints.
- private void ComputeHA(IEnumerable data)
+ private void ComputeDecimal(IEnumerable data)
{
decimal mean = 0;
decimal variance = 0;
diff --git a/src/Numerics/Statistics/Histogram.cs b/src/Numerics/Statistics/Histogram.cs
index 86aa88f2..f5ed110a 100644
--- a/src/Numerics/Statistics/Histogram.cs
+++ b/src/Numerics/Statistics/Histogram.cs
@@ -66,7 +66,7 @@ namespace MathNet.Numerics.Statistics
}
}
- private static readonly PointComparer pointComparer = new PointComparer();
+ private static readonly PointComparer Comparer = new PointComparer();
///
/// Lower Bound of the Bucket.
@@ -132,7 +132,7 @@ namespace MathNet.Numerics.Statistics
///
public static IComparer DefaultPointComparer
{
- get { return pointComparer; }
+ get { return Comparer; }
}
///
@@ -208,7 +208,6 @@ namespace MathNet.Numerics.Statistics
///
/// Formats a human-readable string for this bucket.
///
- ///
public override string ToString()
{
return "(" + LowerBound + ";" + UpperBound + "] = " + Count;
@@ -286,12 +285,12 @@ namespace MathNet.Numerics.Statistics
{
if (lower > upper)
{
- throw new ArgumentOutOfRangeException("The histogram lowerbound must be smaller than the upper bound.");
+ throw new ArgumentOutOfRangeException("upper", "The histogram lowerbound must be smaller than the upper bound.");
}
if (nbuckets < 1)
{
- throw new ArgumentOutOfRangeException("The number of bins in a histogram should be at least 1.");
+ throw new ArgumentOutOfRangeException("nbuckets", "The number of bins in a histogram should be at least 1.");
}
double width = (upper - lower) / nbuckets;
@@ -467,13 +466,11 @@ namespace MathNet.Numerics.Statistics
///
public override string ToString()
{
- StringBuilder sb = new StringBuilder();
-
+ var sb = new StringBuilder();
foreach (Bucket b in _buckets)
{
- sb.Append(b.ToString());
+ sb.Append(b);
}
-
return sb.ToString();
}
}
diff --git a/src/Numerics/Statistics/MCMC/HybridMC.cs b/src/Numerics/Statistics/MCMC/HybridMC.cs
index 7fdd0bbb..c32d86cb 100644
--- a/src/Numerics/Statistics/MCMC/HybridMC.cs
+++ b/src/Numerics/Statistics/MCMC/HybridMC.cs
@@ -198,15 +198,15 @@ namespace MathNet.Numerics.Statistics.Mcmc
{
if (pSdv == null)
{
- throw new ArgumentNullException("Standard deviation cannot be null.");
+ throw new ArgumentNullException("pSdv", "Standard deviation cannot be null.");
}
if (pSdv.Count() != _length)
{
- throw new ArgumentOutOfRangeException("Standard deviation of momentum must have same length as sample.");
+ throw new ArgumentOutOfRangeException("pSdv", "Standard deviation of momentum must have same length as sample.");
}
if (pSdv.Any(sdv => sdv < 0))
{
- throw new ArgumentOutOfRangeException("Standard deviation must be positive.");
+ throw new ArgumentOutOfRangeException("pSdv", "Standard deviation must be positive.");
}
}
diff --git a/src/Numerics/Statistics/MCMC/HybridMCGeneric.cs b/src/Numerics/Statistics/MCMC/HybridMCGeneric.cs
index 55e9593d..ef184ec8 100644
--- a/src/Numerics/Statistics/MCMC/HybridMCGeneric.cs
+++ b/src/Numerics/Statistics/MCMC/HybridMCGeneric.cs
@@ -49,7 +49,6 @@ namespace MathNet.Numerics.Statistics.Mcmc
///
/// Function to be differentiated.
/// Value where the derivative is computed.
- ///
public delegate T DiffMethod(DensityLn f, T x);
///
@@ -133,7 +132,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
/// The method used for differentiation.
/// When the number of burnInterval iteration is negative.
/// When either x0, pdfLnP or diff is null.
- public HybridMCGeneric(T x0, DensityLn pdfLnP, int frogLeapSteps, double stepSize, int burnInterval, Random randomSource, DiffMethod diff)
+ protected HybridMCGeneric(T x0, DensityLn pdfLnP, int frogLeapSteps, double stepSize, int burnInterval, Random randomSource, DiffMethod diff)
{
_energy = x => -pdfLnP(x);
FrogLeapSteps = frogLeapSteps;
@@ -226,7 +225,6 @@ namespace MathNet.Numerics.Statistics.Mcmc
///
/// First vector/scalar in the product.
/// Second vector/scalar in the product.
- ///
abstract protected double DoProduct(T first, T second);
///
diff --git a/src/Numerics/Statistics/MCMC/MCMCDiagnostics.cs b/src/Numerics/Statistics/MCMC/MCMCDiagnostics.cs
index a521ad55..4c9efd8b 100644
--- a/src/Numerics/Statistics/MCMC/MCMCDiagnostics.cs
+++ b/src/Numerics/Statistics/MCMC/MCMCDiagnostics.cs
@@ -53,13 +53,13 @@ namespace MathNet.Numerics.Statistics.Mcmc.Diagnostics
{
if (lag < 0)
{
- throw new ArgumentOutOfRangeException("Lag must be positive");
+ throw new ArgumentOutOfRangeException("lag", "Lag must be positive");
}
int length = series.Count();
if (lag >= length)
{
- throw new ArgumentOutOfRangeException("Lag must be smaller than the sample size");
+ throw new ArgumentOutOfRangeException("lag", "Lag must be smaller than the sample size");
}
var transformedSeries = series.Select(f);
diff --git a/src/Numerics/Statistics/MCMC/MCMCSampler.cs b/src/Numerics/Statistics/MCMC/MCMCSampler.cs
index 1b142243..de3e6a01 100644
--- a/src/Numerics/Statistics/MCMC/MCMCSampler.cs
+++ b/src/Numerics/Statistics/MCMC/MCMCSampler.cs
@@ -138,13 +138,11 @@ namespace MathNet.Numerics.Statistics.Mcmc
/// An array of samples.
public virtual T[] Sample(int n)
{
- T[] ret = new T[n];
-
+ var ret = new T[n];
for (int i = 0; i < n; i++)
{
ret[i] = Sample();
}
-
return ret;
}
diff --git a/src/Numerics/Statistics/MCMC/UnivariateHybridMC.cs b/src/Numerics/Statistics/MCMC/UnivariateHybridMC.cs
index ab43e84a..5db6bcad 100644
--- a/src/Numerics/Statistics/MCMC/UnivariateHybridMC.cs
+++ b/src/Numerics/Statistics/MCMC/UnivariateHybridMC.cs
@@ -137,7 +137,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
/// Random number generator used to sample the momentum.
/// When the number of burnInterval iteration is negative.
public UnivariateHybridMC(double x0, DensityLn pdfLnP, int frogLeapSteps, double stepSize, int burnInterval, double pSdv, Random randomSource)
- : this(x0, pdfLnP, frogLeapSteps, stepSize, burnInterval, pSdv, randomSource, new DiffMethod(UnivariateHybridMC.Grad))
+ : this(x0, pdfLnP, frogLeapSteps, stepSize, burnInterval, pSdv, randomSource, Grad)
{
}
diff --git a/src/Numerics/Statistics/SortedArrayStatistics.cs b/src/Numerics/Statistics/SortedArrayStatistics.cs
index 812b37b6..111858bd 100644
--- a/src/Numerics/Statistics/SortedArrayStatistics.cs
+++ b/src/Numerics/Statistics/SortedArrayStatistics.cs
@@ -176,6 +176,10 @@ namespace MathNet.Numerics.Statistics
///
/// Sample array, must be sorted ascendingly.
/// Quantile selector, between 0.0 and 1.0 (inclusive).
+ /// a-parameter
+ /// b-parameter
+ /// c-parameter
+ /// d-parameter
public static double QuantileCustom(double[] data, double tau, double a, double b, double c, double d)
{
if (data == null) throw new ArgumentNullException("data");
diff --git a/src/Numerics/Threading/CommonParallel.cs b/src/Numerics/Threading/CommonParallel.cs
index a897de96..184b7b17 100644
--- a/src/Numerics/Threading/CommonParallel.cs
+++ b/src/Numerics/Threading/CommonParallel.cs
@@ -62,6 +62,7 @@ namespace MathNet.Numerics.Threading
///
/// The start index, inclusive.
/// The end index, exclusive.
+ /// The partition size for splitting work into smaller pieces.
/// The body to be invoked for each iteration range.
public static void For(int fromInclusive, int toExclusive, int rangeSize, Action body)
{
@@ -282,7 +283,7 @@ namespace MathNet.Numerics.Threading
/// The function to select items over a subset.
/// The function to select the item of selection from the subsets.
/// The selected value.
- public static U Aggregate(T[] array, Func select, Func reduce)
+ public static TOut Aggregate(T[] array, Func select, Func reduce)
{
if (select == null)
{
@@ -296,7 +297,7 @@ namespace MathNet.Numerics.Threading
// Special case: no action
if (array == null || array.Length == 0)
{
- return reduce(new U[0]);
+ return reduce(new TOut[0]);
}
// Special case: single action, inline
@@ -308,7 +309,7 @@ namespace MathNet.Numerics.Threading
// Special case: straight execution without parallelism
if (Control.DisableParallelization || Control.NumberOfParallelWorkerThreads < 2)
{
- var mapped = new U[array.Length];
+ var mapped = new TOut[array.Length];
for (int k = 0; k < mapped.Length; k++)
{
mapped[k] = select(k, array[k]);
@@ -317,7 +318,7 @@ namespace MathNet.Numerics.Threading
}
#if PORTABLE
- var tasks = new Task[Control.NumberOfParallelWorkerThreads];
+ var tasks = new Task[Control.NumberOfParallelWorkerThreads];
var size = array.Length / tasks.Length;
// partition the jobs into separate sets for each but the last worked thread
@@ -328,7 +329,7 @@ namespace MathNet.Numerics.Threading
tasks[i] = Task.Factory.StartNew(() =>
{
- var mapped = new U[stop - start];
+ var mapped = new TOut[stop - start];
for (int k = 0; k < mapped.Length; k++)
{
mapped[k] = select(k + start, array[k + start]);
@@ -341,7 +342,7 @@ namespace MathNet.Numerics.Threading
tasks[tasks.Length - 1] = Task.Factory.StartNew(() =>
{
var start = ((tasks.Length - 1) * size);
- var mapped = new U[array.Length - start];
+ var mapped = new TOut[array.Length - start];
for (int k = 0; k < mapped.Length; k++)
{
mapped[k] = select(k + start, array[k + start]);
@@ -353,16 +354,16 @@ namespace MathNet.Numerics.Threading
.ContinueWhenAll(tasks, tsk => reduce(tsk.Select(t => t.Result).ToArray()))
.Result;
#else
- var intermediateResults = new List();
+ var intermediateResults = new List();
var syncLock = new object();
var maxThreads = Control.DisableParallelization ? 1 : Control.NumberOfParallelWorkerThreads;
Parallel.ForEach(
Partitioner.Create(0, array.Length),
new ParallelOptions {MaxDegreeOfParallelism = maxThreads},
- () => new List(),
+ () => new List(),
(range, loop, localData) =>
{
- var mapped = new U[range.Item2 - range.Item1];
+ var mapped = new TOut[range.Item2 - range.Item1];
for (int k = 0; k < mapped.Length; k++)
{
mapped[k] = select(k + range.Item1, array[k + range.Item1]);
@@ -421,7 +422,7 @@ namespace MathNet.Numerics.Threading
/// The function to select the item of selection from the subsets.
/// Default result of the reduce function on an empty set.
/// The selected value.
- public static U Aggregate(T[] array, Func select, Func reducePair, U reduceDefault)
+ public static TOut Aggregate(T[] array, Func select, Func reducePair, TOut reduceDefault)
{
return Aggregate(array, select, results =>
{
@@ -435,7 +436,7 @@ namespace MathNet.Numerics.Threading
return results[0];
}
- U result = results[0];
+ TOut result = results[0];
for (int i = 1; i < results.Length; i++)
{
result = reducePair(result, results[i]);