diff --git a/src/Numerics/LinearAlgebra/Complex/IO/DelimitedWriter.cs b/src/Numerics/LinearAlgebra/Complex/IO/DelimitedWriter.cs
deleted file mode 100644
index 1a4627d7..00000000
--- a/src/Numerics/LinearAlgebra/Complex/IO/DelimitedWriter.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-//
-// 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.
-//
-
-namespace MathNet.Numerics.LinearAlgebra.Complex.IO
-{
- using Generic;
- using LinearAlgebra.IO;
-
- ///
- /// Writes an to delimited text file. If the user does not
- /// specify a delimiter, a tab separator is used.
- ///
- public class DelimitedWriter : DelimitedWriter
- {
- ///
- /// Initializes a new instance of the class.
- /// a comma as the delimiter.
- ///
- public DelimitedWriter()
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- /// using the given delimiter.
- ///
- ///
- /// the delimiter to use.
- ///
- public DelimitedWriter(char delimiter) : base(delimiter)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- /// using the given delimiter.
- ///
- ///
- /// the delimiter to use.
- ///
- public DelimitedWriter(string delimiter) : base(delimiter)
- {
- }
- }
-}
diff --git a/src/Numerics/LinearAlgebra/Complex32/IO/DelimitedWriter.cs b/src/Numerics/LinearAlgebra/Complex32/IO/DelimitedWriter.cs
deleted file mode 100644
index 1a7906a2..00000000
--- a/src/Numerics/LinearAlgebra/Complex32/IO/DelimitedWriter.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-//
-// 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.
-//
-
-namespace MathNet.Numerics.LinearAlgebra.Complex32.IO
-{
- using Generic;
- using LinearAlgebra.IO;
-
- ///
- /// Writes an to delimited text file. If the user does not
- /// specify a delimiter, a tab separator is used.
- ///
- public class DelimitedWriter : DelimitedWriter
- {
- ///
- /// Initializes a new instance of the class.
- /// a comma as the delimiter.
- ///
- public DelimitedWriter()
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- /// using the given delimiter.
- ///
- ///
- /// the delimiter to use.
- ///
- public DelimitedWriter(char delimiter) : base(delimiter)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- /// using the given delimiter.
- ///
- ///
- /// the delimiter to use.
- ///
- public DelimitedWriter(string delimiter) : base(delimiter)
- {
- }
- }
-}
diff --git a/src/Numerics/LinearAlgebra/Double/IO/DelimitedWriter.cs b/src/Numerics/LinearAlgebra/Double/IO/DelimitedWriter.cs
deleted file mode 100644
index a2f8eb5f..00000000
--- a/src/Numerics/LinearAlgebra/Double/IO/DelimitedWriter.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-//
-// 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.
-//
-
-namespace MathNet.Numerics.LinearAlgebra.Double.IO
-{
- using Generic;
- using LinearAlgebra.IO;
-
- ///
- /// Writes an to delimited text file. If the user does not
- /// specify a delimiter, a tab separator is used.
- ///
- public class DelimitedWriter : DelimitedWriter
- {
- ///
- /// Initializes a new instance of the class.
- /// a comma as the delimiter.
- ///
- public DelimitedWriter()
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- /// using the given delimiter.
- ///
- ///
- /// the delimiter to use.
- ///
- public DelimitedWriter(char delimiter) : base(delimiter)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- /// using the given delimiter.
- ///
- ///
- /// the delimiter to use.
- ///
- public DelimitedWriter(string delimiter) : base(delimiter)
- {
- }
- }
-}
diff --git a/src/Numerics/LinearAlgebra/IO/DelimitedWriter.cs b/src/Numerics/LinearAlgebra/IO/DelimitedWriter.cs
index 47ea5290..b72cdd80 100644
--- a/src/Numerics/LinearAlgebra/IO/DelimitedWriter.cs
+++ b/src/Numerics/LinearAlgebra/IO/DelimitedWriter.cs
@@ -38,8 +38,7 @@ namespace MathNet.Numerics.LinearAlgebra.IO
/// Writes an to delimited text file. If the user does not
/// specify a delimiter, a tab separator is used.
///
- /// The data type of the matrix.
- public class DelimitedWriter : MatrixWriter where TDataType : struct, IEquatable, IFormattable
+ public class DelimitedWriter : MatrixWriter
{
///
/// The delimiter to use.
@@ -47,12 +46,7 @@ namespace MathNet.Numerics.LinearAlgebra.IO
private readonly string _delimiter;
///
- /// The to use.
- ///
- private CultureInfo _cultureInfo = CultureInfo.CurrentCulture;
-
- ///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
/// a comma as the delimiter.
///
public DelimitedWriter()
@@ -61,7 +55,7 @@ namespace MathNet.Numerics.LinearAlgebra.IO
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
/// using the given delimiter.
///
///
@@ -73,7 +67,7 @@ namespace MathNet.Numerics.LinearAlgebra.IO
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
/// using the given delimiter.
///
///
@@ -95,35 +89,16 @@ namespace MathNet.Numerics.LinearAlgebra.IO
set;
}
- ///
- /// Gets or sets the to use when parsing the numbers.
- ///
- /// The culture info.
- /// Defaults to CultureInfo.CurrentCulture.
- public CultureInfo CultureInfo
- {
- get
- {
- return _cultureInfo;
- }
-
- set
- {
- if (value != null)
- {
- _cultureInfo = value;
- }
- }
- }
-
///
/// Writes the given to the given .
///
+ /// The data type of the Matrix. It can be either: double, float, Complex, or Complex32.
/// The matrix to write.
/// The to write the matrix to.
- /// The format to use on each element.
+ /// The number format to use on each element.
+ /// The culture to use.
/// If either or is null.
- protected override void DoWriteMatrix(Matrix matrix, TextWriter writer, string format)
+ protected override void DoWriteMatrix(Matrix matrix, TextWriter writer, string format, CultureInfo cultureInfo)
{
if (matrix == null)
{
@@ -152,7 +127,7 @@ namespace MathNet.Numerics.LinearAlgebra.IO
{
for (var j = 0; j < matrix.ColumnCount; j++)
{
- writer.Write(matrix[i, j].ToString(format, _cultureInfo));
+ writer.Write(matrix[i, j].ToString(format, cultureInfo));
if (j != cols)
{
writer.Write(_delimiter);
diff --git a/src/Numerics/LinearAlgebra/IO/MatrixWriter.cs b/src/Numerics/LinearAlgebra/IO/MatrixWriter.cs
index e955034b..3dd7f46a 100644
--- a/src/Numerics/LinearAlgebra/IO/MatrixWriter.cs
+++ b/src/Numerics/LinearAlgebra/IO/MatrixWriter.cs
@@ -31,48 +31,61 @@ using System.IO;
namespace MathNet.Numerics.LinearAlgebra.IO
{
+ using System.Globalization;
using Generic;
///
/// Base class to write a single to a file or stream.
///
- /// The data type of the matrix.
- public abstract class MatrixWriter where TDataType : struct, IEquatable, IFormattable
+ public abstract class MatrixWriter
{
///
- /// Writes the given to the given file. If the file already exists,
- /// the file will be overwritten.
+ /// The to use.
///
- /// The matrix to write.
- /// The file to write the matrix to.
- /// If either or is null.
- public void WriteMatrix(Matrix matrix, string file)
- {
- if (matrix == null)
- {
- throw new ArgumentNullException("matrix");
- }
+ private CultureInfo _cultureInfo = CultureInfo.CurrentCulture;
- if (file == null)
+ ///
+ /// Gets or sets the to use when parsing the numbers.
+ ///
+ /// The culture info.
+ /// Defaults to CultureInfo.CurrentCulture.
+ /// This property is only used for matrix writers that write out text files.
+ public CultureInfo CultureInfo
+ {
+ get
{
- throw new ArgumentNullException("file");
+ return _cultureInfo;
}
- using (var writer = new StreamWriter(file))
+ set
{
- DoWriteMatrix(matrix, writer, null);
+ if (value != null)
+ {
+ _cultureInfo = value;
+ }
}
}
+ ///
+ /// Gets or sets he number format to use.
+ ///
+ /// The number format to use when writing out each element.
+ /// This property is only used for matrix writers that write out text files.
+ public string Format
+ {
+ get;
+ set;
+ }
+
///
/// Writes the given to the given file. If the file already exists,
/// the file will be overwritten.
///
- /// the matrix to write.
+ /// The matrix to write.
/// The file to write the matrix to.
- /// The format to use on each element.
/// If either or is null.
- public void WriteMatrix(Matrix matrix, string file, string format)
+ /// The data type of the Matrix. It can be either: double, float, Complex, or Complex32.
+ public void WriteMatrix(Matrix matrix, string file) where TDataType : struct, IEquatable, IFormattable
{
if (matrix == null)
{
@@ -84,14 +97,9 @@ namespace MathNet.Numerics.LinearAlgebra.IO
throw new ArgumentNullException("file");
}
- if (File.Exists(file))
- {
- File.Delete(file);
- }
-
using (var writer = new StreamWriter(file))
{
- DoWriteMatrix(matrix, writer, format);
+ DoWriteMatrix(matrix, writer, Format, _cultureInfo);
}
}
@@ -101,32 +109,8 @@ namespace MathNet.Numerics.LinearAlgebra.IO
/// The matrix to write.
/// The to write the matrix to.
/// If either or is null.
- public void WriteMatrix(Matrix matrix, Stream stream)
- {
- if (matrix == null)
- {
- throw new ArgumentNullException("matrix");
- }
-
- if (stream == null)
- {
- throw new ArgumentNullException("stream");
- }
-
- using (var writer = new StreamWriter(stream))
- {
- DoWriteMatrix(matrix, writer, null);
- }
- }
-
- ///
- /// Writes the given to the given stream.
- ///
- /// The to write.
- /// The to write the matrix to.
- /// The format to use on each element.
- /// If either or is null.
- public void WriteMatrix(Matrix matrix, Stream stream, string format)
+ /// The data type of the Matrix. It can be either: double, float, Complex, or Complex32.
+ public void WriteMatrix(Matrix matrix, Stream stream) where TDataType : struct, IEquatable, IFormattable
{
if (matrix == null)
{
@@ -140,29 +124,8 @@ namespace MathNet.Numerics.LinearAlgebra.IO
using (var writer = new StreamWriter(stream))
{
- DoWriteMatrix(matrix, writer, format);
- }
- }
-
- ///
- /// Writes the given to the given .
- ///
- /// The matrix to write.
- /// The to write the matrix to.
- /// If either or is null.
- public void WriteMatrix(Matrix matrix, TextWriter writer)
- {
- if (matrix == null)
- {
- throw new ArgumentNullException("matrix");
- }
-
- if (writer == null)
- {
- throw new ArgumentNullException("writer");
+ DoWriteMatrix(matrix, writer, Format, _cultureInfo);
}
-
- DoWriteMatrix(matrix, writer, null);
}
///
@@ -170,9 +133,9 @@ namespace MathNet.Numerics.LinearAlgebra.IO
///
/// The matrix to write.
/// The to write the matrix to.
- /// The format to use on each element.
/// If either or is null.
- public void WriteMatrix(Matrix matrix, TextWriter writer, string format)
+ /// The data type of the Matrix. It can be either: double, float, Complex, or Complex32.
+ public void WriteMatrix(Matrix matrix, TextWriter writer) where TDataType : struct, IEquatable, IFormattable
{
if (matrix == null)
{
@@ -184,15 +147,17 @@ namespace MathNet.Numerics.LinearAlgebra.IO
throw new ArgumentNullException("writer");
}
- DoWriteMatrix(matrix, writer, format);
+ DoWriteMatrix(matrix, writer, Format, _cultureInfo);
}
///
/// Subclasses must implement this method to do the actually writing.
///
+ /// The data type of the Matrix. It can be either: double, float, Complex, or Complex32.
/// The matrix to serialize.
/// The to write the matrix to.
- /// The format for the new matrix.
- protected abstract void DoWriteMatrix(Matrix matrix, TextWriter writer, string format);
+ /// The number format to use.
+ /// The culture to use.
+ protected abstract void DoWriteMatrix(Matrix matrix, TextWriter writer, string format, CultureInfo cultureInfo) where TDataType : struct, IEquatable, IFormattable;
}
}
diff --git a/src/Numerics/LinearAlgebra/Single/IO/DelimitedWriter.cs b/src/Numerics/LinearAlgebra/Single/IO/DelimitedWriter.cs
deleted file mode 100644
index f674105e..00000000
--- a/src/Numerics/LinearAlgebra/Single/IO/DelimitedWriter.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-//
-// 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.
-//
-
-namespace MathNet.Numerics.LinearAlgebra.Single.IO
-{
- using Generic;
- using LinearAlgebra.IO;
-
- ///
- /// Writes an to delimited text file. If the user does not
- /// specify a delimiter, a tab separator is used.
- ///
- public class DelimitedWriter : DelimitedWriter
- {
- ///
- /// Initializes a new instance of the class.
- /// a comma as the delimiter.
- ///
- public DelimitedWriter()
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- /// using the given delimiter.
- ///
- ///
- /// the delimiter to use.
- ///
- public DelimitedWriter(char delimiter) : base(delimiter)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- /// using the given delimiter.
- ///
- ///
- /// the delimiter to use.
- ///
- public DelimitedWriter(string delimiter) : base(delimiter)
- {
- }
- }
-}
diff --git a/src/Numerics/Numerics.csproj b/src/Numerics/Numerics.csproj
index 69b512d3..48affc99 100644
--- a/src/Numerics/Numerics.csproj
+++ b/src/Numerics/Numerics.csproj
@@ -107,7 +107,6 @@
-
@@ -123,7 +122,6 @@
-
@@ -135,7 +133,6 @@
-
@@ -238,7 +235,6 @@
-
diff --git a/src/UnitTests/LinearAlgebraTests/Complex/IO/DelimitedWriterTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/IO/DelimitedWriterTests.cs
index 0f786e5d..c25d34df 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex/IO/DelimitedWriterTests.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex/IO/DelimitedWriterTests.cs
@@ -5,7 +5,7 @@
using System.Numerics;
using System.IO;
using LinearAlgebra.Complex;
- using LinearAlgebra.Complex.IO;
+ using LinearAlgebra.IO;
using MbUnit.Framework;
[TestFixture]
diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/IO/DelimitedWriterTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/IO/DelimitedWriterTests.cs
index 96bd027d..74eee8c9 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex32/IO/DelimitedWriterTests.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex32/IO/DelimitedWriterTests.cs
@@ -4,7 +4,7 @@
using System.Globalization;
using System.IO;
using LinearAlgebra.Complex32;
- using LinearAlgebra.Complex32.IO;
+ using LinearAlgebra.IO;
using Numerics;
using MbUnit.Framework;
diff --git a/src/UnitTests/LinearAlgebraTests/Double/IO/DelimitedWriterTests.cs b/src/UnitTests/LinearAlgebraTests/Double/IO/DelimitedWriterTests.cs
index a07e2aaf..fa90ce18 100644
--- a/src/UnitTests/LinearAlgebraTests/Double/IO/DelimitedWriterTests.cs
+++ b/src/UnitTests/LinearAlgebraTests/Double/IO/DelimitedWriterTests.cs
@@ -4,7 +4,7 @@
using System.Globalization;
using System.IO;
using LinearAlgebra.Double;
- using LinearAlgebra.Double.IO;
+ using LinearAlgebra.IO;
using MbUnit.Framework;
[TestFixture]
diff --git a/src/UnitTests/LinearAlgebraTests/Single/IO/DelimitedWriterTests.cs b/src/UnitTests/LinearAlgebraTests/Single/IO/DelimitedWriterTests.cs
index 42c5e526..e49a567e 100644
--- a/src/UnitTests/LinearAlgebraTests/Single/IO/DelimitedWriterTests.cs
+++ b/src/UnitTests/LinearAlgebraTests/Single/IO/DelimitedWriterTests.cs
@@ -3,8 +3,8 @@
using System;
using System.Globalization;
using System.IO;
+ using LinearAlgebra.IO;
using LinearAlgebra.Single;
- using LinearAlgebra.Single.IO;
using MbUnit.Framework;
[TestFixture]