|
|
|
@ -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
|
|
|
|
@ -26,10 +30,10 @@ |
|
|
|
|
|
|
|
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
|
{ |
|
|
|
using System; |
|
|
|
using System.Globalization; |
|
|
|
using LinearAlgebra.Complex32; |
|
|
|
using NUnit.Framework; |
|
|
|
using System; |
|
|
|
using System.Globalization; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sparse vector text handling tests.
|
|
|
|
@ -43,20 +47,20 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
|
/// <param name="expectedToString">Expected result.</param>
|
|
|
|
[TestCase("2", "(2, 0)")] |
|
|
|
[TestCase("(3)", "(3, 0)")] |
|
|
|
[TestCase("[1,2,3]", "(1, 0),(2, 0),(3, 0)")]
|
|
|
|
[TestCase(" [ 1.1 , 2.1 , 3.1 ] ", "(1.1, 0),(2.1, 0),(3.1, 0)")]
|
|
|
|
[TestCase(" [ -1.1 , 2.1 , +3.1 ] ", "(-1.1, 0),(2.1, 0),(3.1, 0)")]
|
|
|
|
[TestCase(" [1.2,3.4 , 5.6] ", "(1.2, 0),(3.4, 0),(5.6, 0)")]
|
|
|
|
[TestCase("[1+1i,2+1i,3+1i]", "(1, 1),(2, 1),(3, 1)")]
|
|
|
|
[TestCase(" [ 1.1 + 1i , 2.1+1i , 3.1+1i ] ", "(1.1, 1),(2.1, 1),(3.1, 1)")]
|
|
|
|
[TestCase(" [ -1.1 + 1i , 2.1-1i , +3.1+1i ] ", "(-1.1, 1),(2.1, -1),(3.1, 1)")]
|
|
|
|
[TestCase(" [1.2+2.3i ,3.4+4.5i , 5.6+ 6.7i] ", "(1.2, 2.3),(3.4, 4.5),(5.6, 6.7)")]
|
|
|
|
[TestCase("[1,2,3]", "(1, 0) (2, 0) (3, 0)")]
|
|
|
|
[TestCase(" [ 1.1 , 2.1 , 3.1 ] ", "(1.1, 0) (2.1, 0) (3.1, 0)")]
|
|
|
|
[TestCase(" [ -1.1 , 2.1 , +3.1 ] ", "(-1.1, 0) (2.1, 0) (3.1, 0)")]
|
|
|
|
[TestCase(" [1.2,3.4 , 5.6] ", "(1.2, 0) (3.4, 0) (5.6, 0)")]
|
|
|
|
[TestCase("[1+1i,2+1i,3+1i]", "(1, 1) (2, 1) (3, 1)")]
|
|
|
|
[TestCase(" [ 1.1 + 1i , 2.1+1i , 3.1+1i ] ", "(1.1, 1) (2.1, 1) (3.1, 1)")]
|
|
|
|
[TestCase(" [ -1.1 + 1i , 2.1-1i , +3.1+1i ] ", "(-1.1, 1) (2.1, -1) (3.1, 1)")]
|
|
|
|
[TestCase(" [1.2+2.3i ,3.4+4.5i , 5.6+ 6.7i] ", "(1.2, 2.3) (3.4, 4.5) (5.6, 6.7)")]
|
|
|
|
public void CanParseComplex32SparseVectorsWithInvariant(string stringToParse, string expectedToString) |
|
|
|
{ |
|
|
|
var formatProvider = CultureInfo.InvariantCulture; |
|
|
|
var vector = SparseVector.Parse(stringToParse, formatProvider); |
|
|
|
|
|
|
|
Assert.AreEqual(expectedToString, vector.ToString(formatProvider)); |
|
|
|
Assert.AreEqual(expectedToString, vector.ToVectorString(1, int.MaxValue, 1, "G", formatProvider)); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -65,17 +69,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
|
/// <param name="stringToParse">String to parse.</param>
|
|
|
|
/// <param name="expectedToString">Expected result.</param>
|
|
|
|
/// <param name="culture">Culture name.</param>
|
|
|
|
[TestCase(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", "(1.2, 1),(3.4, 1),(5.6, 1)", "en-US")] |
|
|
|
[TestCase(" 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", "(1.2, 1);(3.4, 1);(5.6, 1)", "de-CH")] |
|
|
|
[TestCase(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", "(1.2, 1) (3.4, 1) (5.6, 1)", "en-US")] |
|
|
|
[TestCase(" 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", "(1.2, 1) (3.4, 1) (5.6, 1)", "de-CH")] |
|
|
|
#if !PORTABLE
|
|
|
|
[TestCase(" 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ", "(1,2, 1);(3,4, 1);(5,6, 1)", "de-DE")] |
|
|
|
[TestCase(" 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ", "(1,2, 1) (3,4, 1) (5,6, 1)", "de-DE")] |
|
|
|
#endif
|
|
|
|
public void CanParseComplex32SparseVectorsWithCulture(string stringToParse, string expectedToString, string culture) |
|
|
|
{ |
|
|
|
var formatProvider = new CultureInfo(culture); |
|
|
|
var vector = SparseVector.Parse(stringToParse, formatProvider); |
|
|
|
|
|
|
|
Assert.AreEqual(expectedToString, vector.ToString(formatProvider)); |
|
|
|
Assert.AreEqual(expectedToString, vector.ToVectorString(1, int.MaxValue, 1, "G", formatProvider)); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -95,11 +99,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
|
[TestCase(null)] |
|
|
|
[TestCase("")] |
|
|
|
[TestCase(",")] |
|
|
|
[TestCase("1,")] |
|
|
|
[TestCase(",1")] |
|
|
|
[TestCase("1,2,")] |
|
|
|
[TestCase(",1,2,")] |
|
|
|
[TestCase("1,,2,,3")] |
|
|
|
[TestCase("1e+")] |
|
|
|
[TestCase("1e")] |
|
|
|
[TestCase("()")] |
|
|
|
|