From 44861dcbfeee041223c4aac1ee075e92fa4daa01 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 18 Sep 2016 12:42:15 +0200 Subject: update --- eigen/lapack/cholesky.cpp | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 eigen/lapack/cholesky.cpp (limited to 'eigen/lapack/cholesky.cpp') diff --git a/eigen/lapack/cholesky.cpp b/eigen/lapack/cholesky.cpp new file mode 100644 index 0000000..ea3bc12 --- /dev/null +++ b/eigen/lapack/cholesky.cpp @@ -0,0 +1,72 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2010-2011 Gael Guennebaud +// +// This Source Code Form is subject to the terms of the Mozilla +// Public License v. 2.0. If a copy of the MPL was not distributed +// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include "lapack_common.h" +#include + +// POTRF computes the Cholesky factorization of a real symmetric positive definite matrix A. +EIGEN_LAPACK_FUNC(potrf,(char* uplo, int *n, RealScalar *pa, int *lda, int *info)) +{ + *info = 0; + if(UPLO(*uplo)==INVALID) *info = -1; + else if(*n<0) *info = -2; + else if(*lda(pa); + MatrixType A(a,*n,*n,*lda); + int ret; + if(UPLO(*uplo)==UP) ret = int(internal::llt_inplace::blocked(A)); + else ret = int(internal::llt_inplace::blocked(A)); + + if(ret>=0) + *info = ret+1; + + return 0; +} + +// POTRS solves a system of linear equations A*X = B with a symmetric +// positive definite matrix A using the Cholesky factorization +// A = U**T*U or A = L*L**T computed by DPOTRF. +EIGEN_LAPACK_FUNC(potrs,(char* uplo, int *n, int *nrhs, RealScalar *pa, int *lda, RealScalar *pb, int *ldb, int *info)) +{ + *info = 0; + if(UPLO(*uplo)==INVALID) *info = -1; + else if(*n<0) *info = -2; + else if(*nrhs<0) *info = -3; + else if(*lda(pa); + Scalar* b = reinterpret_cast(pb); + MatrixType A(a,*n,*n,*lda); + MatrixType B(b,*n,*nrhs,*ldb); + + if(UPLO(*uplo)==UP) + { + A.triangularView().adjoint().solveInPlace(B); + A.triangularView().solveInPlace(B); + } + else + { + A.triangularView().solveInPlace(B); + A.triangularView().adjoint().solveInPlace(B); + } + + return 0; +} -- cgit v1.2.3