Skip to content

Commit cfd79ab

Browse files
committed
Minor code style updates
1 parent 7cb9590 commit cfd79ab

4 files changed

Lines changed: 43 additions & 63 deletions

File tree

build/Building.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let build (solution:Solution) = DotNet.build (minimal >> buildOptions normal) so
2121
let buildStrongNamed (solution:Solution) = DotNet.build (minimal >> buildOptions strongNamed) solution.SolutionFile
2222

2323
let pack (solution:Solution) = DotNet.pack (minimal >> packOptions normal) solution.SolutionFile
24-
let packStrongNamed (solution:Solution) =DotNet.pack (minimal >> packOptions strongNamed) solution.SolutionFile
24+
let packStrongNamed (solution:Solution) = DotNet.pack (minimal >> packOptions strongNamed) solution.SolutionFile
2525

2626
let buildVS2019x86 config isIncremental subject =
2727
MSBuild.run

src/Numerics.Tests/DistanceTests.cs

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -36,41 +36,30 @@ namespace MathNet.Numerics.UnitTests
3636
public class DistanceTests
3737
{
3838
#region Test Data
39-
double[] _dp0 = new double[] { 1, 0.5 };
40-
double[] _dq0 = new double[] { 0.5, 1 };
41-
42-
double[] _dp1 = new double[] { 4.5, 1 };
43-
double[] _dq1 = new double[] { 4, 2 };
44-
45-
double[] _dp2 = new double[] { 0, 0, 0 };
46-
double[] _dq2 = new double[] { 0, 0, 0 };
47-
48-
double[] _dp3 = new double[] { 1, 1, 1 };
49-
double[] _dq3 = new double[] { 1, 1, 1 };
50-
51-
double[] _dp4 = new double[] { 2.5, 3.5, 3.0, 3.5, 2.5, 3.0 };
52-
double[] _dq4 = new double[] { 3.0, 3.5, 1.5, 5.0, 3.5, 3.0 };
53-
54-
double[] _dp5 = new double[] { 1, 3, 5, 6, 8, 9, 6, 4, 3, 2 };
55-
double[] _dq5 = new double[] { 2, 5, 6, 6, 7, 7, 5, 3, 1, 1 };
56-
57-
float[] _fp0 = new float[] { 1, 0.5f };
58-
float[] _fq0 = new float[] { 0.5f, 1 };
59-
60-
float[] _fp1 = new float[] { 4.5f, 1 };
61-
float[] _fq1 = new float[] { 4, 2 };
62-
63-
float[] _fp2 = new float[] { 0, 0, 0 };
64-
float[] _fq2 = new float[] { 0, 0, 0 };
65-
66-
float[] _fp3 = new float[] { 1, 1, 1 };
67-
float[] _fq3 = new float[] { 1, 1, 1 };
68-
69-
float[] _fp4 = new float[] { 2.5f, 3.5f, 3.0f, 3.5f, 2.5f, 3.0f };
70-
float[] _fq4 = new float[] { 3.0f, 3.5f, 1.5f, 5.0f, 3.5f, 3.0f };
71-
72-
float[] _fp5 = new float[] { 1, 3, 5, 6, 8, 9, 6, 4, 3, 2 };
73-
float[] _fq5 = new float[] { 2, 5, 6, 6, 7, 7, 5, 3, 1, 1 };
39+
readonly double[] _dp0 = new double[] { 1, 0.5 };
40+
readonly double[] _dq0 = new double[] { 0.5, 1 };
41+
readonly double[] _dp1 = new double[] { 4.5, 1 };
42+
readonly double[] _dq1 = new double[] { 4, 2 };
43+
readonly double[] _dp2 = new double[] { 0, 0, 0 };
44+
readonly double[] _dq2 = new double[] { 0, 0, 0 };
45+
readonly double[] _dp3 = new double[] { 1, 1, 1 };
46+
readonly double[] _dq3 = new double[] { 1, 1, 1 };
47+
readonly double[] _dp4 = new double[] { 2.5, 3.5, 3.0, 3.5, 2.5, 3.0 };
48+
readonly double[] _dq4 = new double[] { 3.0, 3.5, 1.5, 5.0, 3.5, 3.0 };
49+
readonly double[] _dp5 = new double[] { 1, 3, 5, 6, 8, 9, 6, 4, 3, 2 };
50+
readonly double[] _dq5 = new double[] { 2, 5, 6, 6, 7, 7, 5, 3, 1, 1 };
51+
readonly float[] _fp0 = new float[] { 1, 0.5f };
52+
readonly float[] _fq0 = new float[] { 0.5f, 1 };
53+
readonly float[] _fp1 = new float[] { 4.5f, 1 };
54+
readonly float[] _fq1 = new float[] { 4, 2 };
55+
readonly float[] _fp2 = new float[] { 0, 0, 0 };
56+
readonly float[] _fq2 = new float[] { 0, 0, 0 };
57+
readonly float[] _fp3 = new float[] { 1, 1, 1 };
58+
readonly float[] _fq3 = new float[] { 1, 1, 1 };
59+
readonly float[] _fp4 = new float[] { 2.5f, 3.5f, 3.0f, 3.5f, 2.5f, 3.0f };
60+
readonly float[] _fq4 = new float[] { 3.0f, 3.5f, 1.5f, 5.0f, 3.5f, 3.0f };
61+
readonly float[] _fp5 = new float[] { 1, 3, 5, 6, 8, 9, 6, 4, 3, 2 };
62+
readonly float[] _fq5 = new float[] { 2, 5, 6, 6, 7, 7, 5, 3, 1, 1 };
7463
#endregion
7564

7665
[Test]

src/Numerics/Euclid.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,7 @@ public static long ExtendedGreatestCommonDivisor(long a, long b, out long x, out
439439

440440
while (b != 0)
441441
{
442-
long rem;
443-
long quot = Math.DivRem(a, b, out rem);
442+
long quot = Math.DivRem(a, b, out long rem);
444443
a = b;
445444
b = rem;
446445

@@ -588,8 +587,7 @@ public static BigInteger ExtendedGreatestCommonDivisor(BigInteger a, BigInteger
588587

589588
while (!b.IsZero)
590589
{
591-
BigInteger rem;
592-
BigInteger quot = BigInteger.DivRem(a, b, out rem);
590+
BigInteger quot = BigInteger.DivRem(a, b, out BigInteger rem);
593591
a = b;
594592
b = rem;
595593

src/Numerics/Fit.cs

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ public static (double A, double B) Line(double[] x, double[] y)
5656
/// </summary>
5757
public static Func<double, double> LineFunc(double[] x, double[] y)
5858
{
59-
var parameters = SimpleRegression.Fit(x, y);
60-
double intercept = parameters.Item1, slope = parameters.Item2;
61-
return z => intercept + slope*z;
59+
(double Intercept, double Slope) = SimpleRegression.Fit(x, y);
60+
return z => Intercept + Slope * z;
6261
}
6362

6463
/// <summary>
@@ -99,10 +98,8 @@ public static (double A, double R) Exponential(double[] x, double[] y, DirectReg
9998
/// </summary>
10099
public static Func<double, double> ExponentialFunc(double[] x, double[] y, DirectRegressionMethod method = DirectRegressionMethod.QR)
101100
{
102-
var parameters = Exponential(x, y, method);
103-
var a = parameters.Item1;
104-
var r = parameters.Item2;
105-
return z => a * Math.Exp(r * z);
101+
(double A, double R) = Exponential(x, y, method);
102+
return z => A * Math.Exp(R * z);
106103
}
107104

108105
/// <summary>
@@ -122,10 +119,8 @@ public static (double A, double B) Logarithm(double[] x, double[] y, DirectRegre
122119
/// </summary>
123120
public static Func<double, double> LogarithmFunc(double[] x, double[] y, DirectRegressionMethod method = DirectRegressionMethod.QR)
124121
{
125-
var parameters = Logarithm(x, y, method);
126-
var a = parameters.Item1;
127-
var b = parameters.Item2;
128-
return z => a + b * Math.Log(z);
122+
(double A, double B) = Logarithm(x, y, method);
123+
return z => A + B * Math.Log(z);
129124
}
130125

131126
/// <summary>
@@ -146,10 +141,8 @@ public static (double A, double B) Power(double[] x, double[] y, DirectRegressio
146141
/// </summary>
147142
public static Func<double, double> PowerFunc(double[] x, double[] y, DirectRegressionMethod method = DirectRegressionMethod.QR)
148143
{
149-
var parameters = Power(x, y, method);
150-
var a = parameters.Item1;
151-
var b = parameters.Item2;
152-
return z => a * Math.Pow(z, b);
144+
(double A, double B) = Power(x, y, method);
145+
return z => A * Math.Pow(z, B);
153146
}
154147

155148
/// <summary>
@@ -396,8 +389,8 @@ public static Func<double, double> CurveFunc(double[] x, double[] y, Func<double
396389
/// </summary>
397390
public static Func<double, double> CurveFunc(double[] x, double[] y, Func<double, double, double, double> f, double initialGuess0, double initialGuess1, double tolerance = 1e-8, int maxIterations = 1000)
398391
{
399-
var parameters = Curve(x, y, f, initialGuess0, initialGuess1, tolerance, maxIterations);
400-
return z => f(parameters.P0, parameters.P1, z);
392+
var (P0, P1) = Curve(x, y, f, initialGuess0, initialGuess1, tolerance, maxIterations);
393+
return z => f(P0, P1, z);
401394
}
402395

403396
/// <summary>
@@ -406,8 +399,8 @@ public static Func<double, double> CurveFunc(double[] x, double[] y, Func<double
406399
/// </summary>
407400
public static Func<double, double> CurveFunc(double[] x, double[] y, Func<double, double, double, double, double> f, double initialGuess0, double initialGuess1, double initialGuess2, double tolerance = 1e-8, int maxIterations = 1000)
408401
{
409-
var parameters = Curve(x, y, f, initialGuess0, initialGuess1, initialGuess2, tolerance, maxIterations);
410-
return z => f(parameters.P0, parameters.P1, parameters.P2, z);
402+
var (P0, P1, P2) = Curve(x, y, f, initialGuess0, initialGuess1, initialGuess2, tolerance, maxIterations);
403+
return z => f(P0, P1, P2, z);
411404
}
412405

413406
/// <summary>
@@ -416,8 +409,8 @@ public static Func<double, double> CurveFunc(double[] x, double[] y, Func<double
416409
/// </summary>
417410
public static Func<double, double> CurveFunc(double[] x, double[] y, Func<double, double, double, double, double, double> f, double initialGuess0, double initialGuess1, double initialGuess2, double initialGuess3, double tolerance = 1e-8, int maxIterations = 1000)
418411
{
419-
var parameters = Curve(x, y, f, initialGuess0, initialGuess1, initialGuess2, initialGuess3, tolerance, maxIterations);
420-
return z => f(parameters.P0, parameters.P1, parameters.P2, parameters.P3, z);
412+
var (P0, P1, P2, P3) = Curve(x, y, f, initialGuess0, initialGuess1, initialGuess2, initialGuess3, tolerance, maxIterations);
413+
return z => f(P0, P1, P2, P3, z);
421414
}
422415

423416
/// <summary>
@@ -426,8 +419,8 @@ public static Func<double, double> CurveFunc(double[] x, double[] y, Func<double
426419
/// </summary>
427420
public static Func<double, double> CurveFunc(double[] x, double[] y, Func<double, double, double, double, double, double, double> f, double initialGuess0, double initialGuess1, double initialGuess2, double initialGuess3, double initialGuess4, double tolerance = 1e-8, int maxIterations = 1000)
428421
{
429-
var parameters = Curve(x, y, f, initialGuess0, initialGuess1, initialGuess2, initialGuess3, initialGuess4, tolerance, maxIterations);
430-
return z => f(parameters.P0, parameters.P1, parameters.P2, parameters.P3, parameters.P4, z);
422+
(double P0, double P1, double P2, double P3, double P4) = Curve(x, y, f, initialGuess0, initialGuess1, initialGuess2, initialGuess3, initialGuess4, tolerance, maxIterations);
423+
return z => f(P0, P1, P2, P3, P4, z);
431424
}
432425
}
433426
}

0 commit comments

Comments
 (0)