diff --git a/.gitattributes b/.gitattributes
index 980b231f..bcf2ae8f 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,6 +1,4 @@
*.cs text diff=csharp
-*.csproj text
-*.sln text
*.msbuild text
*.config text
*.conf text
@@ -8,4 +6,20 @@
*.csdef text
*.xml text
*.js text
+
+*.csproj text merge=union
+*.fsproj text merge=union
+*.sln text eol=crlf merge=union
+
+*.jpg binary
+*.png binary
+*.gif binary
+
+*.doc diff=astextplain
+*.DOC diff=astextplain
+*.docx diff=astextplain
+*.DOCX diff=astextplain
+*.pdf diff=astextplain
+*.PDF diff=astextplain
+
* text=auto
diff --git a/MathNet.Numerics.snl.DotSettings b/MathNet.Numerics.snl.DotSettings
new file mode 100644
index 00000000..e872f619
--- /dev/null
+++ b/MathNet.Numerics.snl.DotSettings
@@ -0,0 +1,20 @@
+
+ False
+ False
+ False
+ False
+ False
+ False
+ False
+ False
+ False
+ False
+ False
+ True
+ True
+ False
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Numerics/Complex32.cs b/src/Numerics/Complex32.cs
index ae5473af..85a94285 100644
--- a/src/Numerics/Complex32.cs
+++ b/src/Numerics/Complex32.cs
@@ -417,7 +417,7 @@ namespace MathNet.Numerics
return Zero;
}
- return new Complex32((float)(_real / mod), (float)(_imag / mod));
+ return new Complex32(_real / mod, _imag / mod);
}
}
@@ -1103,7 +1103,7 @@ namespace MathNet.Numerics
{
if (value == null)
{
- throw new ArgumentNullException(value);
+ throw new ArgumentNullException("value");
}
value = value.Trim();
diff --git a/src/Numerics/Complex64.cs b/src/Numerics/Complex64.cs
index 1dc72339..ec16c13f 100644
--- a/src/Numerics/Complex64.cs
+++ b/src/Numerics/Complex64.cs
@@ -28,11 +28,12 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+#if !SYSNUMERICS
using MathNet.Numerics;
namespace System.Numerics
{
-#if !SYSNUMERICS
+
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
@@ -1696,5 +1697,5 @@ namespace System.Numerics
return value.SquareRoot();
}
}
-#endif
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
diff --git a/src/Numerics/ComplexExtensions.cs b/src/Numerics/ComplexExtensions.cs
index fe217e97..27db348b 100644
--- a/src/Numerics/ComplexExtensions.cs
+++ b/src/Numerics/ComplexExtensions.cs
@@ -365,7 +365,7 @@ namespace MathNet.Numerics
{
if (value == null)
{
- throw new ArgumentNullException(value);
+ throw new ArgumentNullException("value");
}
value = value.Trim();
diff --git a/src/Numerics/Constants.cs b/src/Numerics/Constants.cs
index e13b427c..214f7179 100644
--- a/src/Numerics/Constants.cs
+++ b/src/Numerics/Constants.cs
@@ -30,9 +30,6 @@
namespace MathNet.Numerics
{
- using System.Numerics;
- using System.Runtime.InteropServices;
-
///
/// A collection of frequently used mathematical constants.
///
diff --git a/src/Numerics/IPrecisionSupport.cs b/src/Numerics/IPrecisionSupport.cs
index 6091879a..d4787394 100644
--- a/src/Numerics/IPrecisionSupport.cs
+++ b/src/Numerics/IPrecisionSupport.cs
@@ -34,7 +34,7 @@ namespace MathNet.Numerics
/// Support Interface for Precision Operations (like AlmostEquals).
///
/// Type of the implementing class.
- public interface IPrecisionSupport
+ public interface IPrecisionSupport
{
///
/// Returns a Norm of a value of this type, which is appropriate for measuring how
diff --git a/src/Numerics/Interpolation/Algorithms/CubicHermiteSplineInterpolation.cs b/src/Numerics/Interpolation/Algorithms/CubicHermiteSplineInterpolation.cs
index 8e22b6a0..8cae2a60 100644
--- a/src/Numerics/Interpolation/Algorithms/CubicHermiteSplineInterpolation.cs
+++ b/src/Numerics/Interpolation/Algorithms/CubicHermiteSplineInterpolation.cs
@@ -144,7 +144,7 @@ namespace MathNet.Numerics.Interpolation.Algorithms
if (samplePoints.Count != sampleValues.Count
|| samplePoints.Count != sampleDerivatives.Count)
{
- throw new ArgumentException(Properties.Resources.ArgumentVectorsSameLength);
+ throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
for (var i = 1; i < samplePoints.Count; ++i)
diff --git a/src/Numerics/Interpolation/Algorithms/LinearSplineInterpolation.cs b/src/Numerics/Interpolation/Algorithms/LinearSplineInterpolation.cs
index 54146c3a..46b27c26 100644
--- a/src/Numerics/Interpolation/Algorithms/LinearSplineInterpolation.cs
+++ b/src/Numerics/Interpolation/Algorithms/LinearSplineInterpolation.cs
@@ -131,7 +131,7 @@ namespace MathNet.Numerics.Interpolation.Algorithms
if (samplePoints.Count != sampleValues.Count)
{
- throw new ArgumentException(Properties.Resources.ArgumentVectorsSameLength);
+ throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
for (var i = 1; i < samplePoints.Count; ++i)
diff --git a/src/Numerics/Interpolation/Algorithms/NevillePolynomialInterpolation.cs b/src/Numerics/Interpolation/Algorithms/NevillePolynomialInterpolation.cs
index 8000afe2..6b48a615 100644
--- a/src/Numerics/Interpolation/Algorithms/NevillePolynomialInterpolation.cs
+++ b/src/Numerics/Interpolation/Algorithms/NevillePolynomialInterpolation.cs
@@ -123,7 +123,7 @@ namespace MathNet.Numerics.Interpolation.Algorithms
if (samplePoints.Count != sampleValues.Count)
{
- throw new ArgumentException(Properties.Resources.ArgumentVectorsSameLength);
+ throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
for (var i = 1; i < samplePoints.Count; ++i)
diff --git a/src/Numerics/LinearAlgebra/Complex/DenseVector.cs b/src/Numerics/LinearAlgebra/Complex/DenseVector.cs
index f707adc5..cd75ab8b 100644
--- a/src/Numerics/LinearAlgebra/Complex/DenseVector.cs
+++ b/src/Numerics/LinearAlgebra/Complex/DenseVector.cs
@@ -854,7 +854,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
{
if (value == null)
{
- throw new ArgumentNullException(value);
+ throw new ArgumentNullException("value");
}
value = value.Trim();
diff --git a/src/Numerics/LinearAlgebra/Complex/Factorization/DenseEvd.cs b/src/Numerics/LinearAlgebra/Complex/Factorization/DenseEvd.cs
index 6eb340f7..7ed7daa1 100644
--- a/src/Numerics/LinearAlgebra/Complex/Factorization/DenseEvd.cs
+++ b/src/Numerics/LinearAlgebra/Complex/Factorization/DenseEvd.cs
@@ -593,7 +593,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
var eps = Precision.DoubleMachinePrecision;
double norm;
- Complex s, x, y, z, exshift = Complex.Zero;
+ Complex x, y, z, exshift = Complex.Zero;
// Outer loop over eigenvalue index
var iter = 0;
@@ -624,6 +624,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
else
{
// Form shift
+ Complex s;
if (iter != 10 && iter != 20)
{
s = matrixH[n, n];
diff --git a/src/Numerics/LinearAlgebra/Complex/Factorization/DenseLU.cs b/src/Numerics/LinearAlgebra/Complex/Factorization/DenseLU.cs
index 501649a0..49e3c1d2 100644
--- a/src/Numerics/LinearAlgebra/Complex/Factorization/DenseLU.cs
+++ b/src/Numerics/LinearAlgebra/Complex/Factorization/DenseLU.cs
@@ -32,7 +32,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
{
using System;
using System.Numerics;
- using Algorithms.LinearAlgebra;
using Generic;
using Properties;
using Threading;
diff --git a/src/Numerics/LinearAlgebra/Complex/Factorization/UserEvd.cs b/src/Numerics/LinearAlgebra/Complex/Factorization/UserEvd.cs
index 82b91585..0a3331c7 100644
--- a/src/Numerics/LinearAlgebra/Complex/Factorization/UserEvd.cs
+++ b/src/Numerics/LinearAlgebra/Complex/Factorization/UserEvd.cs
@@ -588,7 +588,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
var eps = Precision.DoubleMachinePrecision;
double norm;
- Complex s, x, y, z, exshift = Complex.Zero;
+ Complex x, y, z, exshift = Complex.Zero;
// Outer loop over eigenvalue index
var iter = 0;
@@ -619,6 +619,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
else
{
// Form shift
+ Complex s;
if (iter != 10 && iter != 20)
{
s = matrixH[n, n];
diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/BiCgStab.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/BiCgStab.cs
index 85297fd7..4e94f920 100644
--- a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/BiCgStab.cs
+++ b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/BiCgStab.cs
@@ -32,7 +32,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
{
using System;
using System.Numerics;
- using Generic;
using Generic.Solvers.Status;
using Preconditioners;
using Properties;
diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/CompositeSolver.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/CompositeSolver.cs
index ed96d564..f82d205b 100644
--- a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/CompositeSolver.cs
+++ b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/CompositeSolver.cs
@@ -34,10 +34,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
using System.Collections.Generic;
using System.IO;
using System.Linq;
- using System.Numerics;
using System.Reflection;
- using Generic;
- using Generic.Solvers;
using Generic.Solvers.Status;
using Properties;
@@ -248,7 +245,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
{
if (assembly == null)
{
- throw new ArgumentNullException("Assembly");
+ throw new ArgumentNullException("assembly");
}
if (typesToExclude == null)
diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/GpBiCg.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/GpBiCg.cs
index a0432dbc..f4325558 100644
--- a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/GpBiCg.cs
+++ b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/GpBiCg.cs
@@ -337,7 +337,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
// Define the temporary scalars
Complex beta = 0;
- Complex sigma;
// Define the temporary vectors
// rDash_0 = r_0
@@ -418,6 +417,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
// if we don't do any so ...
var ctdot = c.DotProduct(t);
Complex eta;
+ Complex sigma;
if (((_numberOfBiCgStabSteps == 0) && (iterationNumber == 0)) || ShouldRunBiCgStabSteps(iterationNumber))
{
// sigma_k = (c_k * t_k) / (c_k * c_k)
diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/MlkBiCgStab.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/MlkBiCgStab.cs
index 544529fd..de1eb61e 100644
--- a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/MlkBiCgStab.cs
+++ b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/MlkBiCgStab.cs
@@ -36,8 +36,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
using System.Linq;
using System.Numerics;
using Distributions;
- using Generic;
- using Generic.Factorization;
using Generic.Solvers.Status;
using Preconditioners;
using Properties;
diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/Ilutp.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/Ilutp.cs
index 8cc07747..1f7f01ec 100644
--- a/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/Ilutp.cs
+++ b/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/Ilutp.cs
@@ -170,7 +170,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners
{
if (value < 0)
{
- throw new ArgumentOutOfRangeException("Value");
+ throw new ArgumentOutOfRangeException("value");
}
_fillLevel = value;
@@ -205,7 +205,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners
{
if (value < 0)
{
- throw new ArgumentOutOfRangeException("Value");
+ throw new ArgumentOutOfRangeException("value");
}
_dropTolerance = value;
@@ -242,7 +242,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners
{
if (value < 0)
{
- throw new ArgumentOutOfRangeException("Value");
+ throw new ArgumentOutOfRangeException("value");
}
_pivotTolerance = value;
diff --git a/src/Numerics/LinearAlgebra/Complex/SparseVector.cs b/src/Numerics/LinearAlgebra/Complex/SparseVector.cs
index 96db81a2..353b21a7 100644
--- a/src/Numerics/LinearAlgebra/Complex/SparseVector.cs
+++ b/src/Numerics/LinearAlgebra/Complex/SparseVector.cs
@@ -381,24 +381,24 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (ReferenceEquals(this, result))
{
//populate a new vector with the scalar
- var vnonZeroValues = new Complex[this.Count];
- var vnonZeroIndices = new int[this.Count];
- for (int index = 0; index < this.Count; index++)
+ var vnonZeroValues = new Complex[Count];
+ var vnonZeroIndices = new int[Count];
+ for (int index = 0; index < Count; index++)
{
vnonZeroIndices[index] = index;
vnonZeroValues[index] = scalar;
}
//populate the non zero values from this
- for (int j = 0; j < this.NonZerosCount; j++)
+ for (int j = 0; j < NonZerosCount; j++)
{
- vnonZeroValues[this._nonZeroIndices[j]] = this._nonZeroValues[j] + scalar;
+ vnonZeroValues[_nonZeroIndices[j]] = _nonZeroValues[j] + scalar;
}
//assign this vectors arrary to the new arrays.
- this._nonZeroValues = vnonZeroValues;
- this._nonZeroIndices = vnonZeroIndices;
- this.NonZerosCount = this.Count;
+ _nonZeroValues = vnonZeroValues;
+ _nonZeroIndices = vnonZeroIndices;
+ NonZerosCount = Count;
}
else
{
@@ -1155,7 +1155,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
{
if (value == null)
{
- throw new ArgumentNullException(value);
+ throw new ArgumentNullException("value");
}
value = value.Trim();
diff --git a/src/Numerics/LinearAlgebra/Complex32/DenseVector.cs b/src/Numerics/LinearAlgebra/Complex32/DenseVector.cs
index ce5c9eba..2d074053 100644
--- a/src/Numerics/LinearAlgebra/Complex32/DenseVector.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/DenseVector.cs
@@ -907,7 +907,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
{
if (value == null)
{
- throw new ArgumentNullException(value);
+ throw new ArgumentNullException("value");
}
value = value.Trim();
diff --git a/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseEvd.cs b/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseEvd.cs
index 265aba55..a687983f 100644
--- a/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseEvd.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseEvd.cs
@@ -597,7 +597,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
var eps = (float)Precision.SingleMachinePrecision;
float norm;
- Complex32 s, x, y, z, exshift = Complex32.Zero;
+ Complex32 x, y, z, exshift = Complex32.Zero;
// Outer loop over eigenvalue index
var iter = 0;
@@ -628,6 +628,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
else
{
// Form shift
+ Complex32 s;
if (iter != 10 && iter != 20)
{
s = matrixH[n, n];
diff --git a/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseLU.cs b/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseLU.cs
index 336bfe23..30572c09 100644
--- a/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseLU.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseLU.cs
@@ -31,7 +31,6 @@
namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
{
using System;
- using Algorithms.LinearAlgebra;
using Generic;
using Numerics;
using Properties;
diff --git a/src/Numerics/LinearAlgebra/Complex32/Factorization/UserEvd.cs b/src/Numerics/LinearAlgebra/Complex32/Factorization/UserEvd.cs
index 803f0a86..8c39f02f 100644
--- a/src/Numerics/LinearAlgebra/Complex32/Factorization/UserEvd.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/Factorization/UserEvd.cs
@@ -592,7 +592,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
var eps = (float)Precision.SingleMachinePrecision;
float norm;
- Complex32 s, x, y, z, exshift = Complex32.Zero;
+ Complex32 x, y, z, exshift = Complex32.Zero;
// Outer loop over eigenvalue index
var iter = 0;
@@ -623,6 +623,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
else
{
// Form shift
+ Complex32 s;
if (iter != 10 && iter != 20)
{
s = matrixH[n, n];
diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/CompositeSolver.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/CompositeSolver.cs
index af845551..72a9d156 100644
--- a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/CompositeSolver.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/CompositeSolver.cs
@@ -245,7 +245,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
{
if (assembly == null)
{
- throw new ArgumentNullException("Assembly");
+ throw new ArgumentNullException("assembly");
}
if (typesToExclude == null)
diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/GpBiCg.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/GpBiCg.cs
index eb21e1a3..c5807e7d 100644
--- a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/GpBiCg.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/GpBiCg.cs
@@ -342,7 +342,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
// Define the temporary scalars
Complex32 beta = 0;
- Complex32 sigma;
// Define the temporary vectors
// rDash_0 = r_0
@@ -423,6 +422,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
// if we don't do any so ...
var ctdot = c.DotProduct(t);
Complex32 eta;
+ Complex32 sigma;
if (((_numberOfBiCgStabSteps == 0) && (iterationNumber == 0)) || ShouldRunBiCgStabSteps(iterationNumber))
{
// sigma_k = (c_k * t_k) / (c_k * c_k)
diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/MlkBiCgStab.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/MlkBiCgStab.cs
index 450a7ce7..9908b787 100644
--- a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/MlkBiCgStab.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/MlkBiCgStab.cs
@@ -35,7 +35,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
using System.Diagnostics;
using System.Linq;
using Distributions;
- using Generic.Factorization;
using Generic.Solvers.Status;
using Numerics;
using Preconditioners;
diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/Ilutp.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/Ilutp.cs
index e75179b9..9e2f60c4 100644
--- a/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/Ilutp.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/Ilutp.cs
@@ -170,7 +170,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners
{
if (value < 0)
{
- throw new ArgumentOutOfRangeException("Value");
+ throw new ArgumentOutOfRangeException("value");
}
_fillLevel = value;
@@ -205,7 +205,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners
{
if (value < 0)
{
- throw new ArgumentOutOfRangeException("Value");
+ throw new ArgumentOutOfRangeException("value");
}
_dropTolerance = value;
@@ -242,7 +242,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners
{
if (value < 0)
{
- throw new ArgumentOutOfRangeException("Value");
+ throw new ArgumentOutOfRangeException("value");
}
_pivotTolerance = value;
diff --git a/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs b/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
index 206d24d3..3548e7b3 100644
--- a/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
@@ -411,25 +411,24 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (ReferenceEquals(this, result))
{
//populate a new vector with the scalar
- var vnonZeroValues = new Complex32[this.Count];
- var vnonZeroIndices = new int[this.Count];
- for (int index = 0; index < this.Count; index++)
+ var vnonZeroValues = new Complex32[Count];
+ var vnonZeroIndices = new int[Count];
+ for (int index = 0; index < Count; index++)
{
vnonZeroIndices[index] = index;
vnonZeroValues[index] = scalar;
}
//populate the non zero values from this
- for (int j = 0; j < this.NonZerosCount; j++)
+ for (int j = 0; j < NonZerosCount; j++)
{
- vnonZeroValues[this._nonZeroIndices[j]] = this._nonZeroValues[j] + scalar;
+ vnonZeroValues[_nonZeroIndices[j]] = _nonZeroValues[j] + scalar;
}
//assign this vectors arrary to the new arrays.
- this._nonZeroValues = vnonZeroValues;
- this._nonZeroIndices = vnonZeroIndices;
- this.NonZerosCount = this.Count;
-
+ _nonZeroValues = vnonZeroValues;
+ _nonZeroIndices = vnonZeroIndices;
+ NonZerosCount = Count;
}
else
{
@@ -1186,7 +1185,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
{
if (value == null)
{
- throw new ArgumentNullException(value);
+ throw new ArgumentNullException("value");
}
value = value.Trim();
diff --git a/src/Numerics/LinearAlgebra/Double/DenseVector.cs b/src/Numerics/LinearAlgebra/Double/DenseVector.cs
index 689f01fc..a5cb6682 100644
--- a/src/Numerics/LinearAlgebra/Double/DenseVector.cs
+++ b/src/Numerics/LinearAlgebra/Double/DenseVector.cs
@@ -990,7 +990,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
{
if (value == null)
{
- throw new ArgumentNullException(value);
+ throw new ArgumentNullException("value");
}
value = value.Trim();
diff --git a/src/Numerics/LinearAlgebra/Double/Factorization/DenseLU.cs b/src/Numerics/LinearAlgebra/Double/Factorization/DenseLU.cs
index e4c495f1..12cdf536 100644
--- a/src/Numerics/LinearAlgebra/Double/Factorization/DenseLU.cs
+++ b/src/Numerics/LinearAlgebra/Double/Factorization/DenseLU.cs
@@ -31,7 +31,6 @@
namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
{
using System;
- using Algorithms.LinearAlgebra;
using Generic;
using Properties;
diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/CompositeSolver.cs b/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/CompositeSolver.cs
index 9c80e771..5f46056f 100644
--- a/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/CompositeSolver.cs
+++ b/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/CompositeSolver.cs
@@ -242,7 +242,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
{
if (assembly == null)
{
- throw new ArgumentNullException("Assembly");
+ throw new ArgumentNullException("assembly");
}
if (typesToExclude == null)
diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/GpBiCg.cs b/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/GpBiCg.cs
index 9af36204..eeb729db 100644
--- a/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/GpBiCg.cs
+++ b/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/GpBiCg.cs
@@ -341,7 +341,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
// Define the temporary scalars
double beta = 0;
- double sigma;
// Define the temporary vectors
// rDash_0 = r_0
@@ -422,6 +421,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
// if we don't do any so ...
var ctdot = c.DotProduct(t);
double eta;
+ double sigma;
if (((_numberOfBiCgStabSteps == 0) && (iterationNumber == 0)) || ShouldRunBiCgStabSteps(iterationNumber))
{
// sigma_k = (c_k * t_k) / (c_k * c_k)
diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/MlkBiCgStab.cs b/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/MlkBiCgStab.cs
index d80ce285..9f776611 100644
--- a/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/MlkBiCgStab.cs
+++ b/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/MlkBiCgStab.cs
@@ -35,8 +35,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
using System.Diagnostics;
using System.Linq;
using Distributions;
- using Generic;
- using Generic.Factorization;
using Generic.Solvers.Status;
using Preconditioners;
using Properties;
diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/Ilutp.cs b/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/Ilutp.cs
index 330a6336..ae84cacd 100644
--- a/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/Ilutp.cs
+++ b/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/Ilutp.cs
@@ -169,7 +169,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners
{
if (value < 0)
{
- throw new ArgumentOutOfRangeException("Value");
+ throw new ArgumentOutOfRangeException("value");
}
_fillLevel = value;
@@ -204,7 +204,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners
{
if (value < 0)
{
- throw new ArgumentOutOfRangeException("Value");
+ throw new ArgumentOutOfRangeException("value");
}
_dropTolerance = value;
@@ -241,7 +241,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners
{
if (value < 0)
{
- throw new ArgumentOutOfRangeException("Value");
+ throw new ArgumentOutOfRangeException("value");
}
_pivotTolerance = value;
diff --git a/src/Numerics/LinearAlgebra/Double/SparseVector.cs b/src/Numerics/LinearAlgebra/Double/SparseVector.cs
index 43c03991..411da5cc 100644
--- a/src/Numerics/LinearAlgebra/Double/SparseVector.cs
+++ b/src/Numerics/LinearAlgebra/Double/SparseVector.cs
@@ -329,25 +329,24 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (ReferenceEquals(this, result))
{
//populate a new vector with the scalar
- var vnonZeroValues = new double[this.Count];
- var vnonZeroIndices = new int[this.Count];
- for (int index = 0; index < this.Count; index++)
+ var vnonZeroValues = new double[Count];
+ var vnonZeroIndices = new int[Count];
+ for (int index = 0; index < Count; index++)
{
vnonZeroIndices[index] = index;
vnonZeroValues[index] = scalar;
}
//populate the non zero values from this
- for (int j = 0; j < this.NonZerosCount; j++)
+ for (int j = 0; j < NonZerosCount; j++)
{
- vnonZeroValues[this._nonZeroIndices[j]] = this._nonZeroValues[j] + scalar;
+ vnonZeroValues[_nonZeroIndices[j]] = _nonZeroValues[j] + scalar;
}
//assign this vectors arrary to the new arrays.
- this._nonZeroValues = vnonZeroValues;
- this._nonZeroIndices = vnonZeroIndices;
- this.NonZerosCount = this.Count;
-
+ _nonZeroValues = vnonZeroValues;
+ _nonZeroIndices = vnonZeroIndices;
+ NonZerosCount = Count;
}
else
{
@@ -1215,7 +1214,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
{
if (value == null)
{
- throw new ArgumentNullException(value);
+ throw new ArgumentNullException("value");
}
value = value.Trim();
diff --git a/src/Numerics/LinearAlgebra/Generic/Factorization/QR.cs b/src/Numerics/LinearAlgebra/Generic/Factorization/QR.cs
index ea4c65e3..669375a7 100644
--- a/src/Numerics/LinearAlgebra/Generic/Factorization/QR.cs
+++ b/src/Numerics/LinearAlgebra/Generic/Factorization/QR.cs
@@ -30,7 +30,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic.Factorization
using System.Numerics;
using Generic;
using Numerics;
- using Properties;
///
/// A class which encapsulates the functionality of the QR decomposition.
diff --git a/src/Numerics/LinearAlgebra/Generic/Factorization/Svd.cs b/src/Numerics/LinearAlgebra/Generic/Factorization/Svd.cs
index fae74399..aacf0230 100644
--- a/src/Numerics/LinearAlgebra/Generic/Factorization/Svd.cs
+++ b/src/Numerics/LinearAlgebra/Generic/Factorization/Svd.cs
@@ -31,7 +31,6 @@
namespace MathNet.Numerics.LinearAlgebra.Generic.Factorization
{
using System;
- using System.Linq;
using System.Numerics;
using Generic;
using Numerics;
diff --git a/src/Numerics/LinearAlgebra/Single/DenseVector.cs b/src/Numerics/LinearAlgebra/Single/DenseVector.cs
index 2a1cc810..3e4367a0 100644
--- a/src/Numerics/LinearAlgebra/Single/DenseVector.cs
+++ b/src/Numerics/LinearAlgebra/Single/DenseVector.cs
@@ -991,7 +991,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
{
if (value == null)
{
- throw new ArgumentNullException(value);
+ throw new ArgumentNullException("value");
}
value = value.Trim();
diff --git a/src/Numerics/LinearAlgebra/Single/Factorization/DenseLU.cs b/src/Numerics/LinearAlgebra/Single/Factorization/DenseLU.cs
index edc45b7e..03eb9371 100644
--- a/src/Numerics/LinearAlgebra/Single/Factorization/DenseLU.cs
+++ b/src/Numerics/LinearAlgebra/Single/Factorization/DenseLU.cs
@@ -31,7 +31,6 @@
namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
{
using System;
- using Algorithms.LinearAlgebra;
using Generic;
using Properties;
diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/CompositeSolver.cs b/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/CompositeSolver.cs
index 6005d94d..04f2cc35 100644
--- a/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/CompositeSolver.cs
+++ b/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/CompositeSolver.cs
@@ -245,7 +245,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
{
if (assembly == null)
{
- throw new ArgumentNullException("Assembly");
+ throw new ArgumentNullException("assembly");
}
if (typesToExclude == null)
diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/GpBiCg.cs b/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/GpBiCg.cs
index cef9d85b..71e96b39 100644
--- a/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/GpBiCg.cs
+++ b/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/GpBiCg.cs
@@ -341,7 +341,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
// Define the temporary scalars
float beta = 0;
- float sigma;
// Define the temporary vectors
// rDash_0 = r_0
@@ -422,6 +421,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
// if we don't do any so ...
var ctdot = c.DotProduct(t);
float eta;
+ float sigma;
if (((_numberOfBiCgStabSteps == 0) && (iterationNumber == 0)) || ShouldRunBiCgStabSteps(iterationNumber))
{
// sigma_k = (c_k * t_k) / (c_k * c_k)
diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/MlkBiCgStab.cs b/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/MlkBiCgStab.cs
index 0b3c20f2..056b1195 100644
--- a/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/MlkBiCgStab.cs
+++ b/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/MlkBiCgStab.cs
@@ -34,7 +34,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
using System.Collections.Generic;
using System.Diagnostics;
using Distributions;
- using Generic.Factorization;
using Generic.Solvers.Status;
using Preconditioners;
using Properties;
diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/Ilutp.cs b/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/Ilutp.cs
index 0bb12ef7..161956f0 100644
--- a/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/Ilutp.cs
+++ b/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/Ilutp.cs
@@ -169,7 +169,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners
{
if (value < 0)
{
- throw new ArgumentOutOfRangeException("Value");
+ throw new ArgumentOutOfRangeException("value");
}
_fillLevel = value;
@@ -204,7 +204,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners
{
if (value < 0)
{
- throw new ArgumentOutOfRangeException("Value");
+ throw new ArgumentOutOfRangeException("value");
}
_dropTolerance = value;
@@ -241,7 +241,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners
{
if (value < 0)
{
- throw new ArgumentOutOfRangeException("Value");
+ throw new ArgumentOutOfRangeException("value");
}
_pivotTolerance = value;
diff --git a/src/Numerics/LinearAlgebra/Single/SparseVector.cs b/src/Numerics/LinearAlgebra/Single/SparseVector.cs
index 5bb20311..c962964b 100644
--- a/src/Numerics/LinearAlgebra/Single/SparseVector.cs
+++ b/src/Numerics/LinearAlgebra/Single/SparseVector.cs
@@ -359,24 +359,24 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (ReferenceEquals(this, result))
{
//populate a new vector with the scalar
- var vnonZeroValues = new float[this.Count];
- var vnonZeroIndices = new int[this.Count];
- for (int index = 0; index < this.Count; index++)
+ var vnonZeroValues = new float[Count];
+ var vnonZeroIndices = new int[Count];
+ for (int index = 0; index < Count; index++)
{
vnonZeroIndices[index] = index;
vnonZeroValues[index] = scalar;
}
//populate the non zero values from this
- for (int j = 0; j < this.NonZerosCount; j++)
+ for (int j = 0; j < NonZerosCount; j++)
{
- vnonZeroValues[this._nonZeroIndices[j]] = this._nonZeroValues[j] + scalar;
+ vnonZeroValues[_nonZeroIndices[j]] = _nonZeroValues[j] + scalar;
}
//assign this vectors arrary to the new arrays.
- this._nonZeroValues = vnonZeroValues;
- this._nonZeroIndices = vnonZeroIndices;
- this.NonZerosCount = this.Count;
+ _nonZeroValues = vnonZeroValues;
+ _nonZeroIndices = vnonZeroIndices;
+ NonZerosCount = Count;
}
else
@@ -1225,7 +1225,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
{
if (value == null)
{
- throw new ArgumentNullException(value);
+ throw new ArgumentNullException("value");
}
value = value.Trim();
diff --git a/src/Numerics/Precision.cs b/src/Numerics/Precision.cs
index 25ab0844..4bc674b7 100644
--- a/src/Numerics/Precision.cs
+++ b/src/Numerics/Precision.cs
@@ -1291,14 +1291,10 @@ namespace MathNet.Numerics
// on each side of the numbers, e.g. if decimalPlaces == 2,
// then 0.01 will equal between 0.005 and 0.015, but not 0.02 and not 0.00
double maxDifference = decimalPlaceMagnitude / 2.0;
- if (a > b)
- {
- return (a * Math.Pow(10, -magnitudeOfFirst)) - maxDifference < (b * Math.Pow(10, -magnitudeOfFirst));
- }
- else
- {
- return (b * Math.Pow(10, -magnitudeOfSecond)) - maxDifference < (a * Math.Pow(10, -magnitudeOfSecond));
- }
+
+ return a > b
+ ? (a*Math.Pow(10, -magnitudeOfFirst)) - maxDifference < (b*Math.Pow(10, -magnitudeOfFirst))
+ : (b*Math.Pow(10, -magnitudeOfSecond)) - maxDifference < (a*Math.Pow(10, -magnitudeOfSecond));
}
///
@@ -1333,14 +1329,10 @@ namespace MathNet.Numerics
// on each side of the numbers, e.g. if decimalPlaces == 2,
// then 0.01 will equal between 0.005 and 0.015, but not 0.02 and not 0.00
float maxDifference = decimalPlaceMagnitude / 2.0f;
- if (a > b)
- {
- return (a * (float)Math.Pow(10, -magnitudeOfFirst)) - maxDifference < (b * (float)Math.Pow(10, -magnitudeOfFirst));
- }
- else
- {
- return (b * (float)Math.Pow(10, -magnitudeOfSecond)) - maxDifference < (a * (float)Math.Pow(10, -magnitudeOfSecond));
- }
+
+ return a > b
+ ? (a*(float) Math.Pow(10, -magnitudeOfFirst)) - maxDifference < (b*(float) Math.Pow(10, -magnitudeOfFirst))
+ : (b*(float) Math.Pow(10, -magnitudeOfSecond)) - maxDifference < (a*(float) Math.Pow(10, -magnitudeOfSecond));
}
///
diff --git a/src/Numerics/Random/Xorshift.cs b/src/Numerics/Random/Xorshift.cs
index 621cacef..18720219 100644
--- a/src/Numerics/Random/Xorshift.cs
+++ b/src/Numerics/Random/Xorshift.cs
@@ -247,7 +247,7 @@ namespace MathNet.Numerics.Random
///
/// The multiplier.
///
- private ulong _a;
+ private readonly ulong _a;
///
/// Returns a random number between 0.0 and 1.0.
diff --git a/src/Numerics/SerializableAttribute.cs b/src/Numerics/SerializableAttribute.cs
index adbcf375..ac1e0402 100644
--- a/src/Numerics/SerializableAttribute.cs
+++ b/src/Numerics/SerializableAttribute.cs
@@ -1,11 +1,12 @@
-using System;
+#if PORTABLE
+using System;
namespace MathNet.Numerics
{
-#if PORTABLE
+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
public class SerializableAttribute : Attribute
{
}
-#endif
}
+#endif
diff --git a/src/Numerics/Signals/SignalGenerator.Equidistant.cs b/src/Numerics/Signals/SignalGenerator.Equidistant.cs
index 9fc8ee77..c86c4f94 100644
--- a/src/Numerics/Signals/SignalGenerator.Equidistant.cs
+++ b/src/Numerics/Signals/SignalGenerator.Equidistant.cs
@@ -72,7 +72,7 @@ namespace MathNet.Numerics.Signals
if (sampleCount == 1)
{
- return new T[] { function(0.5 * (intervalBegin + intervalEnd)) };
+ return new[] { function(0.5 * (intervalBegin + intervalEnd)) };
}
var samples = new T[sampleCount];
@@ -128,7 +128,7 @@ namespace MathNet.Numerics.Signals
if (sampleCount == 1)
{
samplePoints = new[] { 0.5 * (intervalBegin + intervalEnd) };
- return new T[] { function(samplePoints[0]) };
+ return new[] { function(samplePoints[0]) };
}
var samples = new T[sampleCount];
diff --git a/src/Numerics/SpecialFunctions/Erf.cs b/src/Numerics/SpecialFunctions/Erf.cs
index 30349fb2..4907f04b 100644
--- a/src/Numerics/SpecialFunctions/Erf.cs
+++ b/src/Numerics/SpecialFunctions/Erf.cs
@@ -169,12 +169,12 @@ namespace MathNet.Numerics
{
if (!invert)
{
- return -ErfImp(-z, invert);
+ return -ErfImp(-z, false);
}
if (z < -0.5)
{
- return 2 - ErfImp((-z), invert);
+ return 2 - ErfImp((-z), true);
}
return 1 + ErfImp(-z, false);
@@ -199,8 +199,8 @@ namespace MathNet.Numerics
else
{
// Worst case absolute error found: 6.688618532e-21
- double[] n = new double[] { 0.00337916709551257388990745, -0.00073695653048167948530905, -0.374732337392919607868241, 0.0817442448733587196071743, -0.0421089319936548595203468, 0.0070165709512095756344528, -0.00495091255982435110337458, 0.000871646599037922480317225 };
- double[] d = new double[] { 1, -0.218088218087924645390535, 0.412542972725442099083918, -0.0841891147873106755410271, 0.0655338856400241519690695, -0.0120019604454941768171266, 0.00408165558926174048329689, -0.000615900721557769691924509 };
+ 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 };
result = (z * 1.125) + (z * EvaluatePolynomial(n, z) / EvaluatePolynomial(d, z));
}
@@ -215,104 +215,104 @@ namespace MathNet.Numerics
if (z < 0.75)
{
// Worst case absolute error found: 5.582813374e-21
- double[] n = new double[] { -0.0361790390718262471360258, 0.292251883444882683221149, 0.281447041797604512774415, 0.125610208862766947294894, 0.0274135028268930549240776, 0.00250839672168065762786937 };
- double[] d = new double[] { 1, 1.8545005897903486499845, 1.43575803037831418074962, 0.582827658753036572454135, 0.124810476932949746447682, 0.0113724176546353285778481 };
+ 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 = EvaluatePolynomial(n, z - 0.5) / EvaluatePolynomial(d, z - 0.5);
b = 0.3440242112F;
}
else if (z < 1.25)
{
// Worst case absolute error found: 4.01854729e-21
- double[] n = new double[] { -0.0397876892611136856954425, 0.153165212467878293257683, 0.191260295600936245503129, 0.10276327061989304213645, 0.029637090615738836726027, 0.0046093486780275489468812, 0.000307607820348680180548455 };
- double[] d = new double[] { 1, 1.95520072987627704987886, 1.64762317199384860109595, 0.768238607022126250082483, 0.209793185936509782784315, 0.0319569316899913392596356, 0.00213363160895785378615014 };
+ 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 = EvaluatePolynomial(n, z - 0.75) / EvaluatePolynomial(d, z - 0.75);
b = 0.419990927F;
}
else if (z < 2.25)
{
// Worst case absolute error found: 2.866005373e-21
- double[] n = new double[] { -0.0300838560557949717328341, 0.0538578829844454508530552, 0.0726211541651914182692959, 0.0367628469888049348429018, 0.00964629015572527529605267, 0.00133453480075291076745275, 0.778087599782504251917881e-4 };
- double[] d = new double[] { 1, 1.75967098147167528287343, 1.32883571437961120556307, 0.552528596508757581287907, 0.133793056941332861912279, 0.0179509645176280768640766, 0.00104712440019937356634038, -0.106640381820357337177643e-7 };
+ 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 = EvaluatePolynomial(n, z - 1.25) / EvaluatePolynomial(d, z - 1.25);
b = 0.4898625016F;
}
else if (z < 3.5)
{
// Worst case absolute error found: 1.045355789e-21
- double[] n = new double[] { -0.0117907570137227847827732, 0.014262132090538809896674, 0.0202234435902960820020765, 0.00930668299990432009042239, 0.00213357802422065994322516, 0.00025022987386460102395382, 0.120534912219588189822126e-4 };
- double[] d = new double[] { 1, 1.50376225203620482047419, 0.965397786204462896346934, 0.339265230476796681555511, 0.0689740649541569716897427, 0.00771060262491768307365526, 0.000371421101531069302990367 };
+ 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 = EvaluatePolynomial(n, z - 2.25) / EvaluatePolynomial(d, z - 2.25);
b = 0.5317370892F;
}
else if (z < 5.25)
{
// Worst case absolute error found: 8.300028706e-22
- double[] n = new double[] { -0.00546954795538729307482955, 0.00404190278731707110245394, 0.0054963369553161170521356, 0.00212616472603945399437862, 0.000394984014495083900689956, 0.365565477064442377259271e-4, 0.135485897109932323253786e-5 };
- double[] d = new double[] { 1, 1.21019697773630784832251, 0.620914668221143886601045, 0.173038430661142762569515, 0.0276550813773432047594539, 0.00240625974424309709745382, 0.891811817251336577241006e-4, -0.465528836283382684461025e-11 };
+ 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 = EvaluatePolynomial(n, z - 3.5) / EvaluatePolynomial(d, z - 3.5);
b = 0.5489973426F;
}
else if (z < 8)
{
// Worst case absolute error found: 1.700157534e-21
- double[] n = new double[] { -0.00270722535905778347999196, 0.0013187563425029400461378, 0.00119925933261002333923989, 0.00027849619811344664248235, 0.267822988218331849989363e-4, 0.923043672315028197865066e-6 };
- double[] d = new double[] { 1, 0.814632808543141591118279, 0.268901665856299542168425, 0.0449877216103041118694989, 0.00381759663320248459168994, 0.000131571897888596914350697, 0.404815359675764138445257e-11 };
+ 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 = EvaluatePolynomial(n, z - 5.25) / EvaluatePolynomial(d, z - 5.25);
b = 0.5571740866F;
}
else if (z < 11.5)
{
// Worst case absolute error found: 3.002278011e-22
- double[] n = new double[] { -0.00109946720691742196814323, 0.000406425442750422675169153, 0.000274499489416900707787024, 0.465293770646659383436343e-4, 0.320955425395767463401993e-5, 0.778286018145020892261936e-7 };
- double[] d = new double[] { 1, 0.588173710611846046373373, 0.139363331289409746077541, 0.0166329340417083678763028, 0.00100023921310234908642639, 0.24254837521587225125068e-4 };
+ 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 = EvaluatePolynomial(n, z - 8) / EvaluatePolynomial(d, z - 8);
b = 0.5609807968F;
}
else if (z < 17)
{
// Worst case absolute error found: 6.741114695e-21
- double[] n = new double[] { -0.00056907993601094962855594, 0.000169498540373762264416984, 0.518472354581100890120501e-4, 0.382819312231928859704678e-5, 0.824989931281894431781794e-7 };
- double[] d = new double[] { 1, 0.339637250051139347430323, 0.043472647870310663055044, 0.00248549335224637114641629, 0.535633305337152900549536e-4, -0.117490944405459578783846e-12 };
+ 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 = EvaluatePolynomial(n, z - 11.5) / EvaluatePolynomial(d, z - 11.5);
b = 0.5626493692F;
}
else if (z < 24)
{
// Worst case absolute error found: 7.802346984e-22
- double[] n = new double[] { -0.000241313599483991337479091, 0.574224975202501512365975e-4, 0.115998962927383778460557e-4, 0.581762134402593739370875e-6, 0.853971555085673614607418e-8 };
- double[] d = new double[] { 1, 0.233044138299687841018015, 0.0204186940546440312625597, 0.000797185647564398289151125, 0.117019281670172327758019e-4 };
+ 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 = EvaluatePolynomial(n, z - 17) / EvaluatePolynomial(d, z - 17);
b = 0.5634598136F;
}
else if (z < 38)
{
// Worst case absolute error found: 2.414228989e-22
- double[] n = new double[] { -0.000146674699277760365803642, 0.162666552112280519955647e-4, 0.269116248509165239294897e-5, 0.979584479468091935086972e-7, 0.101994647625723465722285e-8 };
- double[] d = new double[] { 1, 0.165907812944847226546036, 0.0103361716191505884359634, 0.000286593026373868366935721, 0.298401570840900340874568e-5 };
+ 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 = EvaluatePolynomial(n, z - 24) / EvaluatePolynomial(d, z - 24);
b = 0.5638477802F;
}
else if (z < 60)
{
// Worst case absolute error found: 5.896543869e-24
- double[] n = new double[] { -0.583905797629771786720406e-4, 0.412510325105496173512992e-5, 0.431790922420250949096906e-6, 0.993365155590013193345569e-8, 0.653480510020104699270084e-10 };
- double[] d = new double[] { 1, 0.105077086072039915406159, 0.00414278428675475620830226, 0.726338754644523769144108e-4, 0.477818471047398785369849e-6 };
+ 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 = EvaluatePolynomial(n, z - 38) / EvaluatePolynomial(d, z - 38);
b = 0.5640528202F;
}
else if (z < 85)
{
// Worst case absolute error found: 3.080612264e-21
- double[] n = new double[] { -0.196457797609229579459841e-4, 0.157243887666800692441195e-5, 0.543902511192700878690335e-7, 0.317472492369117710852685e-9 };
- double[] d = new double[] { 1, 0.052803989240957632204885, 0.000926876069151753290378112, 0.541011723226630257077328e-5, 0.535093845803642394908747e-15 };
+ 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 = EvaluatePolynomial(n, z - 60) / EvaluatePolynomial(d, z - 60);
b = 0.5641309023F;
}
else
{
// Worst case absolute error found: 8.094633491e-22
- double[] n = new double[] { -0.789224703978722689089794e-5, 0.622088451660986955124162e-6, 0.145728445676882396797184e-7, 0.603715505542715364529243e-10 };
- double[] d = new double[] { 1, 0.0375328846356293715248719, 0.000467919535974625308126054, 0.193847039275845656900547e-5 };
+ 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 = EvaluatePolynomial(n, z - 85) / EvaluatePolynomial(d, z - 85);
b = 0.5641584396F;
}
@@ -403,9 +403,9 @@ namespace MathNet.Numerics
// long double: Max error found: 1.017064e-20
// Maximum Deviation Found (actual error term at infinite precision) 8.030e-21
//
- float Y = 0.0891314744949340820313f;
- double[] P = new double[] { -0.000508781949658280665617, -0.00836874819741736770379, 0.0334806625409744615033, -0.0126926147662974029034, -0.0365637971411762664006, 0.0219878681111168899165, 0.00822687874676915743155, -0.00538772965071242932965 };
- double[] Q = new double[] { 1, -0.970005043303290640362, -1.56574558234175846809, 1.56221558398423026363, 0.662328840472002992063, -0.71228902341542847553, -0.0527396382340099713954, 0.0795283687341571680018, -0.00233393759374190016776, 0.000886216390456424707504 };
+ 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 = EvaluatePolynomial(P, p) / EvaluatePolynomial(Q, p);
result = (g * Y) + (g * r);
@@ -424,10 +424,10 @@ namespace MathNet.Numerics
// long double : Max error found: 6.084616e-20
// Maximum Deviation Found (error term) 4.811e-20
//
- float Y = 2.249481201171875f;
- double[] P = new double[] { -0.202433508355938759655, 0.105264680699391713268, 8.37050328343119927838, 17.6447298408374015486, -18.8510648058714251895, -44.6382324441786960818, 17.445385985570866523, 21.1294655448340526258, -3.67192254707729348546 };
- double[] Q = new double[] { 1, 6.24264124854247537712, 3.9713437953343869095, -28.6608180499800029974, -20.1432634680485188801, 48.5609213108739935468, 10.8268667355460159008, -22.6436933413139721736, 1.72114765761200282724 };
- double g = System.Math.Sqrt(-2 * System.Math.Log(q));
+ 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));
double xs = q - 0.25;
double r = EvaluatePolynomial(P, xs) / EvaluatePolynomial(Q, xs);
result = g / (Y + r);
@@ -453,13 +453,13 @@ namespace MathNet.Numerics
// small input values indeed: 80 and 128 bit long double's go all the
// way down to ~ 1e-5000 so the "tail" is rather long...
//
- double x = System.Math.Sqrt(-System.Math.Log(q));
+ double x = Math.Sqrt(-Math.Log(q));
if (x < 3)
{
// Max error found: 1.089051e-20
- float Y = 0.807220458984375f;
- double[] P = new double[] { -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 double[] { 1, 3.46625407242567245975, 5.38168345707006855425, 4.77846592945843778382, 2.59301921623620271374, 0.848854343457902036425, 0.152264338295331783612, 0.01105924229346489121 };
+ 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 };
double xs = x - 1.125;
double R = EvaluatePolynomial(P, xs) / EvaluatePolynomial(Q, xs);
result = (Y * x) + (R * x);
@@ -467,9 +467,9 @@ namespace MathNet.Numerics
else if (x < 6)
{
// Max error found: 8.389174e-21
- float Y = 0.93995571136474609375f;
- double[] P = new double[] { -0.0350353787183177984712, -0.00222426529213447927281, 0.0185573306514231072324, 0.00950804701325919603619, 0.00187123492819559223345, 0.000157544617424960554631, 0.460469890584317994083e-5, -0.230404776911882601748e-9, 0.266339227425782031962e-11 };
- double[] Q = new double[] { 1, 1.3653349817554063097, 0.762059164553623404043, 0.220091105764131249824, 0.0341589143670947727934, 0.00263861676657015992959, 0.764675292302794483503e-4 };
+ 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 };
double xs = x - 3;
double R = EvaluatePolynomial(P, xs) / EvaluatePolynomial(Q, xs);
result = (Y * x) + (R * x);
@@ -477,9 +477,9 @@ namespace MathNet.Numerics
else if (x < 18)
{
// Max error found: 1.481312e-19
- float Y = 0.98362827301025390625f;
- double[] P = new double[] { -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 double[] { 1, 0.591429344886417493481, 0.138151865749083321638, 0.0160746087093676504695, 0.000964011807005165528527, 0.275335474764726041141e-4, 0.282243172016108031869e-6 };
+ 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 };
double xs = x - 6;
double R = EvaluatePolynomial(P, xs) / EvaluatePolynomial(Q, xs);
result = (Y * x) + (R * x);
@@ -487,9 +487,9 @@ namespace MathNet.Numerics
else if (x < 44)
{
// Max error found: 5.697761e-20
- float Y = 0.99714565277099609375f;
- double[] P = new double[] { -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 double[] { 1, 0.207123112214422517181, 0.0169410838120975906478, 0.000690538265622684595676, 0.145007359818232637924e-4, 0.144437756628144157666e-6, 0.509761276599778486139e-9 };
+ 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 };
double xs = x - 18;
double R = EvaluatePolynomial(P, xs) / EvaluatePolynomial(Q, xs);
result = (Y * x) + (R * x);
@@ -497,9 +497,9 @@ namespace MathNet.Numerics
else
{
// Max error found: 1.279746e-20
- float Y = 0.99941349029541015625f;
- double[] P = new double[] { -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 double[] { 1, 0.0845746234001899436914, 0.00282092984726264681981, 0.468292921940894236786e-4, 0.399968812193862100054e-6, 0.161809290887904476097e-8, 0.231558608310259605225e-11 };
+ 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 };
double xs = x - 44;
double R = EvaluatePolynomial(P, xs) / EvaluatePolynomial(Q, xs);
result = (Y * x) + (R * x);
diff --git a/src/Numerics/SpecialFunctions/Factorial.cs b/src/Numerics/SpecialFunctions/Factorial.cs
index af2a12dc..9308bc7f 100644
--- a/src/Numerics/SpecialFunctions/Factorial.cs
+++ b/src/Numerics/SpecialFunctions/Factorial.cs
@@ -64,7 +64,7 @@ namespace MathNet.Numerics
{
if (x < 0)
{
- throw new ArgumentOutOfRangeException("x", Properties.Resources.ArgumentPositive);
+ throw new ArgumentOutOfRangeException("x", Resources.ArgumentPositive);
}
if (x < factorialCache.Length)
@@ -83,7 +83,7 @@ namespace MathNet.Numerics
{
if (x < 0)
{
- throw new ArgumentOutOfRangeException("x", Properties.Resources.ArgumentPositive);
+ throw new ArgumentOutOfRangeException("x", Resources.ArgumentPositive);
}
if (x <= 1)
@@ -170,7 +170,7 @@ namespace MathNet.Numerics
throw new ArgumentException(Resources.ArgumentParameterSetInvalid , "ni");
}
- return System.Math.Floor(0.5 + System.Math.Exp(ret));
+ return Math.Floor(0.5 + Math.Exp(ret));
}
}
}
\ No newline at end of file
diff --git a/src/Numerics/SpecialFunctions/Gamma.cs b/src/Numerics/SpecialFunctions/Gamma.cs
index 10a9f11a..ce1c1cf5 100644
--- a/src/Numerics/SpecialFunctions/Gamma.cs
+++ b/src/Numerics/SpecialFunctions/Gamma.cs
@@ -160,67 +160,48 @@ namespace MathNet.Numerics
/// The upper incomplete regularized gamma function.
public static double GammaUpperRegularized(double a, double x)
{
- double result = 0;
- double igammaepsilon = 0;
- double igammabignumber = 0;
- double igammabignumberinv = 0;
- double ans = 0;
- double ax = 0;
- double c = 0;
- double yc = 0;
- double r = 0;
- double t = 0;
- double y = 0;
- double z = 0;
- double pk = 0;
- double pkm1 = 0;
- double pkm2 = 0;
- double qk = 0;
- double qkm1 = 0;
- double qkm2 = 0;
-
- igammaepsilon = 0.000000000000001;
- igammabignumber = 4503599627370496.0;
- igammabignumberinv = 2.22044604925031308085 * 0.0000000000000001;
+ double t;
+
+ const double igammaepsilon = 0.000000000000001;
+ const double igammabignumber = 4503599627370496.0;
+ const double igammabignumberinv = 2.22044604925031308085 * 0.0000000000000001;
+
if (x <= 0 | a <= 0)
{
- result = 1;
- return result;
+ return 1;
}
if (x < 1 | x < a)
{
- result = 1 - GammaLowerRegularized(a, x);
- return result;
+ return 1 - GammaLowerRegularized(a, x);
}
- ax = a * Math.Log(x) - x - GammaLn(a);
+ double ax = a * Math.Log(x) - x - GammaLn(a);
if (ax < -709.78271289338399)
{
- result = 0;
- return result;
+ return 0;
}
ax = Math.Exp(ax);
- y = 1 - a;
- z = x + y + 1;
- c = 0;
- pkm2 = 1;
- qkm2 = x;
- pkm1 = x + 1;
- qkm1 = z * x;
- ans = pkm1 / qkm1;
+ double y = 1 - a;
+ double z = x + y + 1;
+ double c = 0;
+ double pkm2 = 1;
+ double qkm2 = x;
+ double pkm1 = x + 1;
+ double qkm1 = z * x;
+ double ans = pkm1 / qkm1;
do
{
c = c + 1;
y = y + 1;
z = z + 2;
- yc = y * c;
- pk = pkm1 * z - pkm2 * yc;
- qk = qkm1 * z - qkm2 * yc;
+ double yc = y * c;
+ double pk = pkm1 * z - pkm2 * yc;
+ double qk = qkm1 * z - qkm2 * yc;
if (qk != 0)
{
- r = pk / qk;
+ double r = pk / qk;
t = Math.Abs((ans - r) / r);
ans = r;
}
@@ -244,9 +225,7 @@ namespace MathNet.Numerics
}
while (t > igammaepsilon);
- result = ans * ax;
-
- return result;
+ return ans * ax;
}
///
@@ -307,7 +286,7 @@ namespace MathNet.Numerics
return 0d;
}
- double ax = (a * Math.Log(x)) - x - SpecialFunctions.GammaLn(a);
+ double ax = (a * Math.Log(x)) - x - GammaLn(a);
if (ax < -709.78271289338399)
{
return 1d;
@@ -340,7 +319,7 @@ namespace MathNet.Numerics
double q2 = z * x;
double ans = p2 / q2;
- double error = 0;
+ double error;
do
{
diff --git a/src/Numerics/SpecialFunctions/Stability.cs b/src/Numerics/SpecialFunctions/Stability.cs
index 27e137df..b8c27be7 100644
--- a/src/Numerics/SpecialFunctions/Stability.cs
+++ b/src/Numerics/SpecialFunctions/Stability.cs
@@ -172,7 +172,7 @@ namespace MathNet.Numerics
{
double compensation = 0.0;
double current;
- double factor = 1 << 16;
+ const double factor = 1 << 16;
double sum = nextSummand();
diff --git a/src/Numerics/Statistics/Correlation.cs b/src/Numerics/Statistics/Correlation.cs
index e811f1a7..bd31c401 100644
--- a/src/Numerics/Statistics/Correlation.cs
+++ b/src/Numerics/Statistics/Correlation.cs
@@ -32,7 +32,6 @@ namespace MathNet.Numerics.Statistics
{
using System;
using System.Collections.Generic;
- using Properties;
///
/// A class with correlation measures between two datasets.
diff --git a/src/Numerics/Statistics/DescriptiveStatistics.cs b/src/Numerics/Statistics/DescriptiveStatistics.cs
index 8a23fb4d..5d34f72f 100644
--- a/src/Numerics/Statistics/DescriptiveStatistics.cs
+++ b/src/Numerics/Statistics/DescriptiveStatistics.cs
@@ -198,7 +198,7 @@ namespace MathNet.Numerics.Statistics
Minimum = minimum;
Maximum = maximum;
Variance = (variance - (correction * correction / n)) / (n - 1);
- StandardDeviation = System.Math.Sqrt(Variance);
+ StandardDeviation = Math.Sqrt(Variance);
if (Variance != 0)
{
if (n > 2)
@@ -254,7 +254,7 @@ namespace MathNet.Numerics.Statistics
Minimum = minimum;
Maximum = maximum;
Variance = (variance - (correction * correction / n)) / (n - 1);
- StandardDeviation = System.Math.Sqrt(Variance);
+ StandardDeviation = Math.Sqrt(Variance);
if (Variance != 0)
{
if (n > 2)
@@ -307,7 +307,7 @@ namespace MathNet.Numerics.Statistics
Minimum = (double)minimum;
Maximum = (double)maximum;
Variance = (double)(variance - (correction * correction / n)) / (n - 1);
- StandardDeviation = System.Math.Sqrt(Variance);
+ StandardDeviation = Math.Sqrt(Variance);
if (Variance != 0)
{
if (n > 2)
@@ -364,7 +364,7 @@ namespace MathNet.Numerics.Statistics
Minimum = (double) minimum;
Maximum = (double) maximum;
Variance = (double)(variance - (correction * correction / n)) / (n - 1);
- StandardDeviation = System.Math.Sqrt(Variance);
+ StandardDeviation = Math.Sqrt(Variance);
if (Variance != 0)
{
if (n > 2)
diff --git a/src/Numerics/Statistics/Histogram.cs b/src/Numerics/Statistics/Histogram.cs
index 1c438ee2..124a774a 100644
--- a/src/Numerics/Statistics/Histogram.cs
+++ b/src/Numerics/Statistics/Histogram.cs
@@ -60,18 +60,13 @@ namespace MathNet.Numerics.Statistics
/// -1 when the point is less than this bucket, 0 when it is in this bucket and 1 otherwise.
public int Compare(Bucket bkt1, Bucket bkt2)
{
- if (bkt2.Width == 0.0)
- {
- return -bkt1.Contains(bkt2.UpperBound);
- }
- else
- {
- return -bkt2.Contains(bkt1.UpperBound);
- }
+ return bkt2.Width == 0.0
+ ? -bkt1.Contains(bkt2.UpperBound)
+ : -bkt2.Contains(bkt1.UpperBound);
}
}
- private static PointComparer pointComparer = new PointComparer();
+ private static readonly PointComparer pointComparer = new PointComparer();
///
/// Lower Bound of the Bucket.
@@ -166,18 +161,18 @@ namespace MathNet.Numerics.Statistics
///
public int CompareTo(Bucket bucket)
{
- if (this.UpperBound > bucket.LowerBound && this.LowerBound < bucket.LowerBound)
+ if (UpperBound > bucket.LowerBound && LowerBound < bucket.LowerBound)
{
throw new ArgumentException(Resources.PartialOrderException);
}
- if (Precision.AlmostEqual(this.UpperBound, bucket.UpperBound)
- && Precision.AlmostEqual(this.LowerBound, bucket.LowerBound))
+ if (UpperBound.AlmostEqual(bucket.UpperBound)
+ && LowerBound.AlmostEqual(bucket.LowerBound))
{
return 0;
}
- if (bucket.UpperBound <= this.LowerBound)
+ if (bucket.UpperBound <= LowerBound)
{
return 1;
}
@@ -196,10 +191,10 @@ namespace MathNet.Numerics.Statistics
return false;
}
- Bucket b = (Bucket) obj;
- return Precision.AlmostEqual(this.LowerBound, b.LowerBound)
- && Precision.AlmostEqual(this.UpperBound, b.UpperBound)
- && Precision.AlmostEqual(this.Count, b.Count);
+ var bucket = (Bucket) obj;
+ return LowerBound.AlmostEqual(bucket.LowerBound)
+ && UpperBound.AlmostEqual(bucket.UpperBound)
+ && Count.AlmostEqual(bucket.Count);
}
///
@@ -216,7 +211,7 @@ namespace MathNet.Numerics.Statistics
///
public override string ToString()
{
- return "(" + this.LowerBound + ";" + this.UpperBound + "] = " + this.Count;
+ return "(" + LowerBound + ";" + UpperBound + "] = " + Count;
}
}
@@ -229,20 +224,20 @@ namespace MathNet.Numerics.Statistics
///
/// Contains all the Buckets of the Histogram.
///
- private List buckets;
+ private readonly List _buckets;
///
/// Indicates whether the elements of buckets are currently sorted.
///
- private bool areBucketsSorted;
+ private bool _areBucketsSorted;
///
/// Initializes a new instance of the Histogram class.
///
public Histogram()
{
- buckets = new List();
- areBucketsSorted = true;
+ _buckets = new List();
+ _areBucketsSorted = true;
}
///
@@ -256,7 +251,7 @@ namespace MathNet.Numerics.Statistics
{
if (nbuckets < 1)
{
- throw new ArgumentOutOfRangeException("The number of bins in a histogram should be at least 1.");
+ throw new ArgumentOutOfRangeException("data", "The number of bins in a histogram should be at least 1.");
}
double lower = data.Minimum();
@@ -315,20 +310,20 @@ namespace MathNet.Numerics.Statistics
// Sort if needed.
LazySort();
- if (d < this.LowerBound)
+ if (d < LowerBound)
{
// Make the lower bound just slightly smaller than the datapoint so it is contained in this bucket.
- buckets[0].LowerBound = d.Decrement();
- buckets[0].Count++;
+ _buckets[0].LowerBound = d.Decrement();
+ _buckets[0].Count++;
}
- else if (d > this.UpperBound)
+ else if (d > UpperBound)
{
- buckets[BucketCount - 1].UpperBound = d;
- buckets[BucketCount - 1].Count++;
+ _buckets[BucketCount - 1].UpperBound = d;
+ _buckets[BucketCount - 1].Count++;
}
else
{
- buckets[GetBucketIndexOf(d)].Count++;
+ _buckets[GetBucketIndexOf(d)].Count++;
}
}
@@ -350,8 +345,8 @@ namespace MathNet.Numerics.Statistics
///
public void AddBucket(Bucket bucket)
{
- buckets.Add(bucket);
- areBucketsSorted = false;
+ _buckets.Add(bucket);
+ _areBucketsSorted = false;
}
///
@@ -359,10 +354,10 @@ namespace MathNet.Numerics.Statistics
///
private void LazySort()
{
- if (!areBucketsSorted)
+ if (!_areBucketsSorted)
{
- buckets.Sort();
- areBucketsSorted = true;
+ _buckets.Sort();
+ _areBucketsSorted = true;
}
}
@@ -373,7 +368,7 @@ namespace MathNet.Numerics.Statistics
/// A copy of the bucket containing point .
public Bucket GetBucketOf(double v)
{
- return (Bucket) buckets[GetBucketIndexOf(v)].Clone();
+ return (Bucket) _buckets[GetBucketIndexOf(v)].Clone();
}
///
@@ -388,7 +383,7 @@ namespace MathNet.Numerics.Statistics
LazySort();
// Binary search for the bucket index.
- int index = buckets.BinarySearch(new Bucket(v, v), Bucket.DefaultPointComparer);
+ int index = _buckets.BinarySearch(new Bucket(v, v), Bucket.DefaultPointComparer);
if (index < 0)
{
@@ -406,7 +401,7 @@ namespace MathNet.Numerics.Statistics
get
{
LazySort();
- return buckets[0].LowerBound;
+ return _buckets[0].LowerBound;
}
}
@@ -418,7 +413,7 @@ namespace MathNet.Numerics.Statistics
get
{
LazySort();
- return buckets[buckets.Count - 1].UpperBound;
+ return _buckets[_buckets.Count - 1].UpperBound;
}
}
@@ -432,7 +427,7 @@ namespace MathNet.Numerics.Statistics
get
{
LazySort();
- return (Bucket) buckets[n].Clone();
+ return (Bucket) _buckets[n].Clone();
}
}
@@ -441,7 +436,7 @@ namespace MathNet.Numerics.Statistics
///
public int BucketCount
{
- get { return buckets.Count; }
+ get { return _buckets.Count; }
}
///
@@ -453,7 +448,7 @@ namespace MathNet.Numerics.Statistics
{
double totalCount = 0;
- for (int i = 0; i < this.BucketCount; i++)
+ for (int i = 0; i < BucketCount; i++)
{
totalCount += this[i].Count;
}
@@ -469,7 +464,7 @@ namespace MathNet.Numerics.Statistics
{
StringBuilder sb = new StringBuilder();
- foreach (Bucket b in buckets)
+ foreach (Bucket b in _buckets)
{
sb.Append(b.ToString());
}
diff --git a/src/Numerics/Statistics/MCMC/MCMCSampler.cs b/src/Numerics/Statistics/MCMC/MCMCSampler.cs
index 02e475f2..30e92e8b 100644
--- a/src/Numerics/Statistics/MCMC/MCMCSampler.cs
+++ b/src/Numerics/Statistics/MCMC/MCMCSampler.cs
@@ -40,7 +40,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
///
/// The type of the datapoints.
/// A sample from the proposal distribution.
- public delegate T GlobalProposalSampler();
+ public delegate T GlobalProposalSampler();
///
/// A method which samples datapoints from a proposal distribution given an initial sample. The implementation
@@ -58,14 +58,14 @@ namespace MathNet.Numerics.Statistics.Mcmc
///
/// The type of data the distribution is over.
/// The sample we want to evaluate the density for.
- public delegate double Density(T sample);
+ public delegate double Density(T sample);
///
/// A function which evaluates a log density.
///
/// The type of data the distribution is over.
/// The sample we want to evaluate the log density for.
- public delegate double DensityLn(T sample);
+ public delegate double DensityLn(T sample);
///
/// A function which evaluates the log of a transition kernel probability.
@@ -74,7 +74,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
/// The new state in the transition.
/// The previous state in the transition.
/// The log probability of the transition.
- public delegate double TransitionKernelLn(T to, T from);
+ public delegate double TransitionKernelLn(T to, T from);
///
/// The interface which every sampler must implement.
@@ -85,18 +85,18 @@ namespace MathNet.Numerics.Statistics.Mcmc
///
/// The random number generator for this class.
///
- private System.Random mRandomNumberGenerator;
+ private Random _randomNumberGenerator;
///
/// Keeps track of the number of accepted samples.
///
- protected int mAccepts;
+ protected int Accepts;
///
/// Keeps track of the number of calls to the proposal sampler.
///
- protected int mSamples;
-
+ protected int Samples;
+
///
/// Initializes a new instance of the class.
///
@@ -104,18 +104,18 @@ namespace MathNet.Numerics.Statistics.Mcmc
/// safe classes.
protected McmcSampler()
{
- mAccepts = 0;
- mSamples = 0;
- RandomSource = new System.Random();
+ Accepts = 0;
+ Samples = 0;
+ RandomSource = new Random();
}
///
/// Gets or sets the random number generator.
///
/// When the random number generator is null.
- public System.Random RandomSource
+ public Random RandomSource
{
- get { return mRandomNumberGenerator; }
+ get { return _randomNumberGenerator; }
set
{
@@ -123,7 +123,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
{
throw new ArgumentNullException();
}
- mRandomNumberGenerator = value;
+ _randomNumberGenerator = value;
}
}
@@ -154,7 +154,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
///
public double AcceptanceRate
{
- get { return (double)mAccepts / (double)mSamples; }
+ get { return Accepts / (double)Samples; }
}
}
}
\ No newline at end of file
diff --git a/src/Numerics/Statistics/MCMC/MetropolisHastingsSampler.cs b/src/Numerics/Statistics/MCMC/MetropolisHastingsSampler.cs
index 6a914c5f..7bfaf45b 100644
--- a/src/Numerics/Statistics/MCMC/MetropolisHastingsSampler.cs
+++ b/src/Numerics/Statistics/MCMC/MetropolisHastingsSampler.cs
@@ -145,20 +145,20 @@ namespace MathNet.Numerics.Statistics.Mcmc
// Evaluate the backward transition probability
double bwd = mKrnlQ(mCurrent, next);
- mSamples++;
+ Samples++;
- double acc = System.Math.Min(0.0, p + bwd - mCurrentDensityLn - fwd);
+ double acc = Math.Min(0.0, p + bwd - mCurrentDensityLn - fwd);
if (acc == 0.0)
{
mCurrent = next;
mCurrentDensityLn = p;
- mAccepts++;
+ Accepts++;
}
- else if (Bernoulli.Sample(RandomSource, System.Math.Exp(acc)) == 1)
+ else if (Bernoulli.Sample(RandomSource, Math.Exp(acc)) == 1)
{
mCurrent = next;
mCurrentDensityLn = p;
- mAccepts++;
+ Accepts++;
}
}
}
diff --git a/src/Numerics/Statistics/MCMC/MetropolisSampler.cs b/src/Numerics/Statistics/MCMC/MetropolisSampler.cs
index 2dc95dbb..643d22e0 100644
--- a/src/Numerics/Statistics/MCMC/MetropolisSampler.cs
+++ b/src/Numerics/Statistics/MCMC/MetropolisSampler.cs
@@ -131,20 +131,20 @@ namespace MathNet.Numerics.Statistics.Mcmc
// Evaluate the density at the next sample.
double p = mPdfLnP(next);
- mSamples++;
+ Samples++;
- double acc = System.Math.Min(0.0, p - mCurrentDensityLn);
+ double acc = Math.Min(0.0, p - mCurrentDensityLn);
if (acc == 0.0)
{
mCurrent = next;
mCurrentDensityLn = p;
- mAccepts++;
+ Accepts++;
}
- else if (Bernoulli.Sample(RandomSource, System.Math.Exp(acc)) == 1)
+ else if (Bernoulli.Sample(RandomSource, Math.Exp(acc)) == 1)
{
mCurrent = next;
mCurrentDensityLn = p;
- mAccepts++;
+ Accepts++;
}
}
}
diff --git a/src/Numerics/Statistics/MCMC/RejectionSampler.cs b/src/Numerics/Statistics/MCMC/RejectionSampler.cs
index f8cd8550..485b47c2 100644
--- a/src/Numerics/Statistics/MCMC/RejectionSampler.cs
+++ b/src/Numerics/Statistics/MCMC/RejectionSampler.cs
@@ -87,7 +87,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
// Sample a variable between 0.0 and proposal density.
double u = RandomSource.NextDouble() * q;
- mSamples++;
+ Samples++;
if (q < p)
{
@@ -95,7 +95,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
}
if (u < p)
{
- mAccepts++;
+ Accepts++;
return x;
}
}
diff --git a/src/Numerics/Statistics/MCMC/UnivariateSliceSampler.cs b/src/Numerics/Statistics/MCMC/UnivariateSliceSampler.cs
index ec384e02..05ba6545 100644
--- a/src/Numerics/Statistics/MCMC/UnivariateSliceSampler.cs
+++ b/src/Numerics/Statistics/MCMC/UnivariateSliceSampler.cs
@@ -139,17 +139,13 @@ namespace MathNet.Numerics.Statistics.Mcmc
{
for (int i = 0; i < n; i++)
{
- double x_l = mCurrent;
- double x_r = mCurrent;
- double xnew = mCurrent;
-
// The logarithm of the slice height.
- double lu = System.Math.Log(RandomSource.NextDouble()) + mCurrentDensityLn;
+ double lu = Math.Log(RandomSource.NextDouble()) + mCurrentDensityLn;
// Create a horizontal interval (x_l, x_r) enclosing x.
double r = RandomSource.NextDouble();
- x_l = mCurrent - r * Scale;
- x_r = mCurrent + (1.0 - r) * Scale;
+ double x_l = mCurrent - r * Scale;
+ double x_r = mCurrent + (1.0 - r) * Scale;
// Stepping out procedure.
while (mPdfLnP(x_l) > lu) { x_l -= Scale; }
@@ -158,13 +154,13 @@ namespace MathNet.Numerics.Statistics.Mcmc
// Shrinking: propose new x and shrink interval until good one found.
while (true)
{
- xnew = RandomSource.NextDouble() * (x_r - x_l) + x_l;
+ double xnew = RandomSource.NextDouble() * (x_r - x_l) + x_l;
mCurrentDensityLn = mPdfLnP(xnew);
if (mCurrentDensityLn > lu)
{
mCurrent = xnew;
- mAccepts++;
- mSamples++;
+ Accepts++;
+ Samples++;
break;
}
if (xnew > mCurrent)