|
|
@ -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
|
|
|
@ -42,20 +46,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets or sets test matrices values to use.
|
|
|
/// Gets or sets test matrices values to use.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
protected Dictionary<string, Complex32[,]> TestData2D |
|
|
protected Dictionary<string, Complex32[,]> TestData2D { get; set; } |
|
|
{ |
|
|
|
|
|
get; |
|
|
|
|
|
set; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets or sets test matrices instances to use.
|
|
|
/// Gets or sets test matrices instances to use.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
protected Dictionary<string, Matrix> TestMatrices |
|
|
protected Dictionary<string, Matrix> TestMatrices { get; set; } |
|
|
{ |
|
|
|
|
|
get; |
|
|
|
|
|
set; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Creates a matrix for the given number of rows and columns.
|
|
|
/// Creates a matrix for the given number of rows and columns.
|
|
|
@ -95,13 +91,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
{ |
|
|
{ |
|
|
TestData2D = new Dictionary<string, Complex32[,]> |
|
|
TestData2D = new Dictionary<string, Complex32[,]> |
|
|
{ |
|
|
{ |
|
|
{ "Singular3x3", new[,] { { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1) }, { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1) }, { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1) } } }, |
|
|
{"Singular3x3", new[,] {{new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1)}, {new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1)}, {new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1)}}}, |
|
|
{ "Square3x3", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1) }, { new Complex32(-4.4f, 1), new Complex32(5.5f, 1), new Complex32(6.6f, 1) } } }, |
|
|
{"Square3x3", new[,] {{new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1)}, {Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1)}, {new Complex32(-4.4f, 1), new Complex32(5.5f, 1), new Complex32(6.6f, 1)}}}, |
|
|
{ "Square4x4", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1), new Complex32(3.3f, 1) }, { new Complex32(1.0f, 1), new Complex32(2.1f, 1), new Complex32(6.2f, 1), new Complex32(4.3f, 1) }, { new Complex32(-4.4f, 1), new Complex32(5.5f, 1), new Complex32(6.6f, 1), new Complex32(-7.7f, 1) } } }, |
|
|
{"Square4x4", new[,] {{new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1)}, {Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1), new Complex32(3.3f, 1)}, {new Complex32(1.0f, 1), new Complex32(2.1f, 1), new Complex32(6.2f, 1), new Complex32(4.3f, 1)}, {new Complex32(-4.4f, 1), new Complex32(5.5f, 1), new Complex32(6.6f, 1), new Complex32(-7.7f, 1)}}}, |
|
|
{ "Singular4x4", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) } } }, |
|
|
{"Singular4x4", new[,] {{new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1)}, {new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1)}, {new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1)}, {new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1)}}}, |
|
|
{ "Tall3x2", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1) }, { new Complex32(-4.4f, 1), new Complex32(5.5f, 1) } } }, |
|
|
{"Tall3x2", new[,] {{new Complex32(-1.1f, 1), new Complex32(-2.2f, 1)}, {Complex32.Zero, new Complex32(1.1f, 1)}, {new Complex32(-4.4f, 1), new Complex32(5.5f, 1)}}}, |
|
|
{ "Wide2x3", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1) } } }, |
|
|
{"Wide2x3", new[,] {{new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1)}, {Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1)}}}, |
|
|
{ "Symmetric3x3", new[,] { { Complex32.One, 2.0f, 3.0f }, { 2.0f, 2.0f, 0.0f }, { 3.0f, 0.0f, 3.0f } } } |
|
|
{"Symmetric3x3", new[,] {{Complex32.One, 2.0f, 3.0f}, {2.0f, 2.0f, 0.0f}, {3.0f, 0.0f, 3.0f}}} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
TestMatrices = new Dictionary<string, Matrix>(); |
|
|
TestMatrices = new Dictionary<string, Matrix>(); |
|
|
@ -129,7 +125,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
{ |
|
|
{ |
|
|
for (var j = 0; j < col; j++) |
|
|
for (var j = 0; j < col; j++) |
|
|
{ |
|
|
{ |
|
|
matrixA[i, j] = new Complex32((float)normal.Sample(), (float)normal.Sample()); |
|
|
matrixA[i, j] = new Complex32((float) normal.Sample(), (float) normal.Sample()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -153,12 +149,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
{ |
|
|
{ |
|
|
for (var j = 0; j < order; j++) |
|
|
for (var j = 0; j < order; j++) |
|
|
{ |
|
|
{ |
|
|
matrixA[i, j] = new Complex32((float)normal.Sample(), (float)normal.Sample()); |
|
|
matrixA[i, j] = new Complex32((float) normal.Sample(), (float) normal.Sample()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Generate a Hermitian matrix which is positive definite.
|
|
|
// Generate a Hermitian matrix which is positive definite.
|
|
|
return matrixA.ConjugateTranspose() * matrixA; |
|
|
return matrixA.ConjugateTranspose()*matrixA; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
@ -176,7 +172,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
var v = new DenseVector(order); |
|
|
var v = new DenseVector(order); |
|
|
for (var i = 0; i < order; i++) |
|
|
for (var i = 0; i < order; i++) |
|
|
{ |
|
|
{ |
|
|
v[i] = new Complex32((float)normal.Sample(), (float)normal.Sample()); |
|
|
v[i] = new Complex32((float) normal.Sample(), (float) normal.Sample()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return v; |
|
|
return v; |
|
|
@ -200,7 +196,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
{ |
|
|
{ |
|
|
for (var j = 0; j < col; j++) |
|
|
for (var j = 0; j < col; j++) |
|
|
{ |
|
|
{ |
|
|
matrixA[i, j] = new Complex32((float)normal.Sample(), (float)normal.Sample()); |
|
|
matrixA[i, j] = new Complex32((float) normal.Sample(), (float) normal.Sample()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -224,12 +220,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
{ |
|
|
{ |
|
|
for (var j = 0; j < order; j++) |
|
|
for (var j = 0; j < order; j++) |
|
|
{ |
|
|
{ |
|
|
matrixA[i, j] = new Complex32((float)normal.Sample(), (float)normal.Sample()); |
|
|
matrixA[i, j] = new Complex32((float) normal.Sample(), (float) normal.Sample()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Generate a Hermitian matrix which is positive definite.
|
|
|
// Generate a Hermitian matrix which is positive definite.
|
|
|
return matrixA.ConjugateTranspose() * matrixA; |
|
|
return matrixA.ConjugateTranspose()*matrixA; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
@ -247,7 +243,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
var v = new UserDefinedVector(order); |
|
|
var v = new UserDefinedVector(order); |
|
|
for (var i = 0; i < order; i++) |
|
|
for (var i = 0; i < order; i++) |
|
|
{ |
|
|
{ |
|
|
v[i] = new Complex32((float)normal.Sample(), (float)normal.Sample()); |
|
|
v[i] = new Complex32((float) normal.Sample(), (float) normal.Sample()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Generate a matrix which is positive definite.
|
|
|
// Generate a matrix which is positive definite.
|
|
|
|