Browse Source

native: added unit tests for other data types and a bunch of bug fixes

pull/36/head
Marcus Cuda 15 years ago
parent
commit
404e4c6ec2
  1. 8
      src/NativeWrappers/Common/blas.c
  2. 110
      src/NativeWrappers/MKL/lapack.cpp
  3. 51
      src/NativeWrappers/Windows/MKLWrapper32Tests/LinearAlgebra/Complex/MklLinearAlgebraProviderTests.cs
  4. 51
      src/NativeWrappers/Windows/MKLWrapper32Tests/LinearAlgebra/Complex32/MklLinearAlgebraProviderTests.cs
  5. 2
      src/NativeWrappers/Windows/MKLWrapper32Tests/LinearAlgebra/Double/MklLinearAlgebraProviderTests.cs
  6. 51
      src/NativeWrappers/Windows/MKLWrapper32Tests/LinearAlgebra/Single/MklLinearAlgebraProviderTests.cs
  7. 13
      src/NativeWrappers/Windows/MKLWrapper32Tests/MKLWrapper32Tests.csproj
  8. 4
      src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs
  9. 9
      src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs
  10. 5
      src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs
  11. 2
      src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.tt
  12. 2
      src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.tt
  13. 2
      src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.tt
  14. 2
      src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.float.tt
  15. 8
      src/Numerics/Algorithms/LinearAlgebra/native.generic.include
  16. 12
      src/Numerics/Algorithms/LinearAlgebra/safe.native.common.include
  17. 81
      src/Numerics/ArrayExtensions.cs
  18. 1
      src/Numerics/Numerics.csproj
  19. 3
      src/Silverlight/Silverlight.csproj
  20. 1368
      src/UnitTests/LinearAlgebraProviderTests/Complex/LinearAlgebraProviderTests.cs
  21. 1376
      src/UnitTests/LinearAlgebraProviderTests/Complex32/LinearAlgebraProviderTests.cs
  22. 151
      src/UnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs
  23. 1375
      src/UnitTests/LinearAlgebraProviderTests/Single/LinearAlgebraProviderTests.cs
  24. 3
      src/UnitTests/UnitTests.csproj

8
src/NativeWrappers/Common/blas.c

@ -1,19 +1,19 @@
#include "blas.h"
#include "common.h"
DLLEXPORT void s_axpy( const int n, const float alpha, const float x[], float y[]){
DLLEXPORT void s_axpy(const int n, const float alpha, const float x[], float y[]){
cblas_saxpy(n, alpha, x, 1, y, 1);
}
DLLEXPORT void d_axpy( const int n, const double alpha, const double x[], double y[]){
DLLEXPORT void d_axpy(const int n, const double alpha, const double x[], double y[]){
cblas_daxpy(n, alpha, x, 1, y, 1);
}
DLLEXPORT void c_axpy( const int n, const Complex8 alpha, const Complex8 x[], Complex8 y[]){
DLLEXPORT void c_axpy(const int n, const Complex8 alpha, const Complex8 x[], Complex8 y[]){
cblas_caxpy(n, &alpha, x, 1, y, 1);
}
DLLEXPORT void z_axpy( const int n, const Complex16 alpha, const Complex16 x[], Complex16 y[]){
DLLEXPORT void z_axpy(const int n, const Complex16 alpha, const Complex16 x[], Complex16 y[]){
cblas_zaxpy(n, &alpha, x, 1, y, 1);
}

110
src/NativeWrappers/MKL/lapack.cpp

@ -2,7 +2,7 @@
#include "blas.h"
#include "mkl_lapack.h"
#include <string>
#include <algorithm>
extern "C" {
@ -87,12 +87,12 @@ extern "C" {
int* ipiv = new int[n];
int info = 0;
DGETRF(&n,&n,a,&n,ipiv,&info);
if (info != 0){
delete[] ipiv;
return info;
}
DGETRI(&n,a,&n,ipiv,work,&lwork,&info);
delete[] ipiv;
return info;
@ -200,7 +200,7 @@ extern "C" {
for(i = 0; i < n; ++i ){
ipiv[i] += 1;
}
char trans ='N';
SGETRS(&trans, &n, &nrhs, a, &n, ipiv, b, &n, &info);
for(i = 0; i < n; ++i ){
@ -283,7 +283,7 @@ extern "C" {
{
double* clone = new double[n*n];
std::memcpy(clone, a, n*n*sizeof(double));
int* ipiv = new int[n];
int info = 0;
DGETRF(&n, &n, clone, &n, ipiv, &info);
@ -305,11 +305,11 @@ extern "C" {
{
MKL_Complex8* clone = new MKL_Complex8[n*n];
std::memcpy(clone, a, n*n*sizeof(MKL_Complex8));
int* ipiv = new int[n];
int info = 0;
CGETRF(&n, &n, clone, &n, ipiv, &info);
if (info != 0){
delete[] ipiv;
delete[] clone;
@ -327,7 +327,7 @@ extern "C" {
{
MKL_Complex16* clone = new MKL_Complex16[n*n];
std::memcpy(clone, a, n*n*sizeof(MKL_Complex16));
int* ipiv = new int[n];
int info = 0;
ZGETRF(&n, &n, clone, &n, ipiv, &info);
@ -418,7 +418,7 @@ extern "C" {
char uplo = 'L';
int info = 0;
SPOTRF(&uplo, &n, clone, &n, &info);
if (info != 0){
delete[] clone;
return info;
@ -435,7 +435,7 @@ extern "C" {
char uplo = 'L';
int info = 0;
DPOTRF(&uplo, &n, clone, &n, &info);
if (info != 0){
delete[] clone;
return info;
@ -452,7 +452,7 @@ extern "C" {
char uplo = 'L';
int info = 0;
CPOTRF(&uplo, &n, clone, &n, &info);
if (info != 0){
delete[] clone;
return info;
@ -469,7 +469,7 @@ extern "C" {
char uplo = 'L';
int info = 0;
ZPOTRF(&uplo, &n, clone, &n, &info);
if (info != 0){
delete[] clone;
return info;
@ -573,7 +573,7 @@ extern "C" {
{
int info = 0;
CGEQRF(&m, &n, r, &m, tau, work, &len, &info);
for (int i = 0; i < m; ++i)
{
for (int j = 0; j < m && j < n; ++j)
@ -632,7 +632,7 @@ extern "C" {
int info = 0;
float* clone_r = new float[m*n];
std::memcpy(clone_r, r, m*n*sizeof(float));
float* tau = new float[std::max(1, std::min(m,n))];
SGEQRF(&m, &n, clone_r, &m, tau, work, &len, &info);
@ -669,7 +669,7 @@ extern "C" {
int info = 0;
double* clone_r = new double[m*n];
std::memcpy(clone_r, r, m*n*sizeof(double));
double* tau = new double[std::max(1, std::min(m,n))];
DGEQRF(&m, &n, clone_r, &m, tau, work, &len, &info);
@ -679,7 +679,7 @@ extern "C" {
delete[] tau;
return info;
}
double* clone_b = new double[m*bn];
std::memcpy(clone_b, b, m*bn*sizeof(double));
@ -708,7 +708,7 @@ extern "C" {
MKL_Complex8* clone_r = new MKL_Complex8[m*n];
std::memcpy(clone_r, r, m*n*sizeof(MKL_Complex8));
MKL_Complex8* tau = new MKL_Complex8[std::max(1, std::min(m,n))];
MKL_Complex8* tau = new MKL_Complex8[std::min(m,n)];
CGEQRF(&m, &n, clone_r, &m, tau, work, &len, &info);
if (info != 0)
@ -718,15 +718,16 @@ extern "C" {
return info;
}
char side ='L';
char tran = 'C';
MKL_Complex8* clone_b = new MKL_Complex8[m*bn];
std::memcpy(clone_b, b, m*bn*sizeof(MKL_Complex8));
char side ='L';
char tran = 'T';
CUNMQR(&side, &tran, &m, &bn, &n, clone_r, &m, tau, clone_b, &m, work, &len, &info);
MKL_Complex8 one;
one.real = 1.0;
MKL_Complex8 one = {1.0, 0.0};
cblas_ctrsm(CblasColMajor, CblasLeft, CblasUpper, CblasNoTrans, CblasNonUnit, n, bn, &one, clone_r, m, clone_b, m);
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < bn; ++j)
@ -746,8 +747,8 @@ extern "C" {
int info = 0;
MKL_Complex16* clone_r = new MKL_Complex16[m*n];
std::memcpy(clone_r, r, m*n*sizeof(MKL_Complex16));
MKL_Complex16* tau = new MKL_Complex16[std::max(1, std::min(m,n))];
MKL_Complex16* tau = new MKL_Complex16[std::min(m,n)];
ZGEQRF(&m, &n, clone_r, &m, tau, work, &len, &info);
if (info != 0)
@ -757,15 +758,16 @@ extern "C" {
return info;
}
char side ='L';
char tran = 'C';
MKL_Complex16* clone_b = new MKL_Complex16[m*bn];
std::memcpy(clone_b, b, m*bn*sizeof(MKL_Complex16));
char side ='L';
char tran = 'T';
ZUNMQR(&side, &tran, &m, &bn, &n, clone_r, &m, tau, clone_b, &m, work, &len, &info);
MKL_Complex16 one;
one.real = 1.0;
cblas_ctrsm(CblasColMajor, CblasLeft, CblasUpper, CblasNoTrans, CblasNonUnit, n, bn, &one, clone_r, m, clone_b, m);
MKL_Complex16 one = {1.0, 0.0};
cblas_ztrsm(CblasColMajor, CblasLeft, CblasUpper, CblasNoTrans, CblasNonUnit, n, bn, &one, clone_r, m, clone_b, m);
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < bn; ++j)
@ -788,7 +790,7 @@ extern "C" {
float* clone_b = new float[m*bn];
std::memcpy(clone_b, b, m*bn*sizeof(float));
SORMQR(&side, &tran, &m, &bn, &n, r, &m, tau, clone_b, &m, work, &len, &info);
cblas_strsm(CblasColMajor, CblasLeft, CblasUpper, CblasNoTrans, CblasNonUnit, n, bn, 1.0, r, m, clone_b, m);
for (int i = 0; i < n; ++i)
@ -798,11 +800,11 @@ extern "C" {
x[j * n + i] = clone_b[j * m + i];
}
}
delete[] clone_b;
return info;
}
DLLEXPORT int d_qr_solve_factored(int m, int n, int bn, double r[], double b[], double tau[], double x[], double work[], int len)
{
char side ='L';
@ -829,15 +831,14 @@ extern "C" {
DLLEXPORT int c_qr_solve_factored(int m, int n, int bn, MKL_Complex8 r[], MKL_Complex8 b[], MKL_Complex8 tau[], MKL_Complex8 x[], MKL_Complex8 work[], int len)
{
char side ='L';
char tran = 'T';
char tran = 'C';
int info = 0;
MKL_Complex8* clone_b = new MKL_Complex8[m*bn];
std::memcpy(clone_b, b, m*bn*sizeof(MKL_Complex8));
CUNMQR(&side, &tran, &m, &bn, &n, r, &m, tau, clone_b, &m, work, &len, &info);
MKL_Complex8 one;
one.real = 1.0;
MKL_Complex8 one = {1.0f, 0.0f};
cblas_ctrsm(CblasColMajor, CblasLeft, CblasUpper, CblasNoTrans, CblasNonUnit, n, bn, &one, r, m, clone_b, m);
for (int i = 0; i < n; ++i)
{
@ -854,17 +855,16 @@ extern "C" {
DLLEXPORT int z_qr_solve_factored(int m, int n, int bn, MKL_Complex16 r[], MKL_Complex16 b[], MKL_Complex16 tau[], MKL_Complex16 x[], MKL_Complex16 work[], int len)
{
char side ='L';
char tran = 'T';
char tran = 'C';
int info = 0;
MKL_Complex16* clone_b = new MKL_Complex16[m*bn];
std::memcpy(clone_b, b, m*bn*sizeof(MKL_Complex16));
ZUNMQR(&side, &tran, &m, &bn, &n, r, &m, tau, clone_b, &m, work, &len, &info);
MKL_Complex16 one;
one.real = 1.0;
MKL_Complex16 one = {1.0, 0.0};
cblas_ztrsm(CblasColMajor, CblasLeft, CblasUpper, CblasNoTrans, CblasNonUnit, n, bn, &one, r, m, clone_b, m);
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < bn; ++j)
@ -893,19 +893,41 @@ extern "C" {
return info;
}
DLLEXPORT int c_svd_factor(bool compute_vectors, int m, int n, MKL_Complex8 a[], float s[], MKL_Complex8 u[], MKL_Complex8 v[], MKL_Complex8 work[], int len, float rwork[])
DLLEXPORT int c_svd_factor(bool compute_vectors, int m, int n, MKL_Complex8 a[], MKL_Complex8 s[], MKL_Complex8 u[], MKL_Complex8 v[], MKL_Complex8 work[], int len)
{
int info = 0;
int dim_s = std::min(m,n);
float* rwork = new float[5 * dim_s];
float* s_local = new float[dim_s];
char job = compute_vectors ? 'A' : 'N';
CGESVD(&job, &job, &m, &n, a, &m, s, u, &m, v, &n, work, &len, rwork, &info);
CGESVD(&job, &job, &m, &n, a, &m, s_local, u, &m, v, &n, work, &len, rwork, &info);
for(int index = 0; index < dim_s; ++index){
MKL_Complex8 value = {s_local[index], 0.0f};
s[index] = value;
}
delete[] rwork;
delete[] s_local;
return info;
}
DLLEXPORT int z_svd_factor(bool compute_vectors, int m, int n, MKL_Complex16 a[], double s[], MKL_Complex16 u[], MKL_Complex16 v[], MKL_Complex16 work[], int len, double rwork[])
DLLEXPORT int z_svd_factor(bool compute_vectors, int m, int n, MKL_Complex16 a[], MKL_Complex16 s[], MKL_Complex16 u[], MKL_Complex16 v[], MKL_Complex16 work[], int len)
{
int info = 0;
int dim_s = std::min(m,n);
double* rwork = new double[5 * std::min(m, n)];
double* s_local = new double[dim_s];
char job = compute_vectors ? 'A' : 'N';
ZGESVD(&job, &job, &m, &n, a, &m, s, u, &m, v, &n, work, &len, rwork, &info);
ZGESVD(&job, &job, &m, &n, a, &m, s_local, u, &m, v, &n, work, &len, rwork, &info);
for(int index = 0; index < dim_s; ++index){
MKL_Complex16 value = {s_local[index], 0.0f};
s[index] = value;
}
delete[] rwork;
delete[] s_local;
return info;
}
}

51
src/NativeWrappers/Windows/MKLWrapper32Tests/LinearAlgebra/Complex/MklLinearAlgebraProviderTests.cs

@ -0,0 +1,51 @@
// <copyright file="MklLinearAlgebraProviderTests.cs" company="Math.NET">
// 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.
// </copyright>
using MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex;
namespace MathNet.Numerics.MklWrapperTests.LinearAlgebra.Complex
{
using NUnit.Framework;
/// <summary>
/// Unit test container for the MKL linear algebra provider.
/// </summary>
[TestFixture]
public class MklLinearAlgebraProviderTests : LinearAlgebraProviderTests
{
/// <summary>
/// Initializes a new instance of the <see cref="MklLinearAlgebraProviderTests"/> class.
/// </summary>
public MklLinearAlgebraProviderTests()
{
Control.LinearAlgebraProvider = new Algorithms.LinearAlgebra.Mkl.MklLinearAlgebraProvider();
}
}
}

51
src/NativeWrappers/Windows/MKLWrapper32Tests/LinearAlgebra/Complex32/MklLinearAlgebraProviderTests.cs

@ -0,0 +1,51 @@
// <copyright file="MklLinearAlgebraProviderTests.cs" company="Math.NET">
// 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.
// </copyright>
using MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32;
namespace MathNet.Numerics.MklWrapperTests.LinearAlgebra.Complex32
{
using NUnit.Framework;
/// <summary>
/// Unit test container for the MKL linear algebra provider.
/// </summary>
[TestFixture]
public class MklLinearAlgebraProviderTests : LinearAlgebraProviderTests
{
/// <summary>
/// Initializes a new instance of the <see cref="MklLinearAlgebraProviderTests"/> class.
/// </summary>
public MklLinearAlgebraProviderTests()
{
Control.LinearAlgebraProvider = new Algorithms.LinearAlgebra.Mkl.MklLinearAlgebraProvider();
}
}
}

2
src/NativeWrappers/Windows/MKLWrapper32Tests/LinearAlgebra/Double/MklLinearAlgebraProviderTests.cs

@ -45,7 +45,7 @@ namespace MathNet.Numerics.MklWrapperTests.LinearAlgebra.Double
/// </summary>
public MklLinearAlgebraProviderTests()
{
Provider = new Algorithms.LinearAlgebra.Mkl.MklLinearAlgebraProvider();
Control.LinearAlgebraProvider = new Algorithms.LinearAlgebra.Mkl.MklLinearAlgebraProvider();
}
}
}

51
src/NativeWrappers/Windows/MKLWrapper32Tests/LinearAlgebra/Single/MklLinearAlgebraProviderTests.cs

@ -0,0 +1,51 @@
// <copyright file="MklLinearAlgebraProviderTests.cs" company="Math.NET">
// 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.
// </copyright>
using MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Single;
namespace MathNet.Numerics.MklWrapperTests.LinearAlgebra.Single
{
using NUnit.Framework;
/// <summary>
/// Unit test container for the MKL linear algebra provider.
/// </summary>
[TestFixture]
public class MklLinearAlgebraProviderTests : LinearAlgebraProviderTests
{
/// <summary>
/// Initializes a new instance of the <see cref="MklLinearAlgebraProviderTests"/> class.
/// </summary>
public MklLinearAlgebraProviderTests()
{
Control.LinearAlgebraProvider = new Algorithms.LinearAlgebra.Mkl.MklLinearAlgebraProvider();
}
}
}

13
src/NativeWrappers/Windows/MKLWrapper32Tests/MKLWrapper32Tests.csproj

@ -80,10 +80,22 @@
<Compile Include="..\..\..\UnitTests\AssertHelpers.cs">
<Link>AssertHelpers.cs</Link>
</Compile>
<Compile Include="..\..\..\UnitTests\LinearAlgebraProviderTests\Complex32\LinearAlgebraProviderTests.cs">
<Link>LinearAlgebra\Complex32\LinearAlgebraProviderTests.cs</Link>
</Compile>
<Compile Include="..\..\..\UnitTests\LinearAlgebraProviderTests\Complex\LinearAlgebraProviderTests.cs">
<Link>LinearAlgebra\Complex\LinearAlgebraProviderTests.cs</Link>
</Compile>
<Compile Include="..\..\..\UnitTests\LinearAlgebraProviderTests\Double\LinearAlgebraProviderTests.cs">
<Link>LinearAlgebra\Double\LinearAlgebraProviderTests.cs</Link>
</Compile>
<Compile Include="..\..\..\UnitTests\LinearAlgebraProviderTests\Single\LinearAlgebraProviderTests.cs">
<Link>LinearAlgebra\Single\LinearAlgebraProviderTests.cs</Link>
</Compile>
<Compile Include="LinearAlgebra\Complex32\MklLinearAlgebraProviderTests.cs" />
<Compile Include="LinearAlgebra\Complex\MklLinearAlgebraProviderTests.cs" />
<Compile Include="LinearAlgebra\Double\MklLinearAlgebraProviderTests.cs" />
<Compile Include="LinearAlgebra\Single\MklLinearAlgebraProviderTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
@ -113,6 +125,7 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

4
src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs

@ -1678,7 +1678,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
}
var clone = new Complex[a.Length];
Buffer.BlockCopy(a, 0, clone, 0, a.Length * Constants.SizeOfComplex);
a.Copy(clone);
var q = new Complex[rows * rows];
QRFactor(clone, rows, columns, q, work);
QRSolveFactored(q, clone, rows, columns, null, b, columnsB, x);
@ -2607,7 +2607,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
var vt = new Complex[columnsA * columnsA];
var clone = new Complex[a.Length];
Buffer.BlockCopy(a, 0, clone, 0, a.Length * Constants.SizeOfComplex);
a.Copy(clone);
SingularValueDecomposition(true, clone, rowsA, columnsA, s, u, vt, work);
SvdSolveFactored(rowsA, columnsA, s, u, vt, b, columnsB, x);
}

9
src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs

@ -59,11 +59,6 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
if (alpha == 0.0F)
{
return;
}
if (alpha.IsZero())
{
CommonParallel.For(0, y.Length, index => result[index] = y[index]);
@ -1678,7 +1673,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
}
var clone = new Complex32[a.Length];
Buffer.BlockCopy(a, 0, clone, 0, a.Length * Constants.SizeOfComplex32);
a.Copy(clone);
var q = new Complex32[rows * rows];
QRFactor(clone, rows, columns, q, work);
QRSolveFactored(q, clone, rows, columns, null, b, columnsB, x);
@ -2607,7 +2602,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
var vt = new Complex32[columnsA * columnsA];
var clone = new Complex32[a.Length];
Buffer.BlockCopy(a, 0, clone, 0, a.Length * Constants.SizeOfComplex32);
a.Copy(clone);
SingularValueDecomposition(true, clone, rowsA, columnsA, s, u, vt, work);
SvdSolveFactored(rowsA, columnsA, s, u, vt, b, columnsB, x);
}

5
src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs

@ -59,11 +59,6 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
if (alpha == 0.0)
{
return;
}
if (alpha == 0.0)
{
CommonParallel.For(0, y.Length, index => result[index] = y[index]);

2
src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.tt

@ -6,9 +6,7 @@
<# string zero = "Complex.Zero";#>
<# string one = "Complex.One";#>
<# string prefix = "z";#>
<# string reff = "ref ";#>
<# string svd_work = "2 * Math.Min(rowsA, columnsA) + Math.Max(rowsA, columnsA)";#>
<# string data_size = "Constants.SizeOfComplex";#>
<#@ include file="..\native.header.include" #>
<#@ include file="..\native.generic.include" #>
<#@ include file="..\native.vector.include" #>

2
src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.tt

@ -6,9 +6,7 @@
<# string zero = "Complex32.Zero";#>
<# string one = "Complex32.One";#>
<# string prefix = "c";#>
<# string reff = "ref ";#>
<# string svd_work = "2 * Math.Min(rowsA, columnsA) + Math.Max(rowsA, columnsA)";#>
<# string data_size = "Constants.SizeOfComplex32";#>
<#@ include file="..\native.header.include" #>
<#@ include file="..\native.generic.include" #>
<#@ include file="..\native.vector.include" #>

2
src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.tt

@ -6,9 +6,7 @@
<# string zero = "0.0";#>
<# string one = "1.0";#>
<# string prefix = "d";#>
<# string reff = "";#>
<# string svd_work = "Math.Max((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5 * Math.Min(rowsA, columnsA))";#>
<# string data_size = "Constants.SizeOfDouble";#>
<#@ include file="..\native.header.include" #>
<#@ include file="..\native.generic.include" #>
<#@ include file="..\native.vector.include" #>

2
src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.float.tt

@ -6,9 +6,7 @@
<# string zero = "0.0f";#>
<# string one = "1.0f";#>
<# string prefix = "s";#>
<# string reff = "";#>
<# string svd_work = "Math.Max((3 * Math.Min(rowsA, columnsA) + Math.Max(rowsA, columnsA)), 5 * Math.Min(rowsA, columnsA))";#>
<# string data_size = "Constants.SizeOfFloat";#>
<#@ include file="..\native.header.include" #>
<#@ include file="..\native.generic.include" #>
<#@ include file="..\native.vector.include" #>

8
src/Numerics/Algorithms/LinearAlgebra/native.generic.include

@ -34,7 +34,7 @@
return;
}
SafeNativeMethods.<#=prefix#>_axpy(y.Length, <#=reff#>alpha, x, result);
SafeNativeMethods.<#=prefix#>_axpy(y.Length, alpha, x, result);
}
/// <summary>
@ -62,7 +62,7 @@
return;
}
SafeNativeMethods.<#=prefix#>_scale(x.Length, <#=reff#>alpha, result);
SafeNativeMethods.<#=prefix#>_scale(x.Length, alpha, result);
}
/// <summary>
@ -156,7 +156,7 @@
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
SafeNativeMethods.<#=prefix#>_matrix_multiply(transposeA, transposeB, m, n, k, <#=reff#>alpha, a, b, <#=reff#>beta, c);
SafeNativeMethods.<#=prefix#>_matrix_multiply(transposeA, transposeB, m, n, k, alpha, a, b, beta, c);
}
/// <summary>
@ -964,7 +964,7 @@
var vt = new <#=dataType#>[columnsA * columnsA];
var clone = new <#=dataType#>[a.Length];
Buffer.BlockCopy(a, 0, clone, 0, a.Length * <#=data_size#>);
a.Copy(clone);
SingularValueDecomposition(true, clone, rowsA, columnsA, s, u, vt, work);
SvdSolveFactored(rowsA, columnsA, s, u, vt, b, columnsB, x);
}

12
src/Numerics/Algorithms/LinearAlgebra/safe.native.common.include

@ -57,10 +57,10 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#= namespaceSuffix #>
internal static extern void d_axpy(int n, double alpha, double[] x, [In, Out] double[] y);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void c_axpy(int n, ref Complex32 alpha, Complex32[] x, [In, Out] Complex32[] y);
internal static extern void c_axpy(int n, Complex32 alpha, Complex32[] x, [In, Out] Complex32[] y);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void z_axpy(int n, ref Complex alpha, Complex[] x, [In, Out] Complex[] y);
internal static extern void z_axpy(int n, Complex alpha, Complex[] x, [In, Out] Complex[] y);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void s_scale(int n, float alpha, [Out] float[] x);
@ -69,10 +69,10 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#= namespaceSuffix #>
internal static extern void d_scale(int n, double alpha, [Out] double[] x);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void c_scale(int n, ref Complex32 alpha, [In, Out] Complex32[] x);
internal static extern void c_scale(int n, Complex32 alpha, [In, Out] Complex32[] x);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void z_scale(int n, ref Complex alpha, [In, Out] Complex[] x);
internal static extern void z_scale(int n, Complex alpha, [In, Out] Complex[] x);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern float s_dot_product(int n, float[] x, float[] y);
@ -93,10 +93,10 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#= namespaceSuffix #>
internal static extern void d_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, double alpha, double[] x, double[] y, double beta, [In, Out]double[] c);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void c_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, ref Complex32 alpha, Complex32[] x, Complex32[] y, ref Complex32 beta, [In, Out]Complex32[] c);
internal static extern void c_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex32 alpha, Complex32[] x, Complex32[] y, Complex32 beta, [In, Out]Complex32[] c);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void z_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, ref Complex alpha, Complex[] x, Complex[] y, ref Complex beta, [In, Out]Complex[] c);
internal static extern void z_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex alpha, Complex[] x, Complex[] y, Complex beta, [In, Out]Complex[] c);
#endregion BLAS

81
src/Numerics/ArrayExtensions.cs

@ -0,0 +1,81 @@
// <copyright file="ArrayExtensions.cs" company="Math.NET">
// 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) 2011 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.
// </copyright>
namespace MathNet.Numerics
{
using System;
using System.Numerics;
/// <summary>
/// Useful extension methods for Arrays.
/// </summary>
internal static class ArrayExtensions
{
/// <summary>
/// Copies the values from on array to another.
/// </summary>
/// <param name="source">The source array.</param>
/// <param name="dest">The destination array.</param>
public static void Copy(this double[] source, double[] dest)
{
Buffer.BlockCopy(source, 0, dest, 0, source.Length * Constants.SizeOfDouble);
}
/// <summary>
/// Copies the values from on array to another.
/// </summary>
/// <param name="source">The source array.</param>
/// <param name="dest">The destination array.</param>
public static void Copy(this float[] source, float[] dest)
{
Buffer.BlockCopy(source, 0, dest, 0, source.Length * Constants.SizeOfFloat);
}
/// <summary>
/// Copies the values from on array to another.
/// </summary>
/// <param name="source">The source array.</param>
/// <param name="dest">The destination array.</param>
public static void Copy(this Complex[] source, Complex[] dest)
{
Array.Copy(source, 0, dest, 0, source.Length);
}
/// <summary>
/// Copies the values from on array to another.
/// </summary>
/// <param name="source">The source array.</param>
/// <param name="dest">The destination array.</param>
public static void Copy(this Complex32[] source, Complex32[] dest)
{
Array.Copy(source, 0, dest, 0, source.Length);
}
}
}

1
src/Numerics/Numerics.csproj

@ -137,6 +137,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>SafeNativeMethods.tt</DependentUpon>
</Compile>
<Compile Include="ArrayExtensions.cs" />
<Compile Include="Combinatorics.cs" />
<Compile Include="ComplexExtensions.cs" />
<Compile Include="Constants.cs" />

3
src/Silverlight/Silverlight.csproj

@ -75,6 +75,9 @@
<Compile Include="..\Numerics\Algorithms\LinearAlgebra\ManagedLinearAlgebraProvider.Single.cs">
<Link>Algorithms\LinearAlgebra\ManagedLinearAlgebraProvider.Single.cs</Link>
</Compile>
<Compile Include="..\Numerics\ArrayExtensions.cs">
<Link>ArrayExtensions.cs</Link>
</Compile>
<Compile Include="..\Numerics\Combinatorics.cs">
<Link>Combinatorics.cs</Link>
</Compile>

1368
src/UnitTests/LinearAlgebraProviderTests/Complex/LinearAlgebraProviderTests.cs

File diff suppressed because it is too large

1376
src/UnitTests/LinearAlgebraProviderTests/Complex32/LinearAlgebraProviderTests.cs

File diff suppressed because it is too large

151
src/UnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs

@ -28,9 +28,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
{
using System;
using System.Collections.Generic;
using Algorithms.LinearAlgebra;
using LinearAlgebra.Double;
using LinearAlgebra.Generic;
using NUnit.Framework;
@ -41,23 +41,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
[TestFixture]
public class LinearAlgebraProviderTests
{
/// <summary>
/// Initializes a new instance of the <see cref="LinearAlgebraProviderTests"/> class.
/// </summary>
public LinearAlgebraProviderTests()
{
Provider = new ManagedLinearAlgebraProvider();
}
/// <summary>
/// Gets or sets linear algebra provider to test.
/// </summary>
protected ILinearAlgebraProvider Provider
{
get;
set;
}
/// <summary>
/// The Y double test vector.
/// </summary>
@ -89,21 +72,21 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
{
var result = new double[_y.Length];
Provider.AddVectorToScaledVector(_y, 0, _x, result);
Control.LinearAlgebraProvider.AddVectorToScaledVector(_y, 0, _x, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i], result[i]);
}
Array.Copy(_y, result, _y.Length);
Provider.AddVectorToScaledVector(result, 1, _x, result);
Control.LinearAlgebraProvider.AddVectorToScaledVector(result, 1, _x, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i] + _x[i], result[i]);
}
Array.Copy(_y, result, _y.Length);
Provider.AddVectorToScaledVector(result, Math.PI, _x, result);
Control.LinearAlgebraProvider.AddVectorToScaledVector(result, Math.PI, _x, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i] + (Math.PI * _x[i]), result[i]);
@ -118,14 +101,14 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
{
var result = new double[_y.Length];
Provider.ScaleArray(1, _y, result);
Control.LinearAlgebraProvider.ScaleArray(1, _y, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i], result[i]);
}
Array.Copy(_y, result, _y.Length);
Provider.ScaleArray(Math.PI, result, result);
Control.LinearAlgebraProvider.ScaleArray(Math.PI, result, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i] * Math.PI, result[i]);
@ -138,7 +121,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
[Test]
public void CanComputeDotProduct()
{
var result = Provider.DotProduct(_x, _y);
var result = Control.LinearAlgebraProvider.DotProduct(_x, _y);
AssertHelpers.AlmostEqual(152.35, result, 15);
}
@ -149,7 +132,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
public void CanAddArrays()
{
var result = new double[_y.Length];
Provider.AddArrays(_x, _y, result);
Control.LinearAlgebraProvider.AddArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i] + _y[i], result[i]);
@ -163,7 +146,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
public void CanSubtractArrays()
{
var result = new double[_y.Length];
Provider.SubtractArrays(_x, _y, result);
Control.LinearAlgebraProvider.SubtractArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i] - _y[i], result[i]);
@ -177,7 +160,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
public void CanPointWiseMultiplyArrays()
{
var result = new double[_y.Length];
Provider.PointWiseMultiplyArrays(_x, _y, result);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i] * _y[i], result[i]);
@ -191,7 +174,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
public void CanPointWiseDivideArrays()
{
var result = new double[_y.Length];
Provider.PointWiseDivideArrays(_x, _y, result);
Control.LinearAlgebraProvider.PointWiseDivideArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i] / _y[i], result[i]);
@ -206,7 +189,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
{
var matrix = _matrices["Square3x3"];
var work = new double[matrix.RowCount];
var norm = Provider.MatrixNorm(Norm.OneNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data, work);
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.OneNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data, work);
AssertHelpers.AlmostEqual(12.1, norm, 6);
}
@ -218,7 +201,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
{
var matrix = _matrices["Square3x3"];
var work = new double[matrix.RowCount];
var norm = Provider.MatrixNorm(Norm.FrobeniusNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data, work);
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.FrobeniusNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data, work);
AssertHelpers.AlmostEqual(10.777754868246, norm, 8);
}
@ -230,7 +213,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
{
var matrix = _matrices["Square3x3"];
var work = new double[matrix.RowCount];
var norm = Provider.MatrixNorm(Norm.InfinityNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data, work);
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.InfinityNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data, work);
Assert.AreEqual(16.5, norm);
}
@ -241,7 +224,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
public void CanComputeMatrixL1NormWithWorkArray()
{
var matrix = _matrices["Square3x3"];
var norm = Provider.MatrixNorm(Norm.OneNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data);
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.OneNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data);
AssertHelpers.AlmostEqual(12.1, norm, 6);
}
@ -252,7 +235,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
public void CanComputeMatrixFrobeniusNormWithWorkArray()
{
var matrix = _matrices["Square3x3"];
var norm = Provider.MatrixNorm(Norm.FrobeniusNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data);
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.FrobeniusNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data);
AssertHelpers.AlmostEqual(10.777754868246, norm, 8);
}
@ -263,7 +246,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
public void CanComputeMatrixInfinityNormWithWorkArray()
{
var matrix = _matrices["Square3x3"];
var norm = Provider.MatrixNorm(Norm.InfinityNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data);
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.InfinityNorm, matrix.RowCount, matrix.ColumnCount, matrix.Data);
Assert.AreEqual(16.5, norm);
}
@ -277,7 +260,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var y = _matrices["Square3x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Provider.MatrixMultiply(x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, c.Data);
Control.LinearAlgebraProvider.MatrixMultiply(x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, c.Data);
for (var i = 0; i < c.RowCount; i++)
{
@ -298,7 +281,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var y = _matrices["Tall3x2"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Provider.MatrixMultiply(x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, c.Data);
Control.LinearAlgebraProvider.MatrixMultiply(x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, c.Data);
for (var i = 0; i < c.RowCount; i++)
{
@ -319,7 +302,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var y = _matrices["Wide2x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Provider.MatrixMultiply(x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, c.Data);
Control.LinearAlgebraProvider.MatrixMultiply(x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, c.Data);
for (var i = 0; i < c.RowCount; i++)
{
@ -340,7 +323,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var y = _matrices["Square3x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, 1.0, c.Data);
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, 1.0, c.Data);
for (var i = 0; i < c.RowCount; i++)
{
@ -361,7 +344,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var y = _matrices["Tall3x2"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, 1.0, c.Data);
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, 1.0, c.Data);
for (var i = 0; i < c.RowCount; i++)
{
@ -382,7 +365,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var y = _matrices["Wide2x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, 1.0, c.Data);
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, 1.0, c.Data);
for (var i = 0; i < c.RowCount; i++)
{
@ -405,7 +388,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var ipiv = new int[matrix.RowCount];
Provider.LUFactor(a, matrix.RowCount, ipiv);
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
AssertHelpers.AlmostEqual(a[0], -4.4, 15);
AssertHelpers.AlmostEqual(a[1], 0.25, 15);
@ -431,7 +414,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var a = new double[matrix.RowCount * matrix.RowCount];
Array.Copy(matrix.Data, a, a.Length);
Provider.LUInverse(a, matrix.RowCount);
Control.LinearAlgebraProvider.LUInverse(a, matrix.RowCount);
AssertHelpers.AlmostEqual(a[0], -0.454545454545454, 14);
AssertHelpers.AlmostEqual(a[1], -0.909090909090908, 14);
@ -457,8 +440,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var ipiv = new int[matrix.RowCount];
Provider.LUFactor(a, matrix.RowCount, ipiv);
Provider.LUInverseFactored(a, matrix.RowCount, ipiv);
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
Control.LinearAlgebraProvider.LUInverseFactored(a, matrix.RowCount, ipiv);
AssertHelpers.AlmostEqual(a[0], -0.454545454545454, 14);
AssertHelpers.AlmostEqual(a[1], -0.909090909090908, 14);
@ -483,7 +466,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
Array.Copy(matrix.Data, a, a.Length);
var work = new double[matrix.RowCount];
Provider.LUInverse(a, matrix.RowCount, work);
Control.LinearAlgebraProvider.LUInverse(a, matrix.RowCount, work);
AssertHelpers.AlmostEqual(a[0], -0.454545454545454, 14);
AssertHelpers.AlmostEqual(a[1], -0.909090909090908, 14);
@ -509,10 +492,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var ipiv = new int[matrix.RowCount];
Provider.LUFactor(a, matrix.RowCount, ipiv);
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
var work = new double[matrix.RowCount];
Provider.LUInverseFactored(a, matrix.RowCount, ipiv, work);
Control.LinearAlgebraProvider.LUInverseFactored(a, matrix.RowCount, ipiv, work);
AssertHelpers.AlmostEqual(a[0], -0.454545454545454, 14);
AssertHelpers.AlmostEqual(a[1], -0.909090909090908, 14);
@ -536,7 +519,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
Array.Copy(matrix.Data, a, a.Length);
var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
Provider.LUSolve(2, a, matrix.RowCount, b);
Control.LinearAlgebraProvider.LUSolve(2, a, matrix.RowCount, b);
AssertHelpers.AlmostEqual(b[0], -1.477272727272726, 14);
AssertHelpers.AlmostEqual(b[1], -4.318181818181815, 14);
@ -559,10 +542,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
Array.Copy(matrix.Data, a, a.Length);
var ipiv = new int[matrix.RowCount];
Provider.LUFactor(a, matrix.RowCount, ipiv);
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
Provider.LUSolveFactored(2, a, matrix.RowCount, ipiv, b);
Control.LinearAlgebraProvider.LUSolveFactored(2, a, matrix.RowCount, ipiv, b);
AssertHelpers.AlmostEqual(b[0], -1.477272727272726, 14);
AssertHelpers.AlmostEqual(b[1], -4.318181818181815, 14);
@ -579,7 +562,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
public void CanComputeCholeskyFactor()
{
var matrix = new double[] { 1, 1, 1, 1, 1, 5, 5, 5, 1, 5, 14, 14, 1, 5, 14, 15 };
Provider.CholeskyFactor(matrix, 4);
Control.LinearAlgebraProvider.CholeskyFactor(matrix, 4);
Assert.AreEqual(matrix[0], 1);
Assert.AreEqual(matrix[1], 1);
Assert.AreEqual(matrix[2], 1);
@ -608,7 +591,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var a = new double[] { 1, 1, 1, 1, 2, 3, 1, 3, 6 };
var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
Provider.CholeskySolve(a, 3, b, 2);
Control.LinearAlgebraProvider.CholeskySolve(a, 3, b, 2);
AssertHelpers.AlmostEqual(b[0], 0, 14);
AssertHelpers.AlmostEqual(b[1], 1, 14);
@ -628,10 +611,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
{
var a = new double[] { 1, 1, 1, 1, 2, 3, 1, 3, 6 };
Provider.CholeskyFactor(a, 3);
Control.LinearAlgebraProvider.CholeskyFactor(a, 3);
var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
Provider.CholeskySolveFactored(a, 3, b, 2);
Control.LinearAlgebraProvider.CholeskySolveFactored(a, 3, b, 2);
AssertHelpers.AlmostEqual(b[0], 0, 14);
AssertHelpers.AlmostEqual(b[1], 1, 14);
@ -653,7 +636,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double[3];
var q = new double[matrix.RowCount * matrix.RowCount];
Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
var mq = new DenseMatrix(matrix.RowCount, matrix.RowCount, q);
var mr = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
@ -680,7 +663,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double[3];
var q = new double[matrix.RowCount * matrix.RowCount];
Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
var mr = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
var mq = new DenseMatrix(matrix.RowCount, matrix.RowCount, q);
@ -707,7 +690,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double[3];
var q = new double[matrix.RowCount * matrix.RowCount];
Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
var mr = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
var mq = new DenseMatrix(matrix.RowCount, matrix.RowCount, q);
@ -735,7 +718,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double[3];
var q = new double[matrix.RowCount * matrix.RowCount];
var work = new double[matrix.ColumnCount * Control.BlockSize];
Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau, work);
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau, work);
var mq = new DenseMatrix(matrix.RowCount, matrix.RowCount, q);
var mr = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
@ -763,7 +746,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double[3];
var q = new double[matrix.RowCount * matrix.RowCount];
var work = new double[matrix.ColumnCount * Control.BlockSize];
Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau, work);
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau, work);
var mr = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
var mq = new DenseMatrix(matrix.RowCount, matrix.RowCount, q);
@ -791,7 +774,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double[3];
var q = new double[matrix.RowCount * matrix.RowCount];
var work = new double[matrix.ColumnCount * Control.BlockSize];
Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau, work);
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau, work);
var mr = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
var mq = new DenseMatrix(matrix.RowCount, matrix.RowCount, q);
@ -818,7 +801,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
var x = new double[matrix.ColumnCount * 2];
Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 3, a, matrix);
@ -845,7 +828,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
var x = new double[matrix.ColumnCount * 2];
Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 2, a, matrix);
@ -872,7 +855,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
var x = new double[matrix.ColumnCount * 2];
var work = new double[matrix.RowCount * matrix.RowCount];
Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, work);
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, work);
NotModified(3, 3, a, matrix);
@ -901,7 +884,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
var x = new double[matrix.ColumnCount * 2];
var work = new double[matrix.RowCount * matrix.RowCount];
Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, work);
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, work);
NotModified(3, 2, a, matrix);
@ -927,11 +910,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double[matrix.ColumnCount];
var q = new double[matrix.ColumnCount * matrix.ColumnCount];
Provider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
Control.LinearAlgebraProvider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
var x = new double[matrix.ColumnCount * 2];
Provider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
Control.LinearAlgebraProvider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
var mx = new DenseMatrix(matrix.ColumnCount, 2, x);
var mb = matrix * mx;
@ -957,11 +940,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double[matrix.ColumnCount];
var q = new double[matrix.RowCount * matrix.RowCount];
Provider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
Control.LinearAlgebraProvider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
var x = new double[matrix.ColumnCount * 2];
Provider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
Control.LinearAlgebraProvider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
var mb = new DenseMatrix(matrix.RowCount, 2, b);
var test = (matrix.Transpose() * matrix).Inverse() * matrix.Transpose() * mb;
@ -986,11 +969,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double[matrix.ColumnCount];
var q = new double[matrix.ColumnCount * matrix.ColumnCount];
var work = new double[2048];
Provider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau, work);
Control.LinearAlgebraProvider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau, work);
var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
var x = new double[matrix.ColumnCount * 2];
Provider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, work);
Control.LinearAlgebraProvider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, work);
var mx = new DenseMatrix(matrix.ColumnCount, 2, x);
var mb = matrix * mx;
@ -1017,11 +1000,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double[matrix.ColumnCount];
var q = new double[matrix.RowCount * matrix.RowCount];
var work = new double[2048];
Provider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau, work);
Control.LinearAlgebraProvider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau, work);
var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
var x = new double[matrix.ColumnCount * 2];
Provider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, work);
Control.LinearAlgebraProvider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, work);
var mb = new DenseMatrix(matrix.RowCount, 2, b);
var test = (matrix.Transpose() * matrix).Inverse() * matrix.Transpose() * mb;
@ -1046,7 +1029,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var u = new double[matrix.RowCount * matrix.RowCount];
var vt = new double[matrix.ColumnCount * matrix.ColumnCount];
Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -1083,7 +1066,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var u = new double[matrix.RowCount * matrix.RowCount];
var vt = new double[matrix.ColumnCount * matrix.ColumnCount];
Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -1117,7 +1100,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var u = new double[matrix.RowCount * matrix.RowCount];
var vt = new double[matrix.ColumnCount * matrix.ColumnCount];
Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -1153,7 +1136,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var vt = new double[matrix.ColumnCount * matrix.ColumnCount];
var work = new double[100];
Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt, work);
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt, work);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -1192,7 +1175,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var vt = new double[matrix.ColumnCount * matrix.ColumnCount];
var work = new double[100];
Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt, work);
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt, work);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -1228,7 +1211,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var vt = new double[matrix.ColumnCount * matrix.ColumnCount];
var work = new double[100];
Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt, work);
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt, work);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -1260,7 +1243,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
var x = new double[matrix.ColumnCount * 2];
Provider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
Control.LinearAlgebraProvider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 3, a, matrix);
@ -1287,7 +1270,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
var x = new double[matrix.ColumnCount * 2];
Provider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
Control.LinearAlgebraProvider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 2, a, matrix);
@ -1315,11 +1298,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var u = new double[matrix.RowCount * matrix.RowCount];
var vt = new double[matrix.ColumnCount * matrix.ColumnCount];
Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
var x = new double[matrix.ColumnCount * 2];
Provider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
Control.LinearAlgebraProvider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
var mx = new DenseMatrix(matrix.ColumnCount, 2, x);
var mb = matrix * mx;
@ -1347,11 +1330,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var u = new double[matrix.RowCount * matrix.RowCount];
var vt = new double[matrix.ColumnCount * matrix.ColumnCount];
Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
var x = new double[matrix.ColumnCount * 2];
Provider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
Control.LinearAlgebraProvider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
var mb = new DenseMatrix(matrix.RowCount, 2, b);
var test = (matrix.Transpose() * matrix).Inverse() * matrix.Transpose() * mb;

1375
src/UnitTests/LinearAlgebraProviderTests/Single/LinearAlgebraProviderTests.cs

File diff suppressed because it is too large

3
src/UnitTests/UnitTests.csproj

@ -121,9 +121,12 @@
<Compile Include="InterpolationTests\EquidistantPolynomialTest.cs" />
<Compile Include="InterpolationTests\NevillePolynomialTest.cs" />
<Compile Include="InterpolationTests\LinearInterpolationCase.cs" />
<Compile Include="LinearAlgebraProviderTests\Complex32\LinearAlgebraProviderTests.cs" />
<Compile Include="LinearAlgebraProviderTests\Complex\LinearAlgebraProviderTests.cs" />
<Compile Include="LinearAlgebraProviderTests\Double\LinearAlgebraProviderTests.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="LinearAlgebraProviderTests\Single\LinearAlgebraProviderTests.cs" />
<Compile Include="LinearAlgebraTests\Complex32\DenseMatrixTests.cs">
<SubType>Code</SubType>
</Compile>

Loading…
Cancel
Save