Browse Source

Passing most tests now, investigating the stragglers.

pull/306/head
Matthew Johnson 11 years ago
parent
commit
8d06f9d435
  1. 24
      src/NativeProviders/CUDA/blas.cpp
  2. 15
      src/NativeProviders/CUDA/lapack.cpp
  3. 10
      src/Numerics/Providers/LinearAlgebra/Cuda/CudaLinearAlgebraProvider.Complex.cs
  4. 12
      src/Numerics/Providers/LinearAlgebra/Cuda/CudaLinearAlgebraProvider.Complex32.cs
  5. 13
      src/Numerics/Providers/LinearAlgebra/Cuda/CudaLinearAlgebraProvider.Double.cs
  6. 8
      src/Numerics/Providers/LinearAlgebra/Cuda/CudaLinearAlgebraProvider.Single.cs
  7. 4
      src/Numerics/Providers/LinearAlgebra/Cuda/CudaLinearAlgebraProvider.cs
  8. 20
      src/UnitTests/LinearAlgebraProviderTests/Complex/LinearAlgebraProviderTests.cs
  9. 20
      src/UnitTests/LinearAlgebraProviderTests/Complex32/LinearAlgebraProviderTests.cs
  10. 20
      src/UnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs

24
src/NativeProviders/CUDA/blas.cpp

@ -4,7 +4,7 @@
#include "wrapper_common.h"
template<typename T, typename AXPY>
void cuda_axpy(const cublasHandle_t blasHandle, const int n, const T *alpha, const T x[], int incX, T y[], int incY, AXPY axpy)
void cuda_axpy(const cublasHandle_t blasHandle, const int n, const T alpha, const T x[], int incX, T y[], int incY, AXPY axpy)
{
T *d_X = NULL;
T *d_Y = NULL;
@ -14,7 +14,7 @@ void cuda_axpy(const cublasHandle_t blasHandle, const int n, const T *alpha, con
cublasSetVector(n, sizeof(T), x, incX, d_X, incX);
cublasSetVector(n, sizeof(T), y, incY, d_Y, incY);
axpy(blasHandle, n, alpha, d_X, incX, d_Y, incX);
axpy(blasHandle, n, &alpha, d_X, incX, d_Y, incX);
cublasGetVector(n, sizeof(T), d_Y, incY, y, incY);
@ -23,14 +23,14 @@ void cuda_axpy(const cublasHandle_t blasHandle, const int n, const T *alpha, con
}
template<typename T, typename SCAL>
void cuda_scal(const cublasHandle_t blasHandle, const int n, const T *alpha, T x[], int incX, SCAL scal)
void cuda_scal(const cublasHandle_t blasHandle, const int n, const T alpha, T x[], int incX, SCAL scal)
{
T *d_X = NULL;
cudaMalloc((void**)&d_X, n*sizeof(T));
cublasSetVector(n, sizeof(T), x, incX, d_X, incX);
scal(blasHandle, n, alpha, d_X, incX);
scal(blasHandle, n, &alpha, d_X, incX);
cublasGetVector(n, sizeof(T), d_X, incX, x, incX);
@ -81,35 +81,35 @@ void cuda_gemm(const cublasHandle_t handle, const cublasOperation_t transa, cons
extern "C" {
DLLEXPORT void s_axpy(const cublasHandle_t blasHandle, const int n, const float alpha, const float x[], float y[]){
cuda_axpy(blasHandle, n, &alpha, x, 1, y, 1, cublasSaxpy);
cuda_axpy(blasHandle, n, alpha, x, 1, y, 1, cublasSaxpy);
}
DLLEXPORT void d_axpy(const cublasHandle_t blasHandle, const int n, const double alpha, const double x[], double y[]){
cuda_axpy(blasHandle, n, &alpha, x, 1, y, 1, cublasDaxpy);
cuda_axpy(blasHandle, n, alpha, x, 1, y, 1, cublasDaxpy);
}
DLLEXPORT void c_axpy(const cublasHandle_t blasHandle, const int n, const cuComplex alpha, const cuComplex x[], cuComplex y[]){
cuda_axpy(blasHandle, n, &alpha, x, 1, y, 1, cublasCaxpy);
cuda_axpy(blasHandle, n, alpha, x, 1, y, 1, cublasCaxpy);
}
DLLEXPORT void z_axpy(const cublasHandle_t blasHandle, const int n, const cuDoubleComplex alpha, const cuDoubleComplex x[], cuDoubleComplex y[]){
cuda_axpy(blasHandle, n, &alpha, x, 1, y, 1, cublasZaxpy);
cuda_axpy(blasHandle, n, alpha, x, 1, y, 1, cublasZaxpy);
}
DLLEXPORT void s_scale(const cublasHandle_t blasHandle, const int n, const float alpha, float x[]){
cuda_scal(blasHandle, n, &alpha, x, 1, cublasSscal);
cuda_scal(blasHandle, n, alpha, x, 1, cublasSscal);
}
DLLEXPORT void d_scale(const cublasHandle_t blasHandle, const int n, const double alpha, double x[]){
cuda_scal(blasHandle, n, &alpha, x, 1, cublasDscal);
cuda_scal(blasHandle, n, alpha, x, 1, cublasDscal);
}
DLLEXPORT void c_scale(const cublasHandle_t blasHandle, const int n, const cuComplex alpha, cuComplex x[]){
cuda_scal(blasHandle, n, &alpha, x, 1, cublasCscal);
cuda_scal(blasHandle, n, alpha, x, 1, cublasCscal);
}
DLLEXPORT void z_scale(const cublasHandle_t blasHandle, const int n, const cuDoubleComplex alpha, cuDoubleComplex x[]){
cuda_scal(blasHandle, n, &alpha, x, 1, cublasZscal);
cuda_scal(blasHandle, n, alpha, x, 1, cublasZscal);
}
DLLEXPORT float s_dot_product(const cublasHandle_t blasHandle, const int n, const float x[], const float y[]){

15
src/NativeProviders/CUDA/lapack.cpp

@ -31,7 +31,7 @@ inline int lu_factor(cusolverDnHandle_t solverHandle, int m, T a[], int ipiv[],
cudaMemcpy(&info, d_info, sizeof(int), cudaMemcpyDeviceToHost);
cublasGetMatrix(m, m, sizeof(T), d_A, m, a, m);
cublasGetVector(m, sizeof(T), d_I, 1, ipiv, 1);
cublasGetVector(m, sizeof(int), d_I, 1, ipiv, 1);
shift_ipiv_down(m, ipiv);
@ -49,7 +49,7 @@ inline int lu_inverse(cusolverDnHandle_t solverHandle, cublasHandle_t blasHandle
int info = 0;
int* d_I = NULL;
cudaMalloc((void**)&d_I, n*sizeof(T));
cudaMalloc((void**)&d_I, n*sizeof(int));
T* d_A = NULL;
cudaMalloc((void**)&d_A, n*n*sizeof(T));
@ -192,7 +192,7 @@ inline int lu_solve(cusolverDnHandle_t solverHandle, int n, int nrhs, T a[], T b
int info = 0;
int* d_I = NULL;
cudaMalloc((void**)&d_I, n*sizeof(T));
cudaMalloc((void**)&d_I, n*sizeof(int));
T* d_A = NULL;
cudaMalloc((void**)&d_A, n*n*sizeof(T));
@ -306,7 +306,7 @@ inline int cholesky_solve(cusolverDnHandle_t solverHandle, int n, int nrhs, T a[
}
T* d_B = NULL;
cudaMalloc((void**)d_B, n*nrhs*sizeof(T));
cudaMalloc((void**)&d_B, n*nrhs*sizeof(T));
cublasSetMatrix(n, nrhs, sizeof(T), b, n, d_B, n);
potrs(solverHandle, CUBLAS_FILL_MODE_LOWER, n, nrhs, d_A, n, d_B, n, d_info);
@ -331,7 +331,7 @@ inline int cholesky_solve_factored(cusolverDnHandle_t solverHandle, int n, int n
cublasSetMatrix(n, n, sizeof(T), a, n, d_A, n);
T* d_B = NULL;
cudaMalloc((void**)d_B, n*nrhs*sizeof(T));
cudaMalloc((void**)&d_B, n*nrhs*sizeof(T));
cublasSetMatrix(n, nrhs, sizeof(T), b, n, d_B, n);
int* d_info = NULL;
@ -461,7 +461,7 @@ inline int svd_factor(cusolverDnHandle_t solverHandle, bool compute_vectors, int
cudaMalloc((void**)&d_U, m*m*sizeof(T));
T* d_V = NULL;
cudaMalloc((void**)&d_V, n*m*sizeof(T));
cudaMalloc((void**)&d_V, n*n*sizeof(T));
T* work = NULL;
int lWork = 0;
@ -474,7 +474,6 @@ inline int svd_factor(cusolverDnHandle_t solverHandle, bool compute_vectors, int
int* d_info = NULL;
cudaMalloc((void**)&d_info, sizeof(int));
char job = compute_vectors ? 'A' : 'N';
gesvd(solverHandle, job, job, m, n, d_A, m, d_S, d_U, m, d_V, n, work, lWork, rwork, d_info);
cudaMemcpy(&info, d_info, sizeof(int), cudaMemcpyDeviceToHost);
@ -529,7 +528,7 @@ inline int complex_svd_factor(cusolverDnHandle_t solverHandle, bool compute_vect
gesvd(solverHandle, job, job, m, n, d_A, m, d_S, d_U, m, d_V, n, work, lWork, rwork, d_info);
cudaMemcpy(&info, d_info, sizeof(int), cudaMemcpyDeviceToHost);
cublasGetVector(dim_s, sizeof(T), d_S, 1, s_local, 1);
cublasGetVector(dim_s, sizeof(R), d_S, 1, s_local, 1);
cublasGetMatrix(m, m, sizeof(T), d_U, m, u, m);
cublasGetMatrix(n, n, sizeof(T), d_V, n, v, n);

10
src/Numerics/Providers/LinearAlgebra/Cuda/CudaLinearAlgebraProvider.Complex.cs

@ -317,7 +317,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
if (work != null)
{
throw new NotSupportedException(Resources.UserWorkBufferNotSupported);
throw new ArgumentException(Resources.UserWorkBufferNotSupported);
}
Solver(SafeNativeMethods.z_lu_inverse(_solverHandle, _blasHandle, order, a));
@ -356,7 +356,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
if (work != null)
{
throw new NotSupportedException(Resources.UserWorkBufferNotSupported);
throw new ArgumentException(Resources.UserWorkBufferNotSupported);
}
BLAS(SafeNativeMethods.z_lu_inverse_factored(_blasHandle, order, a, ipiv));
@ -677,7 +677,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
if (work != null)
{
throw new NotSupportedException(Resources.UserWorkBufferNotSupported);
throw new ArgumentException(Resources.UserWorkBufferNotSupported);
}
if (u.Length != rowsA*rowsA)
@ -695,7 +695,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
throw new ArgumentException(Resources.ArgumentArraysSameLength, "s");
}
Solver(SafeNativeMethods.z_svd_factor(_solverHandle, computeVectors, rowsA, columnsA, a, s, u, vt));
if (columnsA > rowsA || !computeVectors) // see remarks http://docs.nvidia.com/cuda/cusolver/index.html#cuds-lt-t-gt-gesvd
base.SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt, new Complex[rowsA]);
else Solver(SafeNativeMethods.z_svd_factor(_solverHandle, computeVectors, rowsA, columnsA, a, s, u, vt));
}
}
}

12
src/Numerics/Providers/LinearAlgebra/Cuda/CudaLinearAlgebraProvider.Complex32.cs

@ -317,7 +317,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
if (work != null)
{
throw new NotSupportedException(Resources.UserWorkBufferNotSupported);
throw new ArgumentException(Resources.UserWorkBufferNotSupported);
}
Solver(SafeNativeMethods.c_lu_inverse(_solverHandle, _blasHandle, order, a));
@ -356,7 +356,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
if (work != null)
{
throw new NotSupportedException(Resources.UserWorkBufferNotSupported);
throw new ArgumentException(Resources.UserWorkBufferNotSupported);
}
BLAS(SafeNativeMethods.c_lu_inverse_factored(_blasHandle, order, a, ipiv));
@ -589,7 +589,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
throw new ArgumentException(Resources.ArgumentArraysSameLength, "s");
}
SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt);
SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt, null);
}
/// <summary>
@ -677,7 +677,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
if (work != null)
{
throw new NotSupportedException(Resources.UserWorkBufferNotSupported);
throw new ArgumentException(Resources.UserWorkBufferNotSupported);
}
if (u.Length != rowsA*rowsA)
@ -695,7 +695,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
throw new ArgumentException(Resources.ArgumentArraysSameLength, "s");
}
Solver(SafeNativeMethods.c_svd_factor(_solverHandle, computeVectors, rowsA, columnsA, a, s, u, vt));
if (columnsA > rowsA || !computeVectors) // see remarks http://docs.nvidia.com/cuda/cusolver/index.html#cuds-lt-t-gt-gesvd
base.SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt, new Complex32[rowsA]);
else Solver(SafeNativeMethods.c_svd_factor(_solverHandle, computeVectors, rowsA, columnsA, a, s, u, vt));
}
}
}

13
src/Numerics/Providers/LinearAlgebra/Cuda/CudaLinearAlgebraProvider.Double.cs

@ -317,7 +317,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
if (work != null)
{
throw new NotSupportedException(Resources.UserWorkBufferNotSupported);
throw new ArgumentException(Resources.UserWorkBufferNotSupported);
}
Solver(SafeNativeMethods.d_lu_inverse(_solverHandle, _blasHandle, order, a));
@ -356,7 +356,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
if (work != null)
{
throw new NotSupportedException(Resources.UserWorkBufferNotSupported);
throw new ArgumentException(Resources.UserWorkBufferNotSupported);
}
BLAS(SafeNativeMethods.d_lu_inverse_factored(_blasHandle, order, a, ipiv));
@ -589,7 +589,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
throw new ArgumentException(Resources.ArgumentArraysSameLength, "s");
}
SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt);
SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt, null);
}
/// <summary>
@ -677,7 +677,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
if (work != null)
{
throw new NotSupportedException(Resources.UserWorkBufferNotSupported);
throw new ArgumentException(Resources.UserWorkBufferNotSupported);
}
if (u.Length != rowsA*rowsA)
@ -695,8 +695,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
throw new ArgumentException(Resources.ArgumentArraysSameLength, "s");
}
Solver (SafeNativeMethods.d_svd_factor(_solverHandle, computeVectors, rowsA, columnsA, a, s, u, vt));
if (columnsA > rowsA || !computeVectors) // see remarks http://docs.nvidia.com/cuda/cusolver/index.html#cuds-lt-t-gt-gesvd
base.SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt, new double[rowsA]);
else Solver (SafeNativeMethods.d_svd_factor(_solverHandle, computeVectors, rowsA, columnsA, a, s, u, vt));
}
}
}

8
src/Numerics/Providers/LinearAlgebra/Cuda/CudaLinearAlgebraProvider.Single.cs

@ -317,7 +317,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
if (work != null)
{
throw new NotSupportedException(Resources.UserWorkBufferNotSupported);
throw new ArgumentException(Resources.UserWorkBufferNotSupported);
}
Solver(SafeNativeMethods.s_lu_inverse(_solverHandle, _blasHandle, order, a));
@ -356,7 +356,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
if (work != null)
{
throw new NotSupportedException(Resources.UserWorkBufferNotSupported);
throw new ArgumentException(Resources.UserWorkBufferNotSupported);
}
BLAS(SafeNativeMethods.s_lu_inverse_factored(_blasHandle, order, a, ipiv));
@ -695,7 +695,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
throw new ArgumentException(Resources.ArgumentArraysSameLength, "s");
}
Solver(SafeNativeMethods.s_svd_factor(_solverHandle, computeVectors, rowsA, columnsA, a, s, u, vt));
if (columnsA > rowsA || !computeVectors) // see remarks http://docs.nvidia.com/cuda/cusolver/index.html#cuds-lt-t-gt-gesvd
base.SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt, new float[rowsA]);
else Solver(SafeNativeMethods.s_svd_factor(_solverHandle, computeVectors, rowsA, columnsA, a, s, u, vt));
}
}
}

4
src/Numerics/Providers/LinearAlgebra/Cuda/CudaLinearAlgebraProvider.cs

@ -168,13 +168,13 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
throw new Exception("Mapping error");
case 6: // CUSOLVER_STATUS_EXECUTION_FAILED
throw new Exception("Execution failed");
throw new NonConvergenceException("Execution failed");
case 7: //CUSOLVER_STATUS_INTERNAL_ERROR
throw new Exception("Internal error");
case 8: // CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED
throw new NotSupportedException("Matrix type not supported");
throw new ArgumentException("Matrix type not supported");
case 9: // CUSOLVER_STATUS_NOT_SUPPORTED
throw new NotSupportedException();

20
src/UnitTests/LinearAlgebraProviderTests/Complex/LinearAlgebraProviderTests.cs

@ -444,7 +444,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex
var a = new Complex[matrix.RowCount*matrix.RowCount];
Array.Copy(matrix.Values, a, a.Length);
#if CUDA
Complex[] work = null;
#else
var work = new Complex[matrix.RowCount];
#endif
Control.LinearAlgebraProvider.LUInverse(a, matrix.RowCount, work);
AssertHelpers.AlmostEqualRelative(a[0], -0.454545454545454, 13);
@ -473,7 +477,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
#if CUDA
Complex[] work = null;
#else
var work = new Complex[matrix.RowCount];
#endif
Control.LinearAlgebraProvider.LUInverseFactored(a, matrix.RowCount, ipiv, work);
AssertHelpers.AlmostEqualRelative(a[0], -0.454545454545454, 13);
@ -1447,7 +1455,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex
var s = new Complex[matrix.RowCount];
var u = new Complex[matrix.RowCount*matrix.RowCount];
var vt = new Complex[matrix.ColumnCount*matrix.ColumnCount];
#if CUDA
Complex[] work = null;
#else
var work = new Complex[100];
#endif
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt, work);
@ -1486,7 +1498,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex
var s = new Complex[matrix.ColumnCount];
var u = new Complex[matrix.RowCount*matrix.RowCount];
var vt = new Complex[matrix.ColumnCount*matrix.ColumnCount];
#if CUDA
Complex[] work = null;
#else
var work = new Complex[100];
#endif
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt, work);
@ -1522,7 +1538,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex
var s = new Complex[matrix.RowCount];
var u = new Complex[matrix.RowCount*matrix.RowCount];
var vt = new Complex[matrix.ColumnCount*matrix.ColumnCount];
#if CUDA
Complex[] work = null;
#else
var work = new Complex[100];
#endif
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt, work);

20
src/UnitTests/LinearAlgebraProviderTests/Complex32/LinearAlgebraProviderTests.cs

@ -448,7 +448,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32
var a = new Complex32[matrix.RowCount*matrix.RowCount];
Array.Copy(matrix.Values, a, a.Length);
#if CUDA
Complex32[] work = null;
#else
var work = new Complex32[matrix.RowCount];
#endif
Control.LinearAlgebraProvider.LUInverse(a, matrix.RowCount, work);
AssertHelpers.AlmostEqualRelative(a[0], -0.454545454545454f, 5);
@ -477,7 +481,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
#if CUDA
Complex32[] work = null;
#else
var work = new Complex32[matrix.RowCount];
#endif
Control.LinearAlgebraProvider.LUInverseFactored(a, matrix.RowCount, ipiv, work);
AssertHelpers.AlmostEqualRelative(a[0], -0.454545454545454f, 5);
@ -1452,7 +1460,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32
var s = new Complex32[matrix.RowCount];
var u = new Complex32[matrix.RowCount*matrix.RowCount];
var vt = new Complex32[matrix.ColumnCount*matrix.ColumnCount];
#if CUDA
Complex32[] work = null;
#else
var work = new Complex32[100];
#endif
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt, work);
@ -1491,7 +1503,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32
var s = new Complex32[matrix.ColumnCount];
var u = new Complex32[matrix.RowCount*matrix.RowCount];
var vt = new Complex32[matrix.ColumnCount*matrix.ColumnCount];
#if CUDA
Complex32[] work = null;
#else
var work = new Complex32[100];
#endif
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt, work);
@ -1527,7 +1543,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32
var s = new Complex32[matrix.RowCount];
var u = new Complex32[matrix.RowCount*matrix.RowCount];
var vt = new Complex32[matrix.ColumnCount*matrix.ColumnCount];
#if CUDA
Complex32[] work = null;
#else
var work = new Complex32[100];
#endif
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt, work);

20
src/UnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs

@ -438,7 +438,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var a = new double[matrix.RowCount*matrix.RowCount];
Array.Copy(matrix.Values, a, a.Length);
#if CUDA
double[] work = null;
#else
var work = new double[matrix.RowCount];
#endif
Control.LinearAlgebraProvider.LUInverse(a, matrix.RowCount, work);
AssertHelpers.AlmostEqualRelative(a[0], -0.454545454545454, 13);
@ -467,7 +471,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
#if CUDA
double[] work = null;
#else
var work = new double[matrix.RowCount];
#endif
Control.LinearAlgebraProvider.LUInverseFactored(a, matrix.RowCount, ipiv, work);
AssertHelpers.AlmostEqualRelative(a[0], -0.454545454545454, 13);
@ -1442,7 +1450,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var s = new double[matrix.RowCount];
var u = new double[matrix.RowCount*matrix.RowCount];
var vt = new double[matrix.ColumnCount*matrix.ColumnCount];
#if CUDA
double[] work = null;
#else
var work = new double[100];
#endif
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt, work);
@ -1481,7 +1493,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var s = new double[matrix.ColumnCount];
var u = new double[matrix.RowCount*matrix.RowCount];
var vt = new double[matrix.ColumnCount*matrix.ColumnCount];
#if CUDA
double[] work = null;
#else
var work = new double[100];
#endif
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt, work);
@ -1517,7 +1533,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var s = new double[matrix.RowCount];
var u = new double[matrix.RowCount*matrix.RowCount];
var vt = new double[matrix.ColumnCount*matrix.ColumnCount];
#if CUDA
double[] work = null;
#else
var work = new double[100];
#endif
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt, work);

Loading…
Cancel
Save