From a6928107c428bb70aa7df83ab0a6b112f460009c Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Wed, 14 Aug 2013 19:26:40 +0200 Subject: [PATCH] Complex: use common short names for exp/log/ln extension methods --- src/FSharp/Complex.fs | 8 +++--- src/Numerics/ComplexExtensions.cs | 8 +++--- .../Complex/Factorization/Cholesky.cs | 2 +- src/Numerics/Trigonometry.cs | 28 +++++++++---------- src/UnitTests/ComplexTests/ComplexTest.cs | 4 +-- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/FSharp/Complex.fs b/src/FSharp/Complex.fs index 5d4767f4..665bc487 100644 --- a/src/FSharp/Complex.fs +++ b/src/FSharp/Complex.fs @@ -62,8 +62,8 @@ namespace MathNet.Numerics let sec (x:complex) = Trig.Sec(x) let csc (x:complex) = Trig.Csc(x) - let asin x = Complex.Asin(x) - let acos x = Complex.Acos(x) + let asin (x:complex) = Trig.Asin(x) // numerically more stable than Complex.Asin + let acos (x:complex) = Trig.Acos(x) // numerically more stable than Complex.Acos let atan x = Complex.Atan(x) let acot (x:complex) = Trig.Acot(x) let asec (x:complex) = Trig.Asec(x) @@ -130,8 +130,8 @@ namespace MathNet.Numerics let sec (x:complex32) = ofComplex <| Trig.Sec(x.ToComplex()) let csc (x:complex32) = ofComplex <| Trig.Csc(x.ToComplex()) - let asin x = Complex32.Asin(x) - let acos x = Complex32.Acos(x) + let asin (x:complex32) = ofComplex <| Trig.Asin(x.ToComplex()) // numerically more stable than Complex.Asin + let acos (x:complex32) = ofComplex <| Trig.Acos(x.ToComplex()) // numerically more stable than Complex.Acos let atan x = Complex32.Atan(x) let acot (x:complex32) = ofComplex <| Trig.Acot(x.ToComplex()) let asec (x:complex32) = ofComplex <| Trig.Asec(x.ToComplex()) diff --git a/src/Numerics/ComplexExtensions.cs b/src/Numerics/ComplexExtensions.cs index 72a2203c..3cc80638 100644 --- a/src/Numerics/ComplexExtensions.cs +++ b/src/Numerics/ComplexExtensions.cs @@ -132,7 +132,7 @@ namespace MathNet.Numerics /// The exponential of this complex number. /// [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] - public static Complex Exponential(this Complex complex) + public static Complex Exp(this Complex complex) { return Complex.Exp(complex); } @@ -145,7 +145,7 @@ namespace MathNet.Numerics /// The natural logarithm of this complex number. /// [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] - public static Complex NaturalLogarithm(this Complex complex) + public static Complex Ln(this Complex complex) { return Complex.Log(complex); } @@ -155,7 +155,7 @@ namespace MathNet.Numerics /// /// The common logarithm of this complex number. [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] - public static Complex CommonLogarithm(this Complex complex) + public static Complex Log10(this Complex complex) { return Complex.Log10(complex); } @@ -165,7 +165,7 @@ namespace MathNet.Numerics /// /// The logarithm of this complex number. [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] - public static Complex Logarithm(this Complex complex, double baseValue) + public static Complex Log(this Complex complex, double baseValue) { return Complex.Log(complex, baseValue); } diff --git a/src/Numerics/LinearAlgebra/Complex/Factorization/Cholesky.cs b/src/Numerics/LinearAlgebra/Complex/Factorization/Cholesky.cs index eb4707da..91c7e156 100644 --- a/src/Numerics/LinearAlgebra/Complex/Factorization/Cholesky.cs +++ b/src/Numerics/LinearAlgebra/Complex/Factorization/Cholesky.cs @@ -77,7 +77,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization var det = Complex.Zero; for (var j = 0; j < CholeskyFactor.RowCount; j++) { - det += 2.0 * CholeskyFactor.At(j, j).NaturalLogarithm(); + det += 2.0 * CholeskyFactor.At(j, j).Ln(); } return det; diff --git a/src/Numerics/Trigonometry.cs b/src/Numerics/Trigonometry.cs index c74c40b9..ebf04f9d 100644 --- a/src/Numerics/Trigonometry.cs +++ b/src/Numerics/Trigonometry.cs @@ -378,7 +378,7 @@ namespace MathNet.Numerics return -Asin(-value); } - return -Complex.ImaginaryOne * ((1 - value.Square()).SquareRoot() + (Complex.ImaginaryOne * value)).NaturalLogarithm(); + return -Complex.ImaginaryOne * ((1 - value.Square()).SquareRoot() + (Complex.ImaginaryOne * value)).Ln(); } /// @@ -414,7 +414,7 @@ namespace MathNet.Numerics return Constants.Pi - Acos(-value); } - return -Complex.ImaginaryOne * (value + (Complex.ImaginaryOne * (1 - value.Square()).SquareRoot())).NaturalLogarithm(); + return -Complex.ImaginaryOne * (value + (Complex.ImaginaryOne * (1 - value.Square()).SquareRoot())).Ln(); } /// @@ -443,7 +443,7 @@ namespace MathNet.Numerics public static Complex Atan(this Complex value) { var iz = new Complex(-value.Imaginary, value.Real); // I*this - return new Complex(0, 0.5) * ((1 - iz).NaturalLogarithm() - (1 + iz).NaturalLogarithm()); + return new Complex(0, 0.5) * ((1 - iz).Ln() - (1 + iz).Ln()); } /// @@ -477,7 +477,7 @@ namespace MathNet.Numerics } var inv = Complex.ImaginaryOne / value; - return (Complex.ImaginaryOne * 0.5) * ((1.0 - inv).NaturalLogarithm() - (1.0 + inv).NaturalLogarithm()); + return (Complex.ImaginaryOne * 0.5) * ((1.0 - inv).Ln() - (1.0 + inv).Ln()); } /// @@ -506,7 +506,7 @@ namespace MathNet.Numerics public static Complex Asec(this Complex value) { var inv = 1 / value; - return -Complex.ImaginaryOne * (inv + (Complex.ImaginaryOne * (1 - inv.Square()).SquareRoot())).NaturalLogarithm(); + return -Complex.ImaginaryOne * (inv + (Complex.ImaginaryOne * (1 - inv.Square()).SquareRoot())).Ln(); } /// @@ -538,7 +538,7 @@ namespace MathNet.Numerics public static Complex Acsc(this Complex value) { var inv = 1 / value; - return -Complex.ImaginaryOne * ((Complex.ImaginaryOne * inv) + (1 - inv.Square()).SquareRoot()).NaturalLogarithm(); + return -Complex.ImaginaryOne * ((Complex.ImaginaryOne * inv) + (1 - inv.Square()).SquareRoot()).Ln(); } /// @@ -751,7 +751,7 @@ namespace MathNet.Numerics return new Complex(Sech(value.Real), 0.0); } - var exp = value.Exponential(); + var exp = value.Exp(); if (exp.IsInfinity()) { @@ -791,7 +791,7 @@ namespace MathNet.Numerics return new Complex(Csch(value.Real), 0.0); } - var exp = value.Exponential(); + var exp = value.Exp(); if (exp.IsInfinity()) { @@ -826,7 +826,7 @@ namespace MathNet.Numerics /// public static Complex Asinh(this Complex value) { - return (value + (value.Square() + 1).SquareRoot()).NaturalLogarithm(); + return (value + (value.Square() + 1).SquareRoot()).Ln(); } /// @@ -854,7 +854,7 @@ namespace MathNet.Numerics /// public static Complex Acosh(this Complex value) { - return (value + ((value - 1).SquareRoot() * (value + 1).SquareRoot())).NaturalLogarithm(); + return (value + ((value - 1).SquareRoot() * (value + 1).SquareRoot())).Ln(); } /// @@ -882,7 +882,7 @@ namespace MathNet.Numerics /// public static Complex Atanh(this Complex value) { - return 0.5 * ((1 + value).NaturalLogarithm() - (1 - value).NaturalLogarithm()); + return 0.5 * ((1 + value).Ln() - (1 - value).Ln()); } /// @@ -911,7 +911,7 @@ namespace MathNet.Numerics public static Complex Acoth(this Complex value) { var inv = 1.0 / value; - return 0.5 * ((1.0 + inv).NaturalLogarithm() - (1.0 - inv).NaturalLogarithm()); + return 0.5 * ((1.0 + inv).Ln() - (1.0 - inv).Ln()); } /// @@ -940,7 +940,7 @@ namespace MathNet.Numerics public static Complex Asech(this Complex value) { var inv = 1 / value; - return (inv + ((inv - 1).SquareRoot() * (inv + 1).SquareRoot())).NaturalLogarithm(); + return (inv + ((inv - 1).SquareRoot() * (inv + 1).SquareRoot())).Ln(); } /// @@ -969,7 +969,7 @@ namespace MathNet.Numerics public static Complex Acsch(this Complex value) { var inv = 1 / value; - return (inv + (inv.Square() + 1).SquareRoot()).NaturalLogarithm(); + return (inv + (inv.Square() + 1).SquareRoot()).Ln(); } } } \ No newline at end of file diff --git a/src/UnitTests/ComplexTests/ComplexTest.cs b/src/UnitTests/ComplexTests/ComplexTest.cs index faadf3e6..e0b47b3b 100644 --- a/src/UnitTests/ComplexTests/ComplexTest.cs +++ b/src/UnitTests/ComplexTests/ComplexTest.cs @@ -50,7 +50,7 @@ namespace MathNet.Numerics.UnitTests.ComplexTests { var value = new Complex(real, imag); var expected = new Complex(expectedReal, expectedImag); - AssertHelpers.AlmostEqual(expected, value.Exponential(), 15); + AssertHelpers.AlmostEqual(expected, value.Exp(), 15); } /// @@ -69,7 +69,7 @@ namespace MathNet.Numerics.UnitTests.ComplexTests { var value = new Complex(real, imag); var expected = new Complex(expectedReal, expectedImag); - AssertHelpers.AlmostEqual(expected, value.NaturalLogarithm(), 15); + AssertHelpers.AlmostEqual(expected, value.Ln(), 15); } ///