From b215abc89002e4fe7896380ed21468d45e157d23 Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Sun, 3 Mar 2013 15:23:41 +0100 Subject: [PATCH] LA: Obsolete Vector.Plus, drop some redundant operator overloads --- .../LinearAlgebra/Complex/DenseVector.cs | 17 ----------------- .../LinearAlgebra/Complex/SparseVector.cs | 17 ----------------- .../LinearAlgebra/Complex32/DenseVector.cs | 17 ----------------- .../LinearAlgebra/Complex32/SparseVector.cs | 17 ----------------- .../LinearAlgebra/Double/DenseVector.cs | 17 ----------------- .../LinearAlgebra/Double/SparseVector.cs | 17 ----------------- src/Numerics/LinearAlgebra/Generic/Vector.cs | 3 ++- .../LinearAlgebra/Single/DenseVector.cs | 17 ----------------- .../LinearAlgebra/Single/SparseVector.cs | 17 ----------------- .../Complex/VectorTests.Arithmetic.cs | 11 ----------- .../Complex32/VectorTests.Arithmetic.cs | 11 ----------- .../Double/VectorTests.Arithmetic.cs | 11 ----------- .../Single/VectorTests.Arithmetic.cs | 11 ----------- .../VectorArithmeticTheory.cs | 16 ---------------- 14 files changed, 2 insertions(+), 197 deletions(-) diff --git a/src/Numerics/LinearAlgebra/Complex/DenseVector.cs b/src/Numerics/LinearAlgebra/Complex/DenseVector.cs index a44eafcc..22dc170d 100644 --- a/src/Numerics/LinearAlgebra/Complex/DenseVector.cs +++ b/src/Numerics/LinearAlgebra/Complex/DenseVector.cs @@ -258,23 +258,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex } } - /// - /// Returns a Vector containing the same values of . - /// - /// This method is included for completeness. - /// The vector to get the values from. - /// A vector containing a the same values as . - /// If is . - public static Vector operator +(DenseVector rightSide) - { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - - return rightSide.Plus(); - } - /// /// Adds two Vectors together and returns the results. /// diff --git a/src/Numerics/LinearAlgebra/Complex/SparseVector.cs b/src/Numerics/LinearAlgebra/Complex/SparseVector.cs index f753b2ef..7ff9c269 100644 --- a/src/Numerics/LinearAlgebra/Complex/SparseVector.cs +++ b/src/Numerics/LinearAlgebra/Complex/SparseVector.cs @@ -543,23 +543,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex return result; } - /// - /// Returns a Vector containing the same values of . - /// - /// This method is included for completeness. - /// The vector to get the values from. - /// A vector containing a the same values as . - /// If is . - public static SparseVector operator +(SparseVector rightSide) - { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - - return (SparseVector)rightSide.Plus(); - } - /// /// Adds two Vectors together and returns the results. /// diff --git a/src/Numerics/LinearAlgebra/Complex32/DenseVector.cs b/src/Numerics/LinearAlgebra/Complex32/DenseVector.cs index 2c22bdb0..f5edf257 100644 --- a/src/Numerics/LinearAlgebra/Complex32/DenseVector.cs +++ b/src/Numerics/LinearAlgebra/Complex32/DenseVector.cs @@ -258,23 +258,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 } } - /// - /// Returns a Vector containing the same values of . - /// - /// This method is included for completeness. - /// The vector to get the values from. - /// A vector containing a the same values as . - /// If is . - public static DenseVector operator +(DenseVector rightSide) - { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - - return (DenseVector)rightSide.Plus(); - } - /// /// Adds two Vectors together and returns the results. /// diff --git a/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs b/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs index 25ef6a77..a207a603 100644 --- a/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs +++ b/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs @@ -543,23 +543,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 return result; } - /// - /// Returns a Vector containing the same values of . - /// - /// This method is included for completeness. - /// The vector to get the values from. - /// A vector containing a the same values as . - /// If is . - public static SparseVector operator +(SparseVector rightSide) - { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - - return (SparseVector)rightSide.Plus(); - } - /// /// Adds two Vectors together and returns the results. /// diff --git a/src/Numerics/LinearAlgebra/Double/DenseVector.cs b/src/Numerics/LinearAlgebra/Double/DenseVector.cs index 573a51a2..3550e976 100644 --- a/src/Numerics/LinearAlgebra/Double/DenseVector.cs +++ b/src/Numerics/LinearAlgebra/Double/DenseVector.cs @@ -258,23 +258,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double } } - /// - /// Returns a Vector containing the same values of . - /// - /// This method is included for completeness. - /// The vector to get the values from. - /// A vector containing a the same values as . - /// If is . - public static DenseVector operator +(DenseVector rightSide) - { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - - return (DenseVector)rightSide.Plus(); - } - /// /// Adds two Vectors together and returns the results. /// diff --git a/src/Numerics/LinearAlgebra/Double/SparseVector.cs b/src/Numerics/LinearAlgebra/Double/SparseVector.cs index 2984effd..b158e065 100644 --- a/src/Numerics/LinearAlgebra/Double/SparseVector.cs +++ b/src/Numerics/LinearAlgebra/Double/SparseVector.cs @@ -535,23 +535,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double } } - /// - /// Returns a Vector containing the same values of . - /// - /// This method is included for completeness. - /// The vector to get the values from. - /// A vector containing a the same values as . - /// If is . - public static SparseVector operator +(SparseVector rightSide) - { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - - return (SparseVector)rightSide.Plus(); - } - /// /// Adds two Vectors together and returns the results. /// diff --git a/src/Numerics/LinearAlgebra/Generic/Vector.cs b/src/Numerics/LinearAlgebra/Generic/Vector.cs index 93eb8d07..bd78d803 100644 --- a/src/Numerics/LinearAlgebra/Generic/Vector.cs +++ b/src/Numerics/LinearAlgebra/Generic/Vector.cs @@ -294,6 +294,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// Added as an alternative to the unary addition operator. /// + [Obsolete("Use Clone instead. Scheduled for removal in v3.0.")] public Vector Plus() { return Clone(); @@ -829,7 +830,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic throw new ArgumentNullException("rightSide"); } - return rightSide.Plus(); + return rightSide.Clone(); } /// diff --git a/src/Numerics/LinearAlgebra/Single/DenseVector.cs b/src/Numerics/LinearAlgebra/Single/DenseVector.cs index c41e24c0..88d78fba 100644 --- a/src/Numerics/LinearAlgebra/Single/DenseVector.cs +++ b/src/Numerics/LinearAlgebra/Single/DenseVector.cs @@ -258,23 +258,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single } } - /// - /// Returns a Vector containing the same values of . - /// - /// This method is included for completeness. - /// The vector to get the values from. - /// A vector containing a the same values as . - /// If is . - public static DenseVector operator +(DenseVector rightSide) - { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - - return (DenseVector)rightSide.Plus(); - } - /// /// Adds two Vectors together and returns the results. /// diff --git a/src/Numerics/LinearAlgebra/Single/SparseVector.cs b/src/Numerics/LinearAlgebra/Single/SparseVector.cs index 2ec7207f..75278294 100644 --- a/src/Numerics/LinearAlgebra/Single/SparseVector.cs +++ b/src/Numerics/LinearAlgebra/Single/SparseVector.cs @@ -536,23 +536,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single } } - /// - /// Returns a Vector containing the same values of . - /// - /// This method is included for completeness. - /// The vector to get the values from. - /// A vector containing a the same values as . - /// If is . - public static SparseVector operator +(SparseVector rightSide) - { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - - return (SparseVector)rightSide.Plus(); - } - /// /// Adds two Vectors together and returns the results. /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs index 0b835161..ac962875 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs @@ -36,17 +36,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// public abstract partial class VectorTests { - /// - /// Can call Plus. - /// - [Test] - public void CanCallPlus() - { - var vector = CreateVector(Data); - var other = vector.Plus(); - CollectionAssert.AreEqual(vector, other); - } - /// /// Operator "+" throws ArgumentNullException when call on null vector. /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs index 7562f85c..37b71479 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs @@ -36,17 +36,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// public abstract partial class VectorTests { - /// - /// Can call Plus. - /// - [Test] - public void CanCallPlus() - { - var vector = CreateVector(Data); - var other = vector.Plus(); - CollectionAssert.AreEqual(vector, other); - } - /// /// Operator "+" throws ArgumentNullException when call on null vector. /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs index c2393ab2..46d00758 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs @@ -35,17 +35,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// public abstract partial class VectorTests { - /// - /// Can call Plus. - /// - [Test] - public void CanCallPlus() - { - var vector = CreateVector(Data); - var other = vector.Plus(); - CollectionAssert.AreEqual(vector, other); - } - /// /// Operator "+" throws ArgumentNullException when call on null vector. /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs index db6f04f4..b5141813 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs @@ -35,17 +35,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// public abstract partial class VectorTests { - /// - /// Can call Plus. - /// - [Test] - public void CanCallPlus() - { - var vector = CreateVector(Data); - var other = vector.Plus(); - CollectionAssert.AreEqual(vector, other); - } - /// /// Operator "+" throws ArgumentNullException when call on null vector. /// diff --git a/src/UnitTests/LinearAlgebraTests/VectorArithmeticTheory.cs b/src/UnitTests/LinearAlgebraTests/VectorArithmeticTheory.cs index d24d1f89..9681dbab 100644 --- a/src/UnitTests/LinearAlgebraTests/VectorArithmeticTheory.cs +++ b/src/UnitTests/LinearAlgebraTests/VectorArithmeticTheory.cs @@ -75,22 +75,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests Assert.That(c.Equals(vector.CreateVector(vector.Count))); } - [Theory, Timeout(200)] - public void CanPlusVector(Vector vector) - { - var hash = vector.GetHashCode(); - - var result1 = +vector; - var result2 = vector.Plus(); - - Assert.That(vector.GetHashCode(), Is.EqualTo(hash)); - Assert.That(result1, Is.Not.SameAs(vector)); - Assert.That(result1.Equals(vector)); - Assert.That(result2, Is.Not.SameAs(vector)); - Assert.That(result2.Equals(vector)); - Assert.That(result1.Equals(result2)); - } - [Theory, Timeout(200)] public void CanNegateVector(Vector vector) {