diff --git a/MathNet.Numerics.sln.DotSettings b/MathNet.Numerics.sln.DotSettings index 10562cdc..488e6c6f 100644 --- a/MathNet.Numerics.sln.DotSettings +++ b/MathNet.Numerics.sln.DotSettings @@ -70,10 +70,12 @@ OTHER DEALINGS IN THE SOFTWARE. MKL MSE PDF + PMF QR SAD SAS SPSS + SQR SS SSD SVD @@ -88,8 +90,12 @@ OTHER DEALINGS IN THE SOFTWARE. True True True + True True True + True + True + True True True diff --git a/src/NativeProviders/Windows/MKL/MKLWrapper.vcxproj b/src/NativeProviders/Windows/MKL/MKLWrapper.vcxproj index 08a201bf..8793b00e 100644 --- a/src/NativeProviders/Windows/MKL/MKLWrapper.vcxproj +++ b/src/NativeProviders/Windows/MKL/MKLWrapper.vcxproj @@ -212,4 +212,4 @@ - + \ No newline at end of file diff --git a/src/Numerics.Tests/DistributionTests/Continuous/BurrTests.cs b/src/Numerics.Tests/DistributionTests/Continuous/BurrTests.cs index 39570e98..513305f7 100644 --- a/src/Numerics.Tests/DistributionTests/Continuous/BurrTests.cs +++ b/src/Numerics.Tests/DistributionTests/Continuous/BurrTests.cs @@ -57,9 +57,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void CanCreateBurr(double a, double c, double k) { var n = new Burr(a, c, k); - Assert.AreEqual(a, n.a); - Assert.AreEqual(c, n.c); - Assert.AreEqual(k, n.k); + Assert.AreEqual(a, n.A); + Assert.AreEqual(c, n.C); + Assert.AreEqual(k, n.K); } /// diff --git a/src/Numerics.Tests/DistributionTests/Continuous/InverseGaussianTests.cs b/src/Numerics.Tests/DistributionTests/Continuous/InverseGaussianTests.cs index 74bb186a..3074ea72 100644 --- a/src/Numerics.Tests/DistributionTests/Continuous/InverseGaussianTests.cs +++ b/src/Numerics.Tests/DistributionTests/Continuous/InverseGaussianTests.cs @@ -305,7 +305,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous public void ValidateInverseCumulativeDistribution(double mu, double lambda, double probability, double f) { var n = new InverseGaussian(mu, lambda); - AssertHelpers.AlmostEqualRelative(f, InverseGaussian.ICDF(mu, lambda, probability), precision); + AssertHelpers.AlmostEqualRelative(f, InverseGaussian.InvCDF(mu, lambda, probability), precision); AssertHelpers.AlmostEqualRelative(f, n.InvCDF(probability), precision); } diff --git a/src/Numerics.Tests/DistributionTests/Continuous/TruncatedParetoTests.cs b/src/Numerics.Tests/DistributionTests/Continuous/TruncatedParetoTests.cs index e5ad712f..81238ee6 100644 --- a/src/Numerics.Tests/DistributionTests/Continuous/TruncatedParetoTests.cs +++ b/src/Numerics.Tests/DistributionTests/Continuous/TruncatedParetoTests.cs @@ -350,7 +350,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous { var n = new TruncatedPareto(scale, shape, truncation); AssertHelpers.AlmostEqualRelative(expected, n.InvCDF(p), lowPrecision); - AssertHelpers.AlmostEqualRelative(expected, TruncatedPareto.ICDF(scale, shape, truncation, p), lowPrecision); + AssertHelpers.AlmostEqualRelative(expected, TruncatedPareto.InvCDF(scale, shape, truncation, p), lowPrecision); } /// diff --git a/src/Numerics.Tests/DistributionTests/Discrete/CategoricalTests.cs b/src/Numerics.Tests/DistributionTests/Discrete/CategoricalTests.cs index a8507e3d..6dca6722 100644 --- a/src/Numerics.Tests/DistributionTests/Discrete/CategoricalTests.cs +++ b/src/Numerics.Tests/DistributionTests/Discrete/CategoricalTests.cs @@ -105,9 +105,8 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete public void CategoricalCreateFailsWithNullHistogram() { Histogram h = null; -// ReSharper disable ExpressionIsAlwaysNull +// ReSharper disable once ExpressionIsAlwaysNull Assert.That(() => new Categorical(h), Throws.TypeOf()); -// ReSharper restore ExpressionIsAlwaysNull } /// diff --git a/src/Numerics.Tests/DistributionTests/Multivariate/MultinomialTests.cs b/src/Numerics.Tests/DistributionTests/Multivariate/MultinomialTests.cs index e1c8eac8..9030d2b6 100644 --- a/src/Numerics.Tests/DistributionTests/Multivariate/MultinomialTests.cs +++ b/src/Numerics.Tests/DistributionTests/Multivariate/MultinomialTests.cs @@ -107,9 +107,8 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate public void MultinomialCreateFailsWithNullHistogram() { Histogram h = null; -// ReSharper disable ExpressionIsAlwaysNull +// ReSharper disable once ExpressionIsAlwaysNull Assert.That(() => new Categorical(h), Throws.TypeOf()); -// ReSharper restore ExpressionIsAlwaysNull } /// diff --git a/src/Numerics.Tests/FinancialTests/CompoundReturnTests.cs b/src/Numerics.Tests/FinancialTests/CompoundReturnTests.cs index 89d804fc..2a616928 100644 --- a/src/Numerics.Tests/FinancialTests/CompoundReturnTests.cs +++ b/src/Numerics.Tests/FinancialTests/CompoundReturnTests.cs @@ -43,9 +43,8 @@ namespace MathNet.Numerics.UnitTests.FinancialTests //arrange List inputData = null; //act -// ReSharper disable ExpressionIsAlwaysNull +// ReSharper disable once ExpressionIsAlwaysNull Assert.Throws(() => AbsoluteReturnMeasures.CompoundReturn(inputData)); -// ReSharper restore ExpressionIsAlwaysNull } [Test] diff --git a/src/Numerics.Tests/FinancialTests/DownsideDeviationTests.cs b/src/Numerics.Tests/FinancialTests/DownsideDeviationTests.cs index 5b8003a2..2f4f7bed 100644 --- a/src/Numerics.Tests/FinancialTests/DownsideDeviationTests.cs +++ b/src/Numerics.Tests/FinancialTests/DownsideDeviationTests.cs @@ -108,9 +108,8 @@ namespace MathNet.Numerics.UnitTests.FinancialTests const double minimumAcceptableReturn = 0.05; List inputData = null; //act -// ReSharper disable ExpressionIsAlwaysNull +// ReSharper disable once ExpressionIsAlwaysNull Assert.Throws(() => AbsoluteRiskMeasures.DownsideDeviation(inputData, minimumAcceptableReturn)); -// ReSharper restore ExpressionIsAlwaysNull } } diff --git a/src/Numerics.Tests/FinancialTests/GainLossRatioTests.cs b/src/Numerics.Tests/FinancialTests/GainLossRatioTests.cs index 5d4d8d40..faa6aa99 100644 --- a/src/Numerics.Tests/FinancialTests/GainLossRatioTests.cs +++ b/src/Numerics.Tests/FinancialTests/GainLossRatioTests.cs @@ -45,9 +45,8 @@ namespace MathNet.Numerics.UnitTests.FinancialTests //arrange List inputData = null; //act -// ReSharper disable ExpressionIsAlwaysNull +// ReSharper disable once ExpressionIsAlwaysNull Assert.Throws(() => AbsoluteRiskMeasures.GainLossRatio(inputData)); -// ReSharper restore ExpressionIsAlwaysNull } [Test] diff --git a/src/Numerics.Tests/FinancialTests/GainMeanTests.cs b/src/Numerics.Tests/FinancialTests/GainMeanTests.cs index dccf3686..5c2d9d4f 100644 --- a/src/Numerics.Tests/FinancialTests/GainMeanTests.cs +++ b/src/Numerics.Tests/FinancialTests/GainMeanTests.cs @@ -88,9 +88,8 @@ namespace MathNet.Numerics.UnitTests.FinancialTests //arrange double[] inputData = null; //act -// ReSharper disable ExpressionIsAlwaysNull +// ReSharper disable once ExpressionIsAlwaysNull Assert.Throws(() => AbsoluteReturnMeasures.GainMean(inputData)); -// ReSharper restore ExpressionIsAlwaysNull } [Test] diff --git a/src/Numerics.Tests/FinancialTests/GainStandardDeviationTests.cs b/src/Numerics.Tests/FinancialTests/GainStandardDeviationTests.cs index 2007779c..0ba4eeef 100644 --- a/src/Numerics.Tests/FinancialTests/GainStandardDeviationTests.cs +++ b/src/Numerics.Tests/FinancialTests/GainStandardDeviationTests.cs @@ -113,9 +113,8 @@ namespace MathNet.Numerics.UnitTests.FinancialTests //arrange List inputData = null; //act -// ReSharper disable ExpressionIsAlwaysNull +// ReSharper disable once ExpressionIsAlwaysNull Assert.Throws(() => AbsoluteRiskMeasures.GainStandardDeviation(inputData)); -// ReSharper restore ExpressionIsAlwaysNull } } } diff --git a/src/Numerics.Tests/FinancialTests/LossMeanTests.cs b/src/Numerics.Tests/FinancialTests/LossMeanTests.cs index 9ed83700..0e511319 100644 --- a/src/Numerics.Tests/FinancialTests/LossMeanTests.cs +++ b/src/Numerics.Tests/FinancialTests/LossMeanTests.cs @@ -89,9 +89,8 @@ namespace MathNet.Numerics.UnitTests.FinancialTests //arrange List inputData = null; //act -// ReSharper disable ExpressionIsAlwaysNull +// ReSharper disable once ExpressionIsAlwaysNull Assert.Throws(() => AbsoluteReturnMeasures.LossMean(inputData)); -// ReSharper restore ExpressionIsAlwaysNull } [Test] diff --git a/src/Numerics.Tests/FinancialTests/LossStandardDeviationTests.cs b/src/Numerics.Tests/FinancialTests/LossStandardDeviationTests.cs index a43d71f9..3b6050ec 100644 --- a/src/Numerics.Tests/FinancialTests/LossStandardDeviationTests.cs +++ b/src/Numerics.Tests/FinancialTests/LossStandardDeviationTests.cs @@ -113,9 +113,8 @@ namespace MathNet.Numerics.UnitTests.FinancialTests //arrange List inputData = null; //act -// ReSharper disable ExpressionIsAlwaysNull +// ReSharper disable once ExpressionIsAlwaysNull Assert.Throws(() => AbsoluteRiskMeasures.LossStandardDeviation(inputData)); -// ReSharper restore ExpressionIsAlwaysNull } } } diff --git a/src/Numerics.Tests/FinancialTests/SemiDeviationTests.cs b/src/Numerics.Tests/FinancialTests/SemiDeviationTests.cs index 3576f623..28b60ff6 100644 --- a/src/Numerics.Tests/FinancialTests/SemiDeviationTests.cs +++ b/src/Numerics.Tests/FinancialTests/SemiDeviationTests.cs @@ -104,9 +104,8 @@ namespace MathNet.Numerics.UnitTests.FinancialTests //arrange List inputData = null; //act -// ReSharper disable ExpressionIsAlwaysNull +// ReSharper disable once ExpressionIsAlwaysNull Assert.Throws(() => AbsoluteRiskMeasures.SemiDeviation(inputData)); -// ReSharper restore ExpressionIsAlwaysNull } } } diff --git a/src/Numerics.Tests/LinearAlgebraTests/Complex/Solvers/StopCriterion/IterationCountStopCriteriumTest.cs b/src/Numerics.Tests/LinearAlgebraTests/Complex/Solvers/StopCriterion/IterationCountStopCriteriumTest.cs index 370d9ad0..81a9c24e 100644 --- a/src/Numerics.Tests/LinearAlgebraTests/Complex/Solvers/StopCriterion/IterationCountStopCriteriumTest.cs +++ b/src/Numerics.Tests/LinearAlgebraTests/Complex/Solvers/StopCriterion/IterationCountStopCriteriumTest.cs @@ -136,10 +136,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit var clonedCriterion = clone as IterationCountStopCriterion; Assert.IsNotNull(clonedCriterion); - // ReSharper disable PossibleNullReferenceException + // ReSharper disable once PossibleNullReferenceException Assert.AreEqual(criterion.MaximumNumberOfIterations, clonedCriterion.MaximumNumberOfIterations, "Clone failed"); - - // ReSharper restore PossibleNullReferenceException } } } diff --git a/src/Numerics.Tests/LinearAlgebraTests/Complex32/Solvers/StopCriterion/IterationCountStopCriteriumTest.cs b/src/Numerics.Tests/LinearAlgebraTests/Complex32/Solvers/StopCriterion/IterationCountStopCriteriumTest.cs index 40dad29d..01497696 100644 --- a/src/Numerics.Tests/LinearAlgebraTests/Complex32/Solvers/StopCriterion/IterationCountStopCriteriumTest.cs +++ b/src/Numerics.Tests/LinearAlgebraTests/Complex32/Solvers/StopCriterion/IterationCountStopCriteriumTest.cs @@ -136,10 +136,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr var clonedCriterion = clone as IterationCountStopCriterion; Assert.IsNotNull(clonedCriterion); - // ReSharper disable PossibleNullReferenceException + // ReSharper disable once PossibleNullReferenceException Assert.AreEqual(criterion.MaximumNumberOfIterations, clonedCriterion.MaximumNumberOfIterations, "Clone failed"); - - // ReSharper restore PossibleNullReferenceException } } } diff --git a/src/Numerics.Tests/LinearAlgebraTests/Double/Solvers/StopCriterion/IterationCountStopCriteriumTest.cs b/src/Numerics.Tests/LinearAlgebraTests/Double/Solvers/StopCriterion/IterationCountStopCriteriumTest.cs index cc7002d9..075b19da 100644 --- a/src/Numerics.Tests/LinearAlgebraTests/Double/Solvers/StopCriterion/IterationCountStopCriteriumTest.cs +++ b/src/Numerics.Tests/LinearAlgebraTests/Double/Solvers/StopCriterion/IterationCountStopCriteriumTest.cs @@ -134,10 +134,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite var clonedCriterion = clone as IterationCountStopCriterion; Assert.IsNotNull(clonedCriterion); - // ReSharper disable PossibleNullReferenceException + // ReSharper disable once PossibleNullReferenceException Assert.AreEqual(criterion.MaximumNumberOfIterations, clonedCriterion.MaximumNumberOfIterations, "Clone failed"); - - // ReSharper restore PossibleNullReferenceException } } } diff --git a/src/Numerics.Tests/LinearAlgebraTests/Double/Solvers/StopCriterion/ResidualStopCriteriumTest.cs b/src/Numerics.Tests/LinearAlgebraTests/Double/Solvers/StopCriterion/ResidualStopCriteriumTest.cs index 8993a268..12657968 100644 --- a/src/Numerics.Tests/LinearAlgebraTests/Double/Solvers/StopCriterion/ResidualStopCriteriumTest.cs +++ b/src/Numerics.Tests/LinearAlgebraTests/Double/Solvers/StopCriterion/ResidualStopCriteriumTest.cs @@ -235,7 +235,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite // ReSharper disable PossibleNullReferenceException Assert.AreEqual(criterion.Maximum, clonedCriterion.Maximum, "Clone failed"); Assert.AreEqual(criterion.MinimumIterationsBelowMaximum, clonedCriterion.MinimumIterationsBelowMaximum, "Clone failed"); - // ReSharper restore PossibleNullReferenceException } } diff --git a/src/Numerics.Tests/LinearAlgebraTests/Single/Solvers/StopCriterion/IterationCountStopCriteriumTest.cs b/src/Numerics.Tests/LinearAlgebraTests/Single/Solvers/StopCriterion/IterationCountStopCriteriumTest.cs index c3458c70..1470e409 100644 --- a/src/Numerics.Tests/LinearAlgebraTests/Single/Solvers/StopCriterion/IterationCountStopCriteriumTest.cs +++ b/src/Numerics.Tests/LinearAlgebraTests/Single/Solvers/StopCriterion/IterationCountStopCriteriumTest.cs @@ -134,10 +134,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite var clonedCriterion = clone as IterationCountStopCriterion; Assert.IsNotNull(clonedCriterion); - // ReSharper disable PossibleNullReferenceException + // ReSharper disable once PossibleNullReferenceException Assert.AreEqual(criterion.MaximumNumberOfIterations, clonedCriterion.MaximumNumberOfIterations, "Clone failed"); - - // ReSharper restore PossibleNullReferenceException } } } diff --git a/src/Numerics.Tests/LinearAlgebraTests/Single/Solvers/StopCriterion/ResidualStopCriteriumTest.cs b/src/Numerics.Tests/LinearAlgebraTests/Single/Solvers/StopCriterion/ResidualStopCriteriumTest.cs index 853c6692..037e9efe 100644 --- a/src/Numerics.Tests/LinearAlgebraTests/Single/Solvers/StopCriterion/ResidualStopCriteriumTest.cs +++ b/src/Numerics.Tests/LinearAlgebraTests/Single/Solvers/StopCriterion/ResidualStopCriteriumTest.cs @@ -239,7 +239,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite // ReSharper disable PossibleNullReferenceException Assert.AreEqual(criterion.Maximum, clonedCriterion.Maximum, "Clone failed"); Assert.AreEqual(criterion.MinimumIterationsBelowMaximum, clonedCriterion.MinimumIterationsBelowMaximum, "Clone failed"); - // ReSharper restore PossibleNullReferenceException } } diff --git a/src/Numerics/Compatibility.cs b/src/Numerics/Compatibility.cs index 0122997a..444e41cb 100644 --- a/src/Numerics/Compatibility.cs +++ b/src/Numerics/Compatibility.cs @@ -1,6 +1,6 @@ -using System.Globalization; +#if NET40 +using System.Globalization; -#if NET40 namespace System.Runtime.CompilerServices { internal class FormattableStringFactory @@ -16,13 +16,13 @@ namespace System { internal class FormattableString { - private readonly string format; - private readonly object[] args; + readonly string _format; + readonly object[] _args; public FormattableString(string format, object[] args) { - this.format = format; - this.args = args; + _format = format; + _args = args; } public static string Invariant(FormattableString messageFormat) @@ -32,12 +32,12 @@ namespace System public string ToString(IFormatProvider formatProvider) { - return string.Format(formatProvider, format, args); + return string.Format(formatProvider, _format, _args); } public override string ToString() { - return string.Format(format, args); + return string.Format(_format, _args); } } } diff --git a/src/Numerics/Complex32.cs b/src/Numerics/Complex32.cs index b8c74f02..e09c7fc5 100644 --- a/src/Numerics/Complex32.cs +++ b/src/Numerics/Complex32.cs @@ -73,13 +73,13 @@ namespace MathNet.Numerics /// The real component of the complex number. /// [DataMember(Order = 1)] - private readonly float _real; + readonly float _real; /// /// The imaginary component of the complex number. /// [DataMember(Order = 2)] - private readonly float _imag; + readonly float _imag; /// /// Initializes a new instance of the Complex32 structure with the given real @@ -668,7 +668,7 @@ namespace MathNet.Numerics /// Im second /// /// - private static Complex32 InternalDiv(float a, float b, float c, float d, bool swapped) + static Complex32 InternalDiv(float a, float b, float c, float d, bool swapped) { float r = d / c; float t = 1 / (c + d * r); @@ -927,8 +927,7 @@ namespace MathNet.Numerics var token = tokens.First; // parse the left part - bool isLeftPartImaginary; - var leftPart = ParsePart(ref token, out isLeftPartImaginary, formatProvider); + var leftPart = ParsePart(ref token, out var isLeftPartImaginary, formatProvider); if (token == null) { return isLeftPartImaginary ? new Complex32(0, leftPart) : new Complex32(leftPart, 0); @@ -946,16 +945,14 @@ namespace MathNet.Numerics throw new FormatException(); } - bool isRightPartImaginary; - var rightPart = ParsePart(ref token, out isRightPartImaginary, formatProvider); + var rightPart = ParsePart(ref token, out _, formatProvider); return new Complex32(leftPart, rightPart); } else { // format: real + imag - bool isRightPartImaginary; - var rightPart = ParsePart(ref token, out isRightPartImaginary, formatProvider); + var rightPart = ParsePart(ref token, out var isRightPartImaginary, formatProvider); if (!(isLeftPartImaginary ^ isRightPartImaginary)) { @@ -978,7 +975,7 @@ namespace MathNet.Numerics /// /// Resulting part as float. /// - private static float ParsePart(ref LinkedListNode token, out bool imaginary, IFormatProvider format) + static float ParsePart(ref LinkedListNode token, out bool imaginary, IFormatProvider format) { imaginary = false; if (token == null) diff --git a/src/Numerics/ComplexExtensions.cs b/src/Numerics/ComplexExtensions.cs index 84c401b7..da4d0c1a 100644 --- a/src/Numerics/ComplexExtensions.cs +++ b/src/Numerics/ComplexExtensions.cs @@ -506,8 +506,7 @@ namespace MathNet.Numerics var token = tokens.First; // parse the left part - bool isLeftPartImaginary; - var leftPart = ParsePart(ref token, out isLeftPartImaginary, formatProvider); + var leftPart = ParsePart(ref token, out var isLeftPartImaginary, formatProvider); if (token == null) { return isLeftPartImaginary ? new Complex(0, leftPart) : new Complex(leftPart, 0); @@ -525,16 +524,14 @@ namespace MathNet.Numerics throw new FormatException(); } - bool isRightPartImaginary; - var rightPart = ParsePart(ref token, out isRightPartImaginary, formatProvider); + var rightPart = ParsePart(ref token, out _, formatProvider); return new Complex(leftPart, rightPart); } else { // format: real + imag - bool isRightPartImaginary; - var rightPart = ParsePart(ref token, out isRightPartImaginary, formatProvider); + var rightPart = ParsePart(ref token, out var isRightPartImaginary, formatProvider); if (!(isLeftPartImaginary ^ isRightPartImaginary)) { @@ -557,7 +554,7 @@ namespace MathNet.Numerics /// /// Resulting part as double. /// - private static double ParsePart(ref LinkedListNode token, out bool imaginary, IFormatProvider format) + static double ParsePart(ref LinkedListNode token, out bool imaginary, IFormatProvider format) { imaginary = false; if (token == null) diff --git a/src/Numerics/Differentiation/FiniteDifferenceCoefficients.cs b/src/Numerics/Differentiation/FiniteDifferenceCoefficients.cs index 53ae178d..e9f8b515 100644 --- a/src/Numerics/Differentiation/FiniteDifferenceCoefficients.cs +++ b/src/Numerics/Differentiation/FiniteDifferenceCoefficients.cs @@ -57,8 +57,8 @@ namespace MathNet.Numerics.Differentiation } } - private double[][,] _coefficients; - private int _points; + double[][,] _coefficients; + int _points; /// /// Initializes a new instance of the class. @@ -104,7 +104,7 @@ namespace MathNet.Numerics.Differentiation return _coefficients[center]; } - private void CalculateCoefficients(int points) + void CalculateCoefficients(int points) { var c = new double[points][,]; diff --git a/src/Numerics/Differentiation/NumericalDerivative.cs b/src/Numerics/Differentiation/NumericalDerivative.cs index b3a4d6c3..6c21cd44 100644 --- a/src/Numerics/Differentiation/NumericalDerivative.cs +++ b/src/Numerics/Differentiation/NumericalDerivative.cs @@ -433,16 +433,7 @@ namespace MathNet.Numerics.Differentiation Evaluations = 0; } - private double[] CalculateStepSize(int points, double[] x, double order) - { - var h = new double[x.Length]; - for (int i = 1; i < h.Length; i++) - h[i] = CalculateStepSize(points, x[i], order); - - return h; - } - - private double CalculateStepSize(int points, double x, double order) + double CalculateStepSize(int points, double x, double order) { // Step size relative to function input parameter if (StepType == StepType.RelativeX) diff --git a/src/Numerics/Differentiation/NumericalHessian.cs b/src/Numerics/Differentiation/NumericalHessian.cs index 073d03d6..16757a04 100644 --- a/src/Numerics/Differentiation/NumericalHessian.cs +++ b/src/Numerics/Differentiation/NumericalHessian.cs @@ -42,7 +42,7 @@ namespace MathNet.Numerics.Differentiation /// public int FunctionEvaluations => _df.Evaluations; - private readonly NumericalDerivative _df; + readonly NumericalDerivative _df; /// /// Creates a numerical Hessian object with a three point central difference method. diff --git a/src/Numerics/Differentiation/NumericalJacobian.cs b/src/Numerics/Differentiation/NumericalJacobian.cs index 6d3b271c..323cd8ca 100644 --- a/src/Numerics/Differentiation/NumericalJacobian.cs +++ b/src/Numerics/Differentiation/NumericalJacobian.cs @@ -42,7 +42,7 @@ namespace MathNet.Numerics.Differentiation /// public int FunctionEvaluations => _df.Evaluations; - private readonly NumericalDerivative _df; + readonly NumericalDerivative _df; /// /// Creates a numerical Jacobian object with a three point central difference method. diff --git a/src/Numerics/Distance.cs b/src/Numerics/Distance.cs index c1cfac51..4f358f92 100644 --- a/src/Numerics/Distance.cs +++ b/src/Numerics/Distance.cs @@ -517,7 +517,7 @@ namespace MathNet.Numerics } } - return 1.0 - ((double)intersection / (double)union); + return 1.0 - ((double)intersection / union); } /// @@ -563,7 +563,7 @@ namespace MathNet.Numerics } } - return 1.0 - ((float)intersection / (float)union); + return 1.0 - ((float)intersection / union); } } } diff --git a/src/Numerics/Distributions/Burr.cs b/src/Numerics/Distributions/Burr.cs index a875f842..829911d8 100644 --- a/src/Numerics/Distributions/Burr.cs +++ b/src/Numerics/Distributions/Burr.cs @@ -40,17 +40,17 @@ namespace MathNet.Numerics.Distributions /// /// Gets the scale (a) of the distribution. Range: a > 0. /// - public double a { get; } + public double A { get; } /// /// Gets the first shape parameter (c) of the distribution. Range: c > 0. /// - public double c { get; } + public double C { get; } /// /// Gets the second shape parameter (k) of the distribution. Range: k > 0. /// - public double k { get; } + public double K { get; } /// /// Initializes a new instance of the Burr Type XII class. @@ -66,9 +66,9 @@ namespace MathNet.Numerics.Distributions throw new ArgumentException("Invalid parametrization for the distribution."); } _random = randomSource ?? SystemRandomSource.Default; - this.a = a; - this.c = c; - this.k = k; + A = a; + C = c; + K = k; } /// @@ -77,7 +77,7 @@ namespace MathNet.Numerics.Distributions /// a string representation of the distribution. public override string ToString() { - return $"Burr(a = {a}, c = {c}, k = {k})"; + return $"Burr(a = {A}, c = {C}, k = {K})"; } /// @@ -104,14 +104,14 @@ namespace MathNet.Numerics.Distributions /// /// Gets the mean of the Burr distribution. /// - public double Mean => (1 / SpecialFunctions.Gamma(k)) * a * SpecialFunctions.Gamma(1 + 1 / c) * SpecialFunctions.Gamma(k - 1 / c); + public double Mean => (1 / SpecialFunctions.Gamma(K)) * A * SpecialFunctions.Gamma(1 + 1 / C) * SpecialFunctions.Gamma(K - 1 / C); /// /// Gets the variance of the Burr distribution. /// public double Variance => - (1 / SpecialFunctions.Gamma(k)) * Math.Pow(a, 2) * SpecialFunctions.Gamma(1 + 2 / c) * SpecialFunctions.Gamma(k - 2 / c) - - Math.Pow((1 / SpecialFunctions.Gamma(k)) * a * SpecialFunctions.Gamma(1 + 1 / c) * SpecialFunctions.Gamma(k - 1 / c), 2); + (1 / SpecialFunctions.Gamma(K)) * Math.Pow(A, 2) * SpecialFunctions.Gamma(1 + 2 / C) * SpecialFunctions.Gamma(K - 2 / C) + - Math.Pow((1 / SpecialFunctions.Gamma(K)) * A * SpecialFunctions.Gamma(1 + 1 / C) * SpecialFunctions.Gamma(K - 1 / C), 2); /// /// Gets the standard deviation of the Burr distribution. @@ -121,7 +121,7 @@ namespace MathNet.Numerics.Distributions /// /// Gets the mode of the Burr distribution. /// - public double Mode => a * Math.Pow((c - 1) / (c * k + 1), 1 / c); + public double Mode => A * Math.Pow((C - 1) / (C * K + 1), 1 / C); /// /// Gets the minimum of the Burr distribution. @@ -155,7 +155,7 @@ namespace MathNet.Numerics.Distributions /// /// Gets the median of the Burr distribution. /// - public double Median => a * Math.Pow(Math.Pow(2, 1 / k) - 1, 1 / c); + public double Median => A * Math.Pow(Math.Pow(2, 1 / K) - 1, 1 / C); /// /// Generates a sample from the Burr distribution. @@ -163,7 +163,7 @@ namespace MathNet.Numerics.Distributions /// a sample from the distribution. public double Sample() { - return SampleUnchecked(_random, a, c, k); + return SampleUnchecked(_random, A, C, K); } /// @@ -172,7 +172,7 @@ namespace MathNet.Numerics.Distributions /// The array to fill with the samples. public void Samples(double[] values) { - SamplesUnchecked(_random, values, a, c, k); + SamplesUnchecked(_random, values, A, C, K); } /// @@ -181,7 +181,7 @@ namespace MathNet.Numerics.Distributions /// a sequence of samples from the distribution. public IEnumerable Samples() { - return SamplesUnchecked(_random, a, c, k); + return SamplesUnchecked(_random, A, C, K); } /// @@ -235,31 +235,31 @@ namespace MathNet.Numerics.Distributions return SamplesUnchecked(rnd, a, c, k); } - internal static double SampleUnchecked(System.Random rnd, double a, double c, double k) + static double SampleUnchecked(System.Random rnd, double a, double c, double k) { - var k_inv = 1 / k; - var c_inv = 1 / c; + var kInv = 1 / k; + var cInv = 1 / c; double u = rnd.NextDouble(); - return a * Math.Pow(Math.Pow(1 - u, -k_inv) - 1, c_inv); + return a * Math.Pow(Math.Pow(1 - u, -kInv) - 1, cInv); } - internal static void SamplesUnchecked(System.Random rnd, double[] values, double a, double c, double k) + static void SamplesUnchecked(System.Random rnd, double[] values, double a, double c, double k) { if (values.Length == 0) { return; } - var k_inv = 1 / k; - var c_inv = 1 / c; + var kInv = 1 / k; + var cInv = 1 / c; double[] u = rnd.NextDoubles(values.Length); for (var j = 0; j < values.Length; ++j) { - values[j] = a * Math.Pow(Math.Pow(1 - u[j], -k_inv) - 1, c_inv); + values[j] = a * Math.Pow(Math.Pow(1 - u[j], -kInv) - 1, cInv); } } - internal static IEnumerable SamplesUnchecked(System.Random rnd, double a, double c, double k) + static IEnumerable SamplesUnchecked(System.Random rnd, double a, double c, double k) { while (true) { @@ -274,12 +274,12 @@ namespace MathNet.Numerics.Distributions /// the n-th moment of the distribution. public double GetMoment(double n) { - if (n > k * c) + if (n > K * C) { throw new ArgumentException("The chosen parameter set is invalid (probably some value is out of range)."); } - var lambda_n = (n / c) * SpecialFunctions.Gamma(n / c) * SpecialFunctions.Gamma(k - n / c); - return Math.Pow(a, n) * lambda_n / SpecialFunctions.Gamma(k); + var lambdaN = (n / C) * SpecialFunctions.Gamma(n / C) * SpecialFunctions.Gamma(K - n / C); + return Math.Pow(A, n) * lambdaN / SpecialFunctions.Gamma(K); } /// @@ -290,7 +290,7 @@ namespace MathNet.Numerics.Distributions /// public double Density(double x) { - return DensityImpl(a, c, k, x); + return DensityImpl(A, C, K, x); } /// @@ -301,7 +301,7 @@ namespace MathNet.Numerics.Distributions /// public double DensityLn(double x) { - return DensityLnImpl(a, c, k, x); + return DensityLnImpl(A, C, K, x); } /// @@ -312,7 +312,7 @@ namespace MathNet.Numerics.Distributions /// public double CumulativeDistribution(double x) { - return CumulativeDistributionImpl(a, c, k, x); + return CumulativeDistributionImpl(A, C, K, x); } /// @@ -369,19 +369,19 @@ namespace MathNet.Numerics.Distributions return CumulativeDistributionImpl(a, c, k, x); } - internal static double DensityImpl(double a, double c, double k, double x) + static double DensityImpl(double a, double c, double k, double x) { var numerator = (k * c / a) * Math.Pow(x / a, c - 1); var denominator = Math.Pow(1 + Math.Pow(x / a, c), k + 1); return numerator / denominator; } - internal static double DensityLnImpl(double a, double c, double k, double x) + static double DensityLnImpl(double a, double c, double k, double x) { return Math.Log(DensityImpl(a, c, k, x)); } - internal static double CumulativeDistributionImpl(double a, double c, double k, double x) + static double CumulativeDistributionImpl(double a, double c, double k, double x) { var denominator = Math.Pow(1 + Math.Pow(x / a, c), k); return 1 - 1 / denominator; diff --git a/src/Numerics/Distributions/InverseGaussian.cs b/src/Numerics/Distributions/InverseGaussian.cs index 66b8a085..ead53d25 100644 --- a/src/Numerics/Distributions/InverseGaussian.cs +++ b/src/Numerics/Distributions/InverseGaussian.cs @@ -221,21 +221,21 @@ namespace MathNet.Numerics.Distributions return SamplesUnchecked(rnd, mu, lambda); } - internal static double SampleUnchecked(System.Random rnd, double mu, double lambda) + static double SampleUnchecked(System.Random rnd, double mu, double lambda) { - double v = MathNet.Numerics.Distributions.Normal.Sample(rnd, 0, 1); + double v = Normal.Sample(rnd, 0, 1); double test = rnd.NextDouble(); return InverseGaussianSampleImpl(mu, lambda, v, test); } - internal static void SamplesUnchecked(System.Random rnd, double[] values, double mu, double lambda) + static void SamplesUnchecked(System.Random rnd, double[] values, double mu, double lambda) { if (values.Length == 0) { return; } double[] v = new double[values.Length]; - MathNet.Numerics.Distributions.Normal.Samples(rnd, v, 0, 1); + Normal.Samples(rnd, v, 0, 1); double[] test = rnd.NextDoubles(values.Length); for (var j = 0; j < values.Length; ++j) { @@ -243,7 +243,7 @@ namespace MathNet.Numerics.Distributions } } - internal static IEnumerable SamplesUnchecked(System.Random rnd, double mu, double lambda) + static IEnumerable SamplesUnchecked(System.Random rnd, double mu, double lambda) { while (true) { @@ -251,7 +251,7 @@ namespace MathNet.Numerics.Distributions } } - internal static double InverseGaussianSampleImpl(double mu, double lambda, double normalSample, double uniformSample) + static double InverseGaussianSampleImpl(double mu, double lambda, double normalSample, double uniformSample) { double y = normalSample * normalSample; double x = mu + (mu * mu * y) / (2 * lambda) - (mu / (2 * lambda)) * Math.Sqrt(4 * mu * lambda * y + mu * mu * y * y); @@ -301,11 +301,10 @@ namespace MathNet.Numerics.Distributions /// the inverse cumulative distribution at location . public double InvCDF(double p) { - Func equationToSolve = (x) => CumulativeDistribution(x) - p; - if (RootFinding.NewtonRaphson.TryFindRoot(equationToSolve, Density, Mode, 0, double.PositiveInfinity, 1e-8, 100, out double quantile)) - return quantile; - else + double EquationToSolve(double x) => CumulativeDistribution(x) - p; + if (!RootFinding.NewtonRaphson.TryFindRoot(EquationToSolve, Density, Mode, 0, double.PositiveInfinity, 1e-8, 100, out double quantile)) throw new NonConvergenceException("Numerical estimation of the statistic has failed. The used solver did not succeed in finding a root."); + return quantile; } /// @@ -367,7 +366,7 @@ namespace MathNet.Numerics.Distributions /// The location at which to compute the inverse cumulative distribution function. /// the inverse cumulative distribution at location . /// - public static double ICDF(double mu, double lambda, double p) + public static double InvCDF(double mu, double lambda, double p) { if (!IsValidParameterSet(mu, lambda)) { @@ -385,23 +384,23 @@ namespace MathNet.Numerics.Distributions /// An Inverse Gaussian distribution. public static InverseGaussian Estimate(IEnumerable samples, System.Random randomSource = null) { - var sampleVec = samples.ToArray(); - var muHat = sampleVec.Mean(); - var lambdahat = 1 / (1 / samples.HarmonicMean() - 1 / muHat); - return new InverseGaussian(muHat, lambdahat, randomSource); + var samplesArray = samples.ToArray(); + var muHat = samplesArray.Mean(); + var lambdaHat = 1 / (1 / samplesArray.HarmonicMean() - 1 / muHat); + return new InverseGaussian(muHat, lambdaHat, randomSource); } - internal static double DensityImpl(double mu, double lambda, double x) + static double DensityImpl(double mu, double lambda, double x) { return Math.Sqrt(lambda / (2 * Math.PI * Math.Pow(x, 3))) * Math.Exp(-((lambda * Math.Pow(x - mu, 2)) / (2 * mu * mu * x))); } - internal static double DensityLnImpl(double mu, double lambda, double x) + static double DensityLnImpl(double mu, double lambda, double x) { return Math.Log(Math.Sqrt(lambda / (2 * Math.PI * Math.Pow(x, 3)))) - ((lambda * Math.Pow(x - mu, 2)) / (2 * mu * mu * x)); } - internal static double CumulativeDistributionImpl(double mu, double lambda, double x) + static double CumulativeDistributionImpl(double mu, double lambda, double x) { return Normal.CDF(0, 1, Math.Sqrt(lambda / x) * (x / mu - 1)) + Math.Exp(2 * lambda / mu) * Normal.CDF(0, 1, -Math.Sqrt(lambda / x) * (x / mu + 1)); } diff --git a/src/Numerics/Distributions/Logistic.cs b/src/Numerics/Distributions/Logistic.cs index 3c9c7ffd..5e68656a 100644 --- a/src/Numerics/Distributions/Logistic.cs +++ b/src/Numerics/Distributions/Logistic.cs @@ -30,7 +30,6 @@ using System; using System.Collections.Generic; using MathNet.Numerics.Random; -using MathNet.Numerics.Statistics; namespace MathNet.Numerics.Distributions { @@ -48,7 +47,7 @@ namespace MathNet.Numerics.Distributions /// /// Initializes a new instance of the Logistic class. This is a logistic distribution with mean 0.0 - /// and scale 1.0. The distribution will be initialized with the default + /// and scale 1.0. The distribution will be initialized with the default /// random number generator. /// public Logistic() @@ -58,7 +57,7 @@ namespace MathNet.Numerics.Distributions /// /// Initializes a new instance of the Logistic class. This is a logistic distribution with mean 0.0 - /// and scale 1.0. The distribution will be initialized with the default + /// and scale 1.0. The distribution will be initialized with the default /// random number generator. /// /// The random number generator which is used to draw random samples. @@ -68,7 +67,7 @@ namespace MathNet.Numerics.Distributions } /// - /// Initializes a new instance of the Logistic class with a particular mean and scale parameter. The + /// Initializes a new instance of the Logistic class with a particular mean and scale parameter. The /// distribution will be initialized with the default random number generator. /// /// The mean (μ) of the logistic distribution. @@ -307,12 +306,12 @@ namespace MathNet.Numerics.Distributions return SamplesUnchecked(_random, _mean, _scale); } - internal static double SampleUnchecked(System.Random rnd, double mean, double scale) + static double SampleUnchecked(System.Random rnd, double mean, double scale) { return InvCDF(mean, scale, rnd.NextDouble()); } - internal static IEnumerable SamplesUnchecked(System.Random rnd, double mean, double scale) + static IEnumerable SamplesUnchecked(System.Random rnd, double mean, double scale) { while (true) { @@ -320,13 +319,13 @@ namespace MathNet.Numerics.Distributions } } - internal static void SamplesUnchecked(System.Random rnd, double[] values, double mean, double scale) + static void SamplesUnchecked(System.Random rnd, double[] values, double mean, double scale) { if (values.Length == 0) { return; } - + for (int i = 0; i < values.Length; i++) { values[i] = SampleUnchecked(rnd, mean, scale); @@ -348,7 +347,7 @@ namespace MathNet.Numerics.Distributions throw new ArgumentException("Invalid parametrization for the distribution."); } - var z = (x - mean)/scale; + var z = (x - mean)/scale; return Math.Exp(-z) / (scale * Math.Pow(1.0 + Math.Exp(-z), 2)); } @@ -367,7 +366,7 @@ namespace MathNet.Numerics.Distributions throw new ArgumentException("Invalid parametrization for the distribution."); } - var z = (x - mean)/scale; + var z = (x - mean)/scale; return -z - Math.Log(scale) - (2 * Math.Log(1+Math.Exp(-z))); } diff --git a/src/Numerics/Distributions/Normal.cs b/src/Numerics/Distributions/Normal.cs index 93ca765e..44f54669 100644 --- a/src/Numerics/Distributions/Normal.cs +++ b/src/Numerics/Distributions/Normal.cs @@ -306,8 +306,8 @@ namespace MathNet.Numerics.Distributions internal static double SampleUnchecked(System.Random rnd, double mean, double stddev) { - double x, y; - while (!PolarTransform(rnd.NextDouble(), rnd.NextDouble(), out x, out y)) + double x; + while (!PolarTransform(rnd.NextDouble(), rnd.NextDouble(), out x, out _)) { } @@ -318,8 +318,7 @@ namespace MathNet.Numerics.Distributions { while (true) { - double x, y; - if (!PolarTransform(rnd.NextDouble(), rnd.NextDouble(), out x, out y)) + if (!PolarTransform(rnd.NextDouble(), rnd.NextDouble(), out var x, out var y)) { continue; } diff --git a/src/Numerics/Distributions/SkewedGeneralizedError.cs b/src/Numerics/Distributions/SkewedGeneralizedError.cs index 45a90f1a..8ef9fe08 100644 --- a/src/Numerics/Distributions/SkewedGeneralizedError.cs +++ b/src/Numerics/Distributions/SkewedGeneralizedError.cs @@ -35,7 +35,7 @@ namespace MathNet.Numerics.Distributions { /// /// Continuous Univariate Skewed Generalized Error Distribution (SGED). - /// Implements the univariate SSkewed Generalized Error Distribution. For details about this + /// Implements the univariate Skewed Generalized Error Distribution. For details about this /// distribution, see /// /// Wikipedia - Generalized Error Distribution. @@ -129,22 +129,22 @@ namespace MathNet.Numerics.Distributions /// /// Gets the location (μ) of the Skewed Generalized t-distribution. /// - public double Location { get; private set; } + public double Location { get; } /// /// Gets the scale (σ) of the Skewed Generalized t-distribution. Range: σ > 0. /// - public double Scale { get; private set; } + public double Scale { get; } /// /// Gets the skew (λ) of the Skewed Generalized t-distribution. Range: 1 > λ > -1. /// - public double Skew { get; private set; } + public double Skew { get; } /// /// Gets the parameter that controls the kurtosis of the distribution. Range: p > 0. /// - public double P { get; private set; } + public double P { get; } // No skew implies Median=Mode=Mean public double Mode => diff --git a/src/Numerics/Distributions/TruncatedPareto.cs b/src/Numerics/Distributions/TruncatedPareto.cs index e35fbe9f..5cfc373b 100644 --- a/src/Numerics/Distributions/TruncatedPareto.cs +++ b/src/Numerics/Distributions/TruncatedPareto.cs @@ -333,7 +333,7 @@ namespace MathNet.Numerics.Distributions /// The location at which to compute the inverse cumulative distribution function. /// the inverse cumulative distribution at location . /// - public static double ICDF(double scale, double shape, double truncation, double p) + public static double InvCDF(double scale, double shape, double truncation, double p) { if (!IsValidParameterSet(scale, shape, truncation)) { @@ -396,7 +396,7 @@ namespace MathNet.Numerics.Distributions return CumulativeDistributionImpl(scale, shape, truncation, x); } - internal static double DensityImpl(double scale, double shape, double truncation, double x) + static double DensityImpl(double scale, double shape, double truncation, double x) { if (x < scale || x > truncation) return 0; @@ -404,12 +404,12 @@ namespace MathNet.Numerics.Distributions return (shape * Math.Pow(scale, shape) * Math.Pow(x, -shape - 1)) / (1 - Math.Pow(scale / truncation, shape)); } - internal static double DensityLnImpl(double scale, double shape, double truncation, double x) + static double DensityLnImpl(double scale, double shape, double truncation, double x) { return Math.Log(DensityImpl(scale, shape, truncation, x)); } - internal static double CumulativeDistributionImpl(double scale, double shape, double truncation, double x) + static double CumulativeDistributionImpl(double scale, double shape, double truncation, double x) { if (x <= scale) return 0; @@ -419,7 +419,7 @@ namespace MathNet.Numerics.Distributions return (1 - Math.Pow(scale, shape) * Math.Pow(x, -shape)) / (1 - Math.Pow(scale / truncation, shape)); } - internal static double InvCDFUncheckedImpl(double scale, double shape, double truncation, double p) + static double InvCDFUncheckedImpl(double scale, double shape, double truncation, double p) { var numerator = p * Math.Pow(truncation, shape) - p * Math.Pow(scale, shape) - Math.Pow(truncation, shape); var denominator = Math.Pow(truncation, shape) * Math.Pow(scale, shape); diff --git a/src/Numerics/Integration/GaussKronrodRule.cs b/src/Numerics/Integration/GaussKronrodRule.cs index e5394d3a..56f21af4 100644 --- a/src/Numerics/Integration/GaussKronrodRule.cs +++ b/src/Numerics/Integration/GaussKronrodRule.cs @@ -43,31 +43,31 @@ namespace MathNet.Numerics.Integration { public class GaussKronrodRule { - private readonly GaussPointPair gaussKronrodPoint; + readonly GaussPointPair _gaussKronrodPoint; /// /// Getter for the order. /// - public int Order => gaussKronrodPoint.Order; + public int Order => _gaussKronrodPoint.Order; /// /// Getter that returns a clone of the array containing the Kronrod abscissas. /// - public double[] KronrodAbscissas => gaussKronrodPoint.Abscissas.Clone() as double[]; + public double[] KronrodAbscissas => _gaussKronrodPoint.Abscissas.Clone() as double[]; /// /// Getter that returns a clone of the array containing the Kronrod weights. /// - public double[] KronrodWeights => gaussKronrodPoint.Weights.Clone() as double[]; + public double[] KronrodWeights => _gaussKronrodPoint.Weights.Clone() as double[]; /// /// Getter that returns a clone of the array containing the Gauss weights. /// - public double[] GaussWeights => gaussKronrodPoint.SecondWeights.Clone() as double[]; + public double[] GaussWeights => _gaussKronrodPoint.SecondWeights.Clone() as double[]; public GaussKronrodRule(int order) { - gaussKronrodPoint = GaussKronrodPointFactory.GetGaussPoint(order); + _gaussKronrodPoint = GaussKronrodPointFactory.GetGaussPoint(order); } /// @@ -106,10 +106,7 @@ namespace MathNet.Numerics.Integration // g'(t) = (1 + t^2) / (1 - t^2)^2 if ((intervalBegin < double.MinValue) && (intervalEnd > double.MaxValue)) { - Func u = (t) => - { - return f(t / (1 - t * t)) * (1 + t * t) / ((1 - t * t) * (1 - t * t)); - }; + Func u = (t) => f(t / (1 - t * t)) * (1 + t * t) / ((1 - t * t) * (1 - t * t)); return recursive_adaptive_integrate(u, -1, 1, maximumDepth, targetRelativeError, 0, out error, out L1Norm, gaussKronrodPoint); } // [a, oo) => [0, 1] @@ -120,10 +117,7 @@ namespace MathNet.Numerics.Integration // g'(s) = 1 / (1 - s)^2 else if (intervalEnd > double.MaxValue) { - Func u = (s) => - { - return 2 * s * f(intervalBegin + (s / (1 - s)) * (s / (1 - s))) / ((1 - s) * (1 - s) * (1 - s)); - }; + Func u = (s) => 2 * s * f(intervalBegin + (s / (1 - s)) * (s / (1 - s))) / ((1 - s) * (1 - s) * (1 - s)); return recursive_adaptive_integrate(u, 0, 1, maximumDepth, targetRelativeError, 0, out error, out L1Norm, gaussKronrodPoint); } // (-oo, b] => [-1, 0] @@ -134,10 +128,7 @@ namespace MathNet.Numerics.Integration // g'(s) = 1 / (1 + s)^2 else if (intervalBegin < double.MinValue) { - Func u = (s) => - { - return -2 * s * f(intervalEnd - s / (1 + s) * (s / (1 + s))) / ((1 + s) * (1 + s) * (1 + s)); - }; + Func u = (s) => -2 * s * f(intervalEnd - s / (1 + s) * (s / (1 + s))) / ((1 + s) * (1 + s) * (1 + s)); return recursive_adaptive_integrate(u, -1, 0, maximumDepth, targetRelativeError, 0, out error, out L1Norm, gaussKronrodPoint); } // [a, b] => [-1, 1] @@ -147,10 +138,7 @@ namespace MathNet.Numerics.Integration // g'(t) = 3 / 4 * (b - a) * (1 - t^2) else { - Func u = (t) => - { - return f((intervalEnd - intervalBegin) / 4 * t * (3 - t * t) + (intervalEnd + intervalBegin) / 2) * 3 * (intervalEnd - intervalBegin) / 4 * (1 - t * t); - }; + Func u = (t) => f((intervalEnd - intervalBegin) / 4 * t * (3 - t * t) + (intervalEnd + intervalBegin) / 2) * 3 * (intervalEnd - intervalBegin) / 4 * (1 - t * t); return recursive_adaptive_integrate(u, -1, 1, maximumDepth, targetRelativeError, 0d, out error, out L1Norm, gaussKronrodPoint); } } @@ -192,185 +180,174 @@ namespace MathNet.Numerics.Integration // g'(t) = (1 + t^2) / (1 - t^2)^2 if ((intervalBegin < double.MinValue) && (intervalEnd > double.MaxValue)) { - Func u = (t) => - { - return f(t / (1 - t * t)) * (1 + t * t) / ((1 - t * t) * (1 - t * t)); - }; + Func u = (t) => f(t / (1 - t * t)) * (1 + t * t) / ((1 - t * t) * (1 - t * t)); return contour_recursive_adaptive_integrate(u, -1, 1, maximumDepth, targetRelativeError, 0, out error, out L1Norm, gaussKronrodPoint); } + // [a, oo) => [0, 1] // // integral_(a)^(oo) f(x) dx = integral_(0)^(oo) f(a + t^2) 2 t dt // = integral_(0)^(1) f(a + g(s)^2) 2 g(s) g'(s) ds // g(s) = s / (1 - s) // g'(s) = 1 / (1 - s)^2 - else if (intervalEnd > double.MaxValue) + if (intervalEnd > double.MaxValue) { - Func u = (s) => - { - return 2 * s * f(intervalBegin + (s / (1 - s)) * (s / (1 - s))) / ((1 - s) * (1 - s) * (1 - s)); - }; + Func u = (s) => 2 * s * f(intervalBegin + (s / (1 - s)) * (s / (1 - s))) / ((1 - s) * (1 - s) * (1 - s)); return contour_recursive_adaptive_integrate(u, 0, 1, maximumDepth, targetRelativeError, 0, out error, out L1Norm, gaussKronrodPoint); } + // (-oo, b] => [-1, 0] // // integral_(-oo)^(b) f(x) dx = -integral_(-oo)^(0) f(b - t^2) 2 t dt // = -integral_(-1)^(0) f(b - g(s)^2) 2 g(s) g'(s) ds // g(s) = s / (1 + s) // g'(s) = 1 / (1 + s)^2 - else if (intervalBegin < double.MinValue) + if (intervalBegin < double.MinValue) { - Func u = (s) => - { - return -2 * s * f(intervalEnd - s / (1 + s) * (s / (1 + s))) / ((1 + s) * (1 + s) * (1 + s)); - }; + Func u = (s) => -2 * s * f(intervalEnd - s / (1 + s) * (s / (1 + s))) / ((1 + s) * (1 + s) * (1 + s)); return contour_recursive_adaptive_integrate(u, -1, 0, maximumDepth, targetRelativeError, 0, out error, out L1Norm, gaussKronrodPoint); } + // [a, b] => [-1, 1] // // integral_(a)^(b) f(x) dx = integral_(-1)^(1) f(g(t)) g'(t) dt // g(t) = (b - a) * t * (3 - t^2) / 4 + (b + a) / 2 // g'(t) = 3 / 4 * (b - a) * (1 - t^2) - else { - Func u = (t) => - { - return f((intervalEnd - intervalBegin) / 4 * t * (3 - t * t) + (intervalEnd + intervalBegin) / 2) * 3 * (intervalEnd - intervalBegin) / 4 * (1 - t * t); - }; + Func u = (t) => f((intervalEnd - intervalBegin) / 4 * t * (3 - t * t) + (intervalEnd + intervalBegin) / 2) * 3 * (intervalEnd - intervalBegin) / 4 * (1 - t * t); return contour_recursive_adaptive_integrate(u, -1, 1, maximumDepth, targetRelativeError, 0d, out error, out L1Norm, gaussKronrodPoint); } } - private static double integrate_non_adaptive_m1_1(Func f, out double error, out double pL1, GaussPointPair gaussKronrodPoint) + static double integrate_non_adaptive_m1_1(Func f, out double error, out double pL1, GaussPointPair gaussKronrodPoint) { - int gauss_start = 2; - int kronrod_start = 1; - int gauss_order = (gaussKronrodPoint.Order - 1) / 2; + int gaussStart = 2; + int kronrodStart = 1; + int gaussOrder = (gaussKronrodPoint.Order - 1) / 2; - double kronrod_result = 0d; - double gauss_result = 0d; + double kronrodResult = 0d; + double gaussResult = 0d; double fp, fm; var KAbscissa = gaussKronrodPoint.Abscissas; var KWeights = gaussKronrodPoint.Weights; var GWeights = gaussKronrodPoint.SecondWeights; - if ((gauss_order & 1) == 1) + if ((gaussOrder & 1) == 1) { fp = f(0); - kronrod_result = fp * KWeights[0]; - gauss_result += fp * GWeights[0]; + kronrodResult = fp * KWeights[0]; + gaussResult += fp * GWeights[0]; } else { fp = f(0); - kronrod_result = fp * KWeights[0]; - gauss_start = 1; - kronrod_start = 2; + kronrodResult = fp * KWeights[0]; + gaussStart = 1; + kronrodStart = 2; } - double L1 = Math.Abs(kronrod_result); + double L1 = Math.Abs(kronrodResult); - for (int i = gauss_start; i < KAbscissa.Length; i += 2) + for (int i = gaussStart; i < KAbscissa.Length; i += 2) { fp = f(KAbscissa[i]); fm = f(-KAbscissa[i]); - kronrod_result += (fp + fm) * KWeights[i]; + kronrodResult += (fp + fm) * KWeights[i]; L1 += (Math.Abs(fp) + Math.Abs(fm)) * KWeights[i]; - gauss_result += (fp + fm) * GWeights[i / 2]; + gaussResult += (fp + fm) * GWeights[i / 2]; } - for (int i = kronrod_start; i < KAbscissa.Length; i += 2) + for (int i = kronrodStart; i < KAbscissa.Length; i += 2) { fp = f(KAbscissa[i]); fm = f(-KAbscissa[i]); - kronrod_result += (fp + fm) * KWeights[i]; + kronrodResult += (fp + fm) * KWeights[i]; L1 += (Math.Abs(fp) + Math.Abs(fm)) * KWeights[i]; } pL1 = L1; - error = Math.Max(Math.Abs(kronrod_result - gauss_result), Math.Abs(kronrod_result * Precision.MachineEpsilon * 2d)); - return kronrod_result; + error = Math.Max(Math.Abs(kronrodResult - gaussResult), Math.Abs(kronrodResult * Precision.MachineEpsilon * 2d)); + return kronrodResult; } - private static Complex contour_integrate_non_adaptive_m1_1(Func f, out double error, out double pL1, GaussPointPair gaussKronrodPoint) + static Complex contour_integrate_non_adaptive_m1_1(Func f, out double error, out double pL1, GaussPointPair gaussKronrodPoint) { - int gauss_start = 2; - int kronrod_start = 1; - int gauss_order = (gaussKronrodPoint.Order - 1) / 2; + int gaussStart = 2; + int kronrodStart = 1; + int gaussOrder = (gaussKronrodPoint.Order - 1) / 2; - Complex kronrod_result = new Complex(); - Complex gauss_result = new Complex(); + Complex kronrodResult; + Complex gaussResult = new Complex(); Complex fp, fm; var KAbscissa = gaussKronrodPoint.Abscissas; var KWeights = gaussKronrodPoint.Weights; var GWeights = gaussKronrodPoint.SecondWeights; - if (gauss_order.IsOdd()) + if (gaussOrder.IsOdd()) { fp = f(0); - kronrod_result = fp * KWeights[0]; - gauss_result += fp * GWeights[0]; + kronrodResult = fp * KWeights[0]; + gaussResult += fp * GWeights[0]; } else { fp = f(0); - kronrod_result = fp * KWeights[0]; - gauss_start = 1; - kronrod_start = 2; + kronrodResult = fp * KWeights[0]; + gaussStart = 1; + kronrodStart = 2; } - double L1 = Complex.Abs(kronrod_result); + double L1 = Complex.Abs(kronrodResult); - for (int i = gauss_start; i < KAbscissa.Length; i += 2) + for (int i = gaussStart; i < KAbscissa.Length; i += 2) { fp = f(KAbscissa[i]); fm = f(-KAbscissa[i]); - kronrod_result += (fp + fm) * KWeights[i]; + kronrodResult += (fp + fm) * KWeights[i]; L1 += (Complex.Abs(fp) + Complex.Abs(fm)) * KWeights[i]; - gauss_result += (fp + fm) * GWeights[i / 2]; + gaussResult += (fp + fm) * GWeights[i / 2]; } - for (int i = kronrod_start; i < KAbscissa.Length; i += 2) + for (int i = kronrodStart; i < KAbscissa.Length; i += 2) { fp = f(KAbscissa[i]); fm = f(-KAbscissa[i]); - kronrod_result += (fp + fm) * KWeights[i]; + kronrodResult += (fp + fm) * KWeights[i]; L1 += (Complex.Abs(fp) + Complex.Abs(fm)) * KWeights[i]; } pL1 = L1; - error = Math.Max(Complex.Abs(kronrod_result - gauss_result), Complex.Abs(kronrod_result * Precision.MachineEpsilon * 2d)); - return kronrod_result; + error = Math.Max(Complex.Abs(kronrodResult - gaussResult), Complex.Abs(kronrodResult * Precision.MachineEpsilon * 2d)); + return kronrodResult; } - private static double recursive_adaptive_integrate(Func f, double a, double b, int max_levels, double rel_tol, double abs_tol, out double error, out double L1, GaussPointPair gaussKronrodPoint) + static double recursive_adaptive_integrate(Func f, double a, double b, int maxLevels, double relTol, double absTol, out double error, out double L1, GaussPointPair gaussKronrodPoint) { - double error_local; double mean = (b + a) / 2; double scale = (b - a) / 2; - var r1 = integrate_non_adaptive_m1_1((x) => f(scale * x + mean), out error_local, out L1, gaussKronrodPoint); + var r1 = integrate_non_adaptive_m1_1((x) => f(scale * x + mean), out double errorLocal, out L1, gaussKronrodPoint); var estimate = scale * r1; - var tmp = estimate * rel_tol; - var abs_tol1 = Math.Abs(tmp); - if (abs_tol == 0) + var tmp = estimate * relTol; + var absTol1 = Math.Abs(tmp); + if (absTol == 0) { - abs_tol = abs_tol1; + absTol = absTol1; } - if (max_levels > 0 && (abs_tol1 < error_local) && (abs_tol < error_local)) + if (maxLevels > 0 && (absTol1 < errorLocal) && (absTol < errorLocal)) { double mid = (a + b) / 2d; double L1_local; - estimate = recursive_adaptive_integrate(f, a, mid, max_levels - 1, rel_tol, abs_tol / 2, out error, out L1, gaussKronrodPoint); - estimate += recursive_adaptive_integrate(f, mid, b, max_levels - 1, rel_tol, abs_tol / 2, out error_local, out L1_local, gaussKronrodPoint); - error += error_local; + estimate = recursive_adaptive_integrate(f, a, mid, maxLevels - 1, relTol, absTol / 2, out error, out L1, gaussKronrodPoint); + estimate += recursive_adaptive_integrate(f, mid, b, maxLevels - 1, relTol, absTol / 2, out errorLocal, out L1_local, gaussKronrodPoint); + error += errorLocal; L1 += L1_local; return estimate; } L1 *= scale; - error = error_local; + error = errorLocal; return estimate; } - private static Complex contour_recursive_adaptive_integrate(Func f, double a, double b, int max_levels, double rel_tol, double abs_tol, out double error, out double L1, GaussPointPair gaussKronrodPoint) + static Complex contour_recursive_adaptive_integrate(Func f, double a, double b, int maxLevels, double relTol, double absTol, out double error, out double L1, GaussPointPair gaussKronrodPoint) { double error_local; double mean = (b + a) / 2; @@ -379,19 +356,19 @@ namespace MathNet.Numerics.Integration var r1 = contour_integrate_non_adaptive_m1_1((x) => f(scale * x + mean), out error_local, out L1, gaussKronrodPoint); var estimate = scale * r1; - var tmp = estimate * rel_tol; - var abs_tol1 = Complex.Abs(tmp); - if (abs_tol == 0) + var tmp = estimate * relTol; + var absTol1 = Complex.Abs(tmp); + if (absTol == 0) { - abs_tol = abs_tol1; + absTol = absTol1; } - if (max_levels > 0 && (abs_tol1 < error_local) && (abs_tol < error_local)) + if (maxLevels > 0 && (absTol1 < error_local) && (absTol < error_local)) { double mid = (a + b) / 2d; double L1_local; - estimate = contour_recursive_adaptive_integrate(f, a, mid, max_levels - 1, rel_tol, abs_tol / 2, out error, out L1, gaussKronrodPoint); - estimate += contour_recursive_adaptive_integrate(f, mid, b, max_levels - 1, rel_tol, abs_tol / 2, out error_local, out L1_local, gaussKronrodPoint); + estimate = contour_recursive_adaptive_integrate(f, a, mid, maxLevels - 1, relTol, absTol / 2, out error, out L1, gaussKronrodPoint); + estimate += contour_recursive_adaptive_integrate(f, mid, b, maxLevels - 1, relTol, absTol / 2, out error_local, out L1_local, gaussKronrodPoint); error += error_local; L1 += L1_local; return estimate; diff --git a/src/Numerics/Integration/GaussLegendreRule.cs b/src/Numerics/Integration/GaussLegendreRule.cs index cf723424..1c59d9a4 100644 --- a/src/Numerics/Integration/GaussLegendreRule.cs +++ b/src/Numerics/Integration/GaussLegendreRule.cs @@ -38,7 +38,7 @@ namespace MathNet.Numerics.Integration /// public class GaussLegendreRule { - private readonly GaussPoint _gaussLegendrePoint; + readonly GaussPoint _gaussLegendrePoint; /// /// Initializes a new instance of the class. diff --git a/src/Numerics/Integration/GaussRule/GaussKronrodPoint.cs b/src/Numerics/Integration/GaussRule/GaussKronrodPoint.cs index e1f4e93a..f599f94b 100644 --- a/src/Numerics/Integration/GaussRule/GaussKronrodPoint.cs +++ b/src/Numerics/Integration/GaussRule/GaussKronrodPoint.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Numerics; namespace MathNet.Numerics.Integration.GaussRule { @@ -389,7 +388,7 @@ namespace MathNet.Numerics.Integration.GaussRule // Calculate Kronrod polynomial in terms of Legendre polynomials // K(x) = c0*P(0, x) + c1*P(1, x) + ... - var c = StieltjesP(gaussOrder + 1); + var c = StieltjesP(gaussOrder + 1); // Calculate Abscissas for Kronrod polynomial @@ -420,7 +419,7 @@ namespace MathNet.Numerics.Integration.GaussRule // Concatenate two abscissas var abscissas = new double[gaussAbscissas.Length + kronrodAbscissas.Length]; - gaussAbscissas.CopyTo(abscissas, 0); + gaussAbscissas.CopyTo(abscissas, 0); kronrodAbscissas.CopyTo(abscissas, gaussAbscissas.Length); abscissas = abscissas.OrderBy(v => v).ToArray(); @@ -454,9 +453,9 @@ namespace MathNet.Numerics.Integration.GaussRule /// /// Returns coefficients of a Stieltjes polynomial in terms of Legendre polynomials. /// - internal static double[] StieltjesP(int order) + static double[] StieltjesP(int order) { - // Reference: + // Reference: // 1. Patterson, Thomas NL. "The optimum addition of points to quadrature formulae." Mathematics of Computation 22.104 (1968): 847-856. // 2. Piessens, Robert, and Maria Branders. "A note on the optimal addition of abscissas to quadrature formulas of Gauss and Lobatto type." Mathematics of Computation (1974): 135-139. // 3. Legendre-Stieltjes Polynomials, Boost.Math @@ -475,14 +474,14 @@ namespace MathNet.Numerics.Integration.GaussRule // The added n + 1 Kronrod abscissae is the roots of the Kronrod polynomial. if (order == 1) // P(1, x) - return new double[] { 0, 1 }; - else if (order == 2) // -2/5 * P(0, x) + P(2, x) + return new double[] { 0, 1 }; + if (order == 2) // -2/5 * P(0, x) + P(2, x) return new double[] { -0.4, 0, 1 }; - else if (order == 3) // -9/14 * P(1, x) + P(3, x) + if (order == 3) // -9/14 * P(1, x) + P(3, x) return new double[] { 0, -0.642857142857142857142857142857, 0, 1 }; - else if (order == 4) // 14/891 * P(0, x) - 20/27 * P(2, x) + P(4, x) + if (order == 4) // 14/891 * P(0, x) - 20/27 * P(2, x) + P(4, x) return new double[] { 0.0157126823793490460157126823793, 0, -0.740740740740740740740740740741, 0, 1 }; - else if (order == 5) // 135/12584 * P(1, x) - 35/44 * P(3, x) + P(5, x) + if (order == 5) // 135/12584 * P(1, x) - 35/44 * P(3, x) + P(5, x) return new double[] { 0, 0.0107279084551811824539097266370, 0, -0.795454545454545454545454545455, 0, 1 }; int n = order - 1; @@ -498,7 +497,7 @@ namespace MathNet.Numerics.Integration.GaussRule // a[r - 2] = -a[r] * S[r, 2] / S[r - 2, 2] - a[r - 1] * S[r - 1, 2] / S[r - 2, 2]; // ... // a[1] = -a[r] * S[r, r - 1] / S[1, r - 1] - a[r - 1] * S[r - 1, r - 1] / S[1, r - 1] - ... - a[2] * S[2, r - 1] / S[1, r - 1]; - // + // // S[i, k] / S[r - k, k] = S[i - 1, k] / S[r - k, k] // * ((n - q + 2 * (i + k - 1)) * (n + q + 2 * (k - i + 1)) * (n - 1 - q + 2 * (i - k)) * (2 * (k + i - 1) - 1 - q - n)) // / ((n - q + 2 * (i - k)) * (2 * (k + i - 1) - q - n) * (n + 1 + q + 2 * (k - i)) * (n - 1 - q + 2 * (i + k))); @@ -513,11 +512,11 @@ namespace MathNet.Numerics.Integration.GaussRule double numerator = (n - q + 2 * (i + k - 1)) * (n + q + 2 * (k - i + 1)) * (n - 1 - q + 2 * (i - k)) * (2 * (k + i - 1) - 1 - q - n); double denominator = (n - q + 2 * (i - k)) * (2 * (k + i - 1) - q - n) * (n + 1 + q + 2 * (k - i)) * (n - 1 - q + 2 * (i + k)); ratio = ratio * numerator / denominator; - a[r - k] -= a[i] * ratio; + a[r - k] -= a[i] * ratio; } } - // K = sum c[k] P[k, x] + // K = sum c[k] P[k, x] double[] c = new double[2 * r - q]; for (int i = 1; i < a.Length; i++) @@ -531,22 +530,22 @@ namespace MathNet.Numerics.Integration.GaussRule /// /// Return value and derivative of a Legendre series at given points. /// - internal static Tuple LegendreSeries(double[] a, double x) + static Tuple LegendreSeries(double[] a, double x) { // S = a[0]*P[0, x] + ... + a[k]*P[k, x] + ... + a[n]*P[n, x] // where P[k, x] is the Legendre polynomial of order k // // According to the Clenshaw algorithm, S can be written by // S = a[0] + x*b[1, x] - 1/2 * b[2,x] - // + // // b[n + 1, x] = 0 // b[n + 2, x] = 0 // b[k, x] = a[k] + (2k + 1)/(k + 1)*x*b[k + 1, x] - (k + 1)/(k + 2)*b[k + 2, x] // // Derivative of S is given by - // S' = b[1, x] + x*b'[1, x] - 1/2 * b'[2,x] + // S' = b[1, x] + x*b'[1, x] - 1/2 * b'[2,x] // - // b'[k, x] = (2k + 1)/(k + 1)*b[k + 1, x] + (2k + 1)/(k + 1)*x*b'[k + 1, x] - (k + 1)/(k + 2)*b'[k + 2, x] + // b'[k, x] = (2k + 1)/(k + 1)*b[k + 1, x] + (2k + 1)/(k + 1)*x*b'[k + 1, x] - (k + 1)/(k + 2)*b'[k + 2, x] if (a.Length == 1) return new Tuple(a[0], 0); @@ -576,7 +575,7 @@ namespace MathNet.Numerics.Integration.GaussRule /// /// Return value and derivative of a Legendre polynomial of order at given points. /// - internal static Tuple LegendreP(int order, double x) + static Tuple LegendreP(int order, double x) { // The Legendre polynomial, P[n, x], is defined by the recurrence relation: // @@ -602,7 +601,7 @@ namespace MathNet.Numerics.Integration.GaussRule { b0 = (2.0 * k - 1.0) / k * x * b1 - (k - 1.0) / k * b2; // L(k, x) p0 = (2.0 * k - 1.0) / k * (b1 + x * p1) - (k - 1.0) / k * p2; // L'(k, x) - + b2 = b1; b1 = b0; p2 = p1; diff --git a/src/Numerics/Integration/GaussRule/GaussKronrodPointFactory.cs b/src/Numerics/Integration/GaussRule/GaussKronrodPointFactory.cs index 372fb577..70e608f6 100644 --- a/src/Numerics/Integration/GaussRule/GaussKronrodPointFactory.cs +++ b/src/Numerics/Integration/GaussRule/GaussKronrodPointFactory.cs @@ -8,7 +8,7 @@ namespace MathNet.Numerics.Integration.GaussRule internal static class GaussKronrodPointFactory { [ThreadStatic] - private static GaussPointPair gaussKronrodPoint; + static GaussPointPair _gaussKronrodPoint; /// /// Getter for the GaussKronrodPoint. @@ -18,17 +18,17 @@ namespace MathNet.Numerics.Integration.GaussRule public static GaussPointPair GetGaussPoint(int order) { // Try to get the GaussKronrodPoint from the cached static field. - bool gaussKronrodPointIsCached = gaussKronrodPoint != null && gaussKronrodPoint.Order == order; + bool gaussKronrodPointIsCached = _gaussKronrodPoint != null && _gaussKronrodPoint.Order == order; if (!gaussKronrodPointIsCached) { - // Try to find the GaussKronrodPoint in the precomputed dictionary. - if (!GaussKronrodPoint.PreComputed.TryGetValue(order, out gaussKronrodPoint)) + // Try to find the GaussKronrodPoint in the precomputed dictionary. + if (!GaussKronrodPoint.PreComputed.TryGetValue(order, out _gaussKronrodPoint)) { - gaussKronrodPoint = GaussKronrodPoint.Generate(order, 1E-10); + _gaussKronrodPoint = GaussKronrodPoint.Generate(order, 1E-10); } } - return gaussKronrodPoint; + return _gaussKronrodPoint; } } } diff --git a/src/Numerics/Integration/GaussRule/GaussLegendrePointFactory.cs b/src/Numerics/Integration/GaussRule/GaussLegendrePointFactory.cs index b503c097..85028b5d 100644 --- a/src/Numerics/Integration/GaussRule/GaussLegendrePointFactory.cs +++ b/src/Numerics/Integration/GaussRule/GaussLegendrePointFactory.cs @@ -37,7 +37,7 @@ namespace MathNet.Numerics.Integration.GaussRule internal static class GaussLegendrePointFactory { [ThreadStatic] - private static GaussPoint _gaussLegendrePoint; + static GaussPoint _gaussLegendrePoint; /// /// Getter for the GaussPoint. @@ -79,7 +79,7 @@ namespace MathNet.Numerics.Integration.GaussRule /// Where the interval stops, inclusive and finite. /// Object containing the non-negative abscissas/weights, order, and intervalBegin/intervalEnd. The non-negative abscissas/weights are generated over the interval [-1,1] for the given order. /// Object containing the abscissas/weights, order, and intervalBegin/intervalEnd. - private static GaussPoint Map(double intervalBegin, double intervalEnd, GaussPoint gaussPoint) + static GaussPoint Map(double intervalBegin, double intervalEnd, GaussPoint gaussPoint) { double[] abscissas = new double[gaussPoint.Order]; double[] weights = new double[gaussPoint.Order]; diff --git a/src/Numerics/Integration/GaussRule/GaussPoint.cs b/src/Numerics/Integration/GaussRule/GaussPoint.cs index 6993cb45..022e348e 100644 --- a/src/Numerics/Integration/GaussRule/GaussPoint.cs +++ b/src/Numerics/Integration/GaussRule/GaussPoint.cs @@ -34,15 +34,15 @@ namespace MathNet.Numerics.Integration.GaussRule /// internal class GaussPoint { - internal double[] Abscissas { get; private set; } + internal double[] Abscissas { get; } - internal double[] Weights { get; private set; } + internal double[] Weights { get; } - internal double IntervalBegin { get; private set; } + internal double IntervalBegin { get; } - internal double IntervalEnd { get; private set; } + internal double IntervalEnd { get; } - internal int Order { get; private set; } + internal int Order { get; } internal GaussPoint(double intervalBegin, double intervalEnd, int order, double[] abscissas, double[] weights) { @@ -57,4 +57,4 @@ namespace MathNet.Numerics.Integration.GaussRule { } } -} \ No newline at end of file +} diff --git a/src/Numerics/Integration/GaussRule/GaussPointPair.cs b/src/Numerics/Integration/GaussRule/GaussPointPair.cs index c870474d..06b3df9c 100644 --- a/src/Numerics/Integration/GaussRule/GaussPointPair.cs +++ b/src/Numerics/Integration/GaussRule/GaussPointPair.cs @@ -5,21 +5,21 @@ /// internal class GaussPointPair { - internal int Order { get; private set; } + internal int Order { get; } - internal double[] Abscissas { get; private set; } + internal double[] Abscissas { get; } - internal double[] Weights { get; private set; } - - internal int SecondOrder { get; private set; } + internal double[] Weights { get; } - internal double[] SecondAbscissas { get; private set; } + internal int SecondOrder { get; } - internal double[] SecondWeights { get; private set; } + internal double[] SecondAbscissas { get; } - internal double IntervalBegin { get; private set; } + internal double[] SecondWeights { get; } - internal double IntervalEnd { get; private set; } + internal double IntervalBegin { get; } + + internal double IntervalEnd { get; } internal GaussPointPair(double intervalBegin, double intervalEnd, int order, double[] abscissas, double[] weights, int secondOrder, double[] secondAbscissas, double[] secondWeights) { @@ -30,7 +30,7 @@ Weights = weights; SecondOrder = secondOrder; SecondAbscissas = secondAbscissas; - SecondWeights = secondWeights; + SecondWeights = secondWeights; } internal GaussPointPair(int order, double[] abscissas, double[] weights, int secondOrder, double[] secondWeights) diff --git a/src/Numerics/Interpolate.cs b/src/Numerics/Interpolate.cs index 7c81c638..32275d38 100644 --- a/src/Numerics/Interpolate.cs +++ b/src/Numerics/Interpolate.cs @@ -156,7 +156,7 @@ namespace MathNet.Numerics /// public static IInterpolation Linear(IEnumerable points, IEnumerable values) { - return Interpolation.LinearSpline.Interpolate(points, values); + return LinearSpline.Interpolate(points, values); } /// diff --git a/src/Numerics/Interpolation/Barycentric.cs b/src/Numerics/Interpolation/Barycentric.cs index 977c52ff..90b3418d 100644 --- a/src/Numerics/Interpolation/Barycentric.cs +++ b/src/Numerics/Interpolation/Barycentric.cs @@ -325,38 +325,26 @@ namespace MathNet.Numerics.Interpolation /// /// Point t to interpolate at. /// Interpolated first derivative at point t. - double IInterpolation.Differentiate(double t) - { - throw new NotSupportedException(); - } + double IInterpolation.Differentiate(double t) => throw new NotSupportedException(); /// /// Differentiate twice at point t. NOT SUPPORTED. /// /// Point t to interpolate at. /// Interpolated second derivative at point t. - double IInterpolation.Differentiate2(double t) - { - throw new NotSupportedException(); - } + double IInterpolation.Differentiate2(double t) => throw new NotSupportedException(); /// /// Indefinite integral at point t. NOT SUPPORTED. /// /// Point t to integrate at. - double IInterpolation.Integrate(double t) - { - throw new NotSupportedException(); - } + double IInterpolation.Integrate(double t) => throw new NotSupportedException(); /// /// Definite integral between points a and b. NOT SUPPORTED. /// /// Left bound of the integration interval [a,b]. /// Right bound of the integration interval [a,b]. - double IInterpolation.Integrate(double a, double b) - { - throw new NotSupportedException(); - } + double IInterpolation.Integrate(double a, double b) => throw new NotSupportedException(); } } diff --git a/src/Numerics/Interpolation/BulirschStoerRationalInterpolation.cs b/src/Numerics/Interpolation/BulirschStoerRationalInterpolation.cs index cc9797e9..9dfeb767 100644 --- a/src/Numerics/Interpolation/BulirschStoerRationalInterpolation.cs +++ b/src/Numerics/Interpolation/BulirschStoerRationalInterpolation.cs @@ -173,38 +173,26 @@ namespace MathNet.Numerics.Interpolation /// /// Point t to interpolate at. /// Interpolated first derivative at point t. - double IInterpolation.Differentiate(double t) - { - throw new NotSupportedException(); - } + double IInterpolation.Differentiate(double t) => throw new NotSupportedException(); /// /// Differentiate twice at point t. NOT SUPPORTED. /// /// Point t to interpolate at. /// Interpolated second derivative at point t. - double IInterpolation.Differentiate2(double t) - { - throw new NotSupportedException(); - } + double IInterpolation.Differentiate2(double t) => throw new NotSupportedException(); /// /// Indefinite integral at point t. NOT SUPPORTED. /// /// Point t to integrate at. - double IInterpolation.Integrate(double t) - { - throw new NotSupportedException(); - } + double IInterpolation.Integrate(double t) => throw new NotSupportedException(); /// /// Definite integral between points a and b. NOT SUPPORTED. /// /// Left bound of the integration interval [a,b]. /// Right bound of the integration interval [a,b]. - double IInterpolation.Integrate(double a, double b) - { - throw new NotSupportedException(); - } + double IInterpolation.Integrate(double a, double b) => throw new NotSupportedException(); } } diff --git a/src/Numerics/Interpolation/CubicSpline.cs b/src/Numerics/Interpolation/CubicSpline.cs index 0500c37e..1830da86 100644 --- a/src/Numerics/Interpolation/CubicSpline.cs +++ b/src/Numerics/Interpolation/CubicSpline.cs @@ -229,7 +229,7 @@ namespace MathNet.Numerics.Interpolation } var m = new double[x.Length - 1]; - + for (int i = 0; i < m.Length; i++) { m[i] = (y[i + 1] - y[i])/(x[i + 1] - x[i]); @@ -259,7 +259,7 @@ namespace MathNet.Numerics.Interpolation hPrev = h; mPrevIs0 = mIs0; } - + // Special case end-points. dd[0] = PchipEndPoints(x[1] - x[0], x[2] - x[1], m[0], m[1]); dd[dd.Length - 1] = PchipEndPoints( @@ -595,10 +595,7 @@ namespace MathNet.Numerics.Interpolation /// /// Left bound of the integration interval [a,b]. /// Right bound of the integration interval [a,b]. - public double Integrate(double a, double b) - { - return Integrate(b) - Integrate(a); - } + public double Integrate(double a, double b) => Integrate(b) - Integrate(a); double[] ComputeIndefiniteIntegral() { diff --git a/src/Numerics/Interpolation/LinearSpline.cs b/src/Numerics/Interpolation/LinearSpline.cs index ef38992a..0f192c3e 100644 --- a/src/Numerics/Interpolation/LinearSpline.cs +++ b/src/Numerics/Interpolation/LinearSpline.cs @@ -150,10 +150,7 @@ namespace MathNet.Numerics.Interpolation /// /// Point t to interpolate at. /// Interpolated second derivative at point t. - public double Differentiate2(double t) - { - return 0d; - } + public double Differentiate2(double t) => 0d; /// /// Indefinite integral at point t. @@ -171,10 +168,7 @@ namespace MathNet.Numerics.Interpolation /// /// Left bound of the integration interval [a,b]. /// Right bound of the integration interval [a,b]. - public double Integrate(double a, double b) - { - return Integrate(b) - Integrate(a); - } + public double Integrate(double a, double b) => Integrate(b) - Integrate(a); double[] ComputeIndefiniteIntegral() { diff --git a/src/Numerics/Interpolation/LogLinear.cs b/src/Numerics/Interpolation/LogLinear.cs index b56bf2e3..e40702e0 100644 --- a/src/Numerics/Interpolation/LogLinear.cs +++ b/src/Numerics/Interpolation/LogLinear.cs @@ -156,19 +156,13 @@ namespace MathNet.Numerics.Interpolation /// Indefinite integral at point t. /// /// Point t to integrate at. - double IInterpolation.Integrate(double t) - { - throw new NotSupportedException(); - } + double IInterpolation.Integrate(double t) => throw new NotSupportedException(); /// /// Definite integral between points a and b. /// /// Left bound of the integration interval [a,b]. /// Right bound of the integration interval [a,b]. - double IInterpolation.Integrate(double a, double b) - { - throw new NotSupportedException(); - } + double IInterpolation.Integrate(double a, double b) => throw new NotSupportedException(); } } diff --git a/src/Numerics/Interpolation/NevillePolynomialInterpolation.cs b/src/Numerics/Interpolation/NevillePolynomialInterpolation.cs index 9344a44c..389ea845 100644 --- a/src/Numerics/Interpolation/NevillePolynomialInterpolation.cs +++ b/src/Numerics/Interpolation/NevillePolynomialInterpolation.cs @@ -201,19 +201,13 @@ namespace MathNet.Numerics.Interpolation /// Indefinite integral at point t. NOT SUPPORTED. /// /// Point t to integrate at. - double IInterpolation.Integrate(double t) - { - throw new NotSupportedException(); - } + double IInterpolation.Integrate(double t) => throw new NotSupportedException(); /// /// Definite integral between points a and b. NOT SUPPORTED. /// /// Left bound of the integration interval [a,b]. /// Right bound of the integration interval [a,b]. - double IInterpolation.Integrate(double a, double b) - { - throw new NotSupportedException(); - } + double IInterpolation.Integrate(double a, double b) => throw new NotSupportedException(); } } diff --git a/src/Numerics/Interpolation/QuadraticSpline.cs b/src/Numerics/Interpolation/QuadraticSpline.cs index 843345c4..f25edf55 100644 --- a/src/Numerics/Interpolation/QuadraticSpline.cs +++ b/src/Numerics/Interpolation/QuadraticSpline.cs @@ -126,10 +126,7 @@ namespace MathNet.Numerics.Interpolation /// /// Left bound of the integration interval [a,b]. /// Right bound of the integration interval [a,b]. - public double Integrate(double a, double b) - { - return Integrate(b) - Integrate(a); - } + public double Integrate(double a, double b) => Integrate(b) - Integrate(a); double[] ComputeIndefiniteIntegral() { diff --git a/src/Numerics/Interpolation/StepInterpolation.cs b/src/Numerics/Interpolation/StepInterpolation.cs index e2018224..c439ae87 100644 --- a/src/Numerics/Interpolation/StepInterpolation.cs +++ b/src/Numerics/Interpolation/StepInterpolation.cs @@ -137,10 +137,7 @@ namespace MathNet.Numerics.Interpolation /// /// Point t to interpolate at. /// Interpolated second derivative at point t. - public double Differentiate2(double t) - { - return Differentiate(t); - } + public double Differentiate2(double t) => Differentiate(t); /// /// Indefinite integral at point t. @@ -163,10 +160,7 @@ namespace MathNet.Numerics.Interpolation /// /// Left bound of the integration interval [a,b]. /// Right bound of the integration interval [a,b]. - public double Integrate(double a, double b) - { - return Integrate(b) - Integrate(a); - } + public double Integrate(double a, double b) => Integrate(b) - Integrate(a); double[] ComputeIndefiniteIntegral() { diff --git a/src/Numerics/Interpolation/TransformedInterpolation.cs b/src/Numerics/Interpolation/TransformedInterpolation.cs index b2da0435..36b58a6f 100644 --- a/src/Numerics/Interpolation/TransformedInterpolation.cs +++ b/src/Numerics/Interpolation/TransformedInterpolation.cs @@ -130,48 +130,33 @@ namespace MathNet.Numerics.Interpolation /// /// Point t to interpolate at. /// Interpolated value x(t). - public double Interpolate(double t) - { - return _transform(_interpolation.Interpolate(t)); - } + public double Interpolate(double t) => _transform(_interpolation.Interpolate(t)); /// /// Differentiate at point t. NOT SUPPORTED. /// /// Point t to interpolate at. /// Interpolated first derivative at point t. - double IInterpolation.Differentiate(double t) - { - throw new NotSupportedException(); - } + double IInterpolation.Differentiate(double t) => throw new NotSupportedException(); /// /// Differentiate twice at point t. NOT SUPPORTED. /// /// Point t to interpolate at. /// Interpolated second derivative at point t. - double IInterpolation.Differentiate2(double t) - { - throw new NotSupportedException(); - } + double IInterpolation.Differentiate2(double t) => throw new NotSupportedException(); /// /// Indefinite integral at point t. NOT SUPPORTED. /// /// Point t to integrate at. - double IInterpolation.Integrate(double t) - { - throw new NotSupportedException(); - } + double IInterpolation.Integrate(double t) => throw new NotSupportedException(); /// /// Definite integral between points a and b. NOT SUPPORTED. /// /// Left bound of the integration interval [a,b]. /// Right bound of the integration interval [a,b]. - double IInterpolation.Integrate(double a, double b) - { - throw new NotSupportedException(); - } + double IInterpolation.Integrate(double a, double b) => throw new NotSupportedException(); } } diff --git a/src/Numerics/LinearAlgebra/Builder.cs b/src/Numerics/LinearAlgebra/Builder.cs index bcec4648..bdab2ae3 100644 --- a/src/Numerics/LinearAlgebra/Builder.cs +++ b/src/Numerics/LinearAlgebra/Builder.cs @@ -1622,8 +1622,8 @@ namespace MathNet.Numerics.LinearAlgebra if (typeof (T) == typeof (System.Numerics.Complex)) { return new Tuple, VectorBuilder>( - (MatrixBuilder)(object)new LinearAlgebra.Complex.MatrixBuilder(), - (VectorBuilder)(object)new LinearAlgebra.Complex.VectorBuilder()); + (MatrixBuilder)(object)new Complex.MatrixBuilder(), + (VectorBuilder)(object)new Complex.VectorBuilder()); } if (typeof (T) == typeof (Numerics.Complex32)) diff --git a/src/Numerics/LinearAlgebra/Complex/Factorization/DenseGramSchmidt.cs b/src/Numerics/LinearAlgebra/Complex/Factorization/DenseGramSchmidt.cs index 031b8461..571691a8 100644 --- a/src/Numerics/LinearAlgebra/Complex/Factorization/DenseGramSchmidt.cs +++ b/src/Numerics/LinearAlgebra/Complex/Factorization/DenseGramSchmidt.cs @@ -78,7 +78,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization /// Number of rows in Q. /// Number of columns in Q. /// On exit is filled by R. - private static void Factorize(Complex[] q, int rowsQ, int columnsQ, Complex[] r) + static void Factorize(Complex[] q, int rowsQ, int columnsQ, Complex[] r) { for (var k = 0; k < columnsQ; k++) { diff --git a/src/Numerics/LinearAlgebra/Complex/Matrix.cs b/src/Numerics/LinearAlgebra/Complex/Matrix.cs index 6badc6f3..70cc5fdb 100644 --- a/src/Numerics/LinearAlgebra/Complex/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Complex/Matrix.cs @@ -455,7 +455,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex protected override void DoPointwiseAbs(Matrix result) { - Map(x => (Complex)Complex.Abs(x), result, Zeros.AllowSkip); + Map(x => Complex.Abs(x), result, Zeros.AllowSkip); } protected override void DoPointwiseAcos(Matrix result) { diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/ILUTPPreconditioner.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/ILUTPPreconditioner.cs index ebf1ba99..f0ff042c 100644 --- a/src/Numerics/LinearAlgebra/Complex/Solvers/ILUTPPreconditioner.cs +++ b/src/Numerics/LinearAlgebra/Complex/Solvers/ILUTPPreconditioner.cs @@ -714,7 +714,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers /// The stopping index. /// An array that will contain the sorted indices once the algorithm finishes. /// The that contains the values that need to be sorted. - private static void HeapSortDoublesIndices(int lowerBound, int upperBound, int[] sortedIndices, Vector values) + static void HeapSortDoublesIndices(int lowerBound, int upperBound, int[] sortedIndices, Vector values) { var start = ((upperBound - lowerBound + 1) / 2) - 1 + lowerBound; var end = (upperBound - lowerBound + 1) - 1 + lowerBound; @@ -736,7 +736,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers /// Length of /// Indices of /// Target - private static void BuildDoubleIndexHeap(int start, int count, int[] sortedIndices, Vector values) + static void BuildDoubleIndexHeap(int start, int count, int[] sortedIndices, Vector values) { while (start >= 0) { @@ -752,7 +752,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers /// Target /// Root position /// Length of - private static void SiftDoubleIndices(int[] sortedIndices, Vector values, int begin, int count) + static void SiftDoubleIndices(int[] sortedIndices, Vector values, int begin, int count) { var root = begin; @@ -788,7 +788,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers /// /// Array of values to sort /// Length of - private static void HeapSortIntegers(int[] values, int count) + static void HeapSortIntegers(int[] values, int count) { var start = (count / 2) - 1; var end = count - 1; @@ -809,7 +809,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers /// Target values array /// Root position /// Length of - private static void BuildHeap(int[] values, int start, int count) + static void BuildHeap(int[] values, int start, int count) { while (start >= 0) { @@ -824,7 +824,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers /// Target value array /// Root position /// Length of - private static void Sift(int[] values, int start, int count) + static void Sift(int[] values, int start, int count) { var root = start; @@ -854,7 +854,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers /// Target values array /// First value to exchange /// Second value to exchange - private static void Exchange(int[] values, int first, int second) + static void Exchange(int[] values, int first, int second) { var t = values[first]; values[first] = values[second]; diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/MILU0Preconditioner.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/MILU0Preconditioner.cs index aab88c5b..5e9b810e 100644 --- a/src/Numerics/LinearAlgebra/Complex/Solvers/MILU0Preconditioner.cs +++ b/src/Numerics/LinearAlgebra/Complex/Solvers/MILU0Preconditioner.cs @@ -49,13 +49,13 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers // The diagonal (stored in alu(0:n-1) ) is inverted. Each i-th row of the matrix // contains the i-th row of L (excluding the diagonal entry = 1) followed by // the i-th row of U. - private Complex[] _alu; + Complex[] _alu; // The row pointers (stored in jlu(0:n) ) and column indices to off-diagonal elements. - private int[] _jlu; + int[] _jlu; // Pointer to the diagonal elements in MSR storage (for faster LU solving). - private int[] _diag; + int[] _diag; /// Use modified or standard ILU(0) public MILU0Preconditioner(bool modified = true) @@ -165,7 +165,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers /// Pointer to diagonal elements (output). /// True if the modified/MILU algorithm should be used (recommended) /// Returns 0 on success or k > 0 if a zero pivot was encountered at step k. - private int Compute(int n, Complex[] a, int[] ja, int[] ia, Complex[] alu, int[] jlu, int[] ju, bool modified) + int Compute(int n, Complex[] a, int[] ja, int[] ia, Complex[] alu, int[] jlu, int[] ju, bool modified) { var iw = new int[n]; int i; diff --git a/src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs b/src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs index 5ab1f838..19de6af3 100644 --- a/src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs +++ b/src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs @@ -412,7 +412,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// Puts the lower triangle of this matrix into the result matrix. /// /// Where to store the lower triangle. - private void LowerTriangleImpl(Matrix result) + void LowerTriangleImpl(Matrix result) { var rowPointers = _storage.RowPointers; var columnIndices = _storage.ColumnIndices; @@ -477,7 +477,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// Puts the upper triangle of this matrix into the result matrix. /// /// Where to store the lower triangle. - private void UpperTriangleImpl(Matrix result) + void UpperTriangleImpl(Matrix result) { var rowPointers = _storage.RowPointers; var columnIndices = _storage.ColumnIndices; @@ -543,7 +543,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// Puts the strictly lower triangle of this matrix into the result matrix. /// /// Where to store the lower triangle. - private void StrictlyLowerTriangleImpl(Matrix result) + void StrictlyLowerTriangleImpl(Matrix result) { var rowPointers = _storage.RowPointers; var columnIndices = _storage.ColumnIndices; @@ -609,7 +609,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// Puts the strictly upper triangle of this matrix into the result matrix. /// /// Where to store the lower triangle. - private void StrictlyUpperTriangleImpl(Matrix result) + void StrictlyUpperTriangleImpl(Matrix result) { var rowPointers = _storage.RowPointers; var columnIndices = _storage.ColumnIndices; diff --git a/src/Numerics/LinearAlgebra/Complex/Vector.cs b/src/Numerics/LinearAlgebra/Complex/Vector.cs index 018ddb1c..65b98cca 100644 --- a/src/Numerics/LinearAlgebra/Complex/Vector.cs +++ b/src/Numerics/LinearAlgebra/Complex/Vector.cs @@ -251,7 +251,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex protected override void DoPointwiseAbs(Vector result) { - Map(x => (Complex)Complex.Abs(x), result, Zeros.AllowSkip); + Map(x => Complex.Abs(x), result, Zeros.AllowSkip); } protected override void DoPointwiseAcos(Vector result) { diff --git a/src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs b/src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs index 015f5a12..54943de0 100644 --- a/src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs +++ b/src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs @@ -54,14 +54,14 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// Using this instead of the RowCount property to speed up calculating /// a matrix index in the data array. - private readonly int _rowCount; + readonly int _rowCount; /// /// Number of columns. /// /// Using this instead of the ColumnCount property to speed up calculating /// a matrix index in the data array. - private readonly int _columnCount; + readonly int _columnCount; /// /// Gets the matrix's data. diff --git a/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseGramSchmidt.cs b/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseGramSchmidt.cs index 4f48fa3b..8d65682b 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseGramSchmidt.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseGramSchmidt.cs @@ -78,7 +78,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization /// Number of rows in Q. /// Number of columns in Q. /// On exit is filled by R. - private static void Factorize(Complex32[] q, int rowsQ, int columnsQ, Complex32[] r) + static void Factorize(Complex32[] q, int rowsQ, int columnsQ, Complex32[] r) { for (var k = 0; k < columnsQ; k++) { diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/ILUTPPreconditioner.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/ILUTPPreconditioner.cs index bfd86832..4b29f602 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Solvers/ILUTPPreconditioner.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/ILUTPPreconditioner.cs @@ -720,7 +720,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers /// The stopping index. /// An array that will contain the sorted indices once the algorithm finishes. /// The that contains the values that need to be sorted. - private static void HeapSortDoublesIndices(int lowerBound, int upperBound, int[] sortedIndices, Vector values) + static void HeapSortDoublesIndices(int lowerBound, int upperBound, int[] sortedIndices, Vector values) { var start = ((upperBound - lowerBound + 1) / 2) - 1 + lowerBound; var end = (upperBound - lowerBound + 1) - 1 + lowerBound; @@ -742,7 +742,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers /// Length of /// Indices of /// Target - private static void BuildDoubleIndexHeap(int start, int count, int[] sortedIndices, Vector values) + static void BuildDoubleIndexHeap(int start, int count, int[] sortedIndices, Vector values) { while (start >= 0) { @@ -758,7 +758,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers /// Target /// Root position /// Length of - private static void SiftDoubleIndices(int[] sortedIndices, Vector values, int begin, int count) + static void SiftDoubleIndices(int[] sortedIndices, Vector values, int begin, int count) { var root = begin; @@ -794,7 +794,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers /// /// Array of values to sort /// Length of - private static void HeapSortIntegers(int[] values, int count) + static void HeapSortIntegers(int[] values, int count) { var start = (count / 2) - 1; var end = count - 1; @@ -815,7 +815,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers /// Target values array /// Root position /// Length of - private static void BuildHeap(int[] values, int start, int count) + static void BuildHeap(int[] values, int start, int count) { while (start >= 0) { @@ -830,7 +830,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers /// Target value array /// Root position /// Length of - private static void Sift(int[] values, int start, int count) + static void Sift(int[] values, int start, int count) { var root = start; @@ -860,7 +860,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers /// Target values array /// First value to exchange /// Second value to exchange - private static void Exchange(int[] values, int first, int second) + static void Exchange(int[] values, int first, int second) { var t = values[first]; values[first] = values[second]; diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/MILU0Preconditioner.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/MILU0Preconditioner.cs index 07096e81..ee46fbb1 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Solvers/MILU0Preconditioner.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/MILU0Preconditioner.cs @@ -49,13 +49,13 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers // The diagonal (stored in alu(0:n-1) ) is inverted. Each i-th row of the matrix // contains the i-th row of L (excluding the diagonal entry = 1) followed by // the i-th row of U. - private Complex32[] _alu; + Complex32[] _alu; // The row pointers (stored in jlu(0:n) ) and column indices to off-diagonal elements. - private int[] _jlu; + int[] _jlu; // Pointer to the diagonal elements in MSR storage (for faster LU solving). - private int[] _diag; + int[] _diag; /// Use modified or standard ILU(0) public MILU0Preconditioner(bool modified = true) @@ -165,7 +165,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers /// Pointer to diagonal elements (output). /// True if the modified/MILU algorithm should be used (recommended) /// Returns 0 on success or k > 0 if a zero pivot was encountered at step k. - private int Compute(int n, Complex32[] a, int[] ja, int[] ia, Complex32[] alu, int[] jlu, int[] ju, bool modified) + int Compute(int n, Complex32[] a, int[] ja, int[] ia, Complex32[] alu, int[] jlu, int[] ju, bool modified) { var iw = new int[n]; int i; diff --git a/src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs b/src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs index 7816511b..2680303c 100644 --- a/src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs +++ b/src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs @@ -412,7 +412,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// Puts the lower triangle of this matrix into the result matrix. /// /// Where to store the lower triangle. - private void LowerTriangleImpl(Matrix result) + void LowerTriangleImpl(Matrix result) { var rowPointers = _storage.RowPointers; var columnIndices = _storage.ColumnIndices; @@ -477,7 +477,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// Puts the upper triangle of this matrix into the result matrix. /// /// Where to store the lower triangle. - private void UpperTriangleImpl(Matrix result) + void UpperTriangleImpl(Matrix result) { var rowPointers = _storage.RowPointers; var columnIndices = _storage.ColumnIndices; @@ -543,7 +543,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// Puts the strictly lower triangle of this matrix into the result matrix. /// /// Where to store the lower triangle. - private void StrictlyLowerTriangleImpl(Matrix result) + void StrictlyLowerTriangleImpl(Matrix result) { var rowPointers = _storage.RowPointers; var columnIndices = _storage.ColumnIndices; @@ -609,7 +609,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// Puts the strictly upper triangle of this matrix into the result matrix. /// /// Where to store the lower triangle. - private void StrictlyUpperTriangleImpl(Matrix result) + void StrictlyUpperTriangleImpl(Matrix result) { var rowPointers = _storage.RowPointers; var columnIndices = _storage.ColumnIndices; diff --git a/src/Numerics/LinearAlgebra/Double/Factorization/DenseGramSchmidt.cs b/src/Numerics/LinearAlgebra/Double/Factorization/DenseGramSchmidt.cs index 6986d9f5..d1c12793 100644 --- a/src/Numerics/LinearAlgebra/Double/Factorization/DenseGramSchmidt.cs +++ b/src/Numerics/LinearAlgebra/Double/Factorization/DenseGramSchmidt.cs @@ -76,7 +76,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization /// Number of rows in Q. /// Number of columns in Q. /// On exit is filled by R. - private static void Factorize(double[] q, int rowsQ, int columnsQ, double[] r) + static void Factorize(double[] q, int rowsQ, int columnsQ, double[] r) { for (var k = 0; k < columnsQ; k++) { diff --git a/src/Numerics/LinearAlgebra/Double/Matrix.cs b/src/Numerics/LinearAlgebra/Double/Matrix.cs index 7f5be88d..162cbc0c 100644 --- a/src/Numerics/LinearAlgebra/Double/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Double/Matrix.cs @@ -469,7 +469,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double } protected override void DoPointwiseSign(Matrix result) { - Map(x => (double)Math.Sign(x), result, Zeros.AllowSkip); + Map(x => Math.Sign(x), result, Zeros.AllowSkip); } protected override void DoPointwiseSin(Matrix result) { diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/ILUTPPreconditioner.cs b/src/Numerics/LinearAlgebra/Double/Solvers/ILUTPPreconditioner.cs index 30d88a08..0660d834 100644 --- a/src/Numerics/LinearAlgebra/Double/Solvers/ILUTPPreconditioner.cs +++ b/src/Numerics/LinearAlgebra/Double/Solvers/ILUTPPreconditioner.cs @@ -718,7 +718,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers /// The stopping index. /// An array that will contain the sorted indices once the algorithm finishes. /// The that contains the values that need to be sorted. - private static void HeapSortDoublesIndices(int lowerBound, int upperBound, int[] sortedIndices, Vector values) + static void HeapSortDoublesIndices(int lowerBound, int upperBound, int[] sortedIndices, Vector values) { var start = ((upperBound - lowerBound + 1) / 2) - 1 + lowerBound; var end = (upperBound - lowerBound + 1) - 1 + lowerBound; @@ -740,7 +740,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers /// Length of /// Indices of /// Target - private static void BuildDoubleIndexHeap(int start, int count, int[] sortedIndices, Vector values) + static void BuildDoubleIndexHeap(int start, int count, int[] sortedIndices, Vector values) { while (start >= 0) { @@ -756,7 +756,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers /// Target /// Root position /// Length of - private static void SiftDoubleIndices(int[] sortedIndices, Vector values, int begin, int count) + static void SiftDoubleIndices(int[] sortedIndices, Vector values, int begin, int count) { var root = begin; @@ -792,7 +792,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers /// /// Array of values to sort /// Length of - private static void HeapSortIntegers(int[] values, int count) + static void HeapSortIntegers(int[] values, int count) { var start = (count / 2) - 1; var end = count - 1; @@ -813,7 +813,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers /// Target values array /// Root position /// Length of - private static void BuildHeap(int[] values, int start, int count) + static void BuildHeap(int[] values, int start, int count) { while (start >= 0) { @@ -828,7 +828,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers /// Target value array /// Root position /// Length of - private static void Sift(int[] values, int start, int count) + static void Sift(int[] values, int start, int count) { var root = start; @@ -858,7 +858,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers /// Target values array /// First value to exchange /// Second value to exchange - private static void Exchange(int[] values, int first, int second) + static void Exchange(int[] values, int first, int second) { var t = values[first]; values[first] = values[second]; diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/MILU0Preconditioner.cs b/src/Numerics/LinearAlgebra/Double/Solvers/MILU0Preconditioner.cs index 8f9565a6..5f09aabc 100644 --- a/src/Numerics/LinearAlgebra/Double/Solvers/MILU0Preconditioner.cs +++ b/src/Numerics/LinearAlgebra/Double/Solvers/MILU0Preconditioner.cs @@ -47,13 +47,13 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers // The diagonal (stored in alu(0:n-1) ) is inverted. Each i-th row of the matrix // contains the i-th row of L (excluding the diagonal entry = 1) followed by // the i-th row of U. - private double[] _alu; + double[] _alu; // The row pointers (stored in jlu(0:n) ) and column indices to off-diagonal elements. - private int[] _jlu; + int[] _jlu; // Pointer to the diagonal elements in MSR storage (for faster LU solving). - private int[] _diag; + int[] _diag; /// Use modified or standard ILU(0) public MILU0Preconditioner(bool modified = true) @@ -163,7 +163,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers /// Pointer to diagonal elements (output). /// True if the modified/MILU algorithm should be used (recommended) /// Returns 0 on success or k > 0 if a zero pivot was encountered at step k. - private int Compute(int n, double[] a, int[] ja, int[] ia, double[] alu, int[] jlu, int[] ju, bool modified) + int Compute(int n, double[] a, int[] ja, int[] ia, double[] alu, int[] jlu, int[] ju, bool modified) { var iw = new int[n]; int i; diff --git a/src/Numerics/LinearAlgebra/Double/SparseMatrix.cs b/src/Numerics/LinearAlgebra/Double/SparseMatrix.cs index 56c8d9dd..00b474ca 100644 --- a/src/Numerics/LinearAlgebra/Double/SparseMatrix.cs +++ b/src/Numerics/LinearAlgebra/Double/SparseMatrix.cs @@ -410,7 +410,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// Puts the lower triangle of this matrix into the result matrix. /// /// Where to store the lower triangle. - private void LowerTriangleImpl(Matrix result) + void LowerTriangleImpl(Matrix result) { var rowPointers = _storage.RowPointers; var columnIndices = _storage.ColumnIndices; @@ -475,7 +475,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// Puts the upper triangle of this matrix into the result matrix. /// /// Where to store the lower triangle. - private void UpperTriangleImpl(Matrix result) + void UpperTriangleImpl(Matrix result) { var rowPointers = _storage.RowPointers; var columnIndices = _storage.ColumnIndices; @@ -541,7 +541,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// Puts the strictly lower triangle of this matrix into the result matrix. /// /// Where to store the lower triangle. - private void StrictlyLowerTriangleImpl(Matrix result) + void StrictlyLowerTriangleImpl(Matrix result) { var rowPointers = _storage.RowPointers; var columnIndices = _storage.ColumnIndices; @@ -607,7 +607,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// Puts the strictly upper triangle of this matrix into the result matrix. /// /// Where to store the lower triangle. - private void StrictlyUpperTriangleImpl(Matrix result) + void StrictlyUpperTriangleImpl(Matrix result) { var rowPointers = _storage.RowPointers; var columnIndices = _storage.ColumnIndices; diff --git a/src/Numerics/LinearAlgebra/Double/Vector.cs b/src/Numerics/LinearAlgebra/Double/Vector.cs index 8966b6cd..2729c109 100644 --- a/src/Numerics/LinearAlgebra/Double/Vector.cs +++ b/src/Numerics/LinearAlgebra/Double/Vector.cs @@ -302,7 +302,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double } protected override void DoPointwiseSign(Vector result) { - Map(x => (double)Math.Sign(x), result, Zeros.AllowSkip); + Map(x => Math.Sign(x), result, Zeros.AllowSkip); } protected override void DoPointwiseSin(Vector result) { diff --git a/src/Numerics/LinearAlgebra/Factorization/Cholesky.cs b/src/Numerics/LinearAlgebra/Factorization/Cholesky.cs index fb55b537..935097b0 100644 --- a/src/Numerics/LinearAlgebra/Factorization/Cholesky.cs +++ b/src/Numerics/LinearAlgebra/Factorization/Cholesky.cs @@ -52,7 +52,7 @@ namespace MathNet.Numerics.LinearAlgebra.Factorization /// /// Gets the lower triangular form of the Cholesky matrix. /// - public Matrix Factor { get; private set; } + public Matrix Factor { get; } /// /// Gets the determinant of the matrix for which the Cholesky matrix was computed. diff --git a/src/Numerics/LinearAlgebra/Factorization/Evd.cs b/src/Numerics/LinearAlgebra/Factorization/Evd.cs index 7a2c373b..7eda00e2 100644 --- a/src/Numerics/LinearAlgebra/Factorization/Evd.cs +++ b/src/Numerics/LinearAlgebra/Factorization/Evd.cs @@ -64,7 +64,7 @@ namespace MathNet.Numerics.LinearAlgebra.Factorization /// /// Gets or sets a value indicating whether matrix is symmetric or not /// - public bool IsSymmetric { get; private set; } + public bool IsSymmetric { get; } /// /// Gets the absolute value of determinant of the square matrix for which the EVD was computed. @@ -86,17 +86,17 @@ namespace MathNet.Numerics.LinearAlgebra.Factorization /// /// Gets or sets the eigen values (λ) of matrix in ascending value. /// - public Vector EigenValues { get; private set; } + public Vector EigenValues { get; } /// /// Gets or sets eigenvectors. /// - public Matrix EigenVectors { get; private set; } + public Matrix EigenVectors { get; } /// /// Gets or sets the block diagonal eigenvalue matrix. /// - public Matrix D { get; private set; } + public Matrix D { get; } /// /// Solves a system of linear equations, AX = B, with A EVD factorized. diff --git a/src/Numerics/LinearAlgebra/Matrix.Arithmetic.cs b/src/Numerics/LinearAlgebra/Matrix.Arithmetic.cs index 7845fe27..aef0c9d1 100644 --- a/src/Numerics/LinearAlgebra/Matrix.Arithmetic.cs +++ b/src/Numerics/LinearAlgebra/Matrix.Arithmetic.cs @@ -1045,7 +1045,7 @@ namespace MathNet.Numerics.LinearAlgebra return result; } - private static Matrix IntPower(int exponent, Matrix x, Matrix y, Matrix work) + static Matrix IntPower(int exponent, Matrix x, Matrix y, Matrix work) { // We try to be smart about not allocating more matrices than needed // and to minimize the number of multiplications (not optimal on either though) diff --git a/src/Numerics/LinearAlgebra/Single/Factorization/DenseGramSchmidt.cs b/src/Numerics/LinearAlgebra/Single/Factorization/DenseGramSchmidt.cs index c206c6e3..ef10a9e1 100644 --- a/src/Numerics/LinearAlgebra/Single/Factorization/DenseGramSchmidt.cs +++ b/src/Numerics/LinearAlgebra/Single/Factorization/DenseGramSchmidt.cs @@ -76,7 +76,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization /// Number of rows in Q. /// Number of columns in Q. /// On exit is filled by R. - private static void Factorize(float[] q, int rowsQ, int columnsQ, float[] r) + static void Factorize(float[] q, int rowsQ, int columnsQ, float[] r) { for (var k = 0; k < columnsQ; k++) { diff --git a/src/Numerics/LinearAlgebra/Single/Matrix.cs b/src/Numerics/LinearAlgebra/Single/Matrix.cs index 48987587..e82f7d8b 100644 --- a/src/Numerics/LinearAlgebra/Single/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Single/Matrix.cs @@ -425,7 +425,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single protected override void DoPointwiseAbs(Matrix result) { - Map(x => (float)Math.Abs(x), result, Zeros.AllowSkip); + Map(x => Math.Abs(x), result, Zeros.AllowSkip); } protected override void DoPointwiseAcos(Matrix result) { @@ -441,7 +441,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single } protected override void DoPointwiseAtan2(Matrix other, Matrix result) { - Map2((x, y) => (float)Math.Atan2((double)x, (double)y), other, result, Zeros.Include); + Map2((x, y) => (float)Math.Atan2(x, y), other, result, Zeros.Include); } protected override void DoPointwiseCeiling(Matrix result) { @@ -469,7 +469,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single } protected override void DoPointwiseSign(Matrix result) { - Map(x => (float)Math.Sign(x), result, Zeros.AllowSkip); + Map(x => Math.Sign(x), result, Zeros.AllowSkip); } protected override void DoPointwiseSin(Matrix result) { diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/ILUTPPreconditioner.cs b/src/Numerics/LinearAlgebra/Single/Solvers/ILUTPPreconditioner.cs index 60a45c4f..2c8d4a44 100644 --- a/src/Numerics/LinearAlgebra/Single/Solvers/ILUTPPreconditioner.cs +++ b/src/Numerics/LinearAlgebra/Single/Solvers/ILUTPPreconditioner.cs @@ -718,7 +718,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// The stopping index. /// An array that will contain the sorted indices once the algorithm finishes. /// The that contains the values that need to be sorted. - private static void HeapSortDoublesIndices(int lowerBound, int upperBound, int[] sortedIndices, Vector values) + static void HeapSortDoublesIndices(int lowerBound, int upperBound, int[] sortedIndices, Vector values) { var start = ((upperBound - lowerBound + 1) / 2) - 1 + lowerBound; var end = (upperBound - lowerBound + 1) - 1 + lowerBound; @@ -740,7 +740,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// Length of /// Indices of /// Target - private static void BuildDoubleIndexHeap(int start, int count, int[] sortedIndices, Vector values) + static void BuildDoubleIndexHeap(int start, int count, int[] sortedIndices, Vector values) { while (start >= 0) { @@ -756,7 +756,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// Target /// Root position /// Length of - private static void SiftDoubleIndices(int[] sortedIndices, Vector values, int begin, int count) + static void SiftDoubleIndices(int[] sortedIndices, Vector values, int begin, int count) { var root = begin; @@ -792,7 +792,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// /// Array of values to sort /// Length of - private static void HeapSortIntegers(int[] values, int count) + static void HeapSortIntegers(int[] values, int count) { var start = (count / 2) - 1; var end = count - 1; @@ -813,7 +813,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// Target values array /// Root position /// Length of - private static void BuildHeap(int[] values, int start, int count) + static void BuildHeap(int[] values, int start, int count) { while (start >= 0) { @@ -828,7 +828,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// Target value array /// Root position /// Length of - private static void Sift(int[] values, int start, int count) + static void Sift(int[] values, int start, int count) { var root = start; @@ -858,7 +858,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// Target values array /// First value to exchange /// Second value to exchange - private static void Exchange(int[] values, int first, int second) + static void Exchange(int[] values, int first, int second) { var t = values[first]; values[first] = values[second]; diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/MILU0Preconditioner.cs b/src/Numerics/LinearAlgebra/Single/Solvers/MILU0Preconditioner.cs index 253e1dd2..65ba0609 100644 --- a/src/Numerics/LinearAlgebra/Single/Solvers/MILU0Preconditioner.cs +++ b/src/Numerics/LinearAlgebra/Single/Solvers/MILU0Preconditioner.cs @@ -47,13 +47,13 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers // The diagonal (stored in alu(0:n-1) ) is inverted. Each i-th row of the matrix // contains the i-th row of L (excluding the diagonal entry = 1) followed by // the i-th row of U. - private float[] _alu; + float[] _alu; // The row pointers (stored in jlu(0:n) ) and column indices to off-diagonal elements. - private int[] _jlu; + int[] _jlu; // Pointer to the diagonal elements in MSR storage (for faster LU solving). - private int[] _diag; + int[] _diag; /// Use modified or standard ILU(0) public MILU0Preconditioner(bool modified = true) @@ -163,7 +163,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// Pointer to diagonal elements (output). /// True if the modified/MILU algorithm should be used (recommended) /// Returns 0 on success or k > 0 if a zero pivot was encountered at step k. - private int Compute(int n, float[] a, int[] ja, int[] ia, float[] alu, int[] jlu, int[] ju, bool modified) + int Compute(int n, float[] a, int[] ja, int[] ia, float[] alu, int[] jlu, int[] ju, bool modified) { var iw = new int[n]; int i; diff --git a/src/Numerics/LinearAlgebra/Single/SparseMatrix.cs b/src/Numerics/LinearAlgebra/Single/SparseMatrix.cs index ca4e08e9..462713cb 100644 --- a/src/Numerics/LinearAlgebra/Single/SparseMatrix.cs +++ b/src/Numerics/LinearAlgebra/Single/SparseMatrix.cs @@ -411,7 +411,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// Puts the lower triangle of this matrix into the result matrix. /// /// Where to store the lower triangle. - private void LowerTriangleImpl(Matrix result) + void LowerTriangleImpl(Matrix result) { var rowPointers = _storage.RowPointers; var columnIndices = _storage.ColumnIndices; @@ -476,7 +476,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// Puts the upper triangle of this matrix into the result matrix. /// /// Where to store the lower triangle. - private void UpperTriangleImpl(Matrix result) + void UpperTriangleImpl(Matrix result) { var rowPointers = _storage.RowPointers; var columnIndices = _storage.ColumnIndices; @@ -542,7 +542,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// Puts the strictly lower triangle of this matrix into the result matrix. /// /// Where to store the lower triangle. - private void StrictlyLowerTriangleImpl(Matrix result) + void StrictlyLowerTriangleImpl(Matrix result) { var rowPointers = _storage.RowPointers; var columnIndices = _storage.ColumnIndices; @@ -608,7 +608,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// Puts the strictly upper triangle of this matrix into the result matrix. /// /// Where to store the lower triangle. - private void StrictlyUpperTriangleImpl(Matrix result) + void StrictlyUpperTriangleImpl(Matrix result) { var rowPointers = _storage.RowPointers; var columnIndices = _storage.ColumnIndices; diff --git a/src/Numerics/LinearAlgebra/Single/Vector.cs b/src/Numerics/LinearAlgebra/Single/Vector.cs index 30503562..d2e51e34 100644 --- a/src/Numerics/LinearAlgebra/Single/Vector.cs +++ b/src/Numerics/LinearAlgebra/Single/Vector.cs @@ -254,7 +254,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single protected override void DoPointwiseAbs(Vector result) { - Map(x => (float)Math.Abs(x), result, Zeros.AllowSkip); + Map(x => Math.Abs(x), result, Zeros.AllowSkip); } protected override void DoPointwiseAcos(Vector result) { @@ -270,11 +270,11 @@ namespace MathNet.Numerics.LinearAlgebra.Single } protected override void DoPointwiseAtan2(Vector other, Vector result) { - Map2((x, y) => (float)Math.Atan2((double)x, (double)y), other, result, Zeros.Include); + Map2((x, y) => (float)Math.Atan2(x, y), other, result, Zeros.Include); } protected override void DoPointwiseAtan2(float scalar, Vector result) { - Map(x => (float)Math.Atan2((double)x, (double)scalar), result, Zeros.Include); + Map(x => (float)Math.Atan2(x, scalar), result, Zeros.Include); } protected override void DoPointwiseCeiling(Vector result) { @@ -302,7 +302,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single } protected override void DoPointwiseSign(Vector result) { - Map(x => (float)Math.Sign(x), result, Zeros.AllowSkip); + Map(x => Math.Sign(x), result, Zeros.AllowSkip); } protected override void DoPointwiseSin(Vector result) { diff --git a/src/Numerics/Optimization/BfgsBMinimizer.cs b/src/Numerics/Optimization/BfgsBMinimizer.cs index e9f8034c..99881a9d 100644 --- a/src/Numerics/Optimization/BfgsBMinimizer.cs +++ b/src/Numerics/Optimization/BfgsBMinimizer.cs @@ -147,7 +147,6 @@ namespace MathNet.Numerics.Optimization if (currentExitCondition != ExitCondition.None) return new MinimizationResult(candidatePoint, 0, currentExitCondition); - var gradient = candidatePoint.Gradient; var step = candidatePoint.Point - initialGuess; // Subsequent steps @@ -175,8 +174,6 @@ namespace MathNet.Numerics.Optimization double sy = step * y; if (sy > 0.0) // only do update if it will create a positive definite matrix { - double sts = step * step; - var Hs = pseudoHessian * step; var sHs = step * pseudoHessian * step; pseudoHessian = pseudoHessian + y.OuterProduct(y) * (1.0 / sy) - Hs.OuterProduct(Hs) * (1.0 / sHs); diff --git a/src/Numerics/Optimization/BfgsMinimizer.cs b/src/Numerics/Optimization/BfgsMinimizer.cs index a1a53891..934c1b78 100644 --- a/src/Numerics/Optimization/BfgsMinimizer.cs +++ b/src/Numerics/Optimization/BfgsMinimizer.cs @@ -96,7 +96,6 @@ namespace MathNet.Numerics.Optimization var candidate = lineSearchResult.FunctionInfoAtMinimum; ValidateGradientAndObjective(candidate); - var gradient = candidate.Gradient; var step = candidate.Point - initialGuess; // Subsequent steps diff --git a/src/Numerics/Optimization/BfgsMinimizerBase.cs b/src/Numerics/Optimization/BfgsMinimizerBase.cs index f0b85cd3..53dac386 100644 --- a/src/Numerics/Optimization/BfgsMinimizerBase.cs +++ b/src/Numerics/Optimization/BfgsMinimizerBase.cs @@ -49,9 +49,7 @@ namespace MathNet.Numerics.Optimization int iterations; for (iterations = 1; iterations < MaximumIterations; ++iterations) { - double startingStepSize; - double maxLineSearchStep; - lineSearchDirection = CalculateSearchDirection(ref inversePseudoHessian, out maxLineSearchStep, out startingStepSize, previousPoint, candidate, step); + lineSearchDirection = CalculateSearchDirection(ref inversePseudoHessian, out var maxLineSearchStep, out var startingStepSize, previousPoint, candidate, step); try { diff --git a/src/Numerics/Optimization/BfgsSolver.cs b/src/Numerics/Optimization/BfgsSolver.cs index 5bbe63e8..d143fa8b 100644 --- a/src/Numerics/Optimization/BfgsSolver.cs +++ b/src/Numerics/Optimization/BfgsSolver.cs @@ -41,8 +41,8 @@ namespace MathNet.Numerics.Optimization /// public static class BfgsSolver { - private const double GradientTolerance = 1e-5; - private const int MaxIterations = 100000; + const double GradientTolerance = 1e-5; + const int MaxIterations = 100000; /// /// Finds a minimum of a function by the BFGS quasi-Newton method diff --git a/src/Numerics/Optimization/Exceptions.cs b/src/Numerics/Optimization/Exceptions.cs index eada51a4..a2754c32 100644 --- a/src/Numerics/Optimization/Exceptions.cs +++ b/src/Numerics/Optimization/Exceptions.cs @@ -48,7 +48,7 @@ namespace MathNet.Numerics.Optimization public class EvaluationException : OptimizationException { - public IObjectiveFunctionEvaluation ObjectiveFunction { get; private set; } + public IObjectiveFunctionEvaluation ObjectiveFunction { get; } public EvaluationException(string message, IObjectiveFunctionEvaluation eval) : base(message) @@ -69,8 +69,8 @@ namespace MathNet.Numerics.Optimization public InnerOptimizationException(string message) : base(message) { } - public InnerOptimizationException(string message, Exception inner_exception) - : base(message, inner_exception) { } + public InnerOptimizationException(string message, Exception innerException) + : base(message, innerException) { } } public class IncompatibleObjectiveException : OptimizationException diff --git a/src/Numerics/Optimization/GoldenSectionMinimizer.cs b/src/Numerics/Optimization/GoldenSectionMinimizer.cs index 7b011481..ab7051fd 100644 --- a/src/Numerics/Optimization/GoldenSectionMinimizer.cs +++ b/src/Numerics/Optimization/GoldenSectionMinimizer.cs @@ -69,8 +69,8 @@ namespace MathNet.Numerics.Optimization ValueChecker(middle.Value, middlePointX); ValueChecker(upper.Value, upperBound); - int expansion_steps = 0; - while ((expansion_steps < maxExpansionSteps) && (upper.Value < middle.Value || lower.Value < middle.Value)) + int expansionSteps = 0; + while ((expansionSteps < maxExpansionSteps) && (upper.Value < middle.Value || lower.Value < middle.Value)) { if (lower.Value < middle.Value) { @@ -87,7 +87,7 @@ namespace MathNet.Numerics.Optimization middlePointX = lowerBound + (upperBound - lowerBound)/(1 + Constants.GoldenRatio); middle = objective.Evaluate(middlePointX); - expansion_steps += 1; + expansionSteps += 1; } if (upper.Value < middle.Value || lower.Value < middle.Value) diff --git a/src/Numerics/Optimization/LevenbergMarquardtMinimizer.cs b/src/Numerics/Optimization/LevenbergMarquardtMinimizer.cs index 526ca1df..4994b228 100644 --- a/src/Numerics/Optimization/LevenbergMarquardtMinimizer.cs +++ b/src/Numerics/Optimization/LevenbergMarquardtMinimizer.cs @@ -28,16 +28,16 @@ namespace MathNet.Numerics.Optimization double[] lowerBound = null, double[] upperBound = null, double[] scales = null, bool[] isFixed = null) { if (objective == null) - throw new ArgumentNullException("objective"); + throw new ArgumentNullException(nameof(objective)); if (initialGuess == null) - throw new ArgumentNullException("initialGuess"); + throw new ArgumentNullException(nameof(initialGuess)); - var lb = (lowerBound == null) ? null : CreateVector.Dense(lowerBound); - var ub = (upperBound == null) ? null : CreateVector.Dense(upperBound); - var sc = (scales == null) ? null : CreateVector.Dense(scales); - var fx = (isFixed == null) ? null : isFixed.ToList(); + var lb = (lowerBound == null) ? null : CreateVector.Dense(lowerBound); + var ub = (upperBound == null) ? null : CreateVector.Dense(upperBound); + var sc = (scales == null) ? null : CreateVector.Dense(scales); + var fx = isFixed?.ToList(); - return Minimum(objective, CreateVector.DenseOfArray(initialGuess), lb, ub, sc, fx, InitialMu, GradientTolerance, StepTolerance, FunctionTolerance, MaximumIterations); + return Minimum(objective, CreateVector.DenseOfArray(initialGuess), lb, ub, sc, fx, InitialMu, GradientTolerance, StepTolerance, FunctionTolerance, MaximumIterations); } /// @@ -45,7 +45,7 @@ namespace MathNet.Numerics.Optimization /// /// The objective function, including model, observations, and parameter bounds. /// The initial guess values. - /// The initial damping parameter of mu. + /// The initial damping parameter of mu. /// The stopping threshold for infinity norm of the gradient vector. /// The stopping threshold for L2 norm of the change of parameters. /// The stopping threshold for L2 norm of the residuals. @@ -70,12 +70,12 @@ namespace MathNet.Numerics.Optimization // Residuals, R = L(y - f(x; p)) // Residual sum of squares, RSS = ||R||^2 = R.DotProduct(R) // Jacobian J = df(x; p)/dp - // Gradient g = -J'W(y − f(x; p)) = -J'LR + // Gradient g = -J'W(y − f(x; p)) = -J'LR // Approximated Hessian H = J'WJ // // The Levenberg-Marquardt algorithm is summarized as follows: // initially let μ = τ * max(diag(H)). - // repeat + // repeat // solve linear equations: (H + μI)ΔP = -g // let ρ = (||R||^2 - ||Rnew||^2) / (Δp'(μΔp - g)). // if ρ > ε, P = P + ΔP; μ = μ * max(1/3, 1 - (2ρ - 1)^3); ν = 2; @@ -91,17 +91,17 @@ namespace MathNet.Numerics.Optimization // Availble Online from: http://people.duke.edu/~hpgavin/ce281/lm.pdf if (objective == null) - throw new ArgumentNullException("objective"); - + throw new ArgumentNullException(nameof(objective)); + ValidateBounds(initialGuess, lowerBound, upperBound, scales); - + objective.SetParameters(initialGuess, isFixed); ExitCondition exitCondition = ExitCondition.None; // First, calculate function values and setup variables var P = ProjectToInternalParameters(initialGuess); // current internal parameters - var Pstep = Vector.Build.Dense(P.Count); // the change of parameters + var Pstep = Vector.Build.Dense(P.Count); // the change of parameters var RSS = EvaluateFunction(objective, P); // Residual Sum of Squares = R'R if (maximumIterations < 0) @@ -116,7 +116,7 @@ namespace MathNet.Numerics.Optimization return new NonlinearMinimizationResult(objective, -1, exitCondition); } - // When only function evaluation is needed, set maximumIterations to zero, + // When only function evaluation is needed, set maximumIterations to zero, if (maximumIterations == 0) { exitCondition = ExitCondition.ManuallyStopped; @@ -145,7 +145,7 @@ namespace MathNet.Numerics.Optimization return new NonlinearMinimizationResult(objective, -1, exitCondition); } - double mu = initialMu * diagonalOfHessian.Max(); // μ + double mu = initialMu * diagonalOfHessian.Max(); // μ double nu = 2; // ν int iterations = 0; while (iterations < maximumIterations && exitCondition == ExitCondition.None) @@ -155,7 +155,7 @@ namespace MathNet.Numerics.Optimization while (true) { Hessian.SetDiagonal(Hessian.Diagonal() + mu); // hessian[i, i] = hessian[i, i] + mu; - + // solve normal equations Pstep = Hessian.Solve(-Gradient); @@ -193,7 +193,7 @@ namespace MathNet.Numerics.Optimization jac = EvaluateJacobian(objective, P); Gradient = jac.Item1; // objective.Gradient; Hessian = jac.Item2; // objective.Hessian; - diagonalOfHessian = Hessian.Diagonal(); + diagonalOfHessian = Hessian.Diagonal(); // if ||g||_oo <= gtol, found and stop if (Gradient.InfinityNorm() <= gradientTolerance) diff --git a/src/Numerics/Optimization/LimitedMemoryBfgsMinimizer.cs b/src/Numerics/Optimization/LimitedMemoryBfgsMinimizer.cs index c907fc35..af0621e8 100644 --- a/src/Numerics/Optimization/LimitedMemoryBfgsMinimizer.cs +++ b/src/Numerics/Optimization/LimitedMemoryBfgsMinimizer.cs @@ -98,7 +98,6 @@ namespace MathNet.Numerics.Optimization var candidate = lineSearchResult.FunctionInfoAtMinimum; ValidateGradientAndObjective(candidate); - var gradient = candidate.Gradient; var step = candidate.Point - initialGuess; var yk = candidate.Gradient - previousPoint.Gradient; var ykhistory = new List>() {yk}; @@ -155,7 +154,7 @@ namespace MathNet.Numerics.Optimization return new MinimizationWithLineSearchResult(candidate, iterations, ExitCondition.AbsoluteGradient, totalLineSearchSteps, iterationsWithNontrivialLineSearch); } - private Vector ApplyLbfgsUpdate(IObjectiveFunction previousPoint, List> ykhistory, List> skhistory, List rhokhistory) + Vector ApplyLbfgsUpdate(IObjectiveFunction previousPoint, List> ykhistory, List> skhistory, List rhokhistory) { var q = previousPoint.Gradient.Clone(); var alphas = new Stack(); diff --git a/src/Numerics/Optimization/LineSearch/LineSearchResult.cs b/src/Numerics/Optimization/LineSearch/LineSearchResult.cs index 9300c697..f08ce29a 100644 --- a/src/Numerics/Optimization/LineSearch/LineSearchResult.cs +++ b/src/Numerics/Optimization/LineSearch/LineSearchResult.cs @@ -31,7 +31,7 @@ namespace MathNet.Numerics.Optimization.LineSearch { public class LineSearchResult : MinimizationResult { - public double FinalStep { get; private set; } + public double FinalStep { get; } public LineSearchResult(IObjectiveFunction functionInfo, int iterations, double finalStep, ExitCondition reasonForExit) : base(functionInfo, iterations, reasonForExit) diff --git a/src/Numerics/Optimization/MinimizationWithLineSearchResult.cs b/src/Numerics/Optimization/MinimizationWithLineSearchResult.cs index cef34599..fcc67b8e 100644 --- a/src/Numerics/Optimization/MinimizationWithLineSearchResult.cs +++ b/src/Numerics/Optimization/MinimizationWithLineSearchResult.cs @@ -31,8 +31,8 @@ namespace MathNet.Numerics.Optimization { public class MinimizationWithLineSearchResult : MinimizationResult { - public int TotalLineSearchIterations { get; private set; } - public int IterationsWithNonTrivialLineSearch { get; private set; } + public int TotalLineSearchIterations { get; } + public int IterationsWithNonTrivialLineSearch { get; } public MinimizationWithLineSearchResult(IObjectiveFunction functionInfo, int iterations, ExitCondition reasonForExit, int totalLineSearchIterations, int iterationsWithNonTrivialLineSearch) : base(functionInfo, iterations, reasonForExit) diff --git a/src/Numerics/Optimization/NelderMeadSimplex.cs b/src/Numerics/Optimization/NelderMeadSimplex.cs index ef5b1a9a..7b9cdfec 100644 --- a/src/Numerics/Optimization/NelderMeadSimplex.cs +++ b/src/Numerics/Optimization/NelderMeadSimplex.cs @@ -122,13 +122,12 @@ namespace MathNet.Numerics.Optimization int numDimensions = simplexConstants.Length; int numVertices = numDimensions + 1; Vector[] vertices = InitializeVertices(simplexConstants); - double[] errorValues = new double[numVertices]; int evaluationCount = 0; ExitCondition exitCondition = ExitCondition.None; ErrorProfile errorProfile; - errorValues = InitializeErrorValues(vertices, objectiveFunction); + double[] errorValues = InitializeErrorValues(vertices, objectiveFunction); int numTimesHasConverged = 0; // iterate until we converge, or complete our permitted number of iterations @@ -219,14 +218,7 @@ namespace MathNet.Numerics.Optimization double range = 2 * Math.Abs(errorValues[errorProfile.HighestIndex] - errorValues[errorProfile.LowestIndex]) / (Math.Abs(errorValues[errorProfile.HighestIndex]) + Math.Abs(errorValues[errorProfile.LowestIndex]) + JITTER); - if (range < convergenceTolerance) - { - return true; - } - else - { - return false; - } + return range < convergenceTolerance; } /// @@ -380,7 +372,7 @@ namespace MathNet.Numerics.Optimization sealed class SimplexConstant { - public SimplexConstant(double value, double initialPerturbation) + SimplexConstant(double value, double initialPerturbation) { Value = value; InitialPerturbation = initialPerturbation; diff --git a/src/Numerics/Optimization/NonlinearMinimizationResult.cs b/src/Numerics/Optimization/NonlinearMinimizationResult.cs index d2a0c029..6cc91add 100644 --- a/src/Numerics/Optimization/NonlinearMinimizationResult.cs +++ b/src/Numerics/Optimization/NonlinearMinimizationResult.cs @@ -44,7 +44,7 @@ namespace MathNet.Numerics.Optimization EvaluateCovariance(modelInfo); } - private void EvaluateCovariance(IObjectiveModel objective) + void EvaluateCovariance(IObjectiveModel objective) { objective.EvaluateAt(objective.Point); // Hessian may be not yet updated. diff --git a/src/Numerics/Optimization/NonlinearMinimizerBase.cs b/src/Numerics/Optimization/NonlinearMinimizerBase.cs index b1a7f1f8..863b0956 100644 --- a/src/Numerics/Optimization/NonlinearMinimizerBase.cs +++ b/src/Numerics/Optimization/NonlinearMinimizerBase.cs @@ -41,7 +41,7 @@ namespace MathNet.Numerics.Optimization /// public Vector Scales { get; private set; } - private bool IsBounded => LowerBound != null || UpperBound != null || Scales != null; + bool IsBounded => LowerBound != null || UpperBound != null || Scales != null; protected NonlinearMinimizerBase(double gradientTolerance = 1E-18, double stepTolerance = 1E-18, double functionTolerance = 1E-18, int maximumIterations = -1) { @@ -55,7 +55,7 @@ namespace MathNet.Numerics.Optimization { if (parameters == null) { - throw new ArgumentNullException("parameters"); + throw new ArgumentNullException(nameof(parameters)); } if (lowerBound != null && lowerBound.Count(x => double.IsInfinity(x) || double.IsNaN(x)) > 0) @@ -74,7 +74,7 @@ namespace MathNet.Numerics.Optimization } if (upperBound != null && upperBound.Count != parameters.Count) { - throw new ArgumentException("The upper bounds can't have different size from the parameetrs."); + throw new ArgumentException("The upper bounds can't have different size from the parameters."); } UpperBound = upperBound; @@ -174,7 +174,8 @@ namespace MathNet.Numerics.Optimization return Pint; } - else if (LowerBound != null && UpperBound == null) + + if (LowerBound != null && UpperBound == null) { for (int i = 0; i < Pext.Count; i++) { @@ -185,7 +186,8 @@ namespace MathNet.Numerics.Optimization return Pint; } - else if (LowerBound == null && UpperBound != null) + + if (LowerBound == null && UpperBound != null) { for (int i = 0; i < Pext.Count; i++) { @@ -196,7 +198,8 @@ namespace MathNet.Numerics.Optimization return Pint; } - else if (Scales != null) + + if (Scales != null) { for (int i = 0; i < Pext.Count; i++) { @@ -222,7 +225,8 @@ namespace MathNet.Numerics.Optimization return Pext; } - else if (LowerBound != null && UpperBound == null) + + if (LowerBound != null && UpperBound == null) { for (int i = 0; i < Pint.Count; i++) { @@ -233,7 +237,8 @@ namespace MathNet.Numerics.Optimization return Pext; } - else if (LowerBound == null && UpperBound != null) + + if (LowerBound == null && UpperBound != null) { for (int i = 0; i < Pint.Count; i++) { @@ -244,7 +249,8 @@ namespace MathNet.Numerics.Optimization return Pext; } - else if (Scales != null) + + if (Scales != null) { for (int i = 0; i < Pint.Count; i++) { @@ -269,7 +275,8 @@ namespace MathNet.Numerics.Optimization } return scale; } - else if (LowerBound != null && UpperBound == null) + + if (LowerBound != null && UpperBound == null) { for (int i = 0; i < Pint.Count; i++) { @@ -279,7 +286,8 @@ namespace MathNet.Numerics.Optimization } return scale; } - else if (LowerBound == null && UpperBound != null) + + if (LowerBound == null && UpperBound != null) { for (int i = 0; i < Pint.Count; i++) { @@ -289,7 +297,8 @@ namespace MathNet.Numerics.Optimization } return scale; } - else if (Scales != null) + + if (Scales != null) { return Scales; } diff --git a/src/Numerics/Optimization/ObjectiveFunction.cs b/src/Numerics/Optimization/ObjectiveFunction.cs index eaf1bfed..8d265e61 100644 --- a/src/Numerics/Optimization/ObjectiveFunction.cs +++ b/src/Numerics/Optimization/ObjectiveFunction.cs @@ -146,7 +146,7 @@ namespace MathNet.Numerics.Optimization Func, double, Vector> derivatives, Vector observedX, Vector observedY, Vector weight = null) { - Vector func(Vector point, Vector x) + Vector Func(Vector point, Vector x) { var functionValues = CreateVector.Dense(x.Count); for (int i = 0; i < x.Count; i++) @@ -157,7 +157,7 @@ namespace MathNet.Numerics.Optimization return functionValues; } - Matrix prime(Vector point, Vector x) + Matrix Prime(Vector point, Vector x) { var derivativeValues = CreateMatrix.Dense(x.Count, point.Count); for (int i = 0; i < x.Count; i++) @@ -168,7 +168,7 @@ namespace MathNet.Numerics.Optimization return derivativeValues; } - var objective = new NonlinearObjectiveFunction(func, prime); + var objective = new NonlinearObjectiveFunction(Func, Prime); objective.SetObserved(observedX, observedY, weight); return objective; } @@ -180,7 +180,7 @@ namespace MathNet.Numerics.Optimization Vector observedX, Vector observedY, Vector weight = null, int accuracyOrder = 2) { - Vector func(Vector point, Vector x) + Vector Func(Vector point, Vector x) { var functionValues = CreateVector.Dense(x.Count); for (int i = 0; i < x.Count; i++) @@ -191,7 +191,7 @@ namespace MathNet.Numerics.Optimization return functionValues; } - var objective = new NonlinearObjectiveFunction(func, accuracyOrder: accuracyOrder); + var objective = new NonlinearObjectiveFunction(Func, accuracyOrder: accuracyOrder); objective.SetObserved(observedX, observedY, weight); return objective; } diff --git a/src/Numerics/Optimization/ObjectiveFunctions/ForwardDifferenceGradientObjectiveFunction.cs b/src/Numerics/Optimization/ObjectiveFunctions/ForwardDifferenceGradientObjectiveFunction.cs index 32218859..5be4ad01 100644 --- a/src/Numerics/Optimization/ObjectiveFunctions/ForwardDifferenceGradientObjectiveFunction.cs +++ b/src/Numerics/Optimization/ObjectiveFunctions/ForwardDifferenceGradientObjectiveFunction.cs @@ -48,9 +48,9 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions protected Vector LowerBound { get; set; } protected Vector UpperBound { get; set; } - protected bool ValueEvaluated { get; set; } = false; - protected bool GradientEvaluated { get; set; } = false; - private Vector _gradient; + protected bool ValueEvaluated { get; set; } + protected bool GradientEvaluated { get; set; } + Vector _gradient; public double MinimumIncrement { get; set; } public double RelativeIncrement { get; set; } diff --git a/src/Numerics/Optimization/ObjectiveFunctions/LazyObjectiveFunction.cs b/src/Numerics/Optimization/ObjectiveFunctions/LazyObjectiveFunction.cs index 827d00ff..522caaca 100644 --- a/src/Numerics/Optimization/ObjectiveFunctions/LazyObjectiveFunction.cs +++ b/src/Numerics/Optimization/ObjectiveFunctions/LazyObjectiveFunction.cs @@ -79,8 +79,8 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions }; } - public bool IsGradientSupported { get; private set; } - public bool IsHessianSupported { get; private set; } + public bool IsGradientSupported { get; } + public bool IsHessianSupported { get; } public void EvaluateAt(Vector point) { diff --git a/src/Numerics/Optimization/ObjectiveFunctions/LazyObjectiveFunctionBase.cs b/src/Numerics/Optimization/ObjectiveFunctions/LazyObjectiveFunctionBase.cs index b2de9544..8cbc962f 100644 --- a/src/Numerics/Optimization/ObjectiveFunctions/LazyObjectiveFunctionBase.cs +++ b/src/Numerics/Optimization/ObjectiveFunctions/LazyObjectiveFunctionBase.cs @@ -66,8 +66,8 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions return fork; } - public bool IsGradientSupported { get; private set; } - public bool IsHessianSupported { get; private set; } + public bool IsGradientSupported { get; } + public bool IsHessianSupported { get; } public void EvaluateAt(Vector point) { diff --git a/src/Numerics/Optimization/ObjectiveFunctions/NonlinearObjectiveFunction.cs b/src/Numerics/Optimization/ObjectiveFunctions/NonlinearObjectiveFunction.cs index a892069d..3105ce23 100644 --- a/src/Numerics/Optimization/ObjectiveFunctions/NonlinearObjectiveFunction.cs +++ b/src/Numerics/Optimization/ObjectiveFunctions/NonlinearObjectiveFunction.cs @@ -9,20 +9,20 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions { #region Private Variables - readonly Func, Vector, Vector> userFunction; // (p, x) => f(x; p) - readonly Func, Vector, Matrix> userDerivative; // (p, x) => df(x; p)/dp - readonly int accuracyOrder; // the desired accuracy order to evaluate the jacobian by numerical approximaiton. + readonly Func, Vector, Vector> _userFunction; // (p, x) => f(x; p) + readonly Func, Vector, Matrix> _userDerivative; // (p, x) => df(x; p)/dp + readonly int _accuracyOrder; // the desired accuracy order to evaluate the jacobian by numerical approximaiton. - Vector coefficients; + Vector _coefficients; - bool hasFunctionValue; - double functionValue; // the residual sum of squares, residuals * residuals. - Vector residuals; // the weighted error values + bool _hasFunctionValue; + double _functionValue; // the residual sum of squares, residuals * residuals. + Vector _residuals; // the weighted error values - bool hasJacobianValue; - Matrix jacobianValue; // the Jacobian matrix. - Vector gradientValue; // the Gradient vector. - Matrix hessianValue; // the Hessian matrix. + bool _hasJacobianValue; + Matrix _jacobianValue; // the Jacobian matrix. + Vector _gradientValue; // the Gradient vector. + Matrix _hessianValue; // the Hessian matrix. #endregion Private Variables @@ -42,7 +42,7 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions /// Set or get the values of the weights for the observations. /// public Matrix Weights { get; private set; } - private Vector L; // Weights = LL' + Vector L; // Weights = LL' /// /// Get whether parameters are fixed or free. @@ -69,7 +69,7 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions var df = NumberOfObservations - NumberOfParameters; if (IsFixed != null) { - df = df + IsFixed.Count(p => p == true); + df = df + IsFixed.Count(p => p); } return df; } @@ -90,40 +90,40 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions public NonlinearObjectiveFunction(Func, Vector, Vector> function, Func, Vector, Matrix> derivative = null, int accuracyOrder = 2) { - this.userFunction = function; - this.userDerivative = derivative; - this.accuracyOrder = Math.Min(6, Math.Max(1, accuracyOrder)); + _userFunction = function; + _userDerivative = derivative; + _accuracyOrder = Math.Min(6, Math.Max(1, accuracyOrder)); } public IObjectiveModel Fork() { - return new NonlinearObjectiveFunction(userFunction, userDerivative, accuracyOrder) + return new NonlinearObjectiveFunction(_userFunction, _userDerivative, _accuracyOrder) { ObservedX = ObservedX, ObservedY = ObservedY, Weights = Weights, - coefficients = coefficients, + _coefficients = _coefficients, - hasFunctionValue = hasFunctionValue, - functionValue = functionValue, + _hasFunctionValue = _hasFunctionValue, + _functionValue = _functionValue, - hasJacobianValue = hasJacobianValue, - jacobianValue = jacobianValue, - gradientValue = gradientValue, - hessianValue = hessianValue + _hasJacobianValue = _hasJacobianValue, + _jacobianValue = _jacobianValue, + _gradientValue = _gradientValue, + _hessianValue = _hessianValue }; } public IObjectiveModel CreateNew() { - return new NonlinearObjectiveFunction(userFunction, userDerivative, accuracyOrder); + return new NonlinearObjectiveFunction(_userFunction, _userDerivative, _accuracyOrder); } /// /// Set or get the values of the parameters. /// - public Vector Point => coefficients; + public Vector Point => _coefficients; /// /// Get the y-values of the fitted model that correspond to the independent values. @@ -137,12 +137,12 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions { get { - if (!hasFunctionValue) + if (!_hasFunctionValue) { EvaluateFunction(); - hasFunctionValue = true; + _hasFunctionValue = true; } - return functionValue; + return _functionValue; } } @@ -153,12 +153,12 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions { get { - if (!hasJacobianValue) + if (!_hasJacobianValue) { EvaluateJacobian(); - hasJacobianValue = true; + _hasJacobianValue = true; } - return gradientValue; + return _gradientValue; } } @@ -169,12 +169,12 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions { get { - if (!hasJacobianValue) + if (!_hasJacobianValue) { EvaluateJacobian(); - hasJacobianValue = true; + _hasJacobianValue = true; } - return hessianValue; + return _hessianValue; } } @@ -230,17 +230,13 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions /// The list to the parameters fix or free. public void SetParameters(Vector initialGuess, List isFixed = null) { - if (initialGuess == null) - { - throw new ArgumentNullException("initialGuess"); - } - coefficients = initialGuess; + _coefficients = initialGuess ?? throw new ArgumentNullException(nameof(initialGuess)); if (isFixed != null && isFixed.Count != initialGuess.Count) { throw new ArgumentException("The isFixed can't have different size from the initial guess."); } - if (isFixed != null && isFixed.Count(p => p == true) == isFixed.Count) + if (isFixed != null && isFixed.Count(p => p) == isFixed.Count) { throw new ArgumentException("All the parameters can't be fixed."); } @@ -251,72 +247,70 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions { if (parameters == null) { - throw new ArgumentNullException("parameters"); + throw new ArgumentNullException(nameof(parameters)); } if (parameters.Count(p => double.IsNaN(p) || double.IsInfinity(p)) > 0) { throw new ArgumentException("The parameters must be finite."); } - coefficients = parameters; - hasFunctionValue = false; - hasJacobianValue = false; + _coefficients = parameters; + _hasFunctionValue = false; + _hasJacobianValue = false; - jacobianValue = null; - gradientValue = null; - hessianValue = null; + _jacobianValue = null; + _gradientValue = null; + _hessianValue = null; } public IObjectiveFunction ToObjectiveFunction() { - Tuple, Matrix> function(Vector point) + Tuple, Matrix> Function(Vector point) { EvaluateAt(point); return new Tuple, Matrix>(Value, Gradient, Hessian); } - var objective = new GradientHessianObjectiveFunction(function); + var objective = new GradientHessianObjectiveFunction(Function); return objective; } #region Private Methods - private void EvaluateFunction() + void EvaluateFunction() { // Calculates the residuals, (y[i] - f(x[i]; p)) * L[i] if (ModelValues == null) { ModelValues = Vector.Build.Dense(NumberOfObservations); } - ModelValues = userFunction(Point, ObservedX); + ModelValues = _userFunction(Point, ObservedX); FunctionEvaluations++; // calculate the weighted residuals - residuals = (Weights == null) + _residuals = (Weights == null) ? ObservedY - ModelValues : (ObservedY - ModelValues).PointwiseMultiply(L); // Calculate the residual sum of squares - functionValue = residuals.DotProduct(residuals); - - return; + _functionValue = _residuals.DotProduct(_residuals); } - private void EvaluateJacobian() + void EvaluateJacobian() { // Calculates the jacobian of x and p. - if (userDerivative != null) + if (_userDerivative != null) { // analytical jacobian - jacobianValue = userDerivative(Point, ObservedX); + _jacobianValue = _userDerivative(Point, ObservedX); JacobianEvaluations++; } else { // numerical jacobian - jacobianValue = NumericalJacobian(Point, ModelValues, accuracyOrder); - FunctionEvaluations += accuracyOrder; + _jacobianValue = NumericalJacobian(Point, ModelValues, _accuracyOrder); + FunctionEvaluations += _accuracyOrder; } // weighted jacobian @@ -327,23 +321,23 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions if (IsFixed != null && IsFixed[j]) { // if j-th parameter is fixed, set J[i, j] = 0 - jacobianValue[i, j] = 0.0; + _jacobianValue[i, j] = 0.0; } else if (Weights != null) { - jacobianValue[i, j] = jacobianValue[i, j] * L[i]; + _jacobianValue[i, j] = _jacobianValue[i, j] * L[i]; } } } // Gradient, g = -J'W(y − f(x; p)) = -J'L(L'E) = -J'LR - gradientValue = -jacobianValue.Transpose() * residuals; + _gradientValue = -_jacobianValue.Transpose() * _residuals; // approximated Hessian, H = J'WJ + ∑LRiHi ~ J'WJ near the minimum - hessianValue = jacobianValue.Transpose() * jacobianValue; + _hessianValue = _jacobianValue.Transpose() * _jacobianValue; } - private Matrix NumericalJacobian(Vector parameters, Vector currentValues, int accuracyOrder = 2) + Matrix NumericalJacobian(Vector parameters, Vector currentValues, int accuracyOrder = 2) { const double sqrtEpsilon = 1.4901161193847656250E-8; // sqrt(machineEpsilon) @@ -359,12 +353,12 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions if (accuracyOrder >= 6) { // f'(x) = {- f(x - 3h) + 9f(x - 2h) - 45f(x - h) + 45f(x + h) - 9f(x + 2h) + f(x + 3h)} / 60h + O(h^6) - var f1 = userFunction(parameters - 3 * h, ObservedX); - var f2 = userFunction(parameters - 2 * h, ObservedX); - var f3 = userFunction(parameters - h, ObservedX); - var f4 = userFunction(parameters + h, ObservedX); - var f5 = userFunction(parameters + 2 * h, ObservedX); - var f6 = userFunction(parameters + 3 * h, ObservedX); + var f1 = _userFunction(parameters - 3 * h, ObservedX); + var f2 = _userFunction(parameters - 2 * h, ObservedX); + var f3 = _userFunction(parameters - h, ObservedX); + var f4 = _userFunction(parameters + h, ObservedX); + var f5 = _userFunction(parameters + 2 * h, ObservedX); + var f6 = _userFunction(parameters + 3 * h, ObservedX); var prime = (-f1 + 9 * f2 - 45 * f3 + 45 * f4 - 9 * f5 + f6) / (60 * h[j]); derivertives.SetColumn(j, prime); @@ -373,11 +367,11 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions { // f'(x) = {-137f(x) + 300f(x + h) - 300f(x + 2h) + 200f(x + 3h) - 75f(x + 4h) + 12f(x + 5h)} / 60h + O(h^5) var f1 = currentValues; - var f2 = userFunction(parameters + h, ObservedX); - var f3 = userFunction(parameters + 2 * h, ObservedX); - var f4 = userFunction(parameters + 3 * h, ObservedX); - var f5 = userFunction(parameters + 4 * h, ObservedX); - var f6 = userFunction(parameters + 5 * h, ObservedX); + var f2 = _userFunction(parameters + h, ObservedX); + var f3 = _userFunction(parameters + 2 * h, ObservedX); + var f4 = _userFunction(parameters + 3 * h, ObservedX); + var f5 = _userFunction(parameters + 4 * h, ObservedX); + var f6 = _userFunction(parameters + 5 * h, ObservedX); var prime = (-137 * f1 + 300 * f2 - 300 * f3 + 200 * f4 - 75 * f5 + 12 * f6) / (60 * h[j]); derivertives.SetColumn(j, prime); @@ -385,10 +379,10 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions else if (accuracyOrder == 4) { // f'(x) = {f(x - 2h) - 8f(x - h) + 8f(x + h) - f(x + 2h)} / 12h + O(h^4) - var f1 = userFunction(parameters - 2 * h, ObservedX); - var f2 = userFunction(parameters - h, ObservedX); - var f3 = userFunction(parameters + h, ObservedX); - var f4 = userFunction(parameters + 2 * h, ObservedX); + var f1 = _userFunction(parameters - 2 * h, ObservedX); + var f2 = _userFunction(parameters - h, ObservedX); + var f3 = _userFunction(parameters + h, ObservedX); + var f4 = _userFunction(parameters + 2 * h, ObservedX); var prime = (f1 - 8 * f2 + 8 * f3 - f4) / (12 * h[j]); derivertives.SetColumn(j, prime); @@ -397,9 +391,9 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions { // f'(x) = {-11f(x) + 18f(x + h) - 9f(x + 2h) + 2f(x + 3h)} / 6h + O(h^3) var f1 = currentValues; - var f2 = userFunction(parameters + h, ObservedX); - var f3 = userFunction(parameters + 2 * h, ObservedX); - var f4 = userFunction(parameters + 3 * h, ObservedX); + var f2 = _userFunction(parameters + h, ObservedX); + var f3 = _userFunction(parameters + 2 * h, ObservedX); + var f4 = _userFunction(parameters + 3 * h, ObservedX); var prime = (-11 * f1 + 18 * f2 - 9 * f3 + 2 * f4) / (6 * h[j]); derivertives.SetColumn(j, prime); @@ -407,8 +401,8 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions else if (accuracyOrder == 2) { // f'(x) = {f(x + h) - f(x - h)} / 2h + O(h^2) - var f1 = userFunction(parameters + h, ObservedX); - var f2 = userFunction(parameters - h, ObservedX); + var f1 = _userFunction(parameters + h, ObservedX); + var f2 = _userFunction(parameters - h, ObservedX); var prime = (f1 - f2) / (2 * h[j]); derivertives.SetColumn(j, prime); @@ -417,7 +411,7 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions { // f'(x) = {- f(x) + f(x + h)} / h + O(h) var f1 = currentValues; - var f2 = userFunction(parameters + h, ObservedX); + var f2 = _userFunction(parameters + h, ObservedX); var prime = (-f1 + f2) / h[j]; derivertives.SetColumn(j, prime); diff --git a/src/Numerics/Optimization/ObjectiveFunctions/ObjectiveFunctionBase.cs b/src/Numerics/Optimization/ObjectiveFunctions/ObjectiveFunctionBase.cs index d2d8d3a4..192627d0 100644 --- a/src/Numerics/Optimization/ObjectiveFunctions/ObjectiveFunctionBase.cs +++ b/src/Numerics/Optimization/ObjectiveFunctions/ObjectiveFunctionBase.cs @@ -52,8 +52,8 @@ namespace MathNet.Numerics.Optimization.ObjectiveFunctions return objective; } - public bool IsGradientSupported { get; private set; } - public bool IsHessianSupported { get; private set; } + public bool IsGradientSupported { get; } + public bool IsHessianSupported { get; } public void EvaluateAt(Vector point) { diff --git a/src/Numerics/Optimization/TrustRegion/TrustRegionMinimizerBase.cs b/src/Numerics/Optimization/TrustRegion/TrustRegionMinimizerBase.cs index d003b5b0..c895d008 100644 --- a/src/Numerics/Optimization/TrustRegion/TrustRegionMinimizerBase.cs +++ b/src/Numerics/Optimization/TrustRegion/TrustRegionMinimizerBase.cs @@ -21,10 +21,7 @@ namespace MathNet.Numerics.Optimization.TrustRegion double gradientTolerance = 1E-8, double stepTolerance = 1E-8, double functionTolerance = 1E-8, double radiusTolerance = 1E-8, int maximumIterations = -1) : base(gradientTolerance, stepTolerance, functionTolerance, maximumIterations) { - if (subproblem == null) - throw new ArgumentNullException("subproblem"); - - Subproblem = subproblem; + Subproblem = subproblem ?? throw new ArgumentNullException(nameof(subproblem)); RadiusTolerance = radiusTolerance; } @@ -38,12 +35,12 @@ namespace MathNet.Numerics.Optimization.TrustRegion public NonlinearMinimizationResult FindMinimum(IObjectiveModel objective, double[] initialGuess, double[] lowerBound = null, double[] upperBound = null, double[] scales = null, bool[] isFixed = null) { - var lb = (lowerBound == null) ? null : CreateVector.Dense(lowerBound); - var ub = (upperBound == null) ? null : CreateVector.Dense(upperBound); - var sc = (scales == null) ? null : CreateVector.Dense(scales); + var lb = (lowerBound == null) ? null : CreateVector.Dense(lowerBound); + var ub = (upperBound == null) ? null : CreateVector.Dense(upperBound); + var sc = (scales == null) ? null : CreateVector.Dense(scales); var fx = (isFixed == null) ? null : isFixed.ToList(); - return Minimum(Subproblem, objective, CreateVector.DenseOfArray(initialGuess), lb, ub, sc, fx, + return Minimum(Subproblem, objective, CreateVector.DenseOfArray(initialGuess), lb, ub, sc, fx, GradientTolerance, StepTolerance, FunctionTolerance, RadiusTolerance, MaximumIterations); } @@ -102,7 +99,7 @@ namespace MathNet.Numerics.Optimization.TrustRegion double eta = 0; if (objective == null) - throw new ArgumentNullException("objective"); + throw new ArgumentNullException(nameof(objective)); ValidateBounds(initialGuess, lowerBound, upperBound, scales); diff --git a/src/Numerics/Permutation.cs b/src/Numerics/Permutation.cs index de778365..aa3611fb 100644 --- a/src/Numerics/Permutation.cs +++ b/src/Numerics/Permutation.cs @@ -42,7 +42,7 @@ namespace MathNet.Numerics /// /// Entry _indices[i] represents the location to which i is permuted to. /// - private readonly int[] _indices; + readonly int[] _indices; #endregion fields diff --git a/src/Numerics/Precision.Equality.cs b/src/Numerics/Precision.Equality.cs index 4d64bd41..534e6bbd 100644 --- a/src/Numerics/Precision.Equality.cs +++ b/src/Numerics/Precision.Equality.cs @@ -917,7 +917,7 @@ namespace MathNet.Numerics return true; } - private static bool ListForAll(IList a, IList b, Func predicate, TP parameter) + static bool ListForAll(IList a, IList b, Func predicate, TP parameter) { if (a == null && b == null) { @@ -1040,14 +1040,14 @@ namespace MathNet.Numerics return AlmostEqualNormRelative(a.L2Norm(), b.L2Norm(), (a - b).L2Norm(), decimalPlaces); } - private static readonly double[] NegativePowersOf10 = new double[] + static readonly double[] NegativePowersOf10 = new double[] { 1, 0.1, 0.01, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7, 1e-8, 1e-9, 1e-10, 1e-11, 1e-12, 1e-13, 1e-14, 1e-15, 1e-16, 1e-17, 1e-18, 1e-19, 1e-20 }; - private static double Pow10(int y) + static double Pow10(int y) { return -NegativePowersOf10.Length < y && y <= 0 ? NegativePowersOf10[-y] diff --git a/src/Numerics/Random/CryptoRandomSource.cs b/src/Numerics/Random/CryptoRandomSource.cs index d2994c76..ef6873c1 100644 --- a/src/Numerics/Random/CryptoRandomSource.cs +++ b/src/Numerics/Random/CryptoRandomSource.cs @@ -93,7 +93,7 @@ namespace MathNet.Numerics.Random /// /// Returns a random double-precision floating point number greater than or equal to 0.0, and less than 1.0. /// - protected sealed override double DoSample() + protected override double DoSample() { var bytes = new byte[4]; _crypto.GetBytes(bytes); @@ -103,7 +103,7 @@ namespace MathNet.Numerics.Random /// /// Returns a random 32-bit signed integer greater than or equal to zero and less than /// - protected sealed override int DoSampleInteger() + protected override int DoSampleInteger() { var bytes = new byte[4]; _crypto.GetBytes(bytes); diff --git a/src/Numerics/Random/Xoshiro256StarStar.cs b/src/Numerics/Random/Xoshiro256StarStar.cs index b005fcd6..02fc05e1 100644 --- a/src/Numerics/Random/Xoshiro256StarStar.cs +++ b/src/Numerics/Random/Xoshiro256StarStar.cs @@ -231,7 +231,7 @@ namespace MathNet.Numerics.Random return (long)(NextInnerULong() >> (64 - bitCount)); } - private void Initialise(int seed) + void Initialise(int seed) { // Notes. // xoroshiro256** requires that at least one of the state variable be non-zero, use of splitmix64 @@ -248,7 +248,7 @@ namespace MathNet.Numerics.Random _s3 = Splitmix64(ref longSeed); } - private ulong NextInnerULong() + ulong NextInnerULong() { ulong s0 = _s0; ulong s1 = _s1; @@ -355,7 +355,7 @@ namespace MathNet.Numerics.Random /// Splitmix64 produces equidistributed outputs, thus if a zero is generated then the /// next zero will be after a further 2^64 outputs. /// - private static ulong Splitmix64(ref ulong x) + static ulong Splitmix64(ref ulong x) { ulong z = (x += 0x9E3779B97F4A7C15UL); z = (z ^ (z >> 30)) * 0xBF58476D1CE4E5B9UL; @@ -363,7 +363,7 @@ namespace MathNet.Numerics.Random return z ^ (z >> 31); } - private static ulong RotateLeft(ulong x, int k) + static ulong RotateLeft(ulong x, int k) { // Note. RyuJIT will compile this to a single rotate CPU instruction (as of about .NET 4.6.1 and dotnet core 2.0). return (x << k) | (x >> (64 - k)); diff --git a/src/Numerics/RootFinding/Brent.cs b/src/Numerics/RootFinding/Brent.cs index f797c17d..a8e47156 100644 --- a/src/Numerics/RootFinding/Brent.cs +++ b/src/Numerics/RootFinding/Brent.cs @@ -63,8 +63,7 @@ namespace MathNet.Numerics.RootFinding /// public static double FindRoot(Func f, double lowerBound, double upperBound, double accuracy = 1e-8, int maxIterations = 100) { - double root; - if (TryFindRoot(f, lowerBound, upperBound, accuracy, maxIterations, out root)) + if (TryFindRoot(f, lowerBound, upperBound, accuracy, maxIterations, out var root)) { return root; } diff --git a/src/Numerics/RootFinding/Broyden.cs b/src/Numerics/RootFinding/Broyden.cs index f7c2240c..3b579d34 100644 --- a/src/Numerics/RootFinding/Broyden.cs +++ b/src/Numerics/RootFinding/Broyden.cs @@ -49,8 +49,7 @@ namespace MathNet.Numerics.RootFinding /// public static double[] FindRoot(Func f, double[] initialGuess, double accuracy = 1e-8, int maxIterations = 100, double jacobianStepSize = 1.0e-4) { - double[] root; - if (TryFindRootWithJacobianStep(f, initialGuess, accuracy, maxIterations, jacobianStepSize, out root)) + if (TryFindRootWithJacobianStep(f, initialGuess, accuracy, maxIterations, jacobianStepSize, out var root)) { return root; } diff --git a/src/Numerics/RootFinding/NewtonRaphson.cs b/src/Numerics/RootFinding/NewtonRaphson.cs index 367809c6..9d5e7e67 100644 --- a/src/Numerics/RootFinding/NewtonRaphson.cs +++ b/src/Numerics/RootFinding/NewtonRaphson.cs @@ -49,8 +49,7 @@ namespace MathNet.Numerics.RootFinding /// public static double FindRoot(Func f, Func df, double lowerBound, double upperBound, double accuracy = 1e-8, int maxIterations = 100) { - double root; - if (TryFindRoot(f, df, 0.5 * (lowerBound + upperBound), lowerBound, upperBound, accuracy, maxIterations, out root)) + if (TryFindRoot(f, df, 0.5 * (lowerBound + upperBound), lowerBound, upperBound, accuracy, maxIterations, out var root)) { return root; } @@ -70,8 +69,7 @@ namespace MathNet.Numerics.RootFinding /// public static double FindRootNearGuess(Func f, Func df, double initialGuess, double lowerBound = double.MinValue, double upperBound = double.MaxValue, double accuracy = 1e-8, int maxIterations = 100) { - double root; - if (TryFindRoot(f, df, initialGuess, lowerBound, upperBound, accuracy, maxIterations, out root)) + if (TryFindRoot(f, df, initialGuess, lowerBound, upperBound, accuracy, maxIterations, out var root)) { return root; } diff --git a/src/Numerics/RootFinding/RobustNewtonRaphson.cs b/src/Numerics/RootFinding/RobustNewtonRaphson.cs index 8bf285c6..a77ac4da 100644 --- a/src/Numerics/RootFinding/RobustNewtonRaphson.cs +++ b/src/Numerics/RootFinding/RobustNewtonRaphson.cs @@ -49,8 +49,7 @@ namespace MathNet.Numerics.RootFinding /// public static double FindRoot(Func f, Func df, double lowerBound, double upperBound, double accuracy = 1e-8, int maxIterations = 100, int subdivision = 20) { - double root; - if (TryFindRoot(f, df, lowerBound, upperBound, accuracy, maxIterations, subdivision, out root)) + if (TryFindRoot(f, df, lowerBound, upperBound, accuracy, maxIterations, subdivision, out var root)) { return root; } diff --git a/src/Numerics/RootFinding/Secant.cs b/src/Numerics/RootFinding/Secant.cs index 9de8fe41..57ee0eee 100644 --- a/src/Numerics/RootFinding/Secant.cs +++ b/src/Numerics/RootFinding/Secant.cs @@ -50,8 +50,7 @@ namespace MathNet.Numerics.RootFinding /// public static double FindRoot(Func f, double guess, double secondGuess, double lowerBound = double.MinValue, double upperBound = double.MaxValue, double accuracy = 1e-8, int maxIterations = 100) { - double root; - if (TryFindRoot(f, guess, secondGuess, lowerBound, upperBound, accuracy, maxIterations, out root)) + if (TryFindRoot(f, guess, secondGuess, lowerBound, upperBound, accuracy, maxIterations, out var root)) { return root; } diff --git a/src/Numerics/SpecialFunctions/Airy.cs b/src/Numerics/SpecialFunctions/Airy.cs index 84d717ae..0cf825b5 100644 --- a/src/Numerics/SpecialFunctions/Airy.cs +++ b/src/Numerics/SpecialFunctions/Airy.cs @@ -1,5 +1,6 @@ using Complex = System.Numerics.Complex; +// ReSharper disable once CheckNamespace namespace MathNet.Numerics { /// diff --git a/src/Numerics/SpecialFunctions/Amos/Amos.cs b/src/Numerics/SpecialFunctions/Amos/Amos.cs index b3ae88ca..9c9c1fbf 100644 --- a/src/Numerics/SpecialFunctions/Amos/Amos.cs +++ b/src/Numerics/SpecialFunctions/Amos/Amos.cs @@ -1,13 +1,14 @@ using System; using Complex = System.Numerics.Complex; +// ReSharper disable once CheckNamespace namespace MathNet.Numerics { // References: // [1] https://github.com/scipy/scipy/blob/master/scipy/special/amos_wrappers.c public static partial class SpecialFunctions { - private static class Amos + static class Amos { #region AiryAi @@ -765,7 +766,7 @@ namespace MathNet.Numerics { if (double.IsNaN(v) || double.IsNaN(z.Real) || double.IsNaN(z.Imaginary)) { - return new Complex(double.NaN, double.NaN); ; + return new Complex(double.NaN, double.NaN); } int n = 1; @@ -805,7 +806,7 @@ namespace MathNet.Numerics { if (double.IsNaN(v) || double.IsNaN(z.Real) || double.IsNaN(z.Imaginary)) { - return new Complex(double.NaN, double.NaN); ; + return new Complex(double.NaN, double.NaN); } int n = 1; @@ -936,7 +937,7 @@ namespace MathNet.Numerics #region utilities - private static double SinPi(double x) + static double SinPi(double x) { if (Math.Floor(x) == x && Math.Abs(x) < 1.0e14) { @@ -948,7 +949,7 @@ namespace MathNet.Numerics return Math.Sin(Math.PI * x); } - private static double CosPi(double x) + static double CosPi(double x) { if (Math.Floor(x + 0.5) == x + 0.5 && Math.Abs(x) < 1.0E14) { @@ -960,21 +961,21 @@ namespace MathNet.Numerics return Math.Cos(Math.PI * x); } - private static Complex Rotate(Complex z, double v) + static Complex Rotate(Complex z, double v) { double c = CosPi(v); double s = SinPi(v); return new Complex(z.Real * c - z.Imaginary * s, z.Real * s + z.Imaginary * c); } - private static Complex RotateJY(Complex j, Complex y, double v) + static Complex RotateJY(Complex j, Complex y, double v) { double c = CosPi(v); double s = SinPi(v); return new Complex(j.Real * c - y.Real * s, j.Imaginary * c - y.Imaginary * s); } - private static bool ReflectJY(ref Complex jy, double v) + static bool ReflectJY(ref Complex jy, double v) { //NB: Y_v may be huge near negative integers -- so handle exact // integers carefully @@ -993,7 +994,7 @@ namespace MathNet.Numerics return true; } - private static bool ReflectI(Complex ik, double v) + static bool ReflectI(Complex ik, double v) { if (v != Math.Floor(v)) { @@ -1003,7 +1004,7 @@ namespace MathNet.Numerics return true; //I is symmetric for integer v } - private static Complex RotateI(Complex i, Complex k, double v) + static Complex RotateI(Complex i, Complex k, double v) { double s = Math.Sin(v * Math.PI) * (2.0 / Math.PI); return new Complex(i.Real + s * k.Real, i.Imaginary + s * k.Imaginary); diff --git a/src/Numerics/SpecialFunctions/Amos/AmosHelper.cs b/src/Numerics/SpecialFunctions/Amos/AmosHelper.cs index 453e0797..53583f7b 100644 --- a/src/Numerics/SpecialFunctions/Amos/AmosHelper.cs +++ b/src/Numerics/SpecialFunctions/Amos/AmosHelper.cs @@ -8,7 +8,7 @@ namespace MathNet.Numerics // // References: // [1] Amos package in netlib. http://www.netlib.org/amos - private static class AmosHelper + static class AmosHelper { #region Bessel- related functions @@ -2385,7 +2385,7 @@ namespace MathNet.Numerics #region Fortran utilities - private static double d1mach(int i) + static double d1mach(int i) { #region Description @@ -2463,7 +2463,7 @@ namespace MathNet.Numerics return 0; } - private static int i1mach(int i) + static int i1mach(int i) { #region Description @@ -2552,14 +2552,14 @@ namespace MathNet.Numerics return 0; } - private static double dsign(double a, double b) + static double dsign(double a, double b) { // Returns the absolute value of A times the sign of B double x = (a >= 0 ? a : -a); return (b >= 0 ? x : -x); } - private static double zabs(double zr, double zi) + static double zabs(double zr, double zi) { #region Description @@ -2595,7 +2595,7 @@ namespace MathNet.Numerics return 0.0; } - private static int zdiv(double ar, double ai, double br, double bi, ref double cr, ref double ci) + static int zdiv(double ar, double ai, double br, double bi, ref double cr, ref double ci) { #region Description @@ -2621,7 +2621,7 @@ namespace MathNet.Numerics return 0; } - private static int zexp(double ar, double ai, ref double br, ref double bi) + static int zexp(double ar, double ai, ref double br, ref double bi) { #region Description @@ -2645,7 +2645,7 @@ namespace MathNet.Numerics return 0; } - private static int zlog(double ar, double ai, ref double br, ref double bi, ref int ierr) + static int zlog(double ar, double ai, ref double br, ref double bi, ref int ierr) { #region Description @@ -2697,7 +2697,7 @@ namespace MathNet.Numerics return 0; } - private static int zmlt(double ar, double ai, double br, double bi, ref double cr, ref double ci) + static int zmlt(double ar, double ai, double br, double bi, ref double cr, ref double ci) { #region Description @@ -2720,7 +2720,7 @@ namespace MathNet.Numerics return 0; } - private static int zsqrt(double ar, double ai, ref double br, ref double bi) + static int zsqrt(double ar, double ai, ref double br, ref double bi) { #region Description @@ -2782,7 +2782,7 @@ namespace MathNet.Numerics #region Subroutines to calculate the Bessel functions - private static int zacai(double zr, double zi, double fnu, int kode, int mr, int n, double[] yr, double[] yi, ref int nz, double rl, double tol, double elim, double alim) + static int zacai(double zr, double zi, double fnu, int kode, int mr, int n, double[] yr, double[] yi, ref int nz, double rl, double tol, double elim, double alim) { #region Description @@ -2888,7 +2888,7 @@ namespace MathNet.Numerics return 0; } - private static int zacon(double zr, double zi, double fnu, int kode, int mr, int n, double[] yr, double[] yi, ref int nz, double rl, double fnul, double tol, double elim, double alim) + static int zacon(double zr, double zi, double fnu, int kode, int mr, int n, double[] yr, double[] yi, ref int nz, double rl, double fnul, double tol, double elim, double alim) { #region Description @@ -3105,7 +3105,7 @@ namespace MathNet.Numerics return 0; } - private static int zasyi(double zr, double zi, double fnu, int kode, int n, double[] yr, double[] yi, ref int nz, double rl, double tol, double elim, double alim) + static int zasyi(double zr, double zi, double fnu, int kode, int n, double[] yr, double[] yi, ref int nz, double rl, double tol, double elim, double alim) { #region Description @@ -3283,7 +3283,7 @@ namespace MathNet.Numerics return 0; } - private static int zbinu(double zr, double zi, double fnu, int kode, int n, double[] cyr, double[] cyi, ref int nz, double rl, double fnul, double tol, double elim, double alim) + static int zbinu(double zr, double zi, double fnu, int kode, int n, double[] cyr, double[] cyi, ref int nz, double rl, double fnul, double tol, double elim, double alim) { #region Description @@ -3398,7 +3398,7 @@ namespace MathNet.Numerics return 0; } - private static int zbknu(double zr, double zi, double fnu, int kode, int n, double[] yr, double[] yi, ref int nz, double tol, double elim, double alim) + static int zbknu(double zr, double zi, double fnu, int kode, int n, double[] yr, double[] yi, ref int nz, double tol, double elim, double alim) { #region Description @@ -3994,7 +3994,7 @@ namespace MathNet.Numerics return 0; } - private static int zbuni(double zr, double zi, double fnu, int kode, int n, double[] yr, double[] yi, ref int nz, int nui, ref int nlast, double fnul, double tol, double elim, double alim) + static int zbuni(double zr, double zi, double fnu, int kode, int n, double[] yr, double[] yi, ref int nz, int nui, ref int nlast, double fnul, double tol, double elim, double alim) { #region Description @@ -4178,7 +4178,7 @@ namespace MathNet.Numerics return 0; } - private static int zbunk(double zr, double zi, double fnu, int kode, int mr, int n, double[] yr, double[] yi, ref int nz, double tol, double elim, double alim) + static int zbunk(double zr, double zi, double fnu, int kode, int mr, int n, double[] yr, double[] yi, ref int nz, double tol, double elim, double alim) { #region Description @@ -4217,7 +4217,7 @@ namespace MathNet.Numerics return 0; } - private static int zkscl(double zrr, double zri, double fnu, int n, double[] yr, double[] yi, ref int nz, double rzr, double rzi, double ascle, double tol, double elim) + static int zkscl(double zrr, double zri, double fnu, int n, double[] yr, double[] yi, ref int nz, double rzr, double rzi, double ascle, double tol, double elim) { #region Description @@ -4355,7 +4355,7 @@ namespace MathNet.Numerics return 0; } - private static int zmlri(double zr, double zi, double fnu, int kode, int n, double[] yr, double[] yi, ref int nz, double tol) + static int zmlri(double zr, double zi, double fnu, int kode, int n, double[] yr, double[] yi, ref int nz, double tol) { #region Description @@ -4575,7 +4575,7 @@ namespace MathNet.Numerics return 0; } - private static int zrati(double zr, double zi, double fnu, int n, double[] cyr, double[] cyi, double tol) + static int zrati(double zr, double zi, double fnu, int n, double[] cyr, double[] cyi, double tol) { #region Description @@ -4719,7 +4719,7 @@ namespace MathNet.Numerics return 0; } - private static int zs1s2(double zrr, double zri, ref double s1r, ref double s1i, ref double s2r, ref double s2i, ref int nz, double ascle, double alim, ref int iuf) + static int zs1s2(double zrr, double zri, ref double s1r, ref double s1i, ref double s2r, ref double s2i, ref int nz, double ascle, double alim, ref int iuf) { #region Description @@ -4776,7 +4776,7 @@ namespace MathNet.Numerics return 0; } - private static int zseri(double zr, double zi, double fnu, int kode, int n, double[] yr, double[] yi, ref int nz, double tol, double elim, double alim) + static int zseri(double zr, double zi, double fnu, int kode, int n, double[] yr, double[] yi, ref int nz, double tol, double elim, double alim) { #region Description @@ -4982,7 +4982,7 @@ namespace MathNet.Numerics return 0; } - private static int zshch(double zr, double zi, ref double cshr, ref double cshi, ref double cchr, ref double cchi) + static int zshch(double zr, double zi, ref double cshr, ref double cshi, ref double cchr, ref double cchi) { #region Description @@ -5008,7 +5008,7 @@ namespace MathNet.Numerics return 0; } - private static int zuchk(double yr, double yi, ref int nz, double ascle, double tol) + static int zuchk(double yr, double yi, ref int nz, double ascle, double tol) { #region Description @@ -5041,7 +5041,7 @@ namespace MathNet.Numerics return 0; } - private static int zunhj(double zr, double zi, double fnu, int ipmtr, double tol, ref double phir, ref double phii, ref double argr, ref double argi, ref double zeta1r, ref double zeta1i, ref double zeta2r, ref double zeta2i, ref double asumr, ref double asumi, ref double bsumr, ref double bsumi) + static int zunhj(double zr, double zi, double fnu, int ipmtr, double tol, ref double phir, ref double phii, ref double argr, ref double argi, ref double zeta1r, ref double zeta1i, ref double zeta2r, ref double zeta2i, ref double asumr, ref double asumi, ref double bsumr, ref double bsumi) { #region Description @@ -5655,7 +5655,7 @@ namespace MathNet.Numerics goto L120; } - private static int zuni1(double zr, double zi, double fnu, int kode, int n, double[] yr, double[] yi, ref int nz, ref int nlast, double fnul, double tol, double elim, double alim) + static int zuni1(double zr, double zi, double fnu, int kode, int n, double[] yr, double[] yi, ref int nz, ref int nlast, double fnul, double tol, double elim, double alim) { #region Description @@ -5893,7 +5893,7 @@ namespace MathNet.Numerics return 0; } - private static int zuni2(double zr, double zi, double fnu, int kode, int n, double[] yr, double[] yi, ref int nz, ref int nlast, double fnul, double tol, double elim, double alim) + static int zuni2(double zr, double zi, double fnu, int kode, int n, double[] yr, double[] yi, ref int nz, ref int nlast, double fnul, double tol, double elim, double alim) { #region Description @@ -6174,7 +6174,7 @@ namespace MathNet.Numerics return 0; } - private static int zunik(double zrr, double zri, double fnu, int ikflg, int ipmtr, double tol, ref int init, ref double phir, ref double phii, ref double zeta1r, ref double zeta1i, ref double zeta2r, ref double zeta2i, ref double sumr, ref double sumi, ref double[] cwrkr, ref double[] cwrki) + static int zunik(double zrr, double zri, double fnu, int ikflg, int ipmtr, double tol, ref int init, ref double phir, ref double phii, ref double zeta1r, ref double zeta1i, ref double zeta2r, ref double zeta2i, ref double sumr, ref double sumi, ref double[] cwrkr, ref double[] cwrki) { #region Description @@ -6363,7 +6363,7 @@ namespace MathNet.Numerics return 0; } - private static int zunk1(double zr, double zi, double fnu, int kode, int mr, int n, double[] yr, double[] yi, ref int nz, double tol, double elim, double alim) + static int zunk1(double zr, double zi, double fnu, int kode, int mr, int n, double[] yr, double[] yi, ref int nz, double tol, double elim, double alim) { #region Description @@ -6836,7 +6836,7 @@ namespace MathNet.Numerics return 0; } - private static int zunk2(double zr, double zi, double fnu, int kode, int mr, int n, double[] yr, double[] yi, ref int nz, double tol, double elim, double alim) + static int zunk2(double zr, double zi, double fnu, int kode, int mr, int n, double[] yr, double[] yi, ref int nz, double tol, double elim, double alim) { #region Description @@ -7370,7 +7370,7 @@ namespace MathNet.Numerics return 0; } - private static int zuoik(double zr, double zi, double fnu, int kode, int ikflg, int n, double[] yr, double[] yi, ref int nuf, double tol, double elim, double alim) + static int zuoik(double zr, double zi, double fnu, int kode, int ikflg, int n, double[] yr, double[] yi, ref int nuf, double tol, double elim, double alim) { #region Description @@ -7570,7 +7570,7 @@ namespace MathNet.Numerics return 0; } - private static int zwrsk(double zrr, double zri, double fnu, int kode, int n, double[] yr, double[] yi, ref int nz, double[] cwr, double[] cwi, double tol, double elim, double alim) + static int zwrsk(double zrr, double zri, double fnu, int kode, int n, double[] yr, double[] yi, ref int nz, double[] cwr, double[] cwi, double tol, double elim, double alim) { #region Description diff --git a/src/Numerics/SpecialFunctions/Bessel.cs b/src/Numerics/SpecialFunctions/Bessel.cs index 73145796..94b44ca1 100644 --- a/src/Numerics/SpecialFunctions/Bessel.cs +++ b/src/Numerics/SpecialFunctions/Bessel.cs @@ -1,5 +1,6 @@ using Complex = System.Numerics.Complex; +// ReSharper disable once CheckNamespace namespace MathNet.Numerics { /// diff --git a/src/Numerics/SpecialFunctions/Beta.cs b/src/Numerics/SpecialFunctions/Beta.cs index 06ef61f8..7ea4cc61 100644 --- a/src/Numerics/SpecialFunctions/Beta.cs +++ b/src/Numerics/SpecialFunctions/Beta.cs @@ -34,9 +34,8 @@ using System; -// ReSharper disable CheckNamespace +// ReSharper disable once CheckNamespace namespace MathNet.Numerics -// ReSharper restore CheckNamespace { public static partial class SpecialFunctions diff --git a/src/Numerics/SpecialFunctions/Erf.cs b/src/Numerics/SpecialFunctions/Erf.cs index 1b651768..eb0d5a82 100644 --- a/src/Numerics/SpecialFunctions/Erf.cs +++ b/src/Numerics/SpecialFunctions/Erf.cs @@ -38,9 +38,8 @@ using System; -// ReSharper disable CheckNamespace +// ReSharper disable once CheckNamespace namespace MathNet.Numerics -// ReSharper restore CheckNamespace { /// /// This partial implementation of the SpecialFunctions class contains all methods related to the error function. @@ -55,142 +54,142 @@ namespace MathNet.Numerics /// Polynomial coefficients for a numerator of ErfImp /// calculation for Erf(x) in the interval [1e-10, 0.5]. /// - private static readonly double[] ErfImpAn = { 0.00337916709551257388990745, -0.00073695653048167948530905, -0.374732337392919607868241, 0.0817442448733587196071743, -0.0421089319936548595203468, 0.0070165709512095756344528, -0.00495091255982435110337458, 0.000871646599037922480317225 }; + static readonly double[] ErfImpAn = { 0.00337916709551257388990745, -0.00073695653048167948530905, -0.374732337392919607868241, 0.0817442448733587196071743, -0.0421089319936548595203468, 0.0070165709512095756344528, -0.00495091255982435110337458, 0.000871646599037922480317225 }; /// Polynomial coefficients for a denominator of ErfImp /// calculation for Erf(x) in the interval [1e-10, 0.5]. /// - private static readonly double[] ErfImpAd = { 1, -0.218088218087924645390535, 0.412542972725442099083918, -0.0841891147873106755410271, 0.0655338856400241519690695, -0.0120019604454941768171266, 0.00408165558926174048329689, -0.000615900721557769691924509 }; + static readonly double[] ErfImpAd = { 1, -0.218088218087924645390535, 0.412542972725442099083918, -0.0841891147873106755410271, 0.0655338856400241519690695, -0.0120019604454941768171266, 0.00408165558926174048329689, -0.000615900721557769691924509 }; /// Polynomial coefficients for a numerator in ErfImp /// calculation for Erfc(x) in the interval [0.5, 0.75]. /// - private static readonly double[] ErfImpBn = { -0.0361790390718262471360258, 0.292251883444882683221149, 0.281447041797604512774415, 0.125610208862766947294894, 0.0274135028268930549240776, 0.00250839672168065762786937 }; + static readonly double[] ErfImpBn = { -0.0361790390718262471360258, 0.292251883444882683221149, 0.281447041797604512774415, 0.125610208862766947294894, 0.0274135028268930549240776, 0.00250839672168065762786937 }; /// Polynomial coefficients for a denominator in ErfImp /// calculation for Erfc(x) in the interval [0.5, 0.75]. /// - private static readonly double[] ErfImpBd = { 1, 1.8545005897903486499845, 1.43575803037831418074962, 0.582827658753036572454135, 0.124810476932949746447682, 0.0113724176546353285778481 }; + static readonly double[] ErfImpBd = { 1, 1.8545005897903486499845, 1.43575803037831418074962, 0.582827658753036572454135, 0.124810476932949746447682, 0.0113724176546353285778481 }; /// Polynomial coefficients for a numerator in ErfImp /// calculation for Erfc(x) in the interval [0.75, 1.25]. /// - private static readonly double[] ErfImpCn = { -0.0397876892611136856954425, 0.153165212467878293257683, 0.191260295600936245503129, 0.10276327061989304213645, 0.029637090615738836726027, 0.0046093486780275489468812, 0.000307607820348680180548455 }; + static readonly double[] ErfImpCn = { -0.0397876892611136856954425, 0.153165212467878293257683, 0.191260295600936245503129, 0.10276327061989304213645, 0.029637090615738836726027, 0.0046093486780275489468812, 0.000307607820348680180548455 }; /// Polynomial coefficients for a denominator in ErfImp /// calculation for Erfc(x) in the interval [0.75, 1.25]. /// - private static readonly double[] ErfImpCd = { 1, 1.95520072987627704987886, 1.64762317199384860109595, 0.768238607022126250082483, 0.209793185936509782784315, 0.0319569316899913392596356, 0.00213363160895785378615014 }; + static readonly double[] ErfImpCd = { 1, 1.95520072987627704987886, 1.64762317199384860109595, 0.768238607022126250082483, 0.209793185936509782784315, 0.0319569316899913392596356, 0.00213363160895785378615014 }; /// Polynomial coefficients for a numerator in ErfImp /// calculation for Erfc(x) in the interval [1.25, 2.25]. /// - private static readonly double[] ErfImpDn = { -0.0300838560557949717328341, 0.0538578829844454508530552, 0.0726211541651914182692959, 0.0367628469888049348429018, 0.00964629015572527529605267, 0.00133453480075291076745275, 0.778087599782504251917881e-4 }; + static readonly double[] ErfImpDn = { -0.0300838560557949717328341, 0.0538578829844454508530552, 0.0726211541651914182692959, 0.0367628469888049348429018, 0.00964629015572527529605267, 0.00133453480075291076745275, 0.778087599782504251917881e-4 }; /// Polynomial coefficients for a denominator in ErfImp /// calculation for Erfc(x) in the interval [1.25, 2.25]. /// - private static readonly double[] ErfImpDd = { 1, 1.75967098147167528287343, 1.32883571437961120556307, 0.552528596508757581287907, 0.133793056941332861912279, 0.0179509645176280768640766, 0.00104712440019937356634038, -0.106640381820357337177643e-7 }; + static readonly double[] ErfImpDd = { 1, 1.75967098147167528287343, 1.32883571437961120556307, 0.552528596508757581287907, 0.133793056941332861912279, 0.0179509645176280768640766, 0.00104712440019937356634038, -0.106640381820357337177643e-7 }; /// Polynomial coefficients for a numerator in ErfImp /// calculation for Erfc(x) in the interval [2.25, 3.5]. /// - private static readonly double[] ErfImpEn = { -0.0117907570137227847827732, 0.014262132090538809896674, 0.0202234435902960820020765, 0.00930668299990432009042239, 0.00213357802422065994322516, 0.00025022987386460102395382, 0.120534912219588189822126e-4 }; + static readonly double[] ErfImpEn = { -0.0117907570137227847827732, 0.014262132090538809896674, 0.0202234435902960820020765, 0.00930668299990432009042239, 0.00213357802422065994322516, 0.00025022987386460102395382, 0.120534912219588189822126e-4 }; /// Polynomial coefficients for a denominator in ErfImp /// calculation for Erfc(x) in the interval [2.25, 3.5]. /// - private static readonly double[] ErfImpEd = { 1, 1.50376225203620482047419, 0.965397786204462896346934, 0.339265230476796681555511, 0.0689740649541569716897427, 0.00771060262491768307365526, 0.000371421101531069302990367 }; + static readonly double[] ErfImpEd = { 1, 1.50376225203620482047419, 0.965397786204462896346934, 0.339265230476796681555511, 0.0689740649541569716897427, 0.00771060262491768307365526, 0.000371421101531069302990367 }; /// Polynomial coefficients for a numerator in ErfImp /// calculation for Erfc(x) in the interval [3.5, 5.25]. /// - private static readonly double[] ErfImpFn = { -0.00546954795538729307482955, 0.00404190278731707110245394, 0.0054963369553161170521356, 0.00212616472603945399437862, 0.000394984014495083900689956, 0.365565477064442377259271e-4, 0.135485897109932323253786e-5 }; + static readonly double[] ErfImpFn = { -0.00546954795538729307482955, 0.00404190278731707110245394, 0.0054963369553161170521356, 0.00212616472603945399437862, 0.000394984014495083900689956, 0.365565477064442377259271e-4, 0.135485897109932323253786e-5 }; /// Polynomial coefficients for a denominator in ErfImp /// calculation for Erfc(x) in the interval [3.5, 5.25]. /// - private static readonly double[] ErfImpFd = { 1, 1.21019697773630784832251, 0.620914668221143886601045, 0.173038430661142762569515, 0.0276550813773432047594539, 0.00240625974424309709745382, 0.891811817251336577241006e-4, -0.465528836283382684461025e-11 }; + static readonly double[] ErfImpFd = { 1, 1.21019697773630784832251, 0.620914668221143886601045, 0.173038430661142762569515, 0.0276550813773432047594539, 0.00240625974424309709745382, 0.891811817251336577241006e-4, -0.465528836283382684461025e-11 }; /// Polynomial coefficients for a numerator in ErfImp /// calculation for Erfc(x) in the interval [5.25, 8]. /// - private static readonly double[] ErfImpGn = { -0.00270722535905778347999196, 0.0013187563425029400461378, 0.00119925933261002333923989, 0.00027849619811344664248235, 0.267822988218331849989363e-4, 0.923043672315028197865066e-6 }; + static readonly double[] ErfImpGn = { -0.00270722535905778347999196, 0.0013187563425029400461378, 0.00119925933261002333923989, 0.00027849619811344664248235, 0.267822988218331849989363e-4, 0.923043672315028197865066e-6 }; /// Polynomial coefficients for a denominator in ErfImp /// calculation for Erfc(x) in the interval [5.25, 8]. /// - private static readonly double[] ErfImpGd = { 1, 0.814632808543141591118279, 0.268901665856299542168425, 0.0449877216103041118694989, 0.00381759663320248459168994, 0.000131571897888596914350697, 0.404815359675764138445257e-11 }; + static readonly double[] ErfImpGd = { 1, 0.814632808543141591118279, 0.268901665856299542168425, 0.0449877216103041118694989, 0.00381759663320248459168994, 0.000131571897888596914350697, 0.404815359675764138445257e-11 }; /// Polynomial coefficients for a numerator in ErfImp /// calculation for Erfc(x) in the interval [8, 11.5]. /// - private static readonly double[] ErfImpHn = { -0.00109946720691742196814323, 0.000406425442750422675169153, 0.000274499489416900707787024, 0.465293770646659383436343e-4, 0.320955425395767463401993e-5, 0.778286018145020892261936e-7 }; + static readonly double[] ErfImpHn = { -0.00109946720691742196814323, 0.000406425442750422675169153, 0.000274499489416900707787024, 0.465293770646659383436343e-4, 0.320955425395767463401993e-5, 0.778286018145020892261936e-7 }; /// Polynomial coefficients for a denominator in ErfImp /// calculation for Erfc(x) in the interval [8, 11.5]. /// - private static readonly double[] ErfImpHd = { 1, 0.588173710611846046373373, 0.139363331289409746077541, 0.0166329340417083678763028, 0.00100023921310234908642639, 0.24254837521587225125068e-4 }; + static readonly double[] ErfImpHd = { 1, 0.588173710611846046373373, 0.139363331289409746077541, 0.0166329340417083678763028, 0.00100023921310234908642639, 0.24254837521587225125068e-4 }; /// Polynomial coefficients for a numerator in ErfImp /// calculation for Erfc(x) in the interval [11.5, 17]. /// - private static readonly double[] ErfImpIn = { -0.00056907993601094962855594, 0.000169498540373762264416984, 0.518472354581100890120501e-4, 0.382819312231928859704678e-5, 0.824989931281894431781794e-7 }; + static readonly double[] ErfImpIn = { -0.00056907993601094962855594, 0.000169498540373762264416984, 0.518472354581100890120501e-4, 0.382819312231928859704678e-5, 0.824989931281894431781794e-7 }; /// Polynomial coefficients for a denominator in ErfImp /// calculation for Erfc(x) in the interval [11.5, 17]. /// - private static readonly double[] ErfImpId = { 1, 0.339637250051139347430323, 0.043472647870310663055044, 0.00248549335224637114641629, 0.535633305337152900549536e-4, -0.117490944405459578783846e-12 }; + static readonly double[] ErfImpId = { 1, 0.339637250051139347430323, 0.043472647870310663055044, 0.00248549335224637114641629, 0.535633305337152900549536e-4, -0.117490944405459578783846e-12 }; /// Polynomial coefficients for a numerator in ErfImp /// calculation for Erfc(x) in the interval [17, 24]. /// - private static readonly double[] ErfImpJn = { -0.000241313599483991337479091, 0.574224975202501512365975e-4, 0.115998962927383778460557e-4, 0.581762134402593739370875e-6, 0.853971555085673614607418e-8 }; + static readonly double[] ErfImpJn = { -0.000241313599483991337479091, 0.574224975202501512365975e-4, 0.115998962927383778460557e-4, 0.581762134402593739370875e-6, 0.853971555085673614607418e-8 }; /// Polynomial coefficients for a denominator in ErfImp /// calculation for Erfc(x) in the interval [17, 24]. /// - private static readonly double[] ErfImpJd = { 1, 0.233044138299687841018015, 0.0204186940546440312625597, 0.000797185647564398289151125, 0.117019281670172327758019e-4 }; + static readonly double[] ErfImpJd = { 1, 0.233044138299687841018015, 0.0204186940546440312625597, 0.000797185647564398289151125, 0.117019281670172327758019e-4 }; /// Polynomial coefficients for a numerator in ErfImp /// calculation for Erfc(x) in the interval [24, 38]. /// - private static readonly double[] ErfImpKn = { -0.000146674699277760365803642, 0.162666552112280519955647e-4, 0.269116248509165239294897e-5, 0.979584479468091935086972e-7, 0.101994647625723465722285e-8 }; + static readonly double[] ErfImpKn = { -0.000146674699277760365803642, 0.162666552112280519955647e-4, 0.269116248509165239294897e-5, 0.979584479468091935086972e-7, 0.101994647625723465722285e-8 }; /// Polynomial coefficients for a denominator in ErfImp /// calculation for Erfc(x) in the interval [24, 38]. /// - private static readonly double[] ErfImpKd = { 1, 0.165907812944847226546036, 0.0103361716191505884359634, 0.000286593026373868366935721, 0.298401570840900340874568e-5 }; + static readonly double[] ErfImpKd = { 1, 0.165907812944847226546036, 0.0103361716191505884359634, 0.000286593026373868366935721, 0.298401570840900340874568e-5 }; /// Polynomial coefficients for a numerator in ErfImp /// calculation for Erfc(x) in the interval [38, 60]. /// - private static readonly double[] ErfImpLn = { -0.583905797629771786720406e-4, 0.412510325105496173512992e-5, 0.431790922420250949096906e-6, 0.993365155590013193345569e-8, 0.653480510020104699270084e-10 }; + static readonly double[] ErfImpLn = { -0.583905797629771786720406e-4, 0.412510325105496173512992e-5, 0.431790922420250949096906e-6, 0.993365155590013193345569e-8, 0.653480510020104699270084e-10 }; /// Polynomial coefficients for a denominator in ErfImp /// calculation for Erfc(x) in the interval [38, 60]. /// - private static readonly double[] ErfImpLd = { 1, 0.105077086072039915406159, 0.00414278428675475620830226, 0.726338754644523769144108e-4, 0.477818471047398785369849e-6 }; + static readonly double[] ErfImpLd = { 1, 0.105077086072039915406159, 0.00414278428675475620830226, 0.726338754644523769144108e-4, 0.477818471047398785369849e-6 }; /// Polynomial coefficients for a numerator in ErfImp /// calculation for Erfc(x) in the interval [60, 85]. /// - private static readonly double[] ErfImpMn = { -0.196457797609229579459841e-4, 0.157243887666800692441195e-5, 0.543902511192700878690335e-7, 0.317472492369117710852685e-9 }; + static readonly double[] ErfImpMn = { -0.196457797609229579459841e-4, 0.157243887666800692441195e-5, 0.543902511192700878690335e-7, 0.317472492369117710852685e-9 }; /// Polynomial coefficients for a denominator in ErfImp /// calculation for Erfc(x) in the interval [60, 85]. /// - private static readonly double[] ErfImpMd = { 1, 0.052803989240957632204885, 0.000926876069151753290378112, 0.541011723226630257077328e-5, 0.535093845803642394908747e-15 }; + static readonly double[] ErfImpMd = { 1, 0.052803989240957632204885, 0.000926876069151753290378112, 0.541011723226630257077328e-5, 0.535093845803642394908747e-15 }; /// Polynomial coefficients for a numerator in ErfImp /// calculation for Erfc(x) in the interval [85, 110]. /// - private static readonly double[] ErfImpNn = { -0.789224703978722689089794e-5, 0.622088451660986955124162e-6, 0.145728445676882396797184e-7, 0.603715505542715364529243e-10 }; + static readonly double[] ErfImpNn = { -0.789224703978722689089794e-5, 0.622088451660986955124162e-6, 0.145728445676882396797184e-7, 0.603715505542715364529243e-10 }; /// Polynomial coefficients for a denominator in ErfImp /// calculation for Erfc(x) in the interval [85, 110]. /// - private static readonly double[] ErfImpNd = { 1, 0.0375328846356293715248719, 0.000467919535974625308126054, 0.193847039275845656900547e-5 }; + static readonly double[] ErfImpNd = { 1, 0.0375328846356293715248719, 0.000467919535974625308126054, 0.193847039275845656900547e-5 }; /// /// ************************************** @@ -200,72 +199,72 @@ namespace MathNet.Numerics /// Polynomial coefficients for a numerator of ErfInvImp /// calculation for Erf^-1(z) in the interval [0, 0.5]. /// - private static readonly double[] ErvInvImpAn = { -0.000508781949658280665617, -0.00836874819741736770379, 0.0334806625409744615033, -0.0126926147662974029034, -0.0365637971411762664006, 0.0219878681111168899165, 0.00822687874676915743155, -0.00538772965071242932965 }; + static readonly double[] ErvInvImpAn = { -0.000508781949658280665617, -0.00836874819741736770379, 0.0334806625409744615033, -0.0126926147662974029034, -0.0365637971411762664006, 0.0219878681111168899165, 0.00822687874676915743155, -0.00538772965071242932965 }; /// Polynomial coefficients for a denominator of ErfInvImp /// calculation for Erf^-1(z) in the interval [0, 0.5]. /// - private static readonly double[] ErvInvImpAd = { 1, -0.970005043303290640362, -1.56574558234175846809, 1.56221558398423026363, 0.662328840472002992063, -0.71228902341542847553, -0.0527396382340099713954, 0.0795283687341571680018, -0.00233393759374190016776, 0.000886216390456424707504 }; + static readonly double[] ErvInvImpAd = { 1, -0.970005043303290640362, -1.56574558234175846809, 1.56221558398423026363, 0.662328840472002992063, -0.71228902341542847553, -0.0527396382340099713954, 0.0795283687341571680018, -0.00233393759374190016776, 0.000886216390456424707504 }; /// Polynomial coefficients for a numerator of ErfInvImp /// calculation for Erf^-1(z) in the interval [0.5, 0.75]. /// - private static readonly double[] ErvInvImpBn = { -0.202433508355938759655, 0.105264680699391713268, 8.37050328343119927838, 17.6447298408374015486, -18.8510648058714251895, -44.6382324441786960818, 17.445385985570866523, 21.1294655448340526258, -3.67192254707729348546 }; + static readonly double[] ErvInvImpBn = { -0.202433508355938759655, 0.105264680699391713268, 8.37050328343119927838, 17.6447298408374015486, -18.8510648058714251895, -44.6382324441786960818, 17.445385985570866523, 21.1294655448340526258, -3.67192254707729348546 }; /// Polynomial coefficients for a denominator of ErfInvImp /// calculation for Erf^-1(z) in the interval [0.5, 0.75]. /// - private static readonly double[] ErvInvImpBd = { 1, 6.24264124854247537712, 3.9713437953343869095, -28.6608180499800029974, -20.1432634680485188801, 48.5609213108739935468, 10.8268667355460159008, -22.6436933413139721736, 1.72114765761200282724 }; + static readonly double[] ErvInvImpBd = { 1, 6.24264124854247537712, 3.9713437953343869095, -28.6608180499800029974, -20.1432634680485188801, 48.5609213108739935468, 10.8268667355460159008, -22.6436933413139721736, 1.72114765761200282724 }; /// Polynomial coefficients for a numerator of ErfInvImp /// calculation for Erf^-1(z) in the interval [0.75, 1] with x less than 3. /// - private static readonly double[] ErvInvImpCn = { -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 }; + static readonly double[] ErvInvImpCn = { -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 }; /// Polynomial coefficients for a denominator of ErfInvImp /// calculation for Erf^-1(z) in the interval [0.75, 1] with x less than 3. /// - private static readonly double[] ErvInvImpCd = { 1, 3.46625407242567245975, 5.38168345707006855425, 4.77846592945843778382, 2.59301921623620271374, 0.848854343457902036425, 0.152264338295331783612, 0.01105924229346489121 }; + static readonly double[] ErvInvImpCd = { 1, 3.46625407242567245975, 5.38168345707006855425, 4.77846592945843778382, 2.59301921623620271374, 0.848854343457902036425, 0.152264338295331783612, 0.01105924229346489121 }; /// Polynomial coefficients for a numerator of ErfInvImp /// calculation for Erf^-1(z) in the interval [0.75, 1] with x between 3 and 6. /// - private static readonly double[] ErvInvImpDn = { -0.0350353787183177984712, -0.00222426529213447927281, 0.0185573306514231072324, 0.00950804701325919603619, 0.00187123492819559223345, 0.000157544617424960554631, 0.460469890584317994083e-5, -0.230404776911882601748e-9, 0.266339227425782031962e-11 }; + static readonly double[] ErvInvImpDn = { -0.0350353787183177984712, -0.00222426529213447927281, 0.0185573306514231072324, 0.00950804701325919603619, 0.00187123492819559223345, 0.000157544617424960554631, 0.460469890584317994083e-5, -0.230404776911882601748e-9, 0.266339227425782031962e-11 }; /// Polynomial coefficients for a denominator of ErfInvImp /// calculation for Erf^-1(z) in the interval [0.75, 1] with x between 3 and 6. /// - private static readonly double[] ErvInvImpDd = { 1, 1.3653349817554063097, 0.762059164553623404043, 0.220091105764131249824, 0.0341589143670947727934, 0.00263861676657015992959, 0.764675292302794483503e-4 }; + static readonly double[] ErvInvImpDd = { 1, 1.3653349817554063097, 0.762059164553623404043, 0.220091105764131249824, 0.0341589143670947727934, 0.00263861676657015992959, 0.764675292302794483503e-4 }; /// Polynomial coefficients for a numerator of ErfInvImp /// calculation for Erf^-1(z) in the interval [0.75, 1] with x between 6 and 18. /// - private static readonly double[] ErvInvImpEn = { -0.0167431005076633737133, -0.00112951438745580278863, 0.00105628862152492910091, 0.000209386317487588078668, 0.149624783758342370182e-4, 0.449696789927706453732e-6, 0.462596163522878599135e-8, -0.281128735628831791805e-13, 0.99055709973310326855e-16 }; + static readonly double[] ErvInvImpEn = { -0.0167431005076633737133, -0.00112951438745580278863, 0.00105628862152492910091, 0.000209386317487588078668, 0.149624783758342370182e-4, 0.449696789927706453732e-6, 0.462596163522878599135e-8, -0.281128735628831791805e-13, 0.99055709973310326855e-16 }; /// Polynomial coefficients for a denominator of ErfInvImp /// calculation for Erf^-1(z) in the interval [0.75, 1] with x between 6 and 18. /// - private static readonly double[] ErvInvImpEd = { 1, 0.591429344886417493481, 0.138151865749083321638, 0.0160746087093676504695, 0.000964011807005165528527, 0.275335474764726041141e-4, 0.282243172016108031869e-6 }; + static readonly double[] ErvInvImpEd = { 1, 0.591429344886417493481, 0.138151865749083321638, 0.0160746087093676504695, 0.000964011807005165528527, 0.275335474764726041141e-4, 0.282243172016108031869e-6 }; /// Polynomial coefficients for a numerator of ErfInvImp /// calculation for Erf^-1(z) in the interval [0.75, 1] with x between 18 and 44. /// - private static readonly double[] ErvInvImpFn = { -0.0024978212791898131227, -0.779190719229053954292e-5, 0.254723037413027451751e-4, 0.162397777342510920873e-5, 0.396341011304801168516e-7, 0.411632831190944208473e-9, 0.145596286718675035587e-11, -0.116765012397184275695e-17 }; + static readonly double[] ErvInvImpFn = { -0.0024978212791898131227, -0.779190719229053954292e-5, 0.254723037413027451751e-4, 0.162397777342510920873e-5, 0.396341011304801168516e-7, 0.411632831190944208473e-9, 0.145596286718675035587e-11, -0.116765012397184275695e-17 }; /// Polynomial coefficients for a denominator of ErfInvImp /// calculation for Erf^-1(z) in the interval [0.75, 1] with x between 18 and 44. /// - private static readonly double[] ErvInvImpFd = { 1, 0.207123112214422517181, 0.0169410838120975906478, 0.000690538265622684595676, 0.145007359818232637924e-4, 0.144437756628144157666e-6, 0.509761276599778486139e-9 }; + static readonly double[] ErvInvImpFd = { 1, 0.207123112214422517181, 0.0169410838120975906478, 0.000690538265622684595676, 0.145007359818232637924e-4, 0.144437756628144157666e-6, 0.509761276599778486139e-9 }; /// Polynomial coefficients for a numerator of ErfInvImp /// calculation for Erf^-1(z) in the interval [0.75, 1] with x greater than 44. /// - private static readonly double[] ErvInvImpGn = { -0.000539042911019078575891, -0.28398759004727721098e-6, 0.899465114892291446442e-6, 0.229345859265920864296e-7, 0.225561444863500149219e-9, 0.947846627503022684216e-12, 0.135880130108924861008e-14, -0.348890393399948882918e-21 }; + static readonly double[] ErvInvImpGn = { -0.000539042911019078575891, -0.28398759004727721098e-6, 0.899465114892291446442e-6, 0.229345859265920864296e-7, 0.225561444863500149219e-9, 0.947846627503022684216e-12, 0.135880130108924861008e-14, -0.348890393399948882918e-21 }; /// Polynomial coefficients for a denominator of ErfInvImp /// calculation for Erf^-1(z) in the interval [0.75, 1] with x greater than 44. /// - private static readonly double[] ErvInvImpGd = { 1, 0.0845746234001899436914, 0.00282092984726264681981, 0.468292921940894236786e-4, 0.399968812193862100054e-6, 0.161809290887904476097e-8, 0.231558608310259605225e-11 }; + static readonly double[] ErvInvImpGd = { 1, 0.0845746234001899436914, 0.00282092984726264681981, 0.468292921940894236786e-4, 0.399968812193862100054e-6, 0.161809290887904476097e-8, 0.231558608310259605225e-11 }; /// Calculates the error function. /// The value to evaluate. diff --git a/src/Numerics/SpecialFunctions/Evaluate.cs b/src/Numerics/SpecialFunctions/Evaluate.cs index a8e1bdac..4df41602 100644 --- a/src/Numerics/SpecialFunctions/Evaluate.cs +++ b/src/Numerics/SpecialFunctions/Evaluate.cs @@ -46,9 +46,8 @@ using System; using Complex = System.Numerics.Complex; -// ReSharper disable CheckNamespace +// ReSharper disable once CheckNamespace namespace MathNet.Numerics -// ReSharper restore CheckNamespace { /// /// Evaluation functions, useful for function approximation. diff --git a/src/Numerics/SpecialFunctions/ExponentialIntegral.cs b/src/Numerics/SpecialFunctions/ExponentialIntegral.cs index 0c19e7ca..70e820b2 100644 --- a/src/Numerics/SpecialFunctions/ExponentialIntegral.cs +++ b/src/Numerics/SpecialFunctions/ExponentialIntegral.cs @@ -33,9 +33,8 @@ using System; -// ReSharper disable CheckNamespace +// ReSharper disable once CheckNamespace namespace MathNet.Numerics -// ReSharper restore CheckNamespace { public static partial class SpecialFunctions { @@ -69,7 +68,7 @@ namespace MathNet.Numerics const double epsilon = 0.00000000000000001; int maxIterations = 100; int i, ii; - double ndbl = (double)n; + double ndbl = n; double result; double nearDoubleMin = 1e-100; //needs a very small value that is not quite as small as the lowest value double can take double factorial = 1.0d; @@ -90,13 +89,13 @@ namespace MathNet.Numerics //continued fraction for large x if (x > 1.0d) { - b = x + ((double)n); + b = x + n; c = 1.0d/nearDoubleMin; d = 1.0d/b; h = d; for (i = 1; i <= maxIterations; i++) { - a = -1.0d*((double)i)*((ndbl - 1.0d) + (double)i); + a = -1.0d*i*((ndbl - 1.0d) + i); b += 2.0d; d = 1.0d/(a*d + b); c = b + a/c; @@ -115,7 +114,7 @@ namespace MathNet.Numerics result = ((ndbl - 1.0d) != 0 ? 1.0/(ndbl - 1.0d) : (-1.0d*Math.Log(x) - Constants.EulerMascheroni)); //Set first term. for (i = 1; i <= maxIterations; i++) { - factorial *= (-1.0d*x/((double)i)); + factorial *= (-1.0d*x/i); if (i != (ndbl - 1.0d)) { del = -factorial/(i - (ndbl - 1.0d)); @@ -125,7 +124,7 @@ namespace MathNet.Numerics psi = -1.0d*Constants.EulerMascheroni; for (ii = 1; ii <= (ndbl - 1.0d); ii++) { - psi += (1.0d/((double)ii)); + psi += (1.0d/ii); } del = factorial*(-1.0d*Math.Log(x) + psi); } diff --git a/src/Numerics/SpecialFunctions/Factorial.cs b/src/Numerics/SpecialFunctions/Factorial.cs index a6ba40a4..177cb633 100644 --- a/src/Numerics/SpecialFunctions/Factorial.cs +++ b/src/Numerics/SpecialFunctions/Factorial.cs @@ -30,13 +30,11 @@ using System; using BigInteger = System.Numerics.BigInteger; -// ReSharper disable CheckNamespace +// ReSharper disable once CheckNamespace namespace MathNet.Numerics -// ReSharper restore CheckNamespace { public partial class SpecialFunctions { - const int FactorialMaxArgument = 170; static readonly double[] _factorialCache = new double[171] { 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200, 1307674368000, 20922789888000, 355687428096000, 6402373705728000, 1.21645100408832E+17, 2.43290200817664E+18, 5.109094217170944E+19, 1.1240007277776077E+21, 2.5852016738884978E+22, 6.2044840173323941E+23, 1.5511210043330986E+25, 4.0329146112660565E+26, 1.0888869450418352E+28, 3.0488834461171384E+29, 8.8417619937397008E+30, 2.6525285981219103E+32, 8.2228386541779224E+33, 2.6313083693369352E+35, 8.6833176188118859E+36, 2.9523279903960412E+38, 1.0333147966386144E+40, 3.7199332678990118E+41, 1.3763753091226343E+43, 5.2302261746660104E+44, 2.0397882081197442E+46, 8.1591528324789768E+47, 3.3452526613163803E+49, 1.4050061177528798E+51, 6.0415263063373834E+52, 2.6582715747884485E+54, 1.1962222086548019E+56, 5.5026221598120885E+57, 2.5862324151116818E+59, 1.2413915592536073E+61, 6.0828186403426752E+62, 3.0414093201713376E+64, 1.5511187532873822E+66, 8.0658175170943877E+67, 4.2748832840600255E+69, 2.3084369733924138E+71, 1.2696403353658276E+73, 7.1099858780486348E+74, 4.0526919504877221E+76, 2.3505613312828789E+78, 1.3868311854568986E+80, 8.3209871127413916E+81, 5.0758021387722484E+83, 3.1469973260387939E+85, 1.9826083154044401E+87, 1.2688693218588417E+89, 8.2476505920824715E+90, 5.4434493907744307E+92, 3.6471110918188683E+94, 2.4800355424368305E+96, 1.711224524281413E+98, 1.197857166996989E+100, 8.5047858856786218E+101, 6.1234458376886077E+103, 4.4701154615126834E+105, 3.3078854415193856E+107, 2.4809140811395391E+109, 1.8854947016660498E+111, 1.4518309202828584E+113, 1.1324281178206295E+115, 8.9461821307829729E+116, 7.1569457046263779E+118, 5.7971260207473655E+120, 4.7536433370128398E+122, 3.9455239697206569E+124, 3.314240134565352E+126, 2.8171041143805494E+128, 2.4227095383672724E+130, 2.1077572983795269E+132, 1.8548264225739836E+134, 1.6507955160908452E+136, 1.4857159644817607E+138, 1.3520015276784023E+140, 1.24384140546413E+142, 1.1567725070816409E+144, 1.0873661566567424E+146, 1.0329978488239052E+148, 9.916779348709491E+149, 9.6192759682482062E+151, 9.426890448883242E+153, 9.3326215443944096E+155, 9.3326215443944102E+157, 9.4259477598383536E+159, 9.6144667150351211E+161, 9.9029007164861754E+163, 1.0299016745145622E+166, 1.0813967582402903E+168, 1.1462805637347078E+170, 1.2265202031961373E+172, 1.3246418194518284E+174, 1.4438595832024928E+176, 1.5882455415227421E+178, 1.7629525510902437E+180, 1.9745068572210728E+182, 2.2311927486598123E+184, 2.5435597334721862E+186, 2.9250936934930141E+188, 3.3931086844518965E+190, 3.969937160808719E+192, 4.6845258497542883E+194, 5.5745857612076033E+196, 6.6895029134491239E+198, 8.09429852527344E+200, 9.8750442008335976E+202, 1.2146304367025325E+205, 1.5061417415111404E+207, 1.8826771768889254E+209, 2.3721732428800459E+211, 3.0126600184576582E+213, 3.8562048236258025E+215, 4.9745042224772855E+217, 6.4668554892204716E+219, 8.4715806908788174E+221, 1.1182486511960039E+224, 1.4872707060906852E+226, 1.9929427461615181E+228, 2.6904727073180495E+230, 3.6590428819525472E+232, 5.0128887482749898E+234, 6.9177864726194859E+236, 9.6157231969410859E+238, 1.346201247571752E+241, 1.8981437590761701E+243, 2.6953641378881614E+245, 3.8543707171800706E+247, 5.5502938327393013E+249, 8.0479260574719866E+251, 1.1749972043909099E+254, 1.7272458904546376E+256, 2.5563239178728637E+258, 3.8089226376305671E+260, 5.7133839564458505E+262, 8.6272097742332346E+264, 1.3113358856834518E+267, 2.0063439050956811E+269, 3.0897696138473489E+271, 4.7891429014633912E+273, 7.4710629262828905E+275, 1.1729568794264138E+278, 1.8532718694937338E+280, 2.9467022724950369E+282, 4.714723635992059E+284, 7.5907050539472148E+286, 1.2296942187394488E+289, 2.0044015765453015E+291, 3.2872185855342945E+293, 5.423910666131586E+295, 9.0036917057784329E+297, 1.5036165148649983E+300, 2.5260757449731969E+302, 4.2690680090047027E+304, 7.257415615307994E+306 diff --git a/src/Numerics/SpecialFunctions/Gamma.cs b/src/Numerics/SpecialFunctions/Gamma.cs index fdcd7911..7698d5d9 100644 --- a/src/Numerics/SpecialFunctions/Gamma.cs +++ b/src/Numerics/SpecialFunctions/Gamma.cs @@ -34,9 +34,8 @@ using System; -// ReSharper disable CheckNamespace +// ReSharper disable once CheckNamespace namespace MathNet.Numerics -// ReSharper restore CheckNamespace { public static partial class SpecialFunctions { diff --git a/src/Numerics/SpecialFunctions/GeneralizedHyperGeometric.cs b/src/Numerics/SpecialFunctions/GeneralizedHyperGeometric.cs index 8313f2f6..332151b2 100644 --- a/src/Numerics/SpecialFunctions/GeneralizedHyperGeometric.cs +++ b/src/Numerics/SpecialFunctions/GeneralizedHyperGeometric.cs @@ -34,6 +34,7 @@ using System; using System.Linq; +// ReSharper disable once CheckNamespace namespace MathNet.Numerics { public static partial class SpecialFunctions @@ -100,7 +101,7 @@ namespace MathNet.Numerics } //Calculate each iteration of the function - private static double HGIncrement(double[] a, double[] b, int z, int currentN) + static double HGIncrement(double[] a, double[] b, int z, int currentN) { double incrementAs = 1.0; double incrementBs = 1.0; @@ -127,14 +128,13 @@ namespace MathNet.Numerics { return 0.0; } - else if (numPoles > 0 && numPoles > numZeros) + + if (numPoles > 0 && numPoles > numZeros) { return double.PositiveInfinity; } - else - { - return incrementAs / incrementBs * Math.Pow(z, currentN) / Factorial(currentN); - } + + return incrementAs / incrementBs * Math.Pow(z, currentN) / Factorial(currentN); } } diff --git a/src/Numerics/SpecialFunctions/Hankel.cs b/src/Numerics/SpecialFunctions/Hankel.cs index a0b5127a..c665efd2 100644 --- a/src/Numerics/SpecialFunctions/Hankel.cs +++ b/src/Numerics/SpecialFunctions/Hankel.cs @@ -1,5 +1,6 @@ using Complex = System.Numerics.Complex; +// ReSharper disable once CheckNamespace namespace MathNet.Numerics { /// diff --git a/src/Numerics/SpecialFunctions/Harmonic.cs b/src/Numerics/SpecialFunctions/Harmonic.cs index 2c26fd08..e46457cb 100644 --- a/src/Numerics/SpecialFunctions/Harmonic.cs +++ b/src/Numerics/SpecialFunctions/Harmonic.cs @@ -34,9 +34,8 @@ using System; -// ReSharper disable CheckNamespace +// ReSharper disable once CheckNamespace namespace MathNet.Numerics -// ReSharper restore CheckNamespace { /// /// This partial implementation of the SpecialFunctions class contains all methods related to the harmonic function. diff --git a/src/Numerics/SpecialFunctions/Kelvin.cs b/src/Numerics/SpecialFunctions/Kelvin.cs index 9c6e467a..673ed0cd 100644 --- a/src/Numerics/SpecialFunctions/Kelvin.cs +++ b/src/Numerics/SpecialFunctions/Kelvin.cs @@ -1,6 +1,7 @@ using System; using System.Numerics; +// ReSharper disable once CheckNamespace namespace MathNet.Numerics { /// diff --git a/src/Numerics/SpecialFunctions/Logistic.cs b/src/Numerics/SpecialFunctions/Logistic.cs index b7f2efbc..a20f9708 100644 --- a/src/Numerics/SpecialFunctions/Logistic.cs +++ b/src/Numerics/SpecialFunctions/Logistic.cs @@ -34,9 +34,8 @@ using System; -// ReSharper disable CheckNamespace +// ReSharper disable once CheckNamespace namespace MathNet.Numerics -// ReSharper restore CheckNamespace { /// /// This partial implementation of the SpecialFunctions class contains all methods related to the logistic function. diff --git a/src/Numerics/SpecialFunctions/ModifiedBessel.cs b/src/Numerics/SpecialFunctions/ModifiedBessel.cs index c1009c1f..1fd2ae2b 100644 --- a/src/Numerics/SpecialFunctions/ModifiedBessel.cs +++ b/src/Numerics/SpecialFunctions/ModifiedBessel.cs @@ -45,9 +45,8 @@ using System; -// ReSharper disable CheckNamespace +// ReSharper disable once CheckNamespace namespace MathNet.Numerics -// ReSharper restore CheckNamespace { /// /// This partial implementation of the SpecialFunctions class contains all methods related to the modified Bessel function. @@ -64,14 +63,14 @@ namespace MathNet.Numerics /// /// lim(x->0){ exp(-x) I0(x) } = 1. /// - private static readonly double[] BesselI0A = { -4.41534164647933937950e-18, 3.33079451882223809783e-17, -2.43127984654795469359e-16, 1.71539128555513303061e-15, -1.16853328779934516808e-14, 7.67618549860493561688e-14, -4.85644678311192946090e-13, 2.95505266312963983461e-12, -1.72682629144155570723e-11, 9.67580903537323691224e-11, -5.18979560163526290666e-10, 2.65982372468238665035e-9, -1.30002500998624804212e-8, 6.04699502254191894932e-8, -2.67079385394061173391e-7, 1.11738753912010371815e-6, -4.41673835845875056359e-6, 1.64484480707288970893e-5, -5.75419501008210370398e-5, 1.88502885095841655729e-4, -5.76375574538582365885e-4, 1.63947561694133579842e-3, -4.32430999505057594430e-3, 1.05464603945949983183e-2, -2.37374148058994688156e-2, 4.93052842396707084878e-2, -9.49010970480476444210e-2, 1.71620901522208775349e-1, -3.04682672343198398683e-1, 6.76795274409476084995e-1 }; + static readonly double[] BesselI0A = { -4.41534164647933937950e-18, 3.33079451882223809783e-17, -2.43127984654795469359e-16, 1.71539128555513303061e-15, -1.16853328779934516808e-14, 7.67618549860493561688e-14, -4.85644678311192946090e-13, 2.95505266312963983461e-12, -1.72682629144155570723e-11, 9.67580903537323691224e-11, -5.18979560163526290666e-10, 2.65982372468238665035e-9, -1.30002500998624804212e-8, 6.04699502254191894932e-8, -2.67079385394061173391e-7, 1.11738753912010371815e-6, -4.41673835845875056359e-6, 1.64484480707288970893e-5, -5.75419501008210370398e-5, 1.88502885095841655729e-4, -5.76375574538582365885e-4, 1.63947561694133579842e-3, -4.32430999505057594430e-3, 1.05464603945949983183e-2, -2.37374148058994688156e-2, 4.93052842396707084878e-2, -9.49010970480476444210e-2, 1.71620901522208775349e-1, -3.04682672343198398683e-1, 6.76795274409476084995e-1 }; /// Chebyshev coefficients for exp(-x) sqrt(x) I0(x) /// in the inverted interval [8, infinity]. /// /// lim(x->inf){ exp(-x) sqrt(x) I0(x) } = 1/sqrt(2pi). /// - private static readonly double[] BesselI0B = { -7.23318048787475395456e-18, -4.83050448594418207126e-18, 4.46562142029675999901e-17, 3.46122286769746109310e-17, -2.82762398051658348494e-16, -3.42548561967721913462e-16, 1.77256013305652638360e-15, 3.81168066935262242075e-15, -9.55484669882830764870e-15, -4.15056934728722208663e-14, 1.54008621752140982691e-14, 3.85277838274214270114e-13, 7.18012445138366623367e-13, -1.79417853150680611778e-12, -1.32158118404477131188e-11, -3.14991652796324136454e-11, 1.18891471078464383424e-11, 4.94060238822496958910e-10, 3.39623202570838634515e-9, 2.26666899049817806459e-8, 2.04891858946906374183e-7, 2.89137052083475648297e-6, 6.88975834691682398426e-5, 3.36911647825569408990e-3, 8.04490411014108831608e-1 }; + static readonly double[] BesselI0B = { -7.23318048787475395456e-18, -4.83050448594418207126e-18, 4.46562142029675999901e-17, 3.46122286769746109310e-17, -2.82762398051658348494e-16, -3.42548561967721913462e-16, 1.77256013305652638360e-15, 3.81168066935262242075e-15, -9.55484669882830764870e-15, -4.15056934728722208663e-14, 1.54008621752140982691e-14, 3.85277838274214270114e-13, 7.18012445138366623367e-13, -1.79417853150680611778e-12, -1.32158118404477131188e-11, -3.14991652796324136454e-11, 1.18891471078464383424e-11, 4.94060238822496958910e-10, 3.39623202570838634515e-9, 2.26666899049817806459e-8, 2.04891858946906374183e-7, 2.89137052083475648297e-6, 6.88975834691682398426e-5, 3.36911647825569408990e-3, 8.04490411014108831608e-1 }; /// /// ************************************** @@ -83,14 +82,14 @@ namespace MathNet.Numerics /// /// lim(x->0){ exp(-x) I1(x) / x } = 1/2. /// - private static readonly double[] BesselI1A = { 2.77791411276104639959e-18, -2.11142121435816608115e-17, 1.55363195773620046921e-16, -1.10559694773538630805e-15, 7.60068429473540693410e-15, -5.04218550472791168711e-14, 3.22379336594557470981e-13, -1.98397439776494371520e-12, 1.17361862988909016308e-11, -6.66348972350202774223e-11, 3.62559028155211703701e-10, -1.88724975172282928790e-9, 9.38153738649577178388e-9, -4.44505912879632808065e-8, 2.00329475355213526229e-7, -8.56872026469545474066e-7, 3.47025130813767847674e-6, -1.32731636560394358279e-5, 4.78156510755005422638e-5, -1.61760815825896745588e-4, 5.12285956168575772895e-4, -1.51357245063125314899e-3, 4.15642294431288815669e-3, -1.05640848946261981558e-2, 2.47264490306265168283e-2, -5.29459812080949914269e-2, 1.02643658689847095384e-1, -1.76416518357834055153e-1, 2.52587186443633654823e-1 }; + static readonly double[] BesselI1A = { 2.77791411276104639959e-18, -2.11142121435816608115e-17, 1.55363195773620046921e-16, -1.10559694773538630805e-15, 7.60068429473540693410e-15, -5.04218550472791168711e-14, 3.22379336594557470981e-13, -1.98397439776494371520e-12, 1.17361862988909016308e-11, -6.66348972350202774223e-11, 3.62559028155211703701e-10, -1.88724975172282928790e-9, 9.38153738649577178388e-9, -4.44505912879632808065e-8, 2.00329475355213526229e-7, -8.56872026469545474066e-7, 3.47025130813767847674e-6, -1.32731636560394358279e-5, 4.78156510755005422638e-5, -1.61760815825896745588e-4, 5.12285956168575772895e-4, -1.51357245063125314899e-3, 4.15642294431288815669e-3, -1.05640848946261981558e-2, 2.47264490306265168283e-2, -5.29459812080949914269e-2, 1.02643658689847095384e-1, -1.76416518357834055153e-1, 2.52587186443633654823e-1 }; /// Chebyshev coefficients for exp(-x) sqrt(x) I1(x) /// in the inverted interval [8, infinity]. /// /// lim(x->inf){ exp(-x) sqrt(x) I1(x) } = 1/sqrt(2pi). /// - private static readonly double[] BesselI1B = { 7.51729631084210481353e-18, 4.41434832307170791151e-18, -4.65030536848935832153e-17, -3.20952592199342395980e-17, 2.96262899764595013876e-16, 3.30820231092092828324e-16, -1.88035477551078244854e-15, -3.81440307243700780478e-15, 1.04202769841288027642e-14, 4.27244001671195135429e-14, -2.10154184277266431302e-14, -4.08355111109219731823e-13, -7.19855177624590851209e-13, 2.03562854414708950722e-12, 1.41258074366137813316e-11, 3.25260358301548823856e-11, -1.89749581235054123450e-11, -5.58974346219658380687e-10, -3.83538038596423702205e-9, -2.63146884688951950684e-8, -2.51223623787020892529e-7, -3.88256480887769039346e-6, -1.10588938762623716291e-4, -9.76109749136146840777e-3, 7.78576235018280120474e-1 }; + static readonly double[] BesselI1B = { 7.51729631084210481353e-18, 4.41434832307170791151e-18, -4.65030536848935832153e-17, -3.20952592199342395980e-17, 2.96262899764595013876e-16, 3.30820231092092828324e-16, -1.88035477551078244854e-15, -3.81440307243700780478e-15, 1.04202769841288027642e-14, 4.27244001671195135429e-14, -2.10154184277266431302e-14, -4.08355111109219731823e-13, -7.19855177624590851209e-13, 2.03562854414708950722e-12, 1.41258074366137813316e-11, 3.25260358301548823856e-11, -1.89749581235054123450e-11, -5.58974346219658380687e-10, -3.83538038596423702205e-9, -2.63146884688951950684e-8, -2.51223623787020892529e-7, -3.88256480887769039346e-6, -1.10588938762623716291e-4, -9.76109749136146840777e-3, 7.78576235018280120474e-1 }; /// /// ************************************** @@ -103,14 +102,14 @@ namespace MathNet.Numerics /// /// lim(x->0){ K0(x) + log(x/2) I0(x) } = -EUL. /// - private static readonly double[] BesselK0A = { 1.37446543561352307156e-16, 4.25981614279661018399e-14, 1.03496952576338420167e-11, 1.90451637722020886025e-9, 2.53479107902614945675e-7, 2.28621210311945178607e-5, 1.26461541144692592338e-3, 3.59799365153615016266e-2, 3.44289899924628486886e-1, -5.35327393233902768720e-1 }; + static readonly double[] BesselK0A = { 1.37446543561352307156e-16, 4.25981614279661018399e-14, 1.03496952576338420167e-11, 1.90451637722020886025e-9, 2.53479107902614945675e-7, 2.28621210311945178607e-5, 1.26461541144692592338e-3, 3.59799365153615016266e-2, 3.44289899924628486886e-1, -5.35327393233902768720e-1 }; /// Chebyshev coefficients for exp(x) sqrt(x) K0(x) /// in the inverted interval [2, infinity]. /// /// lim(x->inf){ exp(x) sqrt(x) K0(x) } = sqrt(pi/2). /// - private static readonly double[] BesselK0B = { 5.30043377268626276149e-18, -1.64758043015242134646e-17, 5.21039150503902756861e-17, -1.67823109680541210385e-16, 5.51205597852431940784e-16, -1.84859337734377901440e-15, 6.34007647740507060557e-15, -2.22751332699166985548e-14, 8.03289077536357521100e-14, -2.98009692317273043925e-13, 1.14034058820847496303e-12, -4.51459788337394416547e-12, 1.85594911495471785253e-11, -7.95748924447710747776e-11, 3.57739728140030116597e-10, -1.69753450938905987466e-9, 8.57403401741422608519e-9, -4.66048989768794782956e-8, 2.76681363944501510342e-7, -1.83175552271911948767e-6, 1.39498137188764993662e-5, -1.28495495816278026384e-4, 1.56988388573005337491e-3, -3.14481013119645005427e-2, 2.44030308206595545468e0 }; + static readonly double[] BesselK0B = { 5.30043377268626276149e-18, -1.64758043015242134646e-17, 5.21039150503902756861e-17, -1.67823109680541210385e-16, 5.51205597852431940784e-16, -1.84859337734377901440e-15, 6.34007647740507060557e-15, -2.22751332699166985548e-14, 8.03289077536357521100e-14, -2.98009692317273043925e-13, 1.14034058820847496303e-12, -4.51459788337394416547e-12, 1.85594911495471785253e-11, -7.95748924447710747776e-11, 3.57739728140030116597e-10, -1.69753450938905987466e-9, 8.57403401741422608519e-9, -4.66048989768794782956e-8, 2.76681363944501510342e-7, -1.83175552271911948767e-6, 1.39498137188764993662e-5, -1.28495495816278026384e-4, 1.56988388573005337491e-3, -3.14481013119645005427e-2, 2.44030308206595545468e0 }; /// /// ************************************** @@ -122,14 +121,14 @@ namespace MathNet.Numerics /// /// lim(x->0){ x(K1(x) - log(x/2) I1(x)) } = 1. /// - private static readonly double[] BesselK1A = { -7.02386347938628759343e-18, -2.42744985051936593393e-15, -6.66690169419932900609e-13, -1.41148839263352776110e-10, -2.21338763073472585583e-8, -2.43340614156596823496e-6, -1.73028895751305206302e-4, -6.97572385963986435018e-3, -1.22611180822657148235e-1, -3.53155960776544875667e-1, 1.52530022733894777053e0 }; + static readonly double[] BesselK1A = { -7.02386347938628759343e-18, -2.42744985051936593393e-15, -6.66690169419932900609e-13, -1.41148839263352776110e-10, -2.21338763073472585583e-8, -2.43340614156596823496e-6, -1.73028895751305206302e-4, -6.97572385963986435018e-3, -1.22611180822657148235e-1, -3.53155960776544875667e-1, 1.52530022733894777053e0 }; /// Chebyshev coefficients for exp(x) sqrt(x) K1(x) /// in the interval [2, infinity]. /// /// lim(x->inf){ exp(x) sqrt(x) K1(x) } = sqrt(pi/2). /// - private static readonly double[] BesselK1B = { -5.75674448366501715755e-18, 1.79405087314755922667e-17, -5.68946255844285935196e-17, 1.83809354436663880070e-16, -6.05704724837331885336e-16, 2.03870316562433424052e-15, -7.01983709041831346144e-15, 2.47715442448130437068e-14, -8.97670518232499435011e-14, 3.34841966607842919884e-13, -1.28917396095102890680e-12, 5.13963967348173025100e-12, -2.12996783842756842877e-11, 9.21831518760500529508e-11, -4.19035475934189648750e-10, 2.01504975519703286596e-9, -1.03457624656780970260e-8, 5.74108412545004946722e-8, -3.50196060308781257119e-7, 2.40648494783721712015e-6, -1.93619797416608296024e-5, 1.95215518471351631108e-4, -2.85781685962277938680e-3, 1.03923736576817238437e-1, 2.72062619048444266945e0 }; + static readonly double[] BesselK1B = { -5.75674448366501715755e-18, 1.79405087314755922667e-17, -5.68946255844285935196e-17, 1.83809354436663880070e-16, -6.05704724837331885336e-16, 2.03870316562433424052e-15, -7.01983709041831346144e-15, 2.47715442448130437068e-14, -8.97670518232499435011e-14, 3.34841966607842919884e-13, -1.28917396095102890680e-12, 5.13963967348173025100e-12, -2.12996783842756842877e-11, 9.21831518760500529508e-11, -4.19035475934189648750e-10, 2.01504975519703286596e-9, -1.03457624656780970260e-8, 5.74108412545004946722e-8, -3.50196060308781257119e-7, 2.40648494783721712015e-6, -1.93619797416608296024e-5, 1.95215518471351631108e-4, -2.85781685962277938680e-3, 1.03923736576817238437e-1, 2.72062619048444266945e0 }; /// Returns the modified Bessel function of first kind, order 0 of the argument. ///

diff --git a/src/Numerics/SpecialFunctions/ModifiedStruve.cs b/src/Numerics/SpecialFunctions/ModifiedStruve.cs index a44708a8..d092c33b 100644 --- a/src/Numerics/SpecialFunctions/ModifiedStruve.cs +++ b/src/Numerics/SpecialFunctions/ModifiedStruve.cs @@ -45,9 +45,8 @@ using System; -// ReSharper disable CheckNamespace +// ReSharper disable once CheckNamespace namespace MathNet.Numerics -// ReSharper restore CheckNamespace { ///

/// This partial implementation of the SpecialFunctions class contains all methods related to the modified Bessel function. diff --git a/src/Numerics/SpecialFunctions/SphericalBessel.cs b/src/Numerics/SpecialFunctions/SphericalBessel.cs index da3021a6..ae3a3d1a 100644 --- a/src/Numerics/SpecialFunctions/SphericalBessel.cs +++ b/src/Numerics/SpecialFunctions/SphericalBessel.cs @@ -1,6 +1,7 @@ using System; using Complex = System.Numerics.Complex; +// ReSharper disable once CheckNamespace namespace MathNet.Numerics { /// @@ -21,7 +22,7 @@ namespace MathNet.Numerics { return new Complex(double.NaN, double.NaN); } - + if (double.IsInfinity(z.Real)) { return (z.Imaginary == 0) ? Complex.Zero : new Complex(double.PositiveInfinity, double.PositiveInfinity); diff --git a/src/Numerics/SpecialFunctions/Stability.cs b/src/Numerics/SpecialFunctions/Stability.cs index b3c3a9f6..3758e0f1 100644 --- a/src/Numerics/SpecialFunctions/Stability.cs +++ b/src/Numerics/SpecialFunctions/Stability.cs @@ -30,9 +30,8 @@ using System; using Complex = System.Numerics.Complex; -// ReSharper disable CheckNamespace +// ReSharper disable once CheckNamespace namespace MathNet.Numerics -// ReSharper restore CheckNamespace { public partial class SpecialFunctions { diff --git a/src/Numerics/SpecialFunctions/TestFunctions.cs b/src/Numerics/SpecialFunctions/TestFunctions.cs index 28c289f3..8fc4894a 100644 --- a/src/Numerics/SpecialFunctions/TestFunctions.cs +++ b/src/Numerics/SpecialFunctions/TestFunctions.cs @@ -30,9 +30,8 @@ using System; using System.Linq; -// ReSharper disable CheckNamespace +// ReSharper disable once CheckNamespace namespace MathNet.Numerics -// ReSharper restore CheckNamespace { public static class TestFunctions { diff --git a/src/Numerics/Statistics/Correlation.cs b/src/Numerics/Statistics/Correlation.cs index 1cb38063..c0432fdd 100644 --- a/src/Numerics/Statistics/Correlation.cs +++ b/src/Numerics/Statistics/Correlation.cs @@ -108,7 +108,7 @@ namespace MathNet.Numerics.Statistics /// Min lag to calculate ACF for (0 = no shift with acf=1) must be zero or positive and smaller than x.Length /// Max lag (EXCLUSIVE) to calculate ACF for must be positive and smaller than x.Length /// An array with the ACF as a function of the lags k. - private static double[] AutoCorrelationFft(double[] x, int kLow, int kHigh) + static double[] AutoCorrelationFft(double[] x, int kLow, int kHigh) { if (x == null) throw new ArgumentNullException(nameof(x)); diff --git a/src/Numerics/Statistics/DescriptiveStatistics.cs b/src/Numerics/Statistics/DescriptiveStatistics.cs index 8ed72770..e1991f5c 100644 --- a/src/Numerics/Statistics/DescriptiveStatistics.cs +++ b/src/Numerics/Statistics/DescriptiveStatistics.cs @@ -319,15 +319,15 @@ namespace MathNet.Numerics.Statistics decimal xi = (decimal)x.Value; decimal delta = xi - mean; decimal scaleDelta = delta/++n; - decimal scaleDeltaSQR = scaleDelta*scaleDelta; + decimal scaleDeltaSquared = scaleDelta*scaleDelta; decimal tmpDelta = delta*(n - 1); mean += scaleDelta; - kurtosis += tmpDelta*scaleDelta*scaleDeltaSQR*(n*n - 3*n + 3) - + 6*scaleDeltaSQR*variance - 4*scaleDelta*skewness; + kurtosis += tmpDelta*scaleDelta*scaleDeltaSquared*(n*n - 3*n + 3) + + 6*scaleDeltaSquared*variance - 4*scaleDelta*skewness; - skewness += tmpDelta*scaleDeltaSQR*(n - 2) - 3*scaleDelta*variance; + skewness += tmpDelta*scaleDeltaSquared*(n - 2) - 3*scaleDelta*variance; variance += tmpDelta*scaleDelta; if (minimum > xi) diff --git a/src/Numerics/Statistics/Histogram.cs b/src/Numerics/Statistics/Histogram.cs index 31502cfe..f33d95a6 100644 --- a/src/Numerics/Statistics/Histogram.cs +++ b/src/Numerics/Statistics/Histogram.cs @@ -51,7 +51,7 @@ namespace MathNet.Numerics.Statistics /// /// This IComparer performs comparisons between a point and a bucket. /// - private sealed class PointComparer : IComparer + sealed class PointComparer : IComparer { /// /// Compares a point and a bucket. The point will be encapsulated in a bucket with width 0. @@ -67,7 +67,7 @@ namespace MathNet.Numerics.Statistics } } - private static readonly PointComparer Comparer = new PointComparer(); + static readonly PointComparer Comparer = new PointComparer(); /// /// Lower Bound of the Bucket. @@ -140,7 +140,7 @@ namespace MathNet.Numerics.Statistics /// True if this is a single point argument for /// when performing a Binary search. /// - private bool IsSinglePoint => double.IsNaN(Count); + bool IsSinglePoint => double.IsNaN(Count); /// /// Default comparer. @@ -247,13 +247,13 @@ namespace MathNet.Numerics.Statistics /// Contains all the Buckets of the Histogram. /// [DataMember(Order = 1)] - private readonly List _buckets; + readonly List _buckets; /// /// Indicates whether the elements of buckets are currently sorted. /// [DataMember(Order = 2)] - private bool _areBucketsSorted; + bool _areBucketsSorted; /// /// Initializes a new instance of the Histogram class. @@ -384,7 +384,7 @@ namespace MathNet.Numerics.Statistics /// /// Sort the buckets if needed. /// - private void LazySort() + void LazySort() { if (!_areBucketsSorted) { diff --git a/src/Numerics/Statistics/MCMC/HybridMC.cs b/src/Numerics/Statistics/MCMC/HybridMC.cs index 925eec19..919af937 100644 --- a/src/Numerics/Statistics/MCMC/HybridMC.cs +++ b/src/Numerics/Statistics/MCMC/HybridMC.cs @@ -42,18 +42,18 @@ namespace MathNet.Numerics.Statistics.Mcmc /// /// Number of parameters in the density function. /// - private readonly int _length; + readonly int _length; /// /// Distribution to sample momentum from. /// - private Normal _pDistribution; + Normal _pDistribution; /// /// Standard deviations used in the sampling of different components of the /// momentum. /// - private double[] _mpSdv; + double[] _mpSdv; /// /// Gets or sets the standard deviations used in the sampling of different components of the @@ -165,7 +165,7 @@ namespace MathNet.Numerics.Statistics.Mcmc /// Initialize parameters. /// /// The current location of the sampler. - private void Initialize(double[] x0) + void Initialize(double[] x0) { Current = (double[])x0.Clone(); _pDistribution = new Normal(0.0, 1.0, RandomSource); @@ -178,7 +178,7 @@ namespace MathNet.Numerics.Statistics.Mcmc /// When the length of pSdv is not the same as Length or if any /// component is negative. /// When pSdv is null. - private void CheckVariance(double[] pSdv) + void CheckVariance(double[] pSdv) { if (pSdv == null) { diff --git a/src/Numerics/Statistics/MCMC/MCMCSampler.cs b/src/Numerics/Statistics/MCMC/MCMCSampler.cs index 314e2480..a0951742 100644 --- a/src/Numerics/Statistics/MCMC/MCMCSampler.cs +++ b/src/Numerics/Statistics/MCMC/MCMCSampler.cs @@ -85,7 +85,7 @@ namespace MathNet.Numerics.Statistics.Mcmc /// /// The random number generator for this class. /// - private System.Random _randomNumberGenerator; + System.Random _randomNumberGenerator; /// /// Keeps track of the number of accepted samples. diff --git a/src/Numerics/Statistics/MCMC/MetropolisHastingsSampler.cs b/src/Numerics/Statistics/MCMC/MetropolisHastingsSampler.cs index e0216e7d..199ab3b8 100644 --- a/src/Numerics/Statistics/MCMC/MetropolisHastingsSampler.cs +++ b/src/Numerics/Statistics/MCMC/MetropolisHastingsSampler.cs @@ -47,32 +47,32 @@ namespace MathNet.Numerics.Statistics.Mcmc /// /// Evaluates the log density function of the target distribution. /// - private readonly DensityLn _pdfLnP; + readonly DensityLn _pdfLnP; /// /// Evaluates the log transition probability for the proposal distribution. /// - private readonly TransitionKernelLn _krnlQ; + readonly TransitionKernelLn _krnlQ; /// /// A function which samples from a proposal distribution. /// - private readonly LocalProposalSampler _proposal; + readonly LocalProposalSampler _proposal; /// /// The current location of the sampler. /// - private T _current; + T _current; /// /// The log density at the current location. /// - private double _currentDensityLn; + double _currentDensityLn; /// /// The number of burn iterations between two samples. /// - private int _burnInterval; + int _burnInterval; /// /// Constructs a new Metropolis-Hastings sampler using the default random number generator. This @@ -116,7 +116,7 @@ namespace MathNet.Numerics.Statistics.Mcmc /// /// This method runs the sampler for a number of iterations without returning a sample /// - private void Burn(int n) + void Burn(int n) { for (int i = 0; i < n; i++) { diff --git a/src/Numerics/Statistics/MCMC/MetropolisSampler.cs b/src/Numerics/Statistics/MCMC/MetropolisSampler.cs index 5f586235..2d195472 100644 --- a/src/Numerics/Statistics/MCMC/MetropolisSampler.cs +++ b/src/Numerics/Statistics/MCMC/MetropolisSampler.cs @@ -46,27 +46,27 @@ namespace MathNet.Numerics.Statistics.Mcmc /// /// Evaluates the log density function of the sampling distribution. /// - private readonly DensityLn _pdfLnP; + readonly DensityLn _pdfLnP; /// /// A function which samples from a proposal distribution. /// - private readonly LocalProposalSampler _proposal; + readonly LocalProposalSampler _proposal; /// /// The current location of the sampler. /// - private T _current; + T _current; /// /// The log density at the current location. /// - private double _currentDensityLn; + double _currentDensityLn; /// /// The number of burn iterations between two samples. /// - private int _burnInterval; + int _burnInterval; /// /// Constructs a new Metropolis sampler using the default random number generator. @@ -107,7 +107,7 @@ namespace MathNet.Numerics.Statistics.Mcmc /// /// This method runs the sampler for a number of iterations without returning a sample /// - private void Burn(int n) + void Burn(int n) { for (int i = 0; i < n; i++) { diff --git a/src/Numerics/Statistics/MCMC/RejectionSampler.cs b/src/Numerics/Statistics/MCMC/RejectionSampler.cs index 822879c5..dc522244 100644 --- a/src/Numerics/Statistics/MCMC/RejectionSampler.cs +++ b/src/Numerics/Statistics/MCMC/RejectionSampler.cs @@ -42,17 +42,17 @@ namespace MathNet.Numerics.Statistics.Mcmc /// /// Evaluates the density function of the sampling distribution. /// - private readonly Density _pdfP; + readonly Density _pdfP; /// /// Evaluates the density function of the proposal distribution. /// - private readonly Density _pdfQ; + readonly Density _pdfQ; /// /// A function which samples from a proposal distribution. /// - private readonly GlobalProposalSampler _proposal; + readonly GlobalProposalSampler _proposal; /// /// Constructs a new rejection sampler using the default random number generator. diff --git a/src/Numerics/Statistics/MCMC/UnivariateHybridMC.cs b/src/Numerics/Statistics/MCMC/UnivariateHybridMC.cs index ca97a1f6..21eec451 100644 --- a/src/Numerics/Statistics/MCMC/UnivariateHybridMC.cs +++ b/src/Numerics/Statistics/MCMC/UnivariateHybridMC.cs @@ -41,13 +41,13 @@ namespace MathNet.Numerics.Statistics.Mcmc /// /// Distribution to sample momentum from. /// - private readonly Normal _distribution; + readonly Normal _distribution; /// /// Standard deviations used in the sampling of the /// momentum. /// - private double _sdv; + double _sdv; /// /// Gets or sets the standard deviation used in the sampling of the diff --git a/src/Numerics/Statistics/MCMC/UnivariateSliceSampler.cs b/src/Numerics/Statistics/MCMC/UnivariateSliceSampler.cs index 85649bac..a329d7e8 100644 --- a/src/Numerics/Statistics/MCMC/UnivariateSliceSampler.cs +++ b/src/Numerics/Statistics/MCMC/UnivariateSliceSampler.cs @@ -43,27 +43,27 @@ namespace MathNet.Numerics.Statistics.Mcmc /// /// Evaluates the log density function of the target distribution. /// - private readonly DensityLn _pdfLnP; + readonly DensityLn _pdfLnP; /// /// The current location of the sampler. /// - private double _current; + double _current; /// /// The log density at the current location. /// - private double _currentDensityLn; + double _currentDensityLn; /// /// The number of burn iterations between two samples. /// - private int _burnInterval; + int _burnInterval; /// /// The scale of the slice sampler. /// - private double _scale; + double _scale; /// /// Constructs a new Slice sampler using the default random @@ -135,7 +135,7 @@ namespace MathNet.Numerics.Statistics.Mcmc /// /// This method runs the sampler for a number of iterations without returning a sample /// - private void Burn(int n) + void Burn(int n) { for (int i = 0; i < n; i++) { diff --git a/src/Numerics/Statistics/MovingStatistics.cs b/src/Numerics/Statistics/MovingStatistics.cs index 472446ff..75748cd1 100644 --- a/src/Numerics/Statistics/MovingStatistics.cs +++ b/src/Numerics/Statistics/MovingStatistics.cs @@ -56,7 +56,7 @@ namespace MathNet.Numerics.Statistics { if (windowSize < 1) { - throw new ArgumentException(string.Format("Value must be positive."), nameof(windowSize)); + throw new ArgumentException("Value must be positive.", nameof(windowSize)); } _windowSize = windowSize; _oldValues = new double[_windowSize]; @@ -321,7 +321,7 @@ namespace MathNet.Numerics.Statistics } } - private void DecrementTimeToLive() + void DecrementTimeToLive() { if (_lastNaNTimeToLive > 0) { @@ -339,7 +339,7 @@ namespace MathNet.Numerics.Statistics } } - private void Reset(double min, double max) + void Reset(double min, double max) { _totalCountOffset += _count + 1; _count = 0; diff --git a/src/Numerics/Trigonometry.cs b/src/Numerics/Trigonometry.cs index b2a3e9ec..1d14fbb8 100644 --- a/src/Numerics/Trigonometry.cs +++ b/src/Numerics/Trigonometry.cs @@ -40,7 +40,7 @@ namespace MathNet.Numerics /// /// Constant to convert a degree to grad. /// - private const double DegreeToGradConstant = 10.0 / 9.0; + const double DegreeToGradConstant = 10.0 / 9.0; /// /// Converts a degree (360-periodic) angle to a grad (400-periodic) angle. diff --git a/src/Providers.CUDA/Compatibility.cs b/src/Providers.CUDA/Compatibility.cs index 0122997a..444e41cb 100644 --- a/src/Providers.CUDA/Compatibility.cs +++ b/src/Providers.CUDA/Compatibility.cs @@ -1,6 +1,6 @@ -using System.Globalization; +#if NET40 +using System.Globalization; -#if NET40 namespace System.Runtime.CompilerServices { internal class FormattableStringFactory @@ -16,13 +16,13 @@ namespace System { internal class FormattableString { - private readonly string format; - private readonly object[] args; + readonly string _format; + readonly object[] _args; public FormattableString(string format, object[] args) { - this.format = format; - this.args = args; + _format = format; + _args = args; } public static string Invariant(FormattableString messageFormat) @@ -32,12 +32,12 @@ namespace System public string ToString(IFormatProvider formatProvider) { - return string.Format(formatProvider, format, args); + return string.Format(formatProvider, _format, _args); } public override string ToString() { - return string.Format(format, args); + return string.Format(_format, _args); } } } diff --git a/src/Providers.CUDA/SafeNativeMethods.cs b/src/Providers.CUDA/SafeNativeMethods.cs index 8acdc8a6..fe242d05 100644 --- a/src/Providers.CUDA/SafeNativeMethods.cs +++ b/src/Providers.CUDA/SafeNativeMethods.cs @@ -46,72 +46,71 @@ namespace MathNet.Numerics.Providers.CUDA /// /// Name of the native DLL. /// - const string _DllName = "MathNet.Numerics.CUDA.dll"; - internal static string DllName => _DllName; + internal const string DllName = "MathNet.Numerics.CUDA.dll"; - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int query_capability(int capability); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int createBLASHandle(ref IntPtr blasHandle); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int destroyBLASHandle(IntPtr blasHandle); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int createSolverHandle(ref IntPtr solverHandle); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int destroySolverHandle(IntPtr solverHandle); #region BLAS - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void s_axpy(IntPtr blasHandle, int n, float alpha, float[] x, [In, Out] float[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void d_axpy(IntPtr blasHandle, int n, double alpha, double[] x, [In, Out] double[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void c_axpy(IntPtr blasHandle, int n, Complex32 alpha, Complex32[] x, [In, Out] Complex32[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void z_axpy(IntPtr blasHandle, int n, Complex alpha, Complex[] x, [In, Out] Complex[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void s_scale(IntPtr blasHandle, int n, float alpha, [Out] float[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void d_scale(IntPtr blasHandle, int n, double alpha, [Out] double[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void c_scale(IntPtr blasHandle, int n, Complex32 alpha, [In, Out] Complex32[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void z_scale(IntPtr blasHandle, int n, Complex alpha, [In, Out] Complex[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern float s_dot_product(IntPtr blasHandle, int n, float[] x, float[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern double d_dot_product(IntPtr blasHandle, int n, double[] x, double[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern Complex32 c_dot_product(IntPtr blasHandle, int n, Complex32[] x, Complex32[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern Complex z_dot_product(IntPtr blasHandle, int n, Complex[] x, Complex[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void s_matrix_multiply(IntPtr blasHandle, int transA, int transB, int m, int n, int k, float alpha, float[] x, float[] y, float beta, [In, Out] float[] c); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void d_matrix_multiply(IntPtr blasHandle, int transA, int transB, int m, int n, int k, double alpha, double[] x, double[] y, double beta, [In, Out] double[] c); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void c_matrix_multiply(IntPtr blasHandle, int transA, int transB, int m, int n, int k, Complex32 alpha, Complex32[] x, Complex32[] y, Complex32 beta, [In, Out] Complex32[] c); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void z_matrix_multiply(IntPtr blasHandle, int transA, int transB, int m, int n, int k, Complex alpha, Complex[] x, Complex[] y, Complex beta, [In, Out] Complex[] c); internal static int ToCUDA(this Transpose transpose) @@ -148,100 +147,100 @@ namespace MathNet.Numerics.Providers.CUDA //[DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] //internal static extern double z_matrix_norm(byte norm, int rows, int columns, [In] Complex[] a, [In, Out] double[] work); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_cholesky_factor(IntPtr solverHandle, int n, [In, Out] float[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_cholesky_factor(IntPtr solverHandle, int n, [In, Out] double[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_cholesky_factor(IntPtr solverHandle, int n, [In, Out] Complex32[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_cholesky_factor(IntPtr solverHandle, int n, [In, Out] Complex[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_lu_factor(IntPtr solverHandle, int n, [In, Out] float[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_lu_factor(IntPtr solverHandle, int n, [In, Out] double[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_lu_factor(IntPtr solverHandle, int n, [In, Out] Complex32[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_lu_factor(IntPtr solverHandle, int n, [In, Out] Complex[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_lu_inverse(IntPtr solverHandle, IntPtr blasHandle, int n, [In, Out] float[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_lu_inverse(IntPtr solverHandle, IntPtr blasHandle, int n, [In, Out] double[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_lu_inverse(IntPtr solverHandle, IntPtr blasHandle, int n, [In, Out] Complex32[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_lu_inverse(IntPtr solverHandle, IntPtr blasHandle, int n, [In, Out] Complex[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_lu_inverse_factored(IntPtr blasHandle, int n, [In, Out] float[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_lu_inverse_factored(IntPtr blasHandle, int n, [In, Out] double[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_lu_inverse_factored(IntPtr blasHandle, int n, [In, Out] Complex32[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_lu_inverse_factored(IntPtr blasHandle, int n, [In, Out] Complex[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_lu_solve_factored(IntPtr solverHandle, int n, int nrhs, float[] a, [In, Out] int[] ipiv, [In, Out] float[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_lu_solve_factored(IntPtr solverHandle, int n, int nrhs, double[] a, [In, Out] int[] ipiv, [In, Out] double[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_lu_solve_factored(IntPtr solverHandle, int n, int nrhs, Complex32[] a, [In, Out] int[] ipiv, [In, Out] Complex32[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_lu_solve_factored(IntPtr solverHandle, int n, int nrhs, Complex[] a, [In, Out] int[] ipiv, [In, Out] Complex[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_lu_solve(IntPtr solverHandle, int n, int nrhs, float[] a, [In, Out] float[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_lu_solve(IntPtr solverHandle, int n, int nrhs, double[] a, [In, Out] double[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_lu_solve(IntPtr solverHandle, int n, int nrhs, Complex32[] a, [In, Out] Complex32[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_lu_solve(IntPtr solverHandle, int n, int nrhs, Complex[] a, [In, Out] Complex[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_cholesky_solve(IntPtr solverHandle, int n, int nrhs, float[] a, [In, Out] float[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_cholesky_solve(IntPtr solverHandle, int n, int nrhs, double[] a, [In, Out] double[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_cholesky_solve(IntPtr solverHandle, int n, int nrhs, Complex32[] a, [In, Out] Complex32[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_cholesky_solve(IntPtr solverHandle, int n, int nrhs, Complex[] a, [In, Out] Complex[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_cholesky_solve_factored(IntPtr solverHandle, int n, int nrhs, float[] a, [In, Out] float[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_cholesky_solve_factored(IntPtr solverHandle, int n, int nrhs, double[] a, [In, Out] double[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_cholesky_solve_factored(IntPtr solverHandle, int n, int nrhs, Complex32[] a, [In, Out] Complex32[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_cholesky_solve_factored(IntPtr solverHandle, int n, int nrhs, Complex[] a, [In, Out] Complex[] b); //[DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] @@ -292,16 +291,16 @@ namespace MathNet.Numerics.Providers.CUDA //[DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] //internal static extern int z_qr_solve_factored(int m, int n, int bn, Complex[] r, Complex[] b, Complex[] tau, [In, Out] Complex[] x, [In, Out] Complex[] work, int len); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_svd_factor(IntPtr solverHandle, [MarshalAs(UnmanagedType.U1)] bool computeVectors, int m, int n, [In, Out] float[] a, [In, Out] float[] s, [In, Out] float[] u, [In, Out] float[] v); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_svd_factor(IntPtr solverHandle, [MarshalAs(UnmanagedType.U1)] bool computeVectors, int m, int n, [In, Out] double[] a, [In, Out] double[] s, [In, Out] double[] u, [In, Out] double[] v); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_svd_factor(IntPtr solverHandle, [MarshalAs(UnmanagedType.U1)] bool computeVectors, int m, int n, [In, Out] Complex32[] a, [In, Out] Complex32[] s, [In, Out] Complex32[] u, [In, Out] Complex32[] v); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_svd_factor(IntPtr solverHandle, [MarshalAs(UnmanagedType.U1)] bool computeVectors, int m, int n, [In, Out] Complex[] a, [In, Out] Complex[] s, [In, Out] Complex[] u, [In, Out] Complex[] v); //[DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] diff --git a/src/Providers.MKL/Compatibility.cs b/src/Providers.MKL/Compatibility.cs index 0122997a..444e41cb 100644 --- a/src/Providers.MKL/Compatibility.cs +++ b/src/Providers.MKL/Compatibility.cs @@ -1,6 +1,6 @@ -using System.Globalization; +#if NET40 +using System.Globalization; -#if NET40 namespace System.Runtime.CompilerServices { internal class FormattableStringFactory @@ -16,13 +16,13 @@ namespace System { internal class FormattableString { - private readonly string format; - private readonly object[] args; + readonly string _format; + readonly object[] _args; public FormattableString(string format, object[] args) { - this.format = format; - this.args = args; + _format = format; + _args = args; } public static string Invariant(FormattableString messageFormat) @@ -32,12 +32,12 @@ namespace System public string ToString(IFormatProvider formatProvider) { - return string.Format(formatProvider, format, args); + return string.Format(formatProvider, _format, _args); } public override string ToString() { - return string.Format(format, args); + return string.Format(_format, _args); } } } diff --git a/src/Providers.MKL/SafeNativeMethods.cs b/src/Providers.MKL/SafeNativeMethods.cs index 5844b4bd..bfc41556 100644 --- a/src/Providers.MKL/SafeNativeMethods.cs +++ b/src/Providers.MKL/SafeNativeMethods.cs @@ -46,406 +46,405 @@ namespace MathNet.Numerics.Providers.MKL /// /// Name of the native DLL. /// - const string _DllName = "MathNet.Numerics.MKL.dll"; - internal static string DllName => _DllName; + internal const string DllName = "MathNet.Numerics.MKL.dll"; - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int query_capability(int capability); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void set_consistency_mode(int mode); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void set_vml_mode(uint mode); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void set_max_threads(int num_threads); #region Memory - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void free_buffers(); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void thread_free_buffers(); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int disable_fast_mm(); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern long mem_stat([Out]out int allocatedBuffers); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern long peak_mem_usage(int mode); #endregion Memory #region BLAS - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void s_axpy(int n, float alpha, float[] x, [In, Out] float[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void d_axpy(int n, double alpha, double[] x, [In, Out] double[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void c_axpy(int n, Complex32 alpha, Complex32[] x, [In, Out] Complex32[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void z_axpy(int n, Complex alpha, Complex[] x, [In, Out] Complex[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void s_scale(int n, float alpha, [Out] float[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void d_scale(int n, double alpha, [Out] double[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void c_scale(int n, Complex32 alpha, [In, Out] Complex32[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void z_scale(int n, Complex alpha, [In, Out] Complex[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern float s_dot_product(int n, float[] x, float[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern double d_dot_product(int n, double[] x, double[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern Complex32 c_dot_product(int n, Complex32[] x, Complex32[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern Complex z_dot_product(int n, Complex[] x, Complex[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void s_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, float alpha, float[] x, float[] y, float beta, [In, Out] float[] c); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void d_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, double alpha, double[] x, double[] y, double beta, [In, Out] double[] c); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void c_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex32 alpha, Complex32[] x, Complex32[] y, Complex32 beta, [In, Out] Complex32[] c); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void z_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex alpha, Complex[] x, Complex[] y, Complex beta, [In, Out] Complex[] c); #endregion BLAS #region LAPACK - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern float s_matrix_norm(byte norm, int rows, int columns, [In] float[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern double d_matrix_norm(byte norm, int rows, int columns, [In] double[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern float c_matrix_norm(byte norm, int rows, int columns, [In] Complex32[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern double z_matrix_norm(byte norm, int rows, int columns, [In] Complex[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_cholesky_factor(int n, [In, Out] float[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_cholesky_factor(int n, [In, Out] double[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_cholesky_factor(int n, [In, Out] Complex32[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_cholesky_factor(int n, [In, Out] Complex[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_lu_factor(int n, [In, Out] float[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_lu_factor(int n, [In, Out] double[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_lu_factor(int n, [In, Out] Complex32[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_lu_factor(int n, [In, Out] Complex[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_lu_inverse(int n, [In, Out] float[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_lu_inverse(int n, [In, Out] double[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_lu_inverse(int n, [In, Out] Complex32[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_lu_inverse(int n, [In, Out] Complex[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_lu_inverse_factored(int n, [In, Out] float[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_lu_inverse_factored(int n, [In, Out] double[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_lu_inverse_factored(int n, [In, Out] Complex32[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_lu_inverse_factored(int n, [In, Out] Complex[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_lu_solve_factored(int n, int nrhs, float[] a, [In, Out] int[] ipiv, [In, Out] float[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_lu_solve_factored(int n, int nrhs, double[] a, [In, Out] int[] ipiv, [In, Out] double[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_lu_solve_factored(int n, int nrhs, Complex32[] a, [In, Out] int[] ipiv, [In, Out] Complex32[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_lu_solve_factored(int n, int nrhs, Complex[] a, [In, Out] int[] ipiv, [In, Out] Complex[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_lu_solve(int n, int nrhs, float[] a, [In, Out] float[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_lu_solve(int n, int nrhs, double[] a, [In, Out] double[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_lu_solve(int n, int nrhs, Complex32[] a, [In, Out] Complex32[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_lu_solve(int n, int nrhs, Complex[] a, [In, Out] Complex[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_cholesky_solve(int n, int nrhs, float[] a, [In, Out] float[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_cholesky_solve(int n, int nrhs, double[] a, [In, Out] double[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_cholesky_solve(int n, int nrhs, Complex32[] a, [In, Out] Complex32[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_cholesky_solve(int n, int nrhs, Complex[] a, [In, Out] Complex[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_cholesky_solve_factored(int n, int nrhs, float[] a, [In, Out] float[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_cholesky_solve_factored(int n, int nrhs, double[] a, [In, Out] double[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_cholesky_solve_factored(int n, int nrhs, Complex32[] a, [In, Out] Complex32[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_cholesky_solve_factored(int n, int nrhs, Complex[] a, [In, Out] Complex[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_qr_factor(int m, int n, [In, Out] float[] r, [In, Out] float[] tau, [In, Out] float[] q); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_qr_factor(int m, int n, [In, Out] double[] r, [In, Out] double[] tau, [In, Out] double[] q); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_qr_factor(int m, int n, [In, Out] Complex32[] r, [In, Out] Complex32[] tau, [In, Out] Complex32[] q); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_qr_factor(int m, int n, [In, Out] Complex[] r, [In, Out] Complex[] tau, [In, Out] Complex[] q); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_qr_thin_factor(int m, int n, [In, Out] float[] q, [In, Out] float[] tau, [In, Out] float[] r); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_qr_thin_factor(int m, int n, [In, Out] double[] q, [In, Out] double[] tau, [In, Out] double[] r); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_qr_thin_factor(int m, int n, [In, Out] Complex32[] q, [In, Out] Complex32[] tau, [In, Out] Complex32[] r); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_qr_thin_factor(int m, int n, [In, Out] Complex[] q, [In, Out] Complex[] tau, [In, Out] Complex[] r); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_qr_solve(int m, int n, int bn, float[] r, float[] b, [In, Out] float[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_qr_solve(int m, int n, int bn, double[] r, double[] b, [In, Out] double[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_qr_solve(int m, int n, int bn, Complex32[] r, Complex32[] b, [In, Out] Complex32[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_qr_solve(int m, int n, int bn, Complex[] r, Complex[] b, [In, Out] Complex[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_qr_solve_factored(int m, int n, int bn, float[] r, float[] b, float[] tau, [In, Out] float[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_qr_solve_factored(int m, int n, int bn, double[] r, double[] b, double[] tau, [In, Out] double[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_qr_solve_factored(int m, int n, int bn, Complex32[] r, Complex32[] b, Complex32[] tau, [In, Out] Complex32[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_qr_solve_factored(int m, int n, int bn, Complex[] r, Complex[] b, Complex[] tau, [In, Out] Complex[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_svd_factor([MarshalAs(UnmanagedType.U1)] bool computeVectors, int m, int n, [In, Out] float[] a, [In, Out] float[] s, [In, Out] float[] u, [In, Out] float[] v); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_svd_factor([MarshalAs(UnmanagedType.U1)] bool computeVectors, int m, int n, [In, Out] double[] a, [In, Out] double[] s, [In, Out] double[] u, [In, Out] double[] v); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_svd_factor([MarshalAs(UnmanagedType.U1)] bool computeVectors, int m, int n, [In, Out] Complex32[] a, [In, Out] Complex32[] s, [In, Out] Complex32[] u, [In, Out] Complex32[] v); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_svd_factor([MarshalAs(UnmanagedType.U1)] bool computeVectors, int m, int n, [In, Out] Complex[] a, [In, Out] Complex[] s, [In, Out] Complex[] u, [In, Out] Complex[] v); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_eigen([MarshalAs(UnmanagedType.U1)] bool isSymmetric, int n, [In] float[] a, [In, Out] float[] vectors, [In, Out] Complex[] values, [In, Out] float[] d); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_eigen([MarshalAs(UnmanagedType.U1)] bool isSymmetric, int n, [In] double[] a, [In, Out] double[] vectors, [In, Out] Complex[] values, [In, Out] double[] d); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_eigen([MarshalAs(UnmanagedType.U1)] bool isSymmetric, int n, [In] Complex32[] a, [In, Out] Complex32[] vectors, [In, Out] Complex[] values, [In, Out] Complex32[] d); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_eigen([MarshalAs(UnmanagedType.U1)] bool isSymmetric, int n, [In] Complex[] a, [In, Out] Complex[] vectors, [In, Out] Complex[] values, [In, Out] Complex[] d); #endregion LAPACK #region Vector Functions - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void s_vector_add(int n, float[] x, float[] y, [In, Out] float[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void s_vector_subtract(int n, float[] x, float[] y, [In, Out] float[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void s_vector_multiply(int n, float[] x, float[] y, [In, Out] float[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void s_vector_divide(int n, float[] x, float[] y, [In, Out] float[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void s_vector_power(int n, float[] x, float[] y, [In, Out] float[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void d_vector_add(int n, double[] x, double[] y, [In, Out] double[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void d_vector_subtract(int n, double[] x, double[] y, [In, Out] double[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void d_vector_multiply(int n, double[] x, double[] y, [In, Out] double[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void d_vector_divide(int n, double[] x, double[] y, [In, Out] double[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void d_vector_power(int n, double[] x, double[] y, [In, Out] double[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void c_vector_add(int n, Complex32[] x, Complex32[] y, [In, Out] Complex32[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void c_vector_subtract(int n, Complex32[] x, Complex32[] y, [In, Out] Complex32[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void c_vector_multiply(int n, Complex32[] x, Complex32[] y, [In, Out] Complex32[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void c_vector_divide(int n, Complex32[] x, Complex32[] y, [In, Out] Complex32[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void c_vector_power(int n, Complex32[] x, Complex32[] y, [In, Out] Complex32[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void z_vector_add(int n, Complex[] x, Complex[] y, [In, Out] Complex[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void z_vector_subtract(int n, Complex[] x, Complex[] y, [In, Out] Complex[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void z_vector_multiply(int n, Complex[] x, Complex[] y, [In, Out] Complex[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void z_vector_divide(int n, Complex[] x, Complex[] y, [In, Out] Complex[] result); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void z_vector_power(int n, Complex[] x, Complex[] y, [In, Out] Complex[] result); #endregion Vector Functions #region FFT - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int x_fft_free([In] ref IntPtr handle); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_fft_create([Out] out IntPtr handle, int n, double forward_scale, double backward_scale); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_fft_create([Out] out IntPtr handle, int n, float forward_scale, float backward_scale); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_fft_create([Out] out IntPtr handle, int n, double forward_scale, double backward_scale); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_fft_create([Out] out IntPtr handle, int n, float forward_scale, float backward_scale); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_fft_create_multidim([Out] out IntPtr handle, int dimensions, [In] int[] n, double forward_scale, double backward_scale); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_fft_create_multidim([Out] out IntPtr handle, int dimensions, [In] int[] n, float forward_scale, float backward_scale); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_fft_forward([In] IntPtr handle, [In, Out] Complex[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_fft_forward([In] IntPtr handle, [In, Out] Complex32[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_fft_forward([In] IntPtr handle, [In, Out] double[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_fft_forward([In] IntPtr handle, [In, Out] float[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_fft_backward([In] IntPtr handle, [In, Out] Complex[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_fft_backward([In] IntPtr handle, [In, Out] Complex32[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_fft_backward([In] IntPtr handle, [In, Out] double[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_fft_backward([In] IntPtr handle, [In, Out] float[] x); #endregion FFT #region Direct Sparse Solver - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_dss_solve(int matrixStructure, int matrixType, int systemType, int rowCount, int columnCount, int nonZerosCount, int[] rowPointers, int[] columnIndices, float[] values, int nRhs, [In, Out] float[] rhs, [In, Out] float[] solution); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_dss_solve(int matrixStructure, int matrixType, int systemType, int rowCount, int columnCount, int nonZerosCount, int[] rowPointers, int[] columnIndices, double[] values, int nRhs, [In, Out] double[] rhs, [In, Out] double[] solution); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_dss_solve(int matrixStructure, int matrixType, int systemType, int rowCount, int columnCount, int nonZerosCount, int[] rowPointers, int[] columnIndices, Complex32[] values, int nRhs, [In, Out] Complex32[] rhs, [In, Out] Complex32[] solution); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_dss_solve(int matrixStructure, int matrixType, int systemType, int rowCount, int columnCount, int nonZerosCount, int[] rowPointers, int[] columnIndices, Complex[] values, int nRhs, [In, Out] Complex[] rhs, [In, Out] Complex[] solution); diff --git a/src/Providers.OpenBLAS/Compatibility.cs b/src/Providers.OpenBLAS/Compatibility.cs index 0122997a..444e41cb 100644 --- a/src/Providers.OpenBLAS/Compatibility.cs +++ b/src/Providers.OpenBLAS/Compatibility.cs @@ -1,6 +1,6 @@ -using System.Globalization; +#if NET40 +using System.Globalization; -#if NET40 namespace System.Runtime.CompilerServices { internal class FormattableStringFactory @@ -16,13 +16,13 @@ namespace System { internal class FormattableString { - private readonly string format; - private readonly object[] args; + readonly string _format; + readonly object[] _args; public FormattableString(string format, object[] args) { - this.format = format; - this.args = args; + _format = format; + _args = args; } public static string Invariant(FormattableString messageFormat) @@ -32,12 +32,12 @@ namespace System public string ToString(IFormatProvider formatProvider) { - return string.Format(formatProvider, format, args); + return string.Format(formatProvider, _format, _args); } public override string ToString() { - return string.Format(format, args); + return string.Format(_format, _args); } } } diff --git a/src/Providers.OpenBLAS/SafeNativeMethods.cs b/src/Providers.OpenBLAS/SafeNativeMethods.cs index aa4cf90d..b6ad4c1c 100644 --- a/src/Providers.OpenBLAS/SafeNativeMethods.cs +++ b/src/Providers.OpenBLAS/SafeNativeMethods.cs @@ -44,256 +44,255 @@ namespace MathNet.Numerics.Providers.OpenBLAS /// /// Name of the native DLL. /// - const string _DllName = "MathNET.Numerics.OpenBLAS.dll"; - internal static string DllName => _DllName; + internal const string DllName = "MathNET.Numerics.OpenBLAS.dll"; - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int query_capability(int capability); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern string get_build_config(); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern string get_cpu_core(); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern ParallelType get_parallel_type(); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void set_max_threads(int num_threads); #region BLAS - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void s_axpy(int n, float alpha, float[] x, [In, Out] float[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void d_axpy(int n, double alpha, double[] x, [In, Out] double[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void c_axpy(int n, Complex32 alpha, Complex32[] x, [In, Out] Complex32[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void z_axpy(int n, Complex alpha, Complex[] x, [In, Out] Complex[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void s_scale(int n, float alpha, [Out] float[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void d_scale(int n, double alpha, [Out] double[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void c_scale(int n, Complex32 alpha, [In, Out] Complex32[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void z_scale(int n, Complex alpha, [In, Out] Complex[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern float s_dot_product(int n, float[] x, float[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern double d_dot_product(int n, double[] x, double[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern Complex32 c_dot_product(int n, Complex32[] x, Complex32[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern Complex z_dot_product(int n, Complex[] x, Complex[] y); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void s_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, float alpha, float[] x, float[] y, float beta, [In, Out] float[] c); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void d_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, double alpha, double[] x, double[] y, double beta, [In, Out] double[] c); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void c_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex32 alpha, Complex32[] x, Complex32[] y, Complex32 beta, [In, Out] Complex32[] c); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void z_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex alpha, Complex[] x, Complex[] y, Complex beta, [In, Out] Complex[] c); #endregion BLAS #region LAPACK - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern float s_matrix_norm(byte norm, int rows, int columns, [In] float[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern double d_matrix_norm(byte norm, int rows, int columns, [In] double[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern float c_matrix_norm(byte norm, int rows, int columns, [In] Complex32[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern double z_matrix_norm(byte norm, int rows, int columns, [In] Complex[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_cholesky_factor(int n, [In, Out] float[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_cholesky_factor(int n, [In, Out] double[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_cholesky_factor(int n, [In, Out] Complex32[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_cholesky_factor(int n, [In, Out] Complex[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_lu_factor(int n, [In, Out] float[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_lu_factor(int n, [In, Out] double[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_lu_factor(int n, [In, Out] Complex32[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_lu_factor(int n, [In, Out] Complex[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_lu_inverse(int n, [In, Out] float[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_lu_inverse(int n, [In, Out] double[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_lu_inverse(int n, [In, Out] Complex32[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_lu_inverse(int n, [In, Out] Complex[] a); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_lu_inverse_factored(int n, [In, Out] float[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_lu_inverse_factored(int n, [In, Out] double[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_lu_inverse_factored(int n, [In, Out] Complex32[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_lu_inverse_factored(int n, [In, Out] Complex[] a, [In, Out] int[] ipiv); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_lu_solve_factored(int n, int nrhs, float[] a, [In, Out] int[] ipiv, [In, Out] float[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_lu_solve_factored(int n, int nrhs, double[] a, [In, Out] int[] ipiv, [In, Out] double[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_lu_solve_factored(int n, int nrhs, Complex32[] a, [In, Out] int[] ipiv, [In, Out] Complex32[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_lu_solve_factored(int n, int nrhs, Complex[] a, [In, Out] int[] ipiv, [In, Out] Complex[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_lu_solve(int n, int nrhs, float[] a, [In, Out] float[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_lu_solve(int n, int nrhs, double[] a, [In, Out] double[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_lu_solve(int n, int nrhs, Complex32[] a, [In, Out] Complex32[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_lu_solve(int n, int nrhs, Complex[] a, [In, Out] Complex[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_cholesky_solve(int n, int nrhs, float[] a, [In, Out] float[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_cholesky_solve(int n, int nrhs, double[] a, [In, Out] double[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_cholesky_solve(int n, int nrhs, Complex32[] a, [In, Out] Complex32[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_cholesky_solve(int n, int nrhs, Complex[] a, [In, Out] Complex[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_cholesky_solve_factored(int n, int nrhs, float[] a, [In, Out] float[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_cholesky_solve_factored(int n, int nrhs, double[] a, [In, Out] double[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_cholesky_solve_factored(int n, int nrhs, Complex32[] a, [In, Out] Complex32[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_cholesky_solve_factored(int n, int nrhs, Complex[] a, [In, Out] Complex[] b); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_qr_factor(int m, int n, [In, Out] float[] r, [In, Out] float[] tau, [In, Out] float[] q); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_qr_factor(int m, int n, [In, Out] double[] r, [In, Out] double[] tau, [In, Out] double[] q); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_qr_factor(int m, int n, [In, Out] Complex32[] r, [In, Out] Complex32[] tau, [In, Out] Complex32[] q); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_qr_factor(int m, int n, [In, Out] Complex[] r, [In, Out] Complex[] tau, [In, Out] Complex[] q); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_qr_thin_factor(int m, int n, [In, Out] float[] q, [In, Out] float[] tau, [In, Out] float[] r); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_qr_thin_factor(int m, int n, [In, Out] double[] q, [In, Out] double[] tau, [In, Out] double[] r); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_qr_thin_factor(int m, int n, [In, Out] Complex32[] q, [In, Out] Complex32[] tau, [In, Out] Complex32[] r); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_qr_thin_factor(int m, int n, [In, Out] Complex[] q, [In, Out] Complex[] tau, [In, Out] Complex[] r); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_qr_solve(int m, int n, int bn, float[] r, float[] b, [In, Out] float[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_qr_solve(int m, int n, int bn, double[] r, double[] b, [In, Out] double[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_qr_solve(int m, int n, int bn, Complex32[] r, Complex32[] b, [In, Out] Complex32[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_qr_solve(int m, int n, int bn, Complex[] r, Complex[] b, [In, Out] Complex[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_qr_solve_factored(int m, int n, int bn, float[] r, float[] b, float[] tau, [In, Out] float[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_qr_solve_factored(int m, int n, int bn, double[] r, double[] b, double[] tau, [In, Out] double[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_qr_solve_factored(int m, int n, int bn, Complex32[] r, Complex32[] b, Complex32[] tau, [In, Out] Complex32[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_qr_solve_factored(int m, int n, int bn, Complex[] r, Complex[] b, Complex[] tau, [In, Out] Complex[] x); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_svd_factor([MarshalAs(UnmanagedType.U1)] bool computeVectors, int m, int n, [In, Out] float[] a, [In, Out] float[] s, [In, Out] float[] u, [In, Out] float[] v); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_svd_factor([MarshalAs(UnmanagedType.U1)] bool computeVectors, int m, int n, [In, Out] double[] a, [In, Out] double[] s, [In, Out] double[] u, [In, Out] double[] v); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_svd_factor([MarshalAs(UnmanagedType.U1)] bool computeVectors, int m, int n, [In, Out] Complex32[] a, [In, Out] Complex32[] s, [In, Out] Complex32[] u, [In, Out] Complex32[] v); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_svd_factor([MarshalAs(UnmanagedType.U1)] bool computeVectors, int m, int n, [In, Out] Complex[] a, [In, Out] Complex[] s, [In, Out] Complex[] u, [In, Out] Complex[] v); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int s_eigen([MarshalAs(UnmanagedType.U1)] bool isSymmetric, int n, [In] float[] a, [In, Out] float[] vectors, [In, Out] Complex[] values, [In, Out] float[] d); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int d_eigen([MarshalAs(UnmanagedType.U1)] bool isSymmetric, int n, [In] double[] a, [In, Out] double[] vectors, [In, Out] Complex[] values, [In, Out] double[] d); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_eigen([MarshalAs(UnmanagedType.U1)] bool isSymmetric, int n, [In] Complex32[] a, [In, Out] Complex32[] vectors, [In, Out] Complex[] values, [In, Out] Complex32[] d); - [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_eigen([MarshalAs(UnmanagedType.U1)] bool isSymmetric, int n, [In] Complex[] a, [In, Out] Complex[] vectors, [In, Out] Complex[] values, [In, Out] Complex[] d); #endregion LAPACK