Commit 026abedb authored by Davis King's avatar Davis King

Made cholesky_decomposition use the triangular solver

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403835
parent 788b38d2
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "lapack/potrf.h" #include "lapack/potrf.h"
#endif #endif
#include "matrix_trsm.h"
namespace dlib namespace dlib
{ {
...@@ -208,32 +210,11 @@ namespace dlib ...@@ -208,32 +210,11 @@ namespace dlib
matrix<type, NR, EXP::NC, mem_manager_type, layout_type> X(B); matrix<type, NR, EXP::NC, mem_manager_type, layout_type> X(B);
const long nx = B.nc(); using namespace blas_bindings;
const long n = L_.nr();
// Solve L*y = b; // Solve L*y = b;
for (long j=0; j< nx; j++) triangular_solver(CblasLeft, CblasLower, CblasNoTrans, CblasNonUnit, L_, X);
{
for (long k = 0; k < n; k++)
{
for (long i = 0; i < k; i++)
X(k,j) -= X(i,j)*L_(k,i);
X(k,j) /= L_(k,k);
}
}
// Solve L'*X = Y; // Solve L'*X = Y;
for (long j=0; j<nx; j++) triangular_solver(CblasLeft, CblasLower, CblasTrans, CblasNonUnit, L_, X);
{
for (long k = n-1; k >= 0; k--)
{
for (long i = k+1; i < n; i++)
X(k,j) -= X(i,j)*L_(i,k);
X(k,j) /= L_(k,k);
}
}
return X; return X;
} }
......
// Copyright (C) 2010 Davis E. King (davis@dlib.net) // Copyright (C) 2010 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license. // License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_MATRiX_TRSM_H__
#define DLIB_MATRiX_TRSM_H__
#include "lapack/fortran_id.h" #include "lapack/fortran_id.h"
#include "cblas_constants.h" #include "cblas_constants.h"
...@@ -616,3 +618,5 @@ namespace dlib ...@@ -616,3 +618,5 @@ namespace dlib
} }
} }
#endif // DLIB_MATRiX_TRSM_H__
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment