|
|
|
@ -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
|
|
|
|
@ -42,20 +46,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets test matrices values to use.
|
|
|
|
/// </summary>
|
|
|
|
protected Dictionary<string, Complex32[,]> TestData2D |
|
|
|
{ |
|
|
|
get; |
|
|
|
set; |
|
|
|
} |
|
|
|
protected Dictionary<string, Complex32[,]> TestData2D { get; set; } |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets test matrices instances to use.
|
|
|
|
/// </summary>
|
|
|
|
protected Dictionary<string, Matrix> TestMatrices |
|
|
|
{ |
|
|
|
get; |
|
|
|
set; |
|
|
|
} |
|
|
|
protected Dictionary<string, Matrix> TestMatrices { get; set; } |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a matrix for the given number of rows and columns.
|
|
|
|
@ -94,15 +90,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
|
public virtual void SetupMatrices() |
|
|
|
{ |
|
|
|
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) } } }, |
|
|
|
{ "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) } } }, |
|
|
|
{ "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) } } }, |
|
|
|
{ "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 } } } |
|
|
|
}; |
|
|
|
{ |
|
|
|
{"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)}}}, |
|
|
|
{"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)}}}, |
|
|
|
{"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)}}}, |
|
|
|
{"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>(); |
|
|
|
foreach (var name in TestData2D.Keys) |
|
|
|
@ -121,15 +117,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
|
{ |
|
|
|
// Fill a matrix with standard random numbers.
|
|
|
|
var normal = new Normal |
|
|
|
{ |
|
|
|
RandomSource = new MersenneTwister(1) |
|
|
|
}; |
|
|
|
{ |
|
|
|
RandomSource = new MersenneTwister(1) |
|
|
|
}; |
|
|
|
var matrixA = new DenseMatrix(row, col); |
|
|
|
for (var i = 0; i < row; i++) |
|
|
|
{ |
|
|
|
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()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -145,20 +141,20 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
|
{ |
|
|
|
// Fill a matrix with standard random numbers.
|
|
|
|
var normal = new Normal |
|
|
|
{ |
|
|
|
RandomSource = new MersenneTwister(1) |
|
|
|
}; |
|
|
|
{ |
|
|
|
RandomSource = new MersenneTwister(1) |
|
|
|
}; |
|
|
|
var matrixA = new DenseMatrix(order); |
|
|
|
for (var i = 0; i < order; i++) |
|
|
|
{ |
|
|
|
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.
|
|
|
|
return matrixA.ConjugateTranspose() * matrixA; |
|
|
|
return matrixA.ConjugateTranspose()*matrixA; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -170,13 +166,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
|
{ |
|
|
|
// Fill a matrix with standard random numbers.
|
|
|
|
var normal = new Normal |
|
|
|
{ |
|
|
|
RandomSource = new MersenneTwister(1) |
|
|
|
}; |
|
|
|
{ |
|
|
|
RandomSource = new MersenneTwister(1) |
|
|
|
}; |
|
|
|
var v = new DenseVector(order); |
|
|
|
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; |
|
|
|
@ -192,15 +188,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
|
{ |
|
|
|
// Fill a matrix with standard random numbers.
|
|
|
|
var normal = new Normal |
|
|
|
{ |
|
|
|
RandomSource = new MersenneTwister(1) |
|
|
|
}; |
|
|
|
{ |
|
|
|
RandomSource = new MersenneTwister(1) |
|
|
|
}; |
|
|
|
var matrixA = new UserDefinedMatrix(row, col); |
|
|
|
for (var i = 0; i < row; i++) |
|
|
|
{ |
|
|
|
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()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -216,20 +212,20 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
|
{ |
|
|
|
// Fill a matrix with standard random numbers.
|
|
|
|
var normal = new Normal |
|
|
|
{ |
|
|
|
RandomSource = new MersenneTwister(1) |
|
|
|
}; |
|
|
|
{ |
|
|
|
RandomSource = new MersenneTwister(1) |
|
|
|
}; |
|
|
|
var matrixA = new UserDefinedMatrix(order); |
|
|
|
for (var i = 0; i < order; i++) |
|
|
|
{ |
|
|
|
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.
|
|
|
|
return matrixA.ConjugateTranspose() * matrixA; |
|
|
|
return matrixA.ConjugateTranspose()*matrixA; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -241,13 +237,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
|
{ |
|
|
|
// Fill a matrix with standard random numbers.
|
|
|
|
var normal = new Normal |
|
|
|
{ |
|
|
|
RandomSource = new MersenneTwister(1) |
|
|
|
}; |
|
|
|
{ |
|
|
|
RandomSource = new MersenneTwister(1) |
|
|
|
}; |
|
|
|
var v = new UserDefinedVector(order); |
|
|
|
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.
|
|
|
|
|