From 017a192d946a1468844da00c83329e9b64a9a7a0 Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Sun, 7 Jan 2018 11:20:58 +0100 Subject: [PATCH] Cleanup: remove obsolete code that has been scheduled for removal in v4 (breaking) --- src/Numerics/Control.cs | 18 ----- src/Numerics/Distributions/Erlang.cs | 48 ------------- .../Financial/AbsoluteReturnMeasures.cs | 6 -- src/Numerics/Generate.cs | 54 --------------- src/Numerics/Interpolate.cs | 6 -- src/Numerics/LinearAlgebra/Matrix.cs | 48 ------------- src/Numerics/LinearAlgebra/Options.cs | 3 - src/Numerics/LinearAlgebra/Vector.cs | 26 ------- .../Mkl/MklLinearAlgebraProvider.cs | 68 ++----------------- 9 files changed, 7 insertions(+), 270 deletions(-) diff --git a/src/Numerics/Control.cs b/src/Numerics/Control.cs index 5b47a0c2..d8738472 100644 --- a/src/Numerics/Control.cs +++ b/src/Numerics/Control.cs @@ -103,24 +103,6 @@ namespace MathNet.Numerics FourierTransformControl.UseNativeMKL(); } - /// - /// Use the Intel MKL native provider for linear algebra, with the specified configuration parameters. - /// Throws if it is not available or failed to initialize, in which case the previous provider is still active. - /// - [CLSCompliant(false)] - [Obsolete("Will be removed in the next major version. Use the enums in the Common namespace instead.")] - public static void UseNativeMKL( - Providers.LinearAlgebra.Mkl.MklConsistency consistency = Providers.LinearAlgebra.Mkl.MklConsistency.Auto, - Providers.LinearAlgebra.Mkl.MklPrecision precision = Providers.LinearAlgebra.Mkl.MklPrecision.Double, - Providers.LinearAlgebra.Mkl.MklAccuracy accuracy = Providers.LinearAlgebra.Mkl.MklAccuracy.High) - { - LinearAlgebraControl.UseNativeMKL( - (Providers.Common.Mkl.MklConsistency)consistency, - (Providers.Common.Mkl.MklPrecision)precision, - (Providers.Common.Mkl.MklAccuracy)accuracy); - FourierTransformControl.UseNativeMKL(); - } - /// /// Use the Intel MKL native provider for linear algebra, with the specified configuration parameters. /// Throws if it is not available or failed to initialize, in which case the previous provider is still active. diff --git a/src/Numerics/Distributions/Erlang.cs b/src/Numerics/Distributions/Erlang.cs index ebba4725..fa129e2f 100644 --- a/src/Numerics/Distributions/Erlang.cs +++ b/src/Numerics/Distributions/Erlang.cs @@ -125,12 +125,6 @@ namespace MathNet.Numerics.Distributions return shape >= 0 && rate >= 0.0; } - [Obsolete("Use the variant that expects an int shape, or use Gamma instead. Will be dropped in v4.")] - public static bool IsValidParameterSet(double shape, double rate) - { - return IsValidParameterSet((int)shape, rate); - } - /// /// Gets the shape (k) of the Erlang distribution. Range: k ≥ 0. /// @@ -419,12 +413,6 @@ namespace MathNet.Numerics.Distributions return Math.Pow(rate, shape)*Math.Pow(x, shape - 1.0)*Math.Exp(-rate*x)/SpecialFunctions.Gamma(shape); } - [Obsolete("Use the variant that expects an int shape, or use Gamma instead. Will be dropped in v4.")] - public static double PDF(double shape, double rate, double x) - { - return PDF((int)shape, rate, x); - } - /// /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x). /// @@ -458,12 +446,6 @@ namespace MathNet.Numerics.Distributions return (shape*Math.Log(rate)) + ((shape - 1.0)*Math.Log(x)) - (rate*x) - SpecialFunctions.GammaLn(shape); } - [Obsolete("Use the variant that expects an int shape, or use Gamma instead. Will be dropped in v4.")] - public static double PDFLn(double shape, double rate, double x) - { - return PDFLn((int)shape, rate, x); - } - /// /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X ≤ x). /// @@ -492,12 +474,6 @@ namespace MathNet.Numerics.Distributions return SpecialFunctions.GammaLowerRegularized(shape, x*rate); } - [Obsolete("Use the variant that expects an int shape, or use Gamma instead. Will be dropped in v4.")] - public static double CDF(double shape, double rate, double x) - { - return CDF((int)shape, rate, x); - } - /// /// Generates a sample from the distribution. /// @@ -510,12 +486,6 @@ namespace MathNet.Numerics.Distributions return Gamma.Sample(rnd, shape, rate); } - [Obsolete("Use the variant that expects an int shape, or use Gamma instead. Will be dropped in v4.")] - public static double Sample(System.Random rnd, double shape, double rate) - { - return Sample(rnd, (int)shape, rate); - } - /// /// Generates a sequence of samples from the distribution. /// @@ -528,12 +498,6 @@ namespace MathNet.Numerics.Distributions return Gamma.Samples(rnd, shape, rate); } - [Obsolete("Use the variant that expects an int shape, or use Gamma instead. Will be dropped in v4.")] - public static IEnumerable Samples(System.Random rnd, double shape, double rate) - { - return Samples(rnd, (int)shape, rate); - } - /// /// Fills an array with samples generated from the distribution. /// @@ -558,12 +522,6 @@ namespace MathNet.Numerics.Distributions return Gamma.Sample(shape, rate); } - [Obsolete("Use the variant that expects an int shape, or use Gamma instead. Will be dropped in v4.")] - public static double Sample(double shape, double rate) - { - return Sample((int)shape, rate); - } - /// /// Generates a sequence of samples from the distribution. /// @@ -575,12 +533,6 @@ namespace MathNet.Numerics.Distributions return Gamma.Samples(shape, rate); } - [Obsolete("Use the variant that expects an int shape, or use Gamma instead. Will be dropped in v4.")] - public static IEnumerable Samples(double shape, double rate) - { - return Samples((int)shape, rate); - } - /// /// Fills an array with samples generated from the distribution. /// diff --git a/src/Numerics/Financial/AbsoluteReturnMeasures.cs b/src/Numerics/Financial/AbsoluteReturnMeasures.cs index 359d55b5..867e021e 100644 --- a/src/Numerics/Financial/AbsoluteReturnMeasures.cs +++ b/src/Numerics/Financial/AbsoluteReturnMeasures.cs @@ -36,12 +36,6 @@ namespace MathNet.Numerics.Financial { public static class AbsoluteReturnMeasures { - [Obsolete("Use CompoundReturn instead, will be removed in v4.0")] - public static double CompoundMonthlyReturn(this IEnumerable data) - { - return CompoundReturn(data); - } - /// /// Compound Monthly Return or Geometric Return or Annualized Return /// diff --git a/src/Numerics/Generate.cs b/src/Numerics/Generate.cs index 63281dd0..a72fa5d9 100644 --- a/src/Numerics/Generate.cs +++ b/src/Numerics/Generate.cs @@ -970,58 +970,6 @@ namespace MathNet.Numerics return Distributions.Normal.Samples(SystemRandomSource.Default, mean, standardDeviation); } - /// - /// Create samples with independent amplitudes of normal distribution and a flat spectral density. - /// - [Obsolete("Use Normal instead. Will be removed in v4.")] - public static double[] Gaussian(int length, double mean, double standardDeviation) - { - return Normal(length, mean, standardDeviation); - } - - /// - /// Create an infinite sample sequence with independent amplitudes of normal distribution and a flat spectral density. - /// - [Obsolete("Use NormalSequence instead. Will be removed in v4.")] - public static IEnumerable GaussianSequence(double mean, double standardDeviation) - { - return NormalSequence(mean, standardDeviation); - } - - /// - /// Create skew alpha stable samples. - /// - /// The number of samples to generate. - /// Stability alpha-parameter of the stable distribution - /// Skewness beta-parameter of the stable distribution - /// Scale c-parameter of the stable distribution - /// Location mu-parameter of the stable distribution - [Obsolete("Will be removed in v4.")] - public static double[] Stable(int length, double alpha, double beta, double scale, double location) - { - if (length < 0) - { - throw new ArgumentOutOfRangeException("length"); - } - - var samples = new double[length]; - Distributions.Stable.Samples(SystemRandomSource.Default, samples, alpha, beta, scale, location); - return samples; - } - - /// - /// Create skew alpha stable samples. - /// - /// Stability alpha-parameter of the stable distribution - /// Skewness beta-parameter of the stable distribution - /// Scale c-parameter of the stable distribution - /// Location mu-parameter of the stable distribution - [Obsolete("Will be removed in v4.")] - public static IEnumerable StableSequence(double alpha, double beta, double scale, double location) - { - return Distributions.Stable.Samples(SystemRandomSource.Default, alpha, beta, scale, location); - } - /// /// Create random samples. /// @@ -1147,7 +1095,5 @@ namespace MathNet.Numerics { return distribution.Samples().Zip(distribution.Samples(), map); } - - } } diff --git a/src/Numerics/Interpolate.cs b/src/Numerics/Interpolate.cs index b373192d..21c380e7 100644 --- a/src/Numerics/Interpolate.cs +++ b/src/Numerics/Interpolate.cs @@ -180,12 +180,6 @@ namespace MathNet.Numerics return Interpolation.LogLinear.Interpolate(points, values); } - [Obsolete("Use Linear instead. Will be removed in the next major version.")] - public static IInterpolation LinearSpline(IEnumerable points, IEnumerable values) - { - return Interpolation.LinearSpline.Interpolate(points, values); - } - /// /// Create an piecewise natural cubic spline interpolation based on arbitrary points, /// with zero secondary derivatives at the boundaries. diff --git a/src/Numerics/LinearAlgebra/Matrix.cs b/src/Numerics/LinearAlgebra/Matrix.cs index 11a2d874..0ae1e2d0 100644 --- a/src/Numerics/LinearAlgebra/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Matrix.cs @@ -1282,15 +1282,6 @@ namespace MathNet.Numerics.LinearAlgebra /// public abstract bool IsHermitian(); - /// - /// Evaluates whether this matrix is conjugate symmetric. - /// - [Obsolete("Use IsHermitian instead. Will be removed in v4.")] - public bool IsConjugateSymmetric() - { - return IsHermitian(); - } - /// /// Returns this matrix as a multidimensional array. /// The returned array will be independent from this matrix. @@ -1320,12 +1311,6 @@ namespace MathNet.Numerics.LinearAlgebra return Storage.ToColumnMajorArray(); } - [Obsolete("Use ToColumnMajorArray instead. Will be removed in v4.")] - public T[] ToColumnWiseArray() - { - return ToColumnMajorArray(); - } - /// /// Returns the matrix's elements as an array with the data laid row by row (row major). /// The returned array will be independent from this matrix. @@ -1344,13 +1329,6 @@ namespace MathNet.Numerics.LinearAlgebra return Storage.ToRowMajorArray(); } - - [Obsolete("Use ToRowMajorArray instead. Will be removed in v4.")] - public T[] ToRowWiseArray() - { - return ToRowMajorArray(); - } - /// /// Returns this matrix as array of row arrays. /// The returned arrays will be independent from this matrix. @@ -1499,32 +1477,6 @@ namespace MathNet.Numerics.LinearAlgebra } } - /// - /// Returns an IEnumerable that can be used to iterate through all non-zero values of the matrix. - /// - /// - /// The enumerator will skip all elements with a zero value. - /// - [Obsolete("Use Enumerate(Zeros.AllowSkip) instead. Will be removed in v4.")] - public IEnumerable EnumerateNonZero() - { - return Storage.EnumerateNonZero(); - } - - /// - /// Returns an IEnumerable that can be used to iterate through all non-zero values of the matrix and their index. - /// - /// - /// The enumerator returns a Tuple with the first two values being the row and column index - /// and the third value being the value of the element at that index. - /// The enumerator will skip all elements with a zero value. - /// - [Obsolete("Use EnumerateIndexed(Zeros.AllowSkip) instead. Will be removed in v4.")] - public IEnumerable> EnumerateNonZeroIndexed() - { - return Storage.EnumerateNonZeroIndexed(); - } - /// /// Returns an IEnumerable that can be used to iterate through all columns of the matrix. /// diff --git a/src/Numerics/LinearAlgebra/Options.cs b/src/Numerics/LinearAlgebra/Options.cs index c6f1f1a3..61641694 100644 --- a/src/Numerics/LinearAlgebra/Options.cs +++ b/src/Numerics/LinearAlgebra/Options.cs @@ -77,9 +77,6 @@ namespace MathNet.Numerics.LinearAlgebra /// Hermitian = 2, - [Obsolete("Use Hermitian instead. Will be removed in v4.")] - ConjugateSymmetric = 2, - /// /// A matrix is not symmetric /// diff --git a/src/Numerics/LinearAlgebra/Vector.cs b/src/Numerics/LinearAlgebra/Vector.cs index 58fff043..18266f0c 100644 --- a/src/Numerics/LinearAlgebra/Vector.cs +++ b/src/Numerics/LinearAlgebra/Vector.cs @@ -343,32 +343,6 @@ namespace MathNet.Numerics.LinearAlgebra } } - /// - /// Returns an IEnumerable that can be used to iterate through all non-zero values of the vector. - /// - /// - /// The enumerator will skip all elements with a zero value. - /// - [Obsolete("Use Enumerate(Zeros.AllowSkip) instead. Will be removed in v4.")] - public IEnumerable EnumerateNonZero() - { - return Storage.EnumerateNonZero(); - } - - /// - /// Returns an IEnumerable that can be used to iterate through all non-zero values of the vector and their index. - /// - /// - /// The enumerator returns a Tuple with the first value being the element index - /// and the second value being the value of the element at that index. - /// The enumerator will skip all elements with a zero value. - /// - [Obsolete("Use EnumerateIndexed(Zeros.AllowSkip) instead. Will be removed in v4.")] - public IEnumerable> EnumerateNonZeroIndexed() - { - return Storage.EnumerateNonZeroIndexed(); - } - /// /// Applies a function to each value of this vector and replaces the value with its result. /// If forceMapZero is not set to true, zero values may or may not be skipped depending diff --git a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs index edceb7d9..6aeb685a 100644 --- a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs +++ b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs @@ -37,7 +37,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl /// /// Error codes return from the MKL provider. /// - public enum MklError : int + internal enum MklError : int { /// /// Unable to allocate memory. @@ -45,50 +45,14 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl MemoryAllocation = -999999 } - /// - /// Consistency vs. performance trade-off between runs on different machines. - /// - [Obsolete("Will be removed in the next major version. Use the enums in the Common namespace instead.")] - public enum MklConsistency : int - { - /// Consistent on the same CPU only (maximum performance) - Auto = 2, - /// Consistent on Intel and compatible CPUs with SSE2 support (maximum compatibility) - Compatible = 3, - /// Consistent on Intel CPUs supporting SSE2 or later - SSE2 = 4, - /// Consistent on Intel CPUs supporting SSE4.2 or later - SSE4_2 = 8, - /// Consistent on Intel CPUs supporting AVX or later - AVX = 9, - /// Consistent on Intel CPUs supporting AVX2 or later - AVX2 = 10 - } - - [CLSCompliant(false)] - [Obsolete("Will be removed in the next major version. Use the enums in the Common namespace instead.")] - public enum MklAccuracy : uint - { - Low = 0x1, - High = 0x2 - } - - [CLSCompliant(false)] - [Obsolete("Will be removed in the next major version. Use the enums in the Common namespace instead.")] - public enum MklPrecision : uint - { - Single = 0x10, - Double = 0x20 - } - /// /// Intel's Math Kernel Library (MKL) linear algebra provider. /// public partial class MklLinearAlgebraProvider : ManagedLinearAlgebraProvider { - readonly Common.Mkl.MklConsistency _consistency; - readonly Common.Mkl.MklPrecision _precision; - readonly Common.Mkl.MklAccuracy _accuracy; + readonly MklConsistency _consistency; + readonly MklPrecision _precision; + readonly MklAccuracy _accuracy; int _linearAlgebraMajor; int _linearAlgebraMinor; @@ -102,28 +66,10 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl /// VML optimal precision and rounding. /// VML accuracy mode. [CLSCompliant(false)] - [Obsolete("Will be removed in the next major version. Use the enums in the Common namespace instead.")] public MklLinearAlgebraProvider( MklConsistency consistency = MklConsistency.Auto, MklPrecision precision = MklPrecision.Double, MklAccuracy accuracy = MklAccuracy.High) - { - _consistency = (Common.Mkl.MklConsistency)consistency; - _precision = (Common.Mkl.MklPrecision)precision; - _accuracy = (Common.Mkl.MklAccuracy)accuracy; - } - - /// - /// Sets the desired bit consistency on repeated identical computations on varying CPU architectures, - /// as a trade-off with performance. - /// - /// VML optimal precision and rounding. - /// VML accuracy mode. - [CLSCompliant(false)] - public MklLinearAlgebraProvider( - Common.Mkl.MklConsistency consistency = Common.Mkl.MklConsistency.Auto, - Common.Mkl.MklPrecision precision = Common.Mkl.MklPrecision.Double, - Common.Mkl.MklAccuracy accuracy = Common.Mkl.MklAccuracy.High) { _consistency = consistency; _precision = precision; @@ -132,9 +78,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl public MklLinearAlgebraProvider() { - _consistency = Common.Mkl.MklConsistency.Auto; - _precision = Common.Mkl.MklPrecision.Double; - _accuracy = Common.Mkl.MklAccuracy.High; + _consistency = MklConsistency.Auto; + _precision = MklPrecision.Double; + _accuracy = MklAccuracy.High; } ///