From e5bed3c15830dc7273340624907269c72e3e1a27 Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Sat, 23 Feb 2013 19:19:35 +0100 Subject: [PATCH] LA: Generic Vector: Extract BCL interfaces to partial class --- .../LinearAlgebra/Complex/SparseVector.cs | 67 ---- .../LinearAlgebra/Complex32/SparseVector.cs | 67 ---- .../LinearAlgebra/Double/SparseVector.cs | 67 ---- .../LinearAlgebra/Generic/Vector.BCL.cs | 260 +++++++++++++++ src/Numerics/LinearAlgebra/Generic/Vector.cs | 300 +----------------- .../LinearAlgebra/Single/SparseVector.cs | 67 ---- .../SparseCompressedRowMatrixStorage.cs | 6 +- .../Storage/SparseVectorStorage.cs | 53 ++++ src/Numerics/Numerics.csproj | 1 + src/Portable/Portable.csproj | 3 + .../LinearAlgebraTests/Complex/VectorTests.cs | 2 +- .../Complex32/VectorTests.cs | 2 +- .../LinearAlgebraTests/Double/VectorTests.cs | 2 +- .../LinearAlgebraTests/Single/VectorTests.cs | 2 +- 14 files changed, 329 insertions(+), 570 deletions(-) create mode 100644 src/Numerics/LinearAlgebra/Generic/Vector.BCL.cs diff --git a/src/Numerics/LinearAlgebra/Complex/SparseVector.cs b/src/Numerics/LinearAlgebra/Complex/SparseVector.cs index e104193c..1b676e8b 100644 --- a/src/Numerics/LinearAlgebra/Complex/SparseVector.cs +++ b/src/Numerics/LinearAlgebra/Complex/SparseVector.cs @@ -1225,73 +1225,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex #endregion - /// - /// Indicates whether the current object is equal to another object of the same type. - /// - /// - /// An object to compare with this object. - /// - /// - /// true if the current object is equal to the parameter; otherwise, false. - /// - public override bool Equals(Vector other) - { - // Reject equality when the argument is null or has a different length. - if (other == null) - { - return false; - } - - if (Count != other.Count) - { - return false; - } - - // Accept if the argument is the same object as this. - if (ReferenceEquals(this, other)) - { - return true; - } - - var otherSparse = other as SparseVector; - if (otherSparse == null) - { - return base.Equals(other); - } - - int i = 0, j = 0; - while (i < _storage.ValueCount || j < otherSparse._storage.ValueCount) - { - if (j >= otherSparse._storage.ValueCount || i < _storage.ValueCount && _storage.Indices[i] < otherSparse._storage.Indices[j]) - { - if (_storage.Values[i++] != Complex.Zero) - { - return false; - } - continue; - } - - if (i >= _storage.ValueCount || j < otherSparse._storage.ValueCount && otherSparse._storage.Indices[j] < _storage.Indices[i]) - { - if (otherSparse._storage.Values[j++] != Complex.Zero) - { - return false; - } - continue; - } - - if (!_storage.Values[i].AlmostEqual(otherSparse._storage.Values[j])) - { - return false; - } - - i++; - j++; - } - - return true; - } - /// /// Returns an that contains the position and value of the element. /// diff --git a/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs b/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs index 90db1090..ad054005 100644 --- a/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs +++ b/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs @@ -1225,73 +1225,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 #endregion - /// - /// Indicates whether the current object is equal to another object of the same type. - /// - /// - /// An object to compare with this object. - /// - /// - /// true if the current object is equal to the parameter; otherwise, false. - /// - public override bool Equals(Vector other) - { - // Reject equality when the argument is null or has a different length. - if (other == null) - { - return false; - } - - if (Count != other.Count) - { - return false; - } - - // Accept if the argument is the same object as this. - if (ReferenceEquals(this, other)) - { - return true; - } - - var otherSparse = other as SparseVector; - if (otherSparse == null) - { - return base.Equals(other); - } - - int i = 0, j = 0; - while (i < _storage.ValueCount || j < otherSparse._storage.ValueCount) - { - if (j >= otherSparse._storage.ValueCount || i < _storage.ValueCount && _storage.Indices[i] < otherSparse._storage.Indices[j]) - { - if (_storage.Values[i++] != Complex32.Zero) - { - return false; - } - continue; - } - - if (i >= _storage.ValueCount || j < otherSparse._storage.ValueCount && otherSparse._storage.Indices[j] < _storage.Indices[i]) - { - if (otherSparse._storage.Values[j++] != Complex32.Zero) - { - return false; - } - continue; - } - - if (!_storage.Values[i].AlmostEqual(otherSparse._storage.Values[j])) - { - return false; - } - - i++; - j++; - } - - return true; - } - /// /// Returns an that contains the position and value of the element. /// diff --git a/src/Numerics/LinearAlgebra/Double/SparseVector.cs b/src/Numerics/LinearAlgebra/Double/SparseVector.cs index fbf0b1ee..125f8117 100644 --- a/src/Numerics/LinearAlgebra/Double/SparseVector.cs +++ b/src/Numerics/LinearAlgebra/Double/SparseVector.cs @@ -1277,73 +1277,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double #endregion - /// - /// Indicates whether the current object is equal to another object of the same type. - /// - /// - /// An object to compare with this object. - /// - /// - /// true if the current object is equal to the parameter; otherwise, false. - /// - public override bool Equals(Vector other) - { - // Reject equality when the argument is null or has a different length. - if (other == null) - { - return false; - } - - if (Count != other.Count) - { - return false; - } - - // Accept if the argument is the same object as this. - if (ReferenceEquals(this, other)) - { - return true; - } - - var otherSparse = other as SparseVector; - if (otherSparse == null) - { - return base.Equals(other); - } - - int i = 0, j = 0; - while (i < _storage.ValueCount || j < otherSparse._storage.ValueCount) - { - if (j >= otherSparse._storage.ValueCount || i < _storage.ValueCount && _storage.Indices[i] < otherSparse._storage.Indices[j]) - { - if (_storage.Values[i++] != 0d) - { - return false; - } - continue; - } - - if (i >= _storage.ValueCount || j < otherSparse._storage.ValueCount && otherSparse._storage.Indices[j] < _storage.Indices[i]) - { - if (otherSparse._storage.Values[j++] != 0d) - { - return false; - } - continue; - } - - if (!_storage.Values[i].AlmostEqual(otherSparse._storage.Values[j])) - { - return false; - } - - i++; - j++; - } - - return true; - } - /// /// Returns an that contains the position and value of the element. /// diff --git a/src/Numerics/LinearAlgebra/Generic/Vector.BCL.cs b/src/Numerics/LinearAlgebra/Generic/Vector.BCL.cs new file mode 100644 index 00000000..4675be64 --- /dev/null +++ b/src/Numerics/LinearAlgebra/Generic/Vector.BCL.cs @@ -0,0 +1,260 @@ +// +// Math.NET Numerics, part of the Math.NET Project +// http://numerics.mathdotnet.com +// http://github.com/mathnet/mathnet-numerics +// http://mathnetnumerics.codeplex.com +// +// Copyright (c) 2009-2010 Math.NET +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections; +using System.Collections.Generic; +using MathNet.Numerics.LinearAlgebra.Storage; +using MathNet.Numerics.Properties; + +namespace MathNet.Numerics.LinearAlgebra.Generic +{ + public abstract partial class Vector : +#if PORTABLE + IList, IList +#else + IList, IList, ICloneable +#endif + { + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// An object to compare with this object. + /// + /// true if the current object is equal to the parameter; otherwise, false. + /// + public bool Equals(Vector other) + { + return other != null && Storage.Equals(other.Storage); + } + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public override bool Equals(object obj) + { + var other = obj as Vector; + return other != null && Storage.Equals(other.Storage); + } + + /// + /// Returns a hash code for this instance. + /// + /// + /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. + /// + public override int GetHashCode() + { + return Storage.GetHashCode(); + } + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + { + return ToString(null, null); + } + +#if !PORTABLE + + #region ICloneable + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// + /// A new object that is a copy of this instance. + /// + object ICloneable.Clone() + { + return Clone(); + } + + #endregion + +#endif + + int IList.IndexOf(T item) + { + for (int i = 0; i < Count; ++i) + { + if (this[i].Equals(item)) + return i; + } + return -1; + } + + void IList.Insert(int index, T item) + { + throw new NotSupportedException(); + } + + void IList.RemoveAt(int index) + { + throw new NotSupportedException(); + } + + bool ICollection.IsReadOnly + { + get { return false; } + } + + void ICollection.Add(T item) + { + throw new NotSupportedException(); + } + + bool ICollection.Remove(T item) + { + throw new NotSupportedException(); + } + + bool ICollection.Contains(T item) + { + // Do NOT convert this loop to LINQ (since LINQ would redirect to this very method)! + foreach (var x in this) + { + if (x.Equals(item)) + return true; + } + return false; + } + + void ICollection.CopyTo(T[] array, int arrayIndex) + { + if (array == null) + { + throw new ArgumentNullException("array"); + } + + Storage.CopySubVectorTo(new DenseVectorStorage(array.Length, array), 0, arrayIndex, Count); + } + + bool IList.IsReadOnly + { + get { return false; } + } + + bool IList.IsFixedSize + { + get { return true; } + } + + object IList.this[int index] + { + get { return Storage[index]; } + set { Storage[index] = (T)value; } + } + + int IList.IndexOf(object value) + { + if (!(value is T)) + { + return -1; + } + + return ((IList)this).IndexOf((T)value); + } + + bool IList.Contains(object value) + { + if (!(value is T)) + { + return false; + } + + return ((ICollection)this).Contains((T)value); + } + + void IList.Insert(int index, object value) + { + throw new NotSupportedException(); + } + + int IList.Add(object value) + { + throw new NotSupportedException(); + } + + void IList.Remove(object value) + { + throw new NotSupportedException(); + } + + void IList.RemoveAt(int index) + { + throw new NotSupportedException(); + } + + bool ICollection.IsSynchronized + { + get { return false; } + } + + object ICollection.SyncRoot + { + get { return null; } + } + + void ICollection.CopyTo(Array array, int index) + { + if (array == null) + { + throw new ArgumentNullException("array"); + } + if (array.Rank != 1) + { + throw new ArgumentException(Resources.ArgumentSingleDimensionArray, "array"); + } + + Storage.CopySubVectorTo(new DenseVectorStorage(array.Length, (T[])array), 0, index, Count); + } + + /// + /// Returns an enumerator that iterates through a collection. + /// + /// + /// An object that can be used to iterate through the collection. + /// + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/src/Numerics/LinearAlgebra/Generic/Vector.cs b/src/Numerics/LinearAlgebra/Generic/Vector.cs index 96b22a92..b7008f75 100644 --- a/src/Numerics/LinearAlgebra/Generic/Vector.cs +++ b/src/Numerics/LinearAlgebra/Generic/Vector.cs @@ -3,7 +3,9 @@ // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics // http://mathnetnumerics.codeplex.com +// // Copyright (c) 2009-2010 Math.NET +// // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation // files (the "Software"), to deal in the Software without @@ -12,8 +14,10 @@ // copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following // conditions: +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -41,11 +45,11 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// Supported data types are double, single, , and . [Serializable] - public abstract class Vector : + public abstract partial class Vector : #if PORTABLE - IFormattable, IEnumerable, IEquatable>, IList, IList + IFormattable, IEnumerable, IEquatable> #else - IFormattable, IEnumerable, IEquatable>, IList, IList, ICloneable + IFormattable, IEnumerable, IEquatable> #endif where T : struct, IEquatable, IFormattable { @@ -1348,44 +1352,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic #endregion - #region Implemented Interfaces - -#if !PORTABLE - - #region ICloneable - - /// - /// Creates a new object that is a copy of the current instance. - /// - /// - /// A new object that is a copy of this instance. - /// - object ICloneable.Clone() - { - return Clone(); - } - - #endregion - -#endif - - #region IEnumerable - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// - /// An object that can be used to iterate through the collection. - /// - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - #endregion - - #region IEnumerable - /// /// Returns an enumerator that iterates through the collection. /// @@ -1400,8 +1366,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic } } - #endregion - /// /// Returns an that contains the position and value of the element. /// @@ -1424,52 +1388,8 @@ namespace MathNet.Numerics.LinearAlgebra.Generic } } - #region IEquatable - - /// - /// Indicates whether the current object is equal to another object of the same type. - /// - /// - /// An object to compare with this object. - /// - /// - /// true if the current object is equal to the parameter; otherwise, false. - /// - public virtual bool Equals(Vector other) - { - // Reject equality when the argument is null or has a different length. - if (other == null) - { - return false; - } - - if (Count != other.Count) - { - return false; - } - - // Accept if the argument is the same object as this. - if (ReferenceEquals(this, other)) - { - return true; - } - - // If all else fails, perform element wise comparison. - for (var index = 0; index < Count; index++) - { - if (!this[index].Equals(other[index])) - { - return false; - } - } - - return true; - } - - #endregion #region IFormattable - /// /// Returns a that represents this instance. /// @@ -1511,211 +1431,5 @@ namespace MathNet.Numerics.LinearAlgebra.Generic return stringBuilder.ToString(); } #endregion - - #region IList - - bool IList.IsReadOnly - { - get { return false; } - } - - bool IList.IsFixedSize - { - get { return true; } - } - - object IList.this[int index] - { - get { return Storage[index]; } - set { Storage[index] = (T)value; } - } - - int IList.IndexOf(object value) - { - if (!(value is T)) - { - return -1; - } - - return ((IList)this).IndexOf((T)value); - } - - bool IList.Contains(object value) - { - if (!(value is T)) - { - return false; - } - - return ((ICollection)this).Contains((T)value); - } - - void IList.Insert(int index, object value) - { - throw new NotSupportedException(); - } - - int IList.Add(object value) - { - throw new NotSupportedException(); - } - - void IList.Remove(object value) - { - throw new NotSupportedException(); - } - - void IList.RemoveAt(int index) - { - throw new NotSupportedException(); - } - - #endregion - #region ICollection - - bool ICollection.IsSynchronized - { - get { return false; } - } - - object ICollection.SyncRoot - { - get { return null; } - } - - void ICollection.CopyTo(Array array, int index) - { - if (array == null) - { - throw new ArgumentNullException("array"); - } - if (array.Rank != 1) - { - throw new ArgumentException(Resources.ArgumentSingleDimensionArray, "array"); - } - - Storage.CopySubVectorTo(new DenseVectorStorage(array.Length, (T[])array), 0, index, Count); - } - - #endregion - #region ICollection - - bool ICollection.IsReadOnly - { - get { return false; } - } - - void ICollection.Add(T item) - { - throw new NotSupportedException(); - } - - bool ICollection.Remove(T item) - { - throw new NotSupportedException(); - } - - bool ICollection.Contains(T item) - { - // Do NOT convert this loop to LINQ (since LINQ would redirect to this very method)! - foreach (var x in this) - { - if (x.Equals(item)) - return true; - } - return false; - } - - void ICollection.CopyTo(T[] array, int arrayIndex) - { - if (array == null) - { - throw new ArgumentNullException("array"); - } - - Storage.CopySubVectorTo(new DenseVectorStorage(array.Length, array), 0, arrayIndex, Count); - } - - #endregion - #region IList - - int IList.IndexOf(T item) - { - for (int i = 0; i < Count; ++i) - { - if (this[i].Equals(item)) - return i; - } - return -1; - } - - void IList.Insert(int index, T item) - { - throw new NotSupportedException(); - } - - void IList.RemoveAt(int index) - { - throw new NotSupportedException(); - } - - #endregion - - #endregion - - #region System.Object overrides - - /// - /// Determines whether the specified is equal to this instance. - /// - /// - /// The to compare with this instance. - /// - /// - /// true if the specified is equal to this instance; otherwise, false. - /// - public override bool Equals(object obj) - { - return Equals(obj as Vector); - } - - /// - /// Returns a hash code for this instance. - /// - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - /// - public override int GetHashCode() - { - var hashNum = Math.Min(Count, 20); - long hash = 0; - for (var i = 0; i < hashNum; i++) - { -#if PORTABLE - hash ^= Precision.DoubleToInt64Bits(this[i].GetHashCode()); -#else - hash ^= BitConverter.DoubleToInt64Bits(this[i].GetHashCode()); -#endif - } - - return BitConverter.ToInt32(BitConverter.GetBytes(hash), 4); - } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() - { - return ToString(null, null); - } - - #endregion - - - - } } diff --git a/src/Numerics/LinearAlgebra/Single/SparseVector.cs b/src/Numerics/LinearAlgebra/Single/SparseVector.cs index 4fbd996d..5d1b2ac0 100644 --- a/src/Numerics/LinearAlgebra/Single/SparseVector.cs +++ b/src/Numerics/LinearAlgebra/Single/SparseVector.cs @@ -1275,73 +1275,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single #endregion - /// - /// Indicates whether the current object is equal to another object of the same type. - /// - /// - /// An object to compare with this object. - /// - /// - /// true if the current object is equal to the parameter; otherwise, false. - /// - public override bool Equals(Vector other) - { - // Reject equality when the argument is null or has a different length. - if (other == null) - { - return false; - } - - if (Count != other.Count) - { - return false; - } - - // Accept if the argument is the same object as this. - if (ReferenceEquals(this, other)) - { - return true; - } - - var otherSparse = other as SparseVector; - if (otherSparse == null) - { - return base.Equals(other); - } - - int i = 0, j = 0; - while (i < _storage.ValueCount || j < otherSparse._storage.ValueCount) - { - if (j >= otherSparse._storage.ValueCount || i < _storage.ValueCount && _storage.Indices[i] < otherSparse._storage.Indices[j]) - { - if (_storage.Values[i++] != 0f) - { - return false; - } - continue; - } - - if (i >= _storage.ValueCount || j < otherSparse._storage.ValueCount && otherSparse._storage.Indices[j] < _storage.Indices[i]) - { - if (otherSparse._storage.Values[j++] != 0f) - { - return false; - } - continue; - } - - if (!_storage.Values[i].AlmostEqual(otherSparse._storage.Values[j])) - { - return false; - } - - i++; - j++; - } - - return true; - } - /// /// Returns an that contains the position and value of the element. /// diff --git a/src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs b/src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs index 50b77f7b..bdf093f2 100644 --- a/src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs +++ b/src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs @@ -277,11 +277,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage public override bool Equals(MatrixStorage other) { // Reject equality when the argument is null or has a different shape. - if (other == null) - { - return false; - } - if (ColumnCount != other.ColumnCount || RowCount != other.RowCount) + if (other == null || ColumnCount != other.ColumnCount || RowCount != other.RowCount) { return false; } diff --git a/src/Numerics/LinearAlgebra/Storage/SparseVectorStorage.cs b/src/Numerics/LinearAlgebra/Storage/SparseVectorStorage.cs index 7e7a6053..6e1e63a9 100644 --- a/src/Numerics/LinearAlgebra/Storage/SparseVectorStorage.cs +++ b/src/Numerics/LinearAlgebra/Storage/SparseVectorStorage.cs @@ -180,6 +180,59 @@ namespace MathNet.Numerics.LinearAlgebra.Storage } } + public override bool Equals(VectorStorage other) + { + // Reject equality when the argument is null or has a different shape. + if (other == null || Length != other.Length) + { + return false; + } + + // Accept if the argument is the same object as this. + if (ReferenceEquals(this, other)) + { + return true; + } + + var otherSparse = other as SparseVectorStorage; + if (otherSparse == null) + { + return base.Equals(other); + } + + int i = 0, j = 0; + while (i < ValueCount || j < otherSparse.ValueCount) + { + if (j >= otherSparse.ValueCount || i < ValueCount && Indices[i] < otherSparse.Indices[j]) + { + if (!_zero.Equals(Values[i++])) + { + return false; + } + continue; + } + + if (i >= ValueCount || j < otherSparse.ValueCount && otherSparse.Indices[j] < Indices[i]) + { + if (!_zero.Equals(otherSparse.Values[j++])) + { + return false; + } + continue; + } + + if (!Values[i].Equals(otherSparse.Values[j])) + { + return false; + } + + i++; + j++; + } + + return true; + } + /// Parameters assumed to be validated already. public override void CopyTo(VectorStorage target, bool skipClearing = false) { diff --git a/src/Numerics/Numerics.csproj b/src/Numerics/Numerics.csproj index d53df1bc..bebd6a0d 100644 --- a/src/Numerics/Numerics.csproj +++ b/src/Numerics/Numerics.csproj @@ -104,6 +104,7 @@ + diff --git a/src/Portable/Portable.csproj b/src/Portable/Portable.csproj index f6c13134..3f039af6 100644 --- a/src/Portable/Portable.csproj +++ b/src/Portable/Portable.csproj @@ -747,6 +747,9 @@ LinearAlgebra\Generic\Solvers\StopCriterium\StopLevel.cs + + LinearAlgebra\Generic\Vector.BCL.cs + LinearAlgebra\Generic\Vector.cs diff --git a/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.cs index d1720ab5..65e71447 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.cs @@ -230,7 +230,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex public void CanGetHashCode() { var vector = CreateVector(new[] { new Complex(1, 1), new Complex(2, 1), new Complex(3, 1), new Complex(4, 1), new Complex(5, 1) }); - Assert.AreEqual(1104007323, vector.GetHashCode()); + Assert.AreEqual(-344264403, vector.GetHashCode()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.cs index 7aa015ef..ef6cc95f 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.cs @@ -230,7 +230,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 public void CanGetHashCode() { var vector = CreateVector(new[] { new Complex32(1, 1), new Complex32(2, 1), new Complex32(3, 1), new Complex32(4, 1), new Complex32(5, 1) }); - Assert.AreEqual(-1042380805, vector.GetHashCode()); + Assert.AreEqual(-26300510, vector.GetHashCode()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/VectorTests.cs b/src/UnitTests/LinearAlgebraTests/Double/VectorTests.cs index 0c718a5a..79add890 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/VectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/VectorTests.cs @@ -228,7 +228,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double public void CanGetHashCode() { var vector = CreateVector(new double[] { 1, 2, 3, 4 }); - Assert.AreEqual(2096640, vector.GetHashCode()); + Assert.AreEqual(-1140355183, vector.GetHashCode()); } /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/VectorTests.cs b/src/UnitTests/LinearAlgebraTests/Single/VectorTests.cs index 80be2d66..2c01cb9e 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/VectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/VectorTests.cs @@ -228,7 +228,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single public void CanGetHashCode() { var vector = CreateVector(new float[] { 1, 2, 3, 4 }); - Assert.AreEqual(2093056, vector.GetHashCode()); + Assert.AreEqual(-642805871, vector.GetHashCode()); } ///