Browse Source

LA: Generic Matrix partial Matrix.BCL class

v2
Christoph Ruegg 14 years ago
parent
commit
12c9cd486d
  1. 104
      src/Numerics/LinearAlgebra/Generic/Matrix.BCL.cs
  2. 67
      src/Numerics/LinearAlgebra/Generic/Matrix.cs
  3. 14
      src/Numerics/LinearAlgebra/Generic/Vector.BCL.cs
  4. 7
      src/Numerics/LinearAlgebra/Generic/Vector.cs
  5. 1
      src/Numerics/Numerics.csproj
  6. 3
      src/Portable/Portable.csproj

104
src/Numerics/LinearAlgebra/Generic/Matrix.BCL.cs

@ -0,0 +1,104 @@
// <copyright file="Matrix.BCL.cs" company="Math.NET">
// 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-2013 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.
// </copyright>
using System;
namespace MathNet.Numerics.LinearAlgebra.Generic
{
public abstract partial class Matrix<T>
{
/// <summary>
/// Indicates whether the current object is equal to another object of the same type.
/// </summary>
/// <param name="other">
/// An object to compare with this object.
/// </param>
/// <returns>
/// <c>true</c> if the current object is equal to the <paramref name="other"/> parameter; otherwise, <c>false</c>.
/// </returns>
public bool Equals(Matrix<T> other)
{
return other != null && Storage.Equals(other.Storage);
}
/// <summary>
/// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
/// </summary>
/// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public override bool Equals(object obj)
{
var other = obj as Matrix<T>;
return other != null && Storage.Equals(other.Storage);
}
/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode()
{
return Storage.GetHashCode();
}
/// <summary>
/// Returns a <see cref="System.String"/> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="System.String"/> that represents this instance.
/// </returns>
public override string ToString()
{
return ToString(null, null);
}
#if !PORTABLE
/// <summary>
/// Creates a new object that is a copy of the current instance.
/// </summary>
/// <returns>
/// A new object that is a copy of this instance.
/// </returns>
object ICloneable.Clone()
{
return Clone();
}
#endif
}
}

67
src/Numerics/LinearAlgebra/Generic/Matrix.cs

@ -47,10 +47,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <typeparam name="T">Supported data types are <c>double</c>, <c>single</c>, <see cref="Complex"/>, and <see cref="Complex32"/>.</typeparam>
[Serializable]
public abstract partial class Matrix<T> :
#if PORTABLE
IFormattable, IEquatable<Matrix<T>>
#else
IFormattable, IEquatable<Matrix<T>>, ICloneable
#if !PORTABLE
, ICloneable
#endif
where T : struct, IEquatable<T>, IFormattable
{
@ -293,19 +292,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
return result;
}
#if !PORTABLE
/// <summary>
/// Creates a new object that is a copy of the current instance.
/// </summary>
/// <returns>
/// A new object that is a copy of this instance.
/// </returns>
object ICloneable.Clone()
{
return Clone();
}
#endif
/// <summary>
/// Copies the elements of this matrix to the given matrix.
/// </summary>
@ -1453,17 +1439,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
return Storage.ToRowMajorArray();
}
/// <summary>
/// Returns a <see cref="System.String"/> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="System.String"/> that represents this instance.
/// </returns>
public override string ToString()
{
return ToString(null);
}
/// <summary>
/// Returns a <see cref="System.String"/> that represents this instance.
/// </summary>
@ -1498,43 +1473,5 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
return stringBuilder.ToString();
}
/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode()
{
return Storage.GetHashCode();
}
/// <summary>
/// Indicates whether the current object is equal to another object of the same type.
/// </summary>
/// <param name="other">
/// An object to compare with this object.
/// </param>
/// <returns>
/// <c>true</c> if the current object is equal to the <paramref name="other"/> parameter; otherwise, <c>false</c>.
/// </returns>
public bool Equals(Matrix<T> other)
{
return other != null && Storage.Equals(other.Storage);
}
/// <summary>
/// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
/// </summary>
/// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public override bool Equals(object obj)
{
var other = obj as Matrix<T>;
return other != null && Storage.Equals(other.Storage);
}
}
}

14
src/Numerics/LinearAlgebra/Generic/Vector.BCL.cs

@ -36,14 +36,8 @@ using MathNet.Numerics.Properties;
namespace MathNet.Numerics.LinearAlgebra.Generic
{
public abstract partial class Vector<T> :
#if PORTABLE
IList, IList<T>
#else
IList, IList<T>, ICloneable
#endif
public abstract partial class Vector<T>
{
/// <summary>
/// Indicates whether the current object is equal to another object of the same type.
/// </summary>
@ -107,8 +101,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
#if !PORTABLE
#region ICloneable
/// <summary>
/// Creates a new object that is a copy of the current instance.
/// </summary>
@ -120,8 +112,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
return Clone();
}
#endregion
#endif
int IList<T>.IndexOf(T item)
@ -268,7 +258,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </returns>
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
return Storage.Enumerate().GetEnumerator();
}
}
}

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

@ -28,9 +28,11 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
namespace MathNet.Numerics.LinearAlgebra.Generic
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime;
using System.Text;
@ -43,7 +45,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <typeparam name="T">Supported data types are double, single, <see cref="Complex"/>, and <see cref="Complex32"/>.</typeparam>
[Serializable]
public abstract partial class Vector<T> :
IFormattable, IEnumerable<T>, IEquatable<Vector<T>>
IFormattable, IEnumerable<T>, IEquatable<Vector<T>>, IList, IList<T>
#if !PORTABLE
, ICloneable
#endif
where T : struct, IEquatable<T>, IFormattable
{
/// <summary>

1
src/Numerics/Numerics.csproj

@ -105,6 +105,7 @@
<Compile Include="Constants.cs" />
<Compile Include="Control.cs" />
<Compile Include="Complex32.cs" />
<Compile Include="LinearAlgebra\Generic\Matrix.BCL.cs" />
<Compile Include="LinearAlgebra\Generic\Vector.BCL.cs" />
<Compile Include="SpecialFunctions\Evaluate.cs" />
<Compile Include="SpecialFunctions\ModifiedStruve.cs" />

3
src/Portable/Portable.csproj

@ -717,6 +717,9 @@
<Compile Include="..\Numerics\LinearAlgebra\Generic\Matrix.Arithmetic.cs">
<Link>LinearAlgebra\Generic\Matrix.Arithmetic.cs</Link>
</Compile>
<Compile Include="..\Numerics\LinearAlgebra\Generic\Matrix.BCL.cs">
<Link>LinearAlgebra\Generic\Matrix.BCL.cs</Link>
</Compile>
<Compile Include="..\Numerics\LinearAlgebra\Generic\Matrix.cs">
<Link>LinearAlgebra\Generic\Matrix.cs</Link>
</Compile>

Loading…
Cancel
Save