RQ.h
Go to the documentation of this file.
1 /*!
2  *
3  *
4  * \brief Algorithm for Triangular-Quadratic-Decomposition
5  *
6  *
7  *
8  *
9  * \author O. Krause
10  * \date 2011
11  *
12  *
13  * \par Copyright 1995-2015 Shark Development Team
14  *
15  * <BR><HR>
16  * This file is part of Shark.
17  * <http://image.diku.dk/shark/>
18  *
19  * Shark is free software: you can redistribute it and/or modify
20  * it under the terms of the GNU Lesser General Public License as published
21  * by the Free Software Foundation, either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * Shark is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU Lesser General Public License for more details.
28  *
29  * You should have received a copy of the GNU Lesser General Public License
30  * along with Shark. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
33 #ifndef SHARK_LINALG_RQ_H
34 #define SHARK_LINALG_RQ_H
35 
36 #include <shark/LinAlg/Base.h>
37 namespace shark{ namespace blas{
38 
39 /**
40  * \ingroup shark_globals
41  *
42  * @{
43  */
44 
45 
46 
47 /*!
48  * \brief Determines the RQ Decomposition of the matrix A using pivoting
49  * returning the housholder transformation instead of Q.
50  *
51  * The pivoting RQ-Decomposition finds an orthonormal matrix Q and a lower Triangular matrix R
52  * as well as a permutation matrix P such that PA = R*Q.
53  * Since Q is the multiplication of all householder transformations,
54  * It is quite expensive to compute. Often, Q is only an intermediate step in computations which can be
55  * carried out more efficiently using the Householder Transformations themselves.
56  *
57  * The Matrix format of the householder transform is that the transformations are stored as
58  * upper triangular matrix. The first transformation being in the first row and so on.
59  */
60 template<class MatrixT,class Mat>
61 std::size_t pivotingRQ
62 (
63  blas::matrix_expression<MatrixT> const& matrixA,
64  blas::matrix_container<Mat>& matrixR,
65  blas::matrix_container<Mat>& matrixQ,
66  blas::permutation_matrix& permutation
67 );
68 
69 /*!
70  * \brief Determines the RQ Decomposition of the matrix A using pivoting
71  *
72  * The pivoting RQ-Decomposition finds an orthonormal matrix Q and a lower Triangular matrix R
73  * as well as a permuation matrix P such that PA = R*Q.
74  * This function is better known as the QR-Decomposition
75  * of a transposed matrix B^T = A and B = QR.
76  *
77  * This version of the algorithm is based on householder transformations. since it uses pivoting it can
78  * be used to determine the rank of a matrix. The i-th applied householder decomposition has the form
79  * H_i=I-v_iv_i^T and the v_i are stored separately.
80  * A mxn natrix needs at most k=min{m,n} transformations.
81  * Also as RQ=AH_1,...,H_k Q=H_k,...,H_1
82  */
83 template<class MatrixT,class MatrixU>
84 std::size_t pivotingRQHouseholder
85 (
86  blas::matrix_expression<MatrixT> const& matrixA,
87  blas::matrix_container<MatrixU>& matrixR,
88  blas::matrix_container<MatrixU>& householderV,
89  blas::permutation_matrix& permutation
90 );
91 
92 
93 /** @}*/
94 }}
95 
96 #include "Impl/pivotingRQ.inl"
97 #endif