From 7cdde55061221d77a524f4aa945c7f3a21e29f09 Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Fri, 29 Mar 2013 21:25:34 +0100 Subject: [PATCH] UX: Revert invariant-culture override, move ToString to BCL partial classes --- src/Numerics/LinearAlgebra/Double/Matrix.cs | 6 ++- .../LinearAlgebra/Generic/Matrix.BCL.cs | 41 ++++++++++++++++-- src/Numerics/LinearAlgebra/Generic/Matrix.cs | 42 ------------------- .../LinearAlgebra/Generic/Vector.BCL.cs | 30 +++++++++++++ src/Numerics/LinearAlgebra/Generic/Vector.cs | 34 --------------- 5 files changed, 73 insertions(+), 80 deletions(-) diff --git a/src/Numerics/LinearAlgebra/Double/Matrix.cs b/src/Numerics/LinearAlgebra/Double/Matrix.cs index 65ca4499..f8992e59 100644 --- a/src/Numerics/LinearAlgebra/Double/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Double/Matrix.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 +// +// 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 @@ -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 diff --git a/src/Numerics/LinearAlgebra/Generic/Matrix.BCL.cs b/src/Numerics/LinearAlgebra/Generic/Matrix.BCL.cs index 59896db5..c41b4bfc 100644 --- a/src/Numerics/LinearAlgebra/Generic/Matrix.BCL.cs +++ b/src/Numerics/LinearAlgebra/Generic/Matrix.BCL.cs @@ -30,6 +30,7 @@ using System; using System.Diagnostics; +using System.Text; namespace MathNet.Numerics.LinearAlgebra.Generic { @@ -85,6 +86,43 @@ namespace MathNet.Numerics.LinearAlgebra.Generic return ToString(null, null); } + /// + /// Returns a that represents this instance. + /// + /// + /// The format to use. + /// + /// + /// The format provider to use. + /// + /// + /// A that represents this instance. + /// + 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 /// @@ -99,8 +137,5 @@ namespace MathNet.Numerics.LinearAlgebra.Generic } #endif - - - } } diff --git a/src/Numerics/LinearAlgebra/Generic/Matrix.cs b/src/Numerics/LinearAlgebra/Generic/Matrix.cs index 66383f15..40ca0852 100644 --- a/src/Numerics/LinearAlgebra/Generic/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Generic/Matrix.cs @@ -28,16 +28,12 @@ // OTHER DEALINGS IN THE SOFTWARE. // - -using System.Globalization; - namespace MathNet.Numerics.LinearAlgebra.Generic { using System; using System.Collections.Generic; using System.Numerics; using System.Runtime; - using System.Text; using Factorization; using Numerics; using Properties; @@ -1440,43 +1436,5 @@ namespace MathNet.Numerics.LinearAlgebra.Generic { return Storage.ToRowMajorArray(); } - - /// - /// Returns a that represents this instance. - /// - /// - /// The format to use. - /// - /// - /// The format provider to use. - /// - /// - /// A that represents this instance. - /// - 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(); - } } } diff --git a/src/Numerics/LinearAlgebra/Generic/Vector.BCL.cs b/src/Numerics/LinearAlgebra/Generic/Vector.BCL.cs index 5248662c..befe51c3 100644 --- a/src/Numerics/LinearAlgebra/Generic/Vector.BCL.cs +++ b/src/Numerics/LinearAlgebra/Generic/Vector.BCL.cs @@ -32,6 +32,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; +using System.Text; using MathNet.Numerics.LinearAlgebra.Storage; using MathNet.Numerics.Properties; @@ -101,6 +102,35 @@ namespace MathNet.Numerics.LinearAlgebra.Generic return ToString(null, formatProvider); } + /// + /// Returns a that represents this instance. + /// + /// + /// The format to use. + /// + /// + /// An that supplies culture-specific formatting information. + /// + /// + /// A that represents this instance. + /// + 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 /// diff --git a/src/Numerics/LinearAlgebra/Generic/Vector.cs b/src/Numerics/LinearAlgebra/Generic/Vector.cs index 84254e58..bea0f281 100644 --- a/src/Numerics/LinearAlgebra/Generic/Vector.cs +++ b/src/Numerics/LinearAlgebra/Generic/Vector.cs @@ -28,16 +28,12 @@ // OTHER DEALINGS IN THE SOFTWARE. // - -using System.Globalization; - namespace MathNet.Numerics.LinearAlgebra.Generic { using System; using System.Collections; using System.Collections.Generic; using System.Runtime; - using System.Text; using Properties; using Storage; @@ -1295,35 +1291,5 @@ namespace MathNet.Numerics.LinearAlgebra.Generic { return Storage.EnumerateNonZero(); } - - /// - /// Returns a that represents this instance. - /// - /// - /// The format to use. - /// - /// - /// An that supplies culture-specific formatting information. - /// - /// - /// A that represents this instance. - /// - 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(); - } } }