Browse Source

UX: Revert invariant-culture override, move ToString to BCL partial classes

v2
Christoph Ruegg 14 years ago
parent
commit
7cdde55061
  1. 6
      src/Numerics/LinearAlgebra/Double/Matrix.cs
  2. 41
      src/Numerics/LinearAlgebra/Generic/Matrix.BCL.cs
  3. 42
      src/Numerics/LinearAlgebra/Generic/Matrix.cs
  4. 30
      src/Numerics/LinearAlgebra/Generic/Vector.BCL.cs
  5. 34
      src/Numerics/LinearAlgebra/Generic/Vector.cs

6
src/Numerics/LinearAlgebra/Double/Matrix.cs

@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com // http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// Copyright (c) 2009-2010 Math.NET //
// Copyright (c) 2009-2013 Math.NET
//
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without // files (the "Software"), to deal in the Software without
@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the // copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following // Software is furnished to do so, subject to the following
// conditions: // conditions:
//
// The above copyright notice and this permission notice shall be // The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software. // included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND

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

@ -30,6 +30,7 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Text;
namespace MathNet.Numerics.LinearAlgebra.Generic namespace MathNet.Numerics.LinearAlgebra.Generic
{ {
@ -85,6 +86,43 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
return ToString(null, null); return ToString(null, null);
} }
/// <summary>
/// Returns a <see cref="System.String"/> that represents this instance.
/// </summary>
/// <param name="format">
/// The format to use.
/// </param>
/// <param name="formatProvider">
/// The format provider to use.
/// </param>
/// <returns>
/// A <see cref="System.String"/> that represents this instance.
/// </returns>
public virtual string ToString(string format, IFormatProvider formatProvider = null)
{
var separator = (formatProvider.GetTextInfo().ListSeparator);
var stringBuilder = new StringBuilder();
for (var row = 0; row < RowCount; row++)
{
for (var column = 0; column < ColumnCount; column++)
{
stringBuilder.Append(At(row, column).ToString(format, formatProvider));
if (column != ColumnCount - 1)
{
stringBuilder.Append(separator);
}
}
if (row != RowCount - 1)
{
stringBuilder.Append(Environment.NewLine);
}
}
return stringBuilder.ToString();
}
#if !PORTABLE #if !PORTABLE
/// <summary> /// <summary>
@ -99,8 +137,5 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
} }
#endif #endif
} }
} }

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

@ -28,16 +28,12 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using System.Globalization;
namespace MathNet.Numerics.LinearAlgebra.Generic namespace MathNet.Numerics.LinearAlgebra.Generic
{ {
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics; using System.Numerics;
using System.Runtime; using System.Runtime;
using System.Text;
using Factorization; using Factorization;
using Numerics; using Numerics;
using Properties; using Properties;
@ -1440,43 +1436,5 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
{ {
return Storage.ToRowMajorArray(); return Storage.ToRowMajorArray();
} }
/// <summary>
/// Returns a <see cref="System.String"/> that represents this instance.
/// </summary>
/// <param name="format">
/// The format to use.
/// </param>
/// <param name="formatProvider">
/// The format provider to use.
/// </param>
/// <returns>
/// A <see cref="System.String"/> that represents this instance.
/// </returns>
public virtual string ToString(string format, IFormatProvider formatProvider = null)
{
var provider = formatProvider ?? CultureInfo.InvariantCulture;
var separator = (provider.GetTextInfo().ListSeparator);
var stringBuilder = new StringBuilder();
for (var row = 0; row < RowCount; row++)
{
for (var column = 0; column < ColumnCount; column++)
{
stringBuilder.Append(At(row, column).ToString(format, provider));
if (column != ColumnCount - 1)
{
stringBuilder.Append(separator);
}
}
if (row != RowCount - 1)
{
stringBuilder.Append(Environment.NewLine);
}
}
return stringBuilder.ToString();
}
} }
} }

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

@ -32,6 +32,7 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Text;
using MathNet.Numerics.LinearAlgebra.Storage; using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Properties; using MathNet.Numerics.Properties;
@ -101,6 +102,35 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
return ToString(null, formatProvider); return ToString(null, formatProvider);
} }
/// <summary>
/// Returns a <see cref="System.String"/> that represents this instance.
/// </summary>
/// <param name="format">
/// The format to use.
/// </param>
/// <param name="formatProvider">
/// An <see cref="IFormatProvider"/> that supplies culture-specific formatting information.
/// </param>
/// <returns>
/// A <see cref="System.String"/> that represents this instance.
/// </returns>
public virtual string ToString(string format, IFormatProvider formatProvider = null)
{
var separator = (formatProvider.GetTextInfo().ListSeparator);
var stringBuilder = new StringBuilder();
for (var index = 0; index < Count; index++)
{
stringBuilder.Append(At(index).ToString(format, formatProvider));
if (index != Count - 1)
{
stringBuilder.Append(separator);
}
}
return stringBuilder.ToString();
}
#if !PORTABLE #if !PORTABLE
/// <summary> /// <summary>

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

@ -28,16 +28,12 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using System.Globalization;
namespace MathNet.Numerics.LinearAlgebra.Generic namespace MathNet.Numerics.LinearAlgebra.Generic
{ {
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime; using System.Runtime;
using System.Text;
using Properties; using Properties;
using Storage; using Storage;
@ -1295,35 +1291,5 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
{ {
return Storage.EnumerateNonZero(); return Storage.EnumerateNonZero();
} }
/// <summary>
/// Returns a <see cref="System.String"/> that represents this instance.
/// </summary>
/// <param name="format">
/// The format to use.
/// </param>
/// <param name="formatProvider">
/// An <see cref="IFormatProvider"/> that supplies culture-specific formatting information.
/// </param>
/// <returns>
/// A <see cref="System.String"/> that represents this instance.
/// </returns>
public virtual string ToString(string format, IFormatProvider formatProvider = null)
{
var provider = formatProvider ?? CultureInfo.InvariantCulture;
var separator = (provider.GetTextInfo().ListSeparator);
var stringBuilder = new StringBuilder();
for (var index = 0; index < Count; index++)
{
stringBuilder.Append(this[index].ToString(format, provider));
if (index != Count - 1)
{
stringBuilder.Append(separator);
}
}
return stringBuilder.ToString();
}
} }
} }

Loading…
Cancel
Save