Browse Source

LA: Obsolete Vector.Plus, drop some redundant operator overloads

v2
Christoph Ruegg 14 years ago
parent
commit
b215abc890
  1. 17
      src/Numerics/LinearAlgebra/Complex/DenseVector.cs
  2. 17
      src/Numerics/LinearAlgebra/Complex/SparseVector.cs
  3. 17
      src/Numerics/LinearAlgebra/Complex32/DenseVector.cs
  4. 17
      src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
  5. 17
      src/Numerics/LinearAlgebra/Double/DenseVector.cs
  6. 17
      src/Numerics/LinearAlgebra/Double/SparseVector.cs
  7. 3
      src/Numerics/LinearAlgebra/Generic/Vector.cs
  8. 17
      src/Numerics/LinearAlgebra/Single/DenseVector.cs
  9. 17
      src/Numerics/LinearAlgebra/Single/SparseVector.cs
  10. 11
      src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs
  11. 11
      src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs
  12. 11
      src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs
  13. 11
      src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs
  14. 16
      src/UnitTests/LinearAlgebraTests/VectorArithmeticTheory.cs

17
src/Numerics/LinearAlgebra/Complex/DenseVector.cs

@ -258,23 +258,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the same values of <paramref name="rightSide"/>.
/// </summary>
/// <remarks>This method is included for completeness.</remarks>
/// <param name="rightSide">The vector to get the values from.</param>
/// <returns>A vector containing a the same values as <paramref name="rightSide"/>.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Vector<Complex> operator +(DenseVector rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return rightSide.Plus();
}
/// <summary>
/// Adds two <strong>Vectors</strong> together and returns the results.
/// </summary>

17
src/Numerics/LinearAlgebra/Complex/SparseVector.cs

@ -543,23 +543,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return result;
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the same values of <paramref name="rightSide"/>.
/// </summary>
/// <remarks>This method is included for completeness.</remarks>
/// <param name="rightSide">The vector to get the values from.</param>
/// <returns>A vector containing a the same values as <paramref name="rightSide"/>.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static SparseVector operator +(SparseVector rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return (SparseVector)rightSide.Plus();
}
/// <summary>
/// Adds two <strong>Vectors</strong> together and returns the results.
/// </summary>

17
src/Numerics/LinearAlgebra/Complex32/DenseVector.cs

@ -258,23 +258,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the same values of <paramref name="rightSide"/>.
/// </summary>
/// <remarks>This method is included for completeness.</remarks>
/// <param name="rightSide">The vector to get the values from.</param>
/// <returns>A vector containing a the same values as <paramref name="rightSide"/>.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static DenseVector operator +(DenseVector rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return (DenseVector)rightSide.Plus();
}
/// <summary>
/// Adds two <strong>Vectors</strong> together and returns the results.
/// </summary>

17
src/Numerics/LinearAlgebra/Complex32/SparseVector.cs

@ -543,23 +543,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return result;
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the same values of <paramref name="rightSide"/>.
/// </summary>
/// <remarks>This method is included for completeness.</remarks>
/// <param name="rightSide">The vector to get the values from.</param>
/// <returns>A vector containing a the same values as <paramref name="rightSide"/>.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static SparseVector operator +(SparseVector rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return (SparseVector)rightSide.Plus();
}
/// <summary>
/// Adds two <strong>Vectors</strong> together and returns the results.
/// </summary>

17
src/Numerics/LinearAlgebra/Double/DenseVector.cs

@ -258,23 +258,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the same values of <paramref name="rightSide"/>.
/// </summary>
/// <remarks>This method is included for completeness.</remarks>
/// <param name="rightSide">The vector to get the values from.</param>
/// <returns>A vector containing a the same values as <paramref name="rightSide"/>.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static DenseVector operator +(DenseVector rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return (DenseVector)rightSide.Plus();
}
/// <summary>
/// Adds two <strong>Vectors</strong> together and returns the results.
/// </summary>

17
src/Numerics/LinearAlgebra/Double/SparseVector.cs

@ -535,23 +535,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the same values of <paramref name="rightSide"/>.
/// </summary>
/// <remarks>This method is included for completeness.</remarks>
/// <param name="rightSide">The vector to get the values from.</param>
/// <returns>A vector containing a the same values as <paramref name="rightSide"/>.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static SparseVector operator +(SparseVector rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return (SparseVector)rightSide.Plus();
}
/// <summary>
/// Adds two <strong>Vectors</strong> together and returns the results.
/// </summary>

3
src/Numerics/LinearAlgebra/Generic/Vector.cs

@ -294,6 +294,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <remarks>
/// Added as an alternative to the unary addition operator.
/// </remarks>
[Obsolete("Use Clone instead. Scheduled for removal in v3.0.")]
public Vector<T> Plus()
{
return Clone();
@ -829,7 +830,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
throw new ArgumentNullException("rightSide");
}
return rightSide.Plus();
return rightSide.Clone();
}
/// <summary>

17
src/Numerics/LinearAlgebra/Single/DenseVector.cs

@ -258,23 +258,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the same values of <paramref name="rightSide"/>.
/// </summary>
/// <remarks>This method is included for completeness.</remarks>
/// <param name="rightSide">The vector to get the values from.</param>
/// <returns>A vector containing a the same values as <paramref name="rightSide"/>.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static DenseVector operator +(DenseVector rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return (DenseVector)rightSide.Plus();
}
/// <summary>
/// Adds two <strong>Vectors</strong> together and returns the results.
/// </summary>

17
src/Numerics/LinearAlgebra/Single/SparseVector.cs

@ -536,23 +536,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the same values of <paramref name="rightSide"/>.
/// </summary>
/// <remarks>This method is included for completeness.</remarks>
/// <param name="rightSide">The vector to get the values from.</param>
/// <returns>A vector containing a the same values as <paramref name="rightSide"/>.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static SparseVector operator +(SparseVector rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return (SparseVector)rightSide.Plus();
}
/// <summary>
/// Adds two <strong>Vectors</strong> together and returns the results.
/// </summary>

11
src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs

@ -36,17 +36,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// </summary>
public abstract partial class VectorTests
{
/// <summary>
/// Can call Plus.
/// </summary>
[Test]
public void CanCallPlus()
{
var vector = CreateVector(Data);
var other = vector.Plus();
CollectionAssert.AreEqual(vector, other);
}
/// <summary>
/// Operator "+" throws <c>ArgumentNullException</c> when call on <c>null</c> vector.
/// </summary>

11
src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs

@ -36,17 +36,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// </summary>
public abstract partial class VectorTests
{
/// <summary>
/// Can call Plus.
/// </summary>
[Test]
public void CanCallPlus()
{
var vector = CreateVector(Data);
var other = vector.Plus();
CollectionAssert.AreEqual(vector, other);
}
/// <summary>
/// Operator "+" throws <c>ArgumentNullException</c> when call on <c>null</c> vector.
/// </summary>

11
src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs

@ -35,17 +35,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// </summary>
public abstract partial class VectorTests
{
/// <summary>
/// Can call Plus.
/// </summary>
[Test]
public void CanCallPlus()
{
var vector = CreateVector(Data);
var other = vector.Plus();
CollectionAssert.AreEqual(vector, other);
}
/// <summary>
/// Operator "+" throws <c>ArgumentNullException</c> when call on <c>null</c> vector.
/// </summary>

11
src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs

@ -35,17 +35,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// </summary>
public abstract partial class VectorTests
{
/// <summary>
/// Can call Plus.
/// </summary>
[Test]
public void CanCallPlus()
{
var vector = CreateVector(Data);
var other = vector.Plus();
CollectionAssert.AreEqual(vector, other);
}
/// <summary>
/// Operator "+" throws <c>ArgumentNullException</c> when call on <c>null</c> vector.
/// </summary>

16
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<T> 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<T> vector)
{

Loading…
Cancel
Save