pstrf.hpp
Go to the documentation of this file.
1 /*!
2  *
3  *
4  * \brief Dispatches the POTRF algorithm
5  *
6  * \author O. Krause
7  * \date 2012
8  *
9  *
10  * \par Copyright 1995-2014 Shark Development Team
11  *
12  * <BR><HR>
13  * This file is part of Shark.
14  * <http://image.diku.dk/shark/>
15  *
16  * Shark is free software: you can redistribute it and/or modify
17  * it under the terms of the GNU Lesser General Public License as published
18  * by the Free Software Foundation, either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * Shark is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU Lesser General Public License for more details.
25  *
26  * You should have received a copy of the GNU Lesser General Public License
27  * along with Shark. If not, see <http://www.gnu.org/licenses/>.
28  *
29  */
30 
31 #ifndef REMORA_KERNELS_PSTRF_HPP
32 #define REMORA_KERNELS_PSTRF_HPP
33 
34 #include "default/pstrf.hpp"
35 
36 namespace remora {
37 namespace kernels {
38 
39 /*!
40  * \brief Cholesky decomposition with full pivoting performed in place.
41  *
42  * Given an \f$ m \times m \f$ symmetric positive semi-definite matrix
43  * \f$A\f$, compute thes matrix \f$L\f$ and permutation Matrix P such that
44  * \f$P^TAP = LL^T \f$. If matrix A has rank(A) = k, the first k columns of A hold the full
45  * decomposition, while the rest of the matrix is zero.
46  * This method is slower than the cholesky decomposition without pivoting but numerically more
47  * stable. The diagonal elements are ordered such that i > j => L(i,i) >= L(j,j)
48  *
49  * The implementation used here is described in the working paper
50  * "LAPACK-Style Codes for Level 2 and 3 Pivoted Cholesky Factorizations"
51  * http://www.netlib.org/lapack/lawnspdf/lawn161.pdf
52  *
53  * The computation is carried out in place this means A is destroyed and replaced by L.
54  *
55  *
56  * \param A \f$ m \times m \f$ matrix, which must be symmetric and positive definite. It is replaced by L in the end.
57  * \param P The pivoting matrix of dimension \f$ m \f$
58  * \return The rank of the matrix A
59  */
60 template<class Triangular, class MatA, class VecP>
61 std::size_t pstrf(
62  matrix_expression<MatA, cpu_tag>&A,
63  vector_expression<VecP, cpu_tag>& P
64 ){
65  REMORA_SIZE_CHECK(A().size1() == A().size2());
66  REMORA_SIZE_CHECK(P().size() == A().size1());
67  return bindings::pstrf(A,P, Triangular());
68 }
69 
70 
71 }}
72 
73 #endif