From 4628fc4de6cbf44fafe0cff7579815df98021fb2 Mon Sep 17 00:00:00 2001 From: Marcus Cuda Date: Thu, 24 Feb 2011 20:54:22 +0800 Subject: [PATCH] started lu solve --- src/NativeWrappers/MKL/lapack.cpp | 55 +++++++++++++++++-- .../LinearAlgebra/safe.native.common.include | 23 ++++++++ 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/src/NativeWrappers/MKL/lapack.cpp b/src/NativeWrappers/MKL/lapack.cpp index ba2078df..4f4686dc 100644 --- a/src/NativeWrappers/MKL/lapack.cpp +++ b/src/NativeWrappers/MKL/lapack.cpp @@ -221,7 +221,7 @@ extern "C" { } } - DLLEXPORT void s_lu_solve(int n, int nrhs, float a[], int ipiv[], float b[]) + DLLEXPORT void s_lu_solve_factored(int n, int nrhs, float a[], int ipiv[], float b[]) { int info; int i; @@ -236,7 +236,7 @@ extern "C" { } } - DLLEXPORT void d_lu_solve(int n, int nrhs, double a[], int ipiv[], double b[]) + DLLEXPORT void d_lu_solve_factored(int n, int nrhs, double a[], int ipiv[], double b[]) { int info; int i; @@ -251,7 +251,7 @@ extern "C" { } } - DLLEXPORT void c_lu_solve(int n, int nrhs, MKL_Complex8 a[], int ipiv[], MKL_Complex8 b[]) + DLLEXPORT void c_lu_solve_factored(int n, int nrhs, MKL_Complex8 a[], int ipiv[], MKL_Complex8 b[]) { int info; int i; @@ -266,7 +266,7 @@ extern "C" { } } - DLLEXPORT void z_lu_solve(int n, int nrhs, MKL_Complex16 a[], int ipiv[], MKL_Complex16 b[]) + DLLEXPORT void z_lu_solve_factored(int n, int nrhs, MKL_Complex16 a[], int ipiv[], MKL_Complex16 b[]) { int info; int i; @@ -281,7 +281,52 @@ extern "C" { } } - DLLEXPORT void s_cholesky_solve(int n, int nrhs, float a[], float b[]) + DLLEXPORT void s_lu_solve(int n, int nrhs, float a[], float b[]) + { + int* ipiv = new int[n]; + int info; + SGETRF(&n,&n,a,&n,ipiv,&info); + + char trans = 'N'; + SGETRS(&trans, &n, &nrhs, a, &n, ipiv, b, &n, &info); + delete[] ipiv; + } + + DLLEXPORT void d_lu_solve(int n, int nrhs, double a[], double b[]) + { + int* ipiv = new int[n]; + int info; + DGETRF(&n,&n,a,&n,ipiv,&info); + + char trans = 'N'; + DGETRS(&trans, &n, &nrhs, a, &n, ipiv, b, &n, &info); + delete[] ipiv; + } + + DLLEXPORT void c_lu_solve(int n, int nrhs, MKL_Complex8 a[], MKL_Complex8 b[]) + { + int* ipiv = new int[n]; + int info; + CGETRF(&n,&n,a,&n,ipiv,&info); + + char trans = 'N'; + CGETRS(&trans, &n, &nrhs, a, &n, ipiv, b, &n, &info); + delete[] ipiv; + } + + DLLEXPORT void z_lu_solve(int n, int nrhs, MKL_Complex16 a[], MKL_Complex16 b[]) + { + int* ipiv = new int[n]; + int info; + ZGETRF(&n,&n,a,&n,ipiv,&info); + + char trans = 'N'; + ZGETRS(&trans, &n, &nrhs, a, &n, ipiv, b, &n, &info); + delete[] ipiv; + } + + + DLLEXPORT void s_cholesky_solve(int n, int nrhs, float a[], float b[]) { char uplo = 'L'; int info = 0; diff --git a/src/Numerics/Algorithms/LinearAlgebra/safe.native.common.include b/src/Numerics/Algorithms/LinearAlgebra/safe.native.common.include index 64005896..230e00b8 100644 --- a/src/Numerics/Algorithms/LinearAlgebra/safe.native.common.include +++ b/src/Numerics/Algorithms/LinearAlgebra/safe.native.common.include @@ -161,4 +161,27 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#= namespaceSuffix #> [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern void z_lu_inverse_factored(int n, [In, Out] Complex[] a, [In, Out] int[] ipiv, [In, Out] Complex[] work, int lwork); + /* [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + internal static extern void s_lu_solve_factored(int n, int nrhs, float a[], int ipiv[], float b[]) + + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + internal static extern void d_lu_solve_factored(int n, int nrhs, double a[], int ipiv[], double b[]) + + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + internal static extern void c_lu_solve_factored(int n, int nrhs, MKL_Complex8 a[], int ipiv[], MKL_Complex8 b[]) + + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + internal static extern void z_lu_solve_factored(int n, int nrhs, MKL_Complex16 a[], int ipiv[], MKL_Complex16 b[]) + + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + internal static extern void s_lu_solve(int n, int nrhs, float a[], float b[]) + + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + internal static extern void d_lu_solve(int n, int nrhs, double a[], double b[]) + + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + internal static extern void c_lu_solve(int n, int nrhs, MKL_Complex8 a[], MKL_Complex8 b[]) + + [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + internal static extern void z_lu_solve(int n, int nrhs, MKL_Complex16 a[], MKL_Complex16 b[])*/ #endregion LAPACK