cholesky.cpp
Go to the documentation of this file.
#ifndef _MSC_VER
# include <itpp/config.h>
#else
# include <itpp/config_msvc.h>
#endif
#if defined(HAVE_LAPACK)
# include <itpp/base/algebra/lapack.h>
#endif
#include <itpp/base/algebra/cholesky.h>
namespace itpp
{
#if defined(HAVE_LAPACK)
bool chol(const mat &X, mat &F)
{
char uplo = 'U';
int n, lda, info;
n = lda = X.rows();
F = X; // input matrix is overwritten
dpotrf_(&uplo, &n, F._data(), &lda, &info);
// Set lower part to zero
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
F(j, i) = 0;
return (info == 0);
}
bool chol(const cmat &X, cmat &F)
{
char uplo = 'U';
int n, lda, info;
n = lda = X.rows();
F = X; // input matrix is overwritten
zpotrf_(&uplo, &n, F._data(), &lda, &info);
// Set lower part to zero
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
F(j, i) = 0;
return (info == 0);
}
#else // HAVE_LAPACK
bool chol(const mat &X, mat &F)
{
it_error("LAPACK library is needed to use chol() function");
return false;
}
bool chol(const cmat &X, cmat &F)
{
it_error("LAPACK library is needed to use chol() function");
return false;
}
#endif // HAVE_LAPACK
cmat chol(const cmat &X)
{
cmat F;
if (!chol(X, F)) {
it_warning("cholesky factorization didn't succeed");
}
return F;
}
mat chol(const mat &X)
{
mat F;
if (!chol(X, F)) {
it_warning("cholesky factorization didn't succeed");
}
return F;
}
} // namespace itpp
itpp::chol
bool chol(const mat &X, mat &F)
Cholesky factorisation of real symmetric and positive definite matrix.
Definition: cholesky.cpp:86
itpp
itpp namespace
Definition: itmex.h:36
it_warning
#define it_warning(s)
Display a warning message.
Definition: itassert.h:173
it_error
#define it_error(s)
Abort unconditionally.
Definition: itassert.h:126
cholesky.h
Definitions of Cholesky factorisation functions.

Generated on Thu Aug 20 2015 21:02:49 for IT++ by Doxygen 1.8.9.1