diff --git a/src/Numerics/Differentiation/NumericalDerivative.cs b/src/Numerics/Differentiation/NumericalDerivative.cs index 7f042f7f..cb4338ca 100644 --- a/src/Numerics/Differentiation/NumericalDerivative.cs +++ b/src/Numerics/Differentiation/NumericalDerivative.cs @@ -68,6 +68,39 @@ namespace MathNet.Numerics.Differentiation /// public class NumericalDerivative { + readonly int _points; + int _center; + double _stepSize = Math.Pow(2, -10); + double _epsilon = Precision.PositiveMachineEpsilon; + double _baseStepSize = Math.Pow(2, -26); + StepType _stepType = StepType.Relative; + readonly FiniteDifferenceCoefficients _coefficients; + + /// + /// Initializes a NumericalDerivative class with the default 3 point center difference method. + /// + public NumericalDerivative() : this(3, 1) + { + } + + /// + /// Initialized a NumericalDerivative class. + /// + /// Number of points for finite difference derivatives. + /// Location of the center with respect to other points. Value ranges from zero to points-1. + public NumericalDerivative(int points, int center) + { + if (points < 2) + { + throw new ArgumentOutOfRangeException("points", "Points must be two or greater."); + } + + _center = center; + _points = points; + Center = center; + _coefficients = new FiniteDifferenceCoefficients(points); + } + /// /// Sets and gets the finite difference step size. This value is for each function evaluation if relative stepsize types are used. /// If the base step size used in scaling is desired, see . @@ -147,37 +180,6 @@ namespace MathNet.Numerics.Differentiation set { _stepType = value; } } - private readonly int _points; - private int _center; - private double _stepSize = Math.Pow(2, -10); - private double _epsilon = Math.Pow(2, -52); - private double _baseStepSize = Math.Pow(2, -26); - private StepType _stepType = StepType.Relative; - private readonly FiniteDifferenceCoefficients _coefficients; - - /// - /// Initializes a NumericalDerivative class with the default 3 point center difference method. - /// - public NumericalDerivative() : this(3, 1) - { - } - - /// - /// Initialized a NumericalDerivative class. - /// - /// Number of points for finite difference derivatives. - /// Location of the center with respect to other points. Value ranges from zero to points-1. - public NumericalDerivative(int points, int center) - { - _center = center; - if (points < 2) - throw new ArgumentOutOfRangeException("points", "Points must be two or greater."); - _points = points; - Center = center; - _epsilon = Precision.PositiveMachineEpsilon; - _coefficients = new FiniteDifferenceCoefficients(points); - } - /// /// Evaluates the derivative of equidistant points using the finite difference method. /// diff --git a/src/Numerics/Distributions/Beta.cs b/src/Numerics/Distributions/Beta.cs index f78e53d0..7974c38b 100644 --- a/src/Numerics/Distributions/Beta.cs +++ b/src/Numerics/Distributions/Beta.cs @@ -413,14 +413,14 @@ namespace MathNet.Numerics.Distributions /// The α shape parameter of the Beta distribution. Range: α ≥ 0. /// The β shape parameter of the Beta distribution. Range: β ≥ 0. /// a random number from the Beta distribution. - static internal double SampleUnchecked(System.Random rnd, double a, double b) + internal static double SampleUnchecked(System.Random rnd, double a, double b) { var x = Gamma.SampleUnchecked(rnd, a, 1.0); var y = Gamma.SampleUnchecked(rnd, b, 1.0); return x/(x + y); } - static internal void SamplesUnchecked(System.Random rnd, double[] values, double a, double b) + internal static void SamplesUnchecked(System.Random rnd, double[] values, double a, double b) { var y = new double[values.Length]; Gamma.SamplesUnchecked(rnd, values, a, 1.0); diff --git a/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs index ca593468..c6dcb43e 100644 --- a/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs +++ b/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs @@ -1007,7 +1007,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// Evaluates whether this matrix is symmetric. /// - public override sealed bool IsSymmetric() + public sealed override bool IsSymmetric() { return true; } @@ -1015,7 +1015,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// Evaluates whether this matrix is hermitian (conjugate symmetric). /// - public override sealed bool IsHermitian() + public sealed override bool IsHermitian() { for (var k = 0; k < _data.Length; k ++) { diff --git a/src/Numerics/LinearAlgebra/Complex/Matrix.cs b/src/Numerics/LinearAlgebra/Complex/Matrix.cs index 0b111ca4..f113dc65 100644 --- a/src/Numerics/LinearAlgebra/Complex/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Complex/Matrix.cs @@ -69,7 +69,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// Returns the conjugate transpose of this matrix. /// /// The conjugate transpose of this matrix. - public override sealed Matrix ConjugateTranspose() + public sealed override Matrix ConjugateTranspose() { var ret = Transpose(); ret.MapInplace(c => c.Conjugate(), Zeros.AllowSkip); @@ -363,7 +363,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// The pointwise denominator matrix to use /// The result of the modulus. - protected override sealed void DoPointwiseModulus(Matrix divisor, Matrix result) + protected sealed override void DoPointwiseModulus(Matrix divisor, Matrix result) { throw new NotSupportedException(); } @@ -374,7 +374,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// The pointwise denominator matrix to use /// The result of the modulus. - protected override sealed void DoPointwiseRemainder(Matrix divisor, Matrix result) + protected sealed override void DoPointwiseRemainder(Matrix divisor, Matrix result) { throw new NotSupportedException(); } @@ -385,7 +385,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// The scalar denominator to use. /// Matrix to store the results in. - protected override sealed void DoModulus(Complex divisor, Matrix result) + protected sealed override void DoModulus(Complex divisor, Matrix result) { throw new NotSupportedException(); } @@ -396,7 +396,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// The scalar numerator to use. /// A vector to store the results in. - protected override sealed void DoModulusByThis(Complex dividend, Matrix result) + protected sealed override void DoModulusByThis(Complex dividend, Matrix result) { throw new NotSupportedException(); } @@ -407,7 +407,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// The scalar denominator to use. /// Matrix to store the results in. - protected override sealed void DoRemainder(Complex divisor, Matrix result) + protected sealed override void DoRemainder(Complex divisor, Matrix result) { throw new NotSupportedException(); } @@ -418,7 +418,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// The scalar numerator to use. /// A vector to store the results in. - protected override sealed void DoRemainderByThis(Complex dividend, Matrix result) + protected sealed override void DoRemainderByThis(Complex dividend, Matrix result) { throw new NotSupportedException(); } @@ -559,7 +559,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// Normalizes all row vectors to a unit p-norm. /// Typical values for p are 1.0 (L1, Manhattan norm), 2.0 (L2, Euclidean norm) and positive infinity (infinity norm) /// - public override sealed Matrix NormalizeRows(double norm) + public sealed override Matrix NormalizeRows(double norm) { var norminv = ((DenseVectorStorage)RowNorms(norm).Storage).Data; for (int i = 0; i < norminv.Length; i++) @@ -576,7 +576,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// Normalizes all column vectors to a unit p-norm. /// Typical values for p are 1.0 (L1, Manhattan norm), 2.0 (L2, Euclidean norm) and positive infinity (infinity norm) /// - public override sealed Matrix NormalizeColumns(double norm) + public sealed override Matrix NormalizeColumns(double norm) { var norminv = ((DenseVectorStorage)ColumnNorms(norm).Storage).Data; for (int i = 0; i < norminv.Length; i++) diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/ILUTPPreconditioner.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/ILUTPPreconditioner.cs index f9499eb3..d660a3e5 100644 --- a/src/Numerics/LinearAlgebra/Complex/Solvers/ILUTPPreconditioner.cs +++ b/src/Numerics/LinearAlgebra/Complex/Solvers/ILUTPPreconditioner.cs @@ -112,11 +112,11 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers /// Initializes a new instance of the class with the specified settings. /// /// - /// The amount of fill that is allowed in the matrix. The value is a fraction of + /// The amount of fill that is allowed in the matrix. The value is a fraction of /// the number of non-zero entries in the original matrix. Values should be positive. /// /// - /// The absolute drop tolerance which indicates below what absolute value an entry + /// The absolute drop tolerance which indicates below what absolute value an entry /// will be dropped from the matrix. A drop tolerance of 0.0 means that no values /// will be dropped. Values should always be positive. /// @@ -156,7 +156,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers /// Values should always be positive and can be higher than 1.0. A value lower /// than 1.0 means that the eventual preconditioner matrix will have fewer /// non-zero entries as the original matrix. A value higher than 1.0 means that - /// the eventual preconditioner can have more non-zero values than the original + /// the eventual preconditioner can have more non-zero values than the original /// matrix. /// /// @@ -187,7 +187,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers /// /// /// The values should always be positive and can be larger than 1.0. A low value will - /// keep more small numbers in the preconditioner matrix. A high value will remove + /// keep more small numbers in the preconditioner matrix. A high value will remove /// more small numbers from the preconditioner matrix. /// /// @@ -218,7 +218,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers /// /// /// The pivot tolerance is used to calculate if pivoting is necessary. Pivoting - /// will take place if any of the values in a row is bigger than the + /// will take place if any of the values in a row is bigger than the /// diagonal value of that row divided by the pivot tolerance, i.e. pivoting /// will take place if row(i,j) > row(i,i) / PivotTolerance for /// any j that is not equal to i. @@ -291,8 +291,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers /// Initializes the preconditioner and loads the internal data structures. /// /// - /// The upon which this preconditioner is based. Note that the - /// method takes a general matrix type. However internally the data is stored + /// The upon which this preconditioner is based. Note that the + /// method takes a general matrix type. However internally the data is stored /// as a sparse matrix. Therefore it is not recommended to pass a dense matrix. /// /// If is . @@ -309,7 +309,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers throw new ArgumentException(Resources.ArgumentMatrixSquare, "matrix"); } - var sparseMatrix = (matrix is SparseMatrix) ? matrix as SparseMatrix : SparseMatrix.OfMatrix(matrix); + var sparseMatrix = matrix as SparseMatrix ?? SparseMatrix.OfMatrix(matrix); // The creation of the preconditioner follows the following algorithm. // spaceLeft = lfilNnz * nnz(A) @@ -347,7 +347,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers // lfil = spaceRow - nnz(L(i,:)) // space for this row of U // u(i,j) = w(j) for j = i, .. , n // only the largest lfil - 1 elements // w = 0 - // + // // if max(U(i,i + 1: n)) > U(i,i) / pivTol then // pivot if necessary // { // pivot by swapping the max and the diagonal entries @@ -797,7 +797,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers } /// - /// Sort the given integers in a decreasing fashion using heapsort algorithm + /// Sort the given integers in a decreasing fashion using heapsort algorithm /// /// Array of values to sort /// Length of diff --git a/src/Numerics/LinearAlgebra/Complex/Vector.cs b/src/Numerics/LinearAlgebra/Complex/Vector.cs index 068634cb..781ec3e5 100644 --- a/src/Numerics/LinearAlgebra/Complex/Vector.cs +++ b/src/Numerics/LinearAlgebra/Complex/Vector.cs @@ -211,7 +211,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// The pointwise denominator vector to use. /// The result of the modulus. - protected override sealed void DoPointwiseModulus(Vector divisor, Vector result) + protected sealed override void DoPointwiseModulus(Vector divisor, Vector result) { throw new NotSupportedException(); } @@ -222,7 +222,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// The pointwise denominator vector to use. /// The result of the modulus. - protected override sealed void DoPointwiseRemainder(Vector divisor, Vector result) + protected sealed override void DoPointwiseRemainder(Vector divisor, Vector result) { throw new NotSupportedException(); } @@ -281,7 +281,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// The scalar denominator to use. /// A vector to store the results in. - protected override sealed void DoModulus(Complex divisor, Vector result) + protected sealed override void DoModulus(Complex divisor, Vector result) { throw new NotSupportedException(); } @@ -292,7 +292,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// The scalar numerator to use. /// A vector to store the results in. - protected override sealed void DoModulusByThis(Complex dividend, Vector result) + protected sealed override void DoModulusByThis(Complex dividend, Vector result) { throw new NotSupportedException(); } @@ -303,7 +303,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// The scalar denominator to use. /// A vector to store the results in. - protected override sealed void DoRemainder(Complex divisor, Vector result) + protected sealed override void DoRemainder(Complex divisor, Vector result) { throw new NotSupportedException(); } @@ -314,7 +314,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// The scalar numerator to use. /// A vector to store the results in. - protected override sealed void DoRemainderByThis(Complex dividend, Vector result) + protected sealed override void DoRemainderByThis(Complex dividend, Vector result) { throw new NotSupportedException(); } diff --git a/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs index 989632f4..97af0e6e 100644 --- a/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs +++ b/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs @@ -1001,7 +1001,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// Evaluates whether this matrix is symmetric. /// - public override sealed bool IsSymmetric() + public sealed override bool IsSymmetric() { return true; } @@ -1009,7 +1009,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// Evaluates whether this matrix is hermitian (conjugate symmetric). /// - public override sealed bool IsHermitian() + public sealed override bool IsHermitian() { for (var k = 0; k < _data.Length; k++) { diff --git a/src/Numerics/LinearAlgebra/Complex32/Matrix.cs b/src/Numerics/LinearAlgebra/Complex32/Matrix.cs index a4501582..f2609eed 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Matrix.cs @@ -64,7 +64,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// Returns the conjugate transpose of this matrix. /// /// The conjugate transpose of this matrix. - public override sealed Matrix ConjugateTranspose() + public sealed override Matrix ConjugateTranspose() { var ret = Transpose(); ret.MapInplace(c => c.Conjugate(), Zeros.AllowSkip); @@ -358,7 +358,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// The pointwise denominator matrix to use /// The result of the modulus. - protected override sealed void DoPointwiseModulus(Matrix divisor, Matrix result) + protected sealed override void DoPointwiseModulus(Matrix divisor, Matrix result) { throw new NotSupportedException(); } @@ -369,7 +369,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// The pointwise denominator matrix to use /// The result of the modulus. - protected override sealed void DoPointwiseRemainder(Matrix divisor, Matrix result) + protected sealed override void DoPointwiseRemainder(Matrix divisor, Matrix result) { throw new NotSupportedException(); } @@ -380,7 +380,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// The scalar denominator to use. /// Matrix to store the results in. - protected override sealed void DoModulus(Complex32 divisor, Matrix result) + protected sealed override void DoModulus(Complex32 divisor, Matrix result) { throw new NotSupportedException(); } @@ -391,7 +391,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// The scalar numerator to use. /// A vector to store the results in. - protected override sealed void DoModulusByThis(Complex32 dividend, Matrix result) + protected sealed override void DoModulusByThis(Complex32 dividend, Matrix result) { throw new NotSupportedException(); } @@ -402,7 +402,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// The scalar denominator to use. /// Matrix to store the results in. - protected override sealed void DoRemainder(Complex32 divisor, Matrix result) + protected sealed override void DoRemainder(Complex32 divisor, Matrix result) { throw new NotSupportedException(); } @@ -413,7 +413,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// The scalar numerator to use. /// A vector to store the results in. - protected override sealed void DoRemainderByThis(Complex32 dividend, Matrix result) + protected sealed override void DoRemainderByThis(Complex32 dividend, Matrix result) { throw new NotSupportedException(); } @@ -552,7 +552,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// Normalizes all row vectors to a unit p-norm. /// Typical values for p are 1.0 (L1, Manhattan norm), 2.0 (L2, Euclidean norm) and positive infinity (infinity norm) /// - public override sealed Matrix NormalizeRows(double norm) + public sealed override Matrix NormalizeRows(double norm) { var norminv = ((DenseVectorStorage)RowNorms(norm).Storage).Data; for (int i = 0; i < norminv.Length; i++) @@ -569,7 +569,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// Normalizes all column vectors to a unit p-norm. /// Typical values for p are 1.0 (L1, Manhattan norm), 2.0 (L2, Euclidean norm) and positive infinity (infinity norm) /// - public override sealed Matrix NormalizeColumns(double norm) + public sealed override Matrix NormalizeColumns(double norm) { var norminv = ((DenseVectorStorage)ColumnNorms(norm).Storage).Data; for (int i = 0; i < norminv.Length; i++) diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/ILUTPPreconditioner.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/ILUTPPreconditioner.cs index b12d6158..ba6af38e 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Solvers/ILUTPPreconditioner.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/ILUTPPreconditioner.cs @@ -107,11 +107,11 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers /// Initializes a new instance of the class with the specified settings. /// /// - /// The amount of fill that is allowed in the matrix. The value is a fraction of + /// The amount of fill that is allowed in the matrix. The value is a fraction of /// the number of non-zero entries in the original matrix. Values should be positive. /// /// - /// The absolute drop tolerance which indicates below what absolute value an entry + /// The absolute drop tolerance which indicates below what absolute value an entry /// will be dropped from the matrix. A drop tolerance of 0.0 means that no values /// will be dropped. Values should always be positive. /// @@ -151,7 +151,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers /// Values should always be positive and can be higher than 1.0. A value lower /// than 1.0 means that the eventual preconditioner matrix will have fewer /// non-zero entries as the original matrix. A value higher than 1.0 means that - /// the eventual preconditioner can have more non-zero values than the original + /// the eventual preconditioner can have more non-zero values than the original /// matrix. /// /// @@ -182,7 +182,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers /// /// /// The values should always be positive and can be larger than 1.0. A low value will - /// keep more small numbers in the preconditioner matrix. A high value will remove + /// keep more small numbers in the preconditioner matrix. A high value will remove /// more small numbers from the preconditioner matrix. /// /// @@ -213,7 +213,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers /// /// /// The pivot tolerance is used to calculate if pivoting is necessary. Pivoting - /// will take place if any of the values in a row is bigger than the + /// will take place if any of the values in a row is bigger than the /// diagonal value of that row divided by the pivot tolerance, i.e. pivoting /// will take place if row(i,j) > row(i,i) / PivotTolerance for /// any j that is not equal to i. @@ -286,8 +286,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers /// Initializes the preconditioner and loads the internal data structures. /// /// - /// The upon which this preconditioner is based. Note that the - /// method takes a general matrix type. However internally the data is stored + /// The upon which this preconditioner is based. Note that the + /// method takes a general matrix type. However internally the data is stored /// as a sparse matrix. Therefore it is not recommended to pass a dense matrix. /// /// If is . @@ -304,7 +304,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers throw new ArgumentException(Resources.ArgumentMatrixSquare, "matrix"); } - var sparseMatrix = (matrix is SparseMatrix) ? matrix as SparseMatrix : SparseMatrix.OfMatrix(matrix); + var sparseMatrix = matrix as SparseMatrix ?? SparseMatrix.OfMatrix(matrix); // The creation of the preconditioner follows the following algorithm. // spaceLeft = lfilNnz * nnz(A) @@ -342,7 +342,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers // lfil = spaceRow - nnz(L(i,:)) // space for this row of U // u(i,j) = w(j) for j = i, .. , n // only the largest lfil - 1 elements // w = 0 - // + // // if max(U(i,i + 1: n)) > U(i,i) / pivTol then // pivot if necessary // { // pivot by swapping the max and the diagonal entries @@ -792,7 +792,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers } /// - /// Sort the given integers in a decreasing fashion using heapsort algorithm + /// Sort the given integers in a decreasing fashion using heapsort algorithm /// /// Array of values to sort /// Length of diff --git a/src/Numerics/LinearAlgebra/Complex32/Vector.cs b/src/Numerics/LinearAlgebra/Complex32/Vector.cs index 392a1d08..f98b62ab 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Vector.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Vector.cs @@ -206,7 +206,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// The pointwise denominator vector to use. /// The result of the modulus. - protected override sealed void DoPointwiseModulus(Vector divisor, Vector result) + protected sealed override void DoPointwiseModulus(Vector divisor, Vector result) { throw new NotSupportedException(); } @@ -217,7 +217,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// The pointwise denominator vector to use. /// The result of the modulus. - protected override sealed void DoPointwiseRemainder(Vector divisor, Vector result) + protected sealed override void DoPointwiseRemainder(Vector divisor, Vector result) { throw new NotSupportedException(); } @@ -276,7 +276,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// The scalar denominator to use. /// A vector to store the results in. - protected override sealed void DoModulus(Complex32 divisor, Vector result) + protected sealed override void DoModulus(Complex32 divisor, Vector result) { throw new NotSupportedException(); } @@ -287,7 +287,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// The scalar numerator to use. /// A vector to store the results in. - protected override sealed void DoModulusByThis(Complex32 dividend, Vector result) + protected sealed override void DoModulusByThis(Complex32 dividend, Vector result) { throw new NotSupportedException(); } @@ -298,7 +298,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// The scalar denominator to use. /// A vector to store the results in. - protected override sealed void DoRemainder(Complex32 divisor, Vector result) + protected sealed override void DoRemainder(Complex32 divisor, Vector result) { throw new NotSupportedException(); } @@ -309,7 +309,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// The scalar numerator to use. /// A vector to store the results in. - protected override sealed void DoRemainderByThis(Complex32 dividend, Vector result) + protected sealed override void DoRemainderByThis(Complex32 dividend, Vector result) { throw new NotSupportedException(); } diff --git a/src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs index 79189fef..6885cf1a 100644 --- a/src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs +++ b/src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs @@ -850,7 +850,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// Evaluates whether this matrix is symmetric. /// - public override sealed bool IsSymmetric() + public sealed override bool IsSymmetric() { return true; } diff --git a/src/Numerics/LinearAlgebra/Double/Matrix.cs b/src/Numerics/LinearAlgebra/Double/Matrix.cs index edf8c603..a3c16b2c 100644 --- a/src/Numerics/LinearAlgebra/Double/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Double/Matrix.cs @@ -62,7 +62,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// Returns the conjugate transpose of this matrix. /// /// The conjugate transpose of this matrix. - public override sealed Matrix ConjugateTranspose() + public sealed override Matrix ConjugateTranspose() { return Transpose(); } @@ -71,7 +71,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// Complex conjugates each element of this matrix and place the results into the result matrix. /// /// The result of the conjugation. - protected override sealed void DoConjugate(Matrix result) + protected sealed override void DoConjugate(Matrix result) { if (ReferenceEquals(this, result)) { @@ -229,7 +229,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// The matrix to multiply with. /// The result of the multiplication. - protected override sealed void DoConjugateTransposeAndMultiply(Matrix other, Matrix result) + protected sealed override void DoConjugateTransposeAndMultiply(Matrix other, Matrix result) { DoTransposeAndMultiply(other, result); } @@ -260,7 +260,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// The matrix to multiply with. /// The result of the multiplication. - protected override sealed void DoConjugateTransposeThisAndMultiply(Matrix other, Matrix result) + protected sealed override void DoConjugateTransposeThisAndMultiply(Matrix other, Matrix result) { DoTransposeThisAndMultiply(other, result); } @@ -288,7 +288,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// The vector to multiply with. /// The result of the multiplication. - protected override sealed void DoConjugateTransposeThisAndMultiply(Vector rightSide, Vector result) + protected sealed override void DoConjugateTransposeThisAndMultiply(Vector rightSide, Vector result) { DoTransposeThisAndMultiply(rightSide, result); } @@ -523,7 +523,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// Normalizes all row vectors to a unit p-norm. /// Typical values for p are 1.0 (L1, Manhattan norm), 2.0 (L2, Euclidean norm) and positive infinity (infinity norm) /// - public override sealed Matrix NormalizeRows(double norm) + public sealed override Matrix NormalizeRows(double norm) { var norminv = ((DenseVectorStorage)RowNorms(norm).Storage).Data; for (int i = 0; i < norminv.Length; i++) @@ -540,7 +540,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// Normalizes all column vectors to a unit p-norm. /// Typical values for p are 1.0 (L1, Manhattan norm), 2.0 (L2, Euclidean norm) and positive infinity (infinity norm) /// - public override sealed Matrix NormalizeColumns(double norm) + public sealed override Matrix NormalizeColumns(double norm) { var norminv = ((DenseVectorStorage)ColumnNorms(norm).Storage).Data; for (int i = 0; i < norminv.Length; i++) @@ -617,7 +617,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// Evaluates whether this matrix is hermitian (conjugate symmetric). /// - public override sealed bool IsHermitian() + public sealed override bool IsHermitian() { return IsSymmetric(); } diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/ILUTPPreconditioner.cs b/src/Numerics/LinearAlgebra/Double/Solvers/ILUTPPreconditioner.cs index a9e680ab..4bec682e 100644 --- a/src/Numerics/LinearAlgebra/Double/Solvers/ILUTPPreconditioner.cs +++ b/src/Numerics/LinearAlgebra/Double/Solvers/ILUTPPreconditioner.cs @@ -105,11 +105,11 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers /// Initializes a new instance of the class with the specified settings. /// /// - /// The amount of fill that is allowed in the matrix. The value is a fraction of + /// The amount of fill that is allowed in the matrix. The value is a fraction of /// the number of non-zero entries in the original matrix. Values should be positive. /// /// - /// The absolute drop tolerance which indicates below what absolute value an entry + /// The absolute drop tolerance which indicates below what absolute value an entry /// will be dropped from the matrix. A drop tolerance of 0.0 means that no values /// will be dropped. Values should always be positive. /// @@ -149,7 +149,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers /// Values should always be positive and can be higher than 1.0. A value lower /// than 1.0 means that the eventual preconditioner matrix will have fewer /// non-zero entries as the original matrix. A value higher than 1.0 means that - /// the eventual preconditioner can have more non-zero values than the original + /// the eventual preconditioner can have more non-zero values than the original /// matrix. /// /// @@ -180,7 +180,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers /// /// /// The values should always be positive and can be larger than 1.0. A low value will - /// keep more small numbers in the preconditioner matrix. A high value will remove + /// keep more small numbers in the preconditioner matrix. A high value will remove /// more small numbers from the preconditioner matrix. /// /// @@ -211,7 +211,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers /// /// /// The pivot tolerance is used to calculate if pivoting is necessary. Pivoting - /// will take place if any of the values in a row is bigger than the + /// will take place if any of the values in a row is bigger than the /// diagonal value of that row divided by the pivot tolerance, i.e. pivoting /// will take place if row(i,j) > row(i,i) / PivotTolerance for /// any j that is not equal to i. @@ -284,8 +284,8 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers /// Initializes the preconditioner and loads the internal data structures. /// /// - /// The upon which this preconditioner is based. Note that the - /// method takes a general matrix type. However internally the data is stored + /// The upon which this preconditioner is based. Note that the + /// method takes a general matrix type. However internally the data is stored /// as a sparse matrix. Therefore it is not recommended to pass a dense matrix. /// /// If is . @@ -302,7 +302,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers throw new ArgumentException(Resources.ArgumentMatrixSquare, "matrix"); } - var sparseMatrix = (matrix is SparseMatrix) ? matrix as SparseMatrix : SparseMatrix.OfMatrix(matrix); + var sparseMatrix = matrix as SparseMatrix ?? SparseMatrix.OfMatrix(matrix); // The creation of the preconditioner follows the following algorithm. // spaceLeft = lfilNnz * nnz(A) @@ -340,7 +340,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers // lfil = spaceRow - nnz(L(i,:)) // space for this row of U // u(i,j) = w(j) for j = i, .. , n // only the largest lfil - 1 elements // w = 0 - // + // // if max(U(i,i + 1: n)) > U(i,i) / pivTol then // pivot if necessary // { // pivot by swapping the max and the diagonal entries @@ -790,7 +790,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers } /// - /// Sort the given integers in a decreasing fashion using heapsort algorithm + /// Sort the given integers in a decreasing fashion using heapsort algorithm /// /// Array of values to sort /// Length of diff --git a/src/Numerics/LinearAlgebra/Double/Vector.cs b/src/Numerics/LinearAlgebra/Double/Vector.cs index d72d12f8..ee35ad63 100644 --- a/src/Numerics/LinearAlgebra/Double/Vector.cs +++ b/src/Numerics/LinearAlgebra/Double/Vector.cs @@ -60,7 +60,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// Conjugates vector and save result to /// /// Target vector - protected override sealed void DoConjugate(Vector result) + protected sealed override void DoConjugate(Vector result) { if (ReferenceEquals(this, result)) { @@ -263,7 +263,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// The other vector. /// The sum of conj(a[i])*b[i] for all i. - protected override sealed double DoConjugateDotProduct(Vector other) + protected sealed override double DoConjugateDotProduct(Vector other) { return DoDotProduct(other); } diff --git a/src/Numerics/LinearAlgebra/Matrix.BCL.cs b/src/Numerics/LinearAlgebra/Matrix.BCL.cs index 7c329c14..2eea8088 100644 --- a/src/Numerics/LinearAlgebra/Matrix.BCL.cs +++ b/src/Numerics/LinearAlgebra/Matrix.BCL.cs @@ -376,7 +376,7 @@ namespace MathNet.Numerics.LinearAlgebra /// Returns a string that summarizes this matrix. /// The maximum number of cells can be configured in the class. /// - public override sealed string ToString() + public sealed override string ToString() { return string.Concat(ToTypeString(), Environment.NewLine, ToMatrixString()); } diff --git a/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs index 6828cf12..0ace9829 100644 --- a/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs +++ b/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs @@ -850,7 +850,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// Evaluates whether this matrix is symmetric. /// - public override sealed bool IsSymmetric() + public sealed override bool IsSymmetric() { return true; } diff --git a/src/Numerics/LinearAlgebra/Single/Matrix.cs b/src/Numerics/LinearAlgebra/Single/Matrix.cs index 599fec1c..9bc6fe48 100644 --- a/src/Numerics/LinearAlgebra/Single/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Single/Matrix.cs @@ -62,7 +62,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// Returns the conjugate transpose of this matrix. /// /// The conjugate transpose of this matrix. - public override sealed Matrix ConjugateTranspose() + public sealed override Matrix ConjugateTranspose() { return Transpose(); } @@ -71,7 +71,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// Complex conjugates each element of this matrix and place the results into the result matrix. /// /// The result of the conjugation. - protected override sealed void DoConjugate(Matrix result) + protected sealed override void DoConjugate(Matrix result) { if (ReferenceEquals(this, result)) { @@ -229,7 +229,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// The matrix to multiply with. /// The result of the multiplication. - protected override sealed void DoConjugateTransposeAndMultiply(Matrix other, Matrix result) + protected sealed override void DoConjugateTransposeAndMultiply(Matrix other, Matrix result) { DoTransposeAndMultiply(other, result); } @@ -260,7 +260,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// The matrix to multiply with. /// The result of the multiplication. - protected override sealed void DoConjugateTransposeThisAndMultiply(Matrix other, Matrix result) + protected sealed override void DoConjugateTransposeThisAndMultiply(Matrix other, Matrix result) { DoTransposeThisAndMultiply(other, result); } @@ -288,7 +288,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// The vector to multiply with. /// The result of the multiplication. - protected override sealed void DoConjugateTransposeThisAndMultiply(Vector rightSide, Vector result) + protected sealed override void DoConjugateTransposeThisAndMultiply(Vector rightSide, Vector result) { DoTransposeThisAndMultiply(rightSide, result); } @@ -544,7 +544,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// Normalizes all row vectors to a unit p-norm. /// Typical values for p are 1.0 (L1, Manhattan norm), 2.0 (L2, Euclidean norm) and positive infinity (infinity norm) /// - public override sealed Matrix NormalizeRows(double norm) + public sealed override Matrix NormalizeRows(double norm) { var norminv = ((DenseVectorStorage)RowNorms(norm).Storage).Data; for (int i = 0; i < norminv.Length; i++) @@ -561,7 +561,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// Normalizes all column vectors to a unit p-norm. /// Typical values for p are 1.0 (L1, Manhattan norm), 2.0 (L2, Euclidean norm) and positive infinity (infinity norm) /// - public override sealed Matrix NormalizeColumns(double norm) + public sealed override Matrix NormalizeColumns(double norm) { var norminv = ((DenseVectorStorage)ColumnNorms(norm).Storage).Data; for (int i = 0; i < norminv.Length; i++) @@ -617,7 +617,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// Evaluates whether this matrix is hermitian (conjugate symmetric). /// - public override sealed bool IsHermitian() + public sealed override bool IsHermitian() { return IsSymmetric(); } diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/ILUTPPreconditioner.cs b/src/Numerics/LinearAlgebra/Single/Solvers/ILUTPPreconditioner.cs index 172860aa..18dbece7 100644 --- a/src/Numerics/LinearAlgebra/Single/Solvers/ILUTPPreconditioner.cs +++ b/src/Numerics/LinearAlgebra/Single/Solvers/ILUTPPreconditioner.cs @@ -105,11 +105,11 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// Initializes a new instance of the class with the specified settings. /// /// - /// The amount of fill that is allowed in the matrix. The value is a fraction of + /// The amount of fill that is allowed in the matrix. The value is a fraction of /// the number of non-zero entries in the original matrix. Values should be positive. /// /// - /// The absolute drop tolerance which indicates below what absolute value an entry + /// The absolute drop tolerance which indicates below what absolute value an entry /// will be dropped from the matrix. A drop tolerance of 0.0 means that no values /// will be dropped. Values should always be positive. /// @@ -149,7 +149,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// Values should always be positive and can be higher than 1.0. A value lower /// than 1.0 means that the eventual preconditioner matrix will have fewer /// non-zero entries as the original matrix. A value higher than 1.0 means that - /// the eventual preconditioner can have more non-zero values than the original + /// the eventual preconditioner can have more non-zero values than the original /// matrix. /// /// @@ -180,7 +180,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// /// /// The values should always be positive and can be larger than 1.0. A low value will - /// keep more small numbers in the preconditioner matrix. A high value will remove + /// keep more small numbers in the preconditioner matrix. A high value will remove /// more small numbers from the preconditioner matrix. /// /// @@ -211,7 +211,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// /// /// The pivot tolerance is used to calculate if pivoting is necessary. Pivoting - /// will take place if any of the values in a row is bigger than the + /// will take place if any of the values in a row is bigger than the /// diagonal value of that row divided by the pivot tolerance, i.e. pivoting /// will take place if row(i,j) > row(i,i) / PivotTolerance for /// any j that is not equal to i. @@ -284,8 +284,8 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// Initializes the preconditioner and loads the internal data structures. /// /// - /// The upon which this preconditioner is based. Note that the - /// method takes a general matrix type. However internally the data is stored + /// The upon which this preconditioner is based. Note that the + /// method takes a general matrix type. However internally the data is stored /// as a sparse matrix. Therefore it is not recommended to pass a dense matrix. /// /// If is . @@ -302,7 +302,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers throw new ArgumentException(Resources.ArgumentMatrixSquare, "matrix"); } - var sparseMatrix = (matrix is SparseMatrix) ? matrix as SparseMatrix : SparseMatrix.OfMatrix(matrix); + SparseMatrix sparseMatrix = matrix as SparseMatrix ?? SparseMatrix.OfMatrix(matrix); // The creation of the preconditioner follows the following algorithm. // spaceLeft = lfilNnz * nnz(A) @@ -340,7 +340,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers // lfil = spaceRow - nnz(L(i,:)) // space for this row of U // u(i,j) = w(j) for j = i, .. , n // only the largest lfil - 1 elements // w = 0 - // + // // if max(U(i,i + 1: n)) > U(i,i) / pivTol then // pivot if necessary // { // pivot by swapping the max and the diagonal entries @@ -790,7 +790,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers } /// - /// Sort the given integers in a decreasing fashion using heapsort algorithm + /// Sort the given integers in a decreasing fashion using heapsort algorithm /// /// Array of values to sort /// Length of diff --git a/src/Numerics/LinearAlgebra/Single/Vector.cs b/src/Numerics/LinearAlgebra/Single/Vector.cs index 1a8de510..53d52a7e 100644 --- a/src/Numerics/LinearAlgebra/Single/Vector.cs +++ b/src/Numerics/LinearAlgebra/Single/Vector.cs @@ -60,7 +60,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// Conjugates vector and save result to /// /// Target vector - protected override sealed void DoConjugate(Vector result) + protected sealed override void DoConjugate(Vector result) { if (ReferenceEquals(this, result)) { @@ -263,7 +263,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// The other vector. /// The sum of conj(a[i])*b[i] for all i. - protected override sealed float DoConjugateDotProduct(Vector other) + protected sealed override float DoConjugateDotProduct(Vector other) { return DoDotProduct(other); } diff --git a/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs b/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs index 89e8e5b6..a1c2799e 100644 --- a/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs +++ b/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs @@ -172,7 +172,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage /// true if the specified is equal to the current ; otherwise, false. /// /// The to compare with the current . - public override sealed bool Equals(object obj) + public sealed override bool Equals(object obj) { return Equals(obj as MatrixStorage); } diff --git a/src/Numerics/LinearAlgebra/Storage/VectorStorage.cs b/src/Numerics/LinearAlgebra/Storage/VectorStorage.cs index 89dba3fe..8c7a2c74 100644 --- a/src/Numerics/LinearAlgebra/Storage/VectorStorage.cs +++ b/src/Numerics/LinearAlgebra/Storage/VectorStorage.cs @@ -148,7 +148,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage /// true if the specified is equal to the current ; otherwise, false. /// /// The to compare with the current . - public override sealed bool Equals(object obj) + public sealed override bool Equals(object obj) { return Equals(obj as VectorStorage); } diff --git a/src/Numerics/LinearAlgebra/Vector.BCL.cs b/src/Numerics/LinearAlgebra/Vector.BCL.cs index 6b95a422..2ae95477 100644 --- a/src/Numerics/LinearAlgebra/Vector.BCL.cs +++ b/src/Numerics/LinearAlgebra/Vector.BCL.cs @@ -61,7 +61,7 @@ namespace MathNet.Numerics.LinearAlgebra /// /// true if the specified is equal to this instance; otherwise, false. /// - public override sealed bool Equals(object obj) + public sealed override bool Equals(object obj) { var other = obj as Vector; return other != null && Storage.Equals(other.Storage); @@ -73,7 +73,7 @@ namespace MathNet.Numerics.LinearAlgebra /// /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. /// - public override sealed int GetHashCode() + public sealed override int GetHashCode() { return Storage.GetHashCode(); } @@ -399,7 +399,7 @@ namespace MathNet.Numerics.LinearAlgebra /// Returns a string that summarizes this vector. /// The maximum number of cells can be configured in the class. /// - public override sealed string ToString() + public sealed override string ToString() { return string.Concat(ToTypeString(), Environment.NewLine, ToVectorString()); } diff --git a/src/Numerics/Permutation.cs b/src/Numerics/Permutation.cs index 0e5d93fb..08d462a0 100644 --- a/src/Numerics/Permutation.cs +++ b/src/Numerics/Permutation.cs @@ -177,7 +177,7 @@ namespace MathNet.Numerics /// An array which represents where each integer is permuted too: indices[i] represents that integer i /// is permuted to location indices[i]. /// True if represents a proper permutation, false otherwise. - static private bool CheckForProperPermutation(int[] indices) + static bool CheckForProperPermutation(int[] indices) { var idxCheck = new bool[indices.Length]; diff --git a/src/Numerics/Statistics/MCMC/HybridMC.cs b/src/Numerics/Statistics/MCMC/HybridMC.cs index 0c917d97..16b589be 100644 --- a/src/Numerics/Statistics/MCMC/HybridMC.cs +++ b/src/Numerics/Statistics/MCMC/HybridMC.cs @@ -85,7 +85,7 @@ namespace MathNet.Numerics.Statistics.Mcmc /// The number of iterations in between returning samples. /// When the number of burnInterval iteration is negative. public HybridMC(double[] x0, DensityLn pdfLnP, int frogLeapSteps, double stepSize, int burnInterval = 0) - : this(x0, pdfLnP, frogLeapSteps, stepSize, burnInterval, new double[x0.Count()], SystemRandomSource.Default, Grad) + : this(x0, pdfLnP, frogLeapSteps, stepSize, burnInterval, new double[x0.Length], SystemRandomSource.Default, Grad) { for (int i = 0; i < _length; i++) { @@ -154,7 +154,7 @@ namespace MathNet.Numerics.Statistics.Mcmc public HybridMC(double[] x0, DensityLn pdfLnP, int frogLeapSteps, double stepSize, int burnInterval, double[] pSdv, System.Random randomSource, DiffMethod diff) : base(x0, pdfLnP, frogLeapSteps, stepSize, burnInterval, randomSource, diff) { - _length = x0.Count(); + _length = x0.Length; MomentumStdDev = pSdv; Initialize(x0); @@ -185,7 +185,7 @@ namespace MathNet.Numerics.Statistics.Mcmc { throw new ArgumentNullException("pSdv", "Standard deviation cannot be null."); } - if (pSdv.Count() != _length) + if (pSdv.Length != _length) { throw new ArgumentOutOfRangeException("pSdv", "Standard deviation of momentum must have same length as sample."); } @@ -263,7 +263,7 @@ namespace MathNet.Numerics.Statistics.Mcmc /// Function which the gradient is to be evaluated. /// The location where the gradient is to be evaluated. /// The gradient of the function at the point x. - static private double[] Grad(DensityLn function, double[] x) + static double[] Grad(DensityLn function, double[] x) { int length = x.Length; var returnValue = new double[length]; diff --git a/src/Numerics/Statistics/MCMC/HybridMCGeneric.cs b/src/Numerics/Statistics/MCMC/HybridMCGeneric.cs index 03bf86dd..28f02ddf 100644 --- a/src/Numerics/Statistics/MCMC/HybridMCGeneric.cs +++ b/src/Numerics/Statistics/MCMC/HybridMCGeneric.cs @@ -42,7 +42,7 @@ namespace MathNet.Numerics.Statistics.Mcmc /// (). /// /// The type of samples this sampler produces. - abstract public class HybridMCGeneric : McmcSampler + public abstract class HybridMCGeneric : McmcSampler { /// /// The delegate type that defines a derivative evaluated at a certain point. @@ -211,21 +211,21 @@ namespace MathNet.Numerics.Statistics.Mcmc /// Use for creating temporary objects in the Burn method. /// /// An object of type T. - abstract protected T Create(); + protected abstract T Create(); /// /// Use for copying objects in the Burn method. /// /// The source of copying. /// A copy of the source object. - abstract protected T Copy(T source); + protected abstract T Copy(T source); /// /// Method for doing dot product. /// /// First vector/scalar in the product. /// Second vector/scalar in the product. - abstract protected double DoProduct(T first, T second); + protected abstract double DoProduct(T first, T second); /// /// Method for adding, multiply the second vector/scalar by factor and then @@ -234,7 +234,7 @@ namespace MathNet.Numerics.Statistics.Mcmc /// First vector/scalar. /// Scalar factor multiplying by the second vector/scalar. /// Second vector/scalar. - abstract protected void DoAdd(ref T first, double factor, T second); + protected abstract void DoAdd(ref T first, double factor, T second); /// /// Multiplying the second vector/scalar by factor and then subtract it from @@ -243,13 +243,13 @@ namespace MathNet.Numerics.Statistics.Mcmc /// First vector/scalar. /// Scalar factor to be multiplied to the second vector/scalar. /// Second vector/scalar. - abstract protected void DoSubtract(ref T first, double factor, T second); + protected abstract void DoSubtract(ref T first, double factor, T second); /// /// Method for sampling a random momentum. /// /// Momentum to be randomized. - abstract protected void RandomizeMomentum(ref T p); + protected abstract void RandomizeMomentum(ref T p); /// /// The Hamiltonian equations that is used to produce the new sample. diff --git a/src/Numerics/Statistics/MCMC/MCMCDiagnostics.cs b/src/Numerics/Statistics/MCMC/MCMCDiagnostics.cs index 6f95b741..f2d941e9 100644 --- a/src/Numerics/Statistics/MCMC/MCMCDiagnostics.cs +++ b/src/Numerics/Statistics/MCMC/MCMCDiagnostics.cs @@ -39,7 +39,7 @@ namespace MathNet.Numerics.Statistics.Mcmc /// Provides utilities to analysis the convergence of a set of samples from /// a . /// - static public class MCMCDiagnostics + public static class MCMCDiagnostics { /// /// Computes the auto correlations of a series evaluated by a function f. @@ -50,7 +50,7 @@ namespace MathNet.Numerics.Statistics.Mcmc /// The auto correlation. /// Throws if lag is zero or if lag is /// greater than or equal to the length of Series. - static public double ACF(IEnumerable series, int lag, Func f) + public static double ACF(IEnumerable series, int lag, Func f) { if (lag < 0) { @@ -78,7 +78,7 @@ namespace MathNet.Numerics.Statistics.Mcmc /// The samples. /// The function use for evaluating the series. /// The effective size when auto correlation is taken into account. - static public double EffectiveSize(IEnumerable series, Func f) + public static double EffectiveSize(IEnumerable series, Func f) { int length = series.Count(); double rho = ACF(series, 1, f); diff --git a/src/Numerics/Statistics/MCMC/UnivariateHybridMC.cs b/src/Numerics/Statistics/MCMC/UnivariateHybridMC.cs index 1cd72c24..b9ab175b 100644 --- a/src/Numerics/Statistics/MCMC/UnivariateHybridMC.cs +++ b/src/Numerics/Statistics/MCMC/UnivariateHybridMC.cs @@ -185,7 +185,7 @@ namespace MathNet.Numerics.Statistics.Mcmc /// Function for which the derivative is to be evaluated. /// The location where the derivative is to be evaluated. /// The derivative of the function at the point x. - static private double Grad(DensityLn function, double x) + static double Grad(DensityLn function, double x) { double h = Math.Max(10e-4, (10e-7) * x); double increment = x + h;