1 | /*! |
---|
2 | * \file |
---|
3 | * \brief Definitions of LU factorisation functions |
---|
4 | * \author Tony Ottosson |
---|
5 | * |
---|
6 | * ------------------------------------------------------------------------- |
---|
7 | * |
---|
8 | * IT++ - C++ library of mathematical, signal processing, speech processing, |
---|
9 | * and communications classes and functions |
---|
10 | * |
---|
11 | * Copyright (C) 1995-2007 (see AUTHORS file for a list of contributors) |
---|
12 | * |
---|
13 | * This program is free software; you can redistribute it and/or modify |
---|
14 | * it under the terms of the GNU General Public License as published by |
---|
15 | * the Free Software Foundation; either version 2 of the License, or |
---|
16 | * (at your option) any later version. |
---|
17 | * |
---|
18 | * This program is distributed in the hope that it will be useful, |
---|
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
21 | * GNU General Public License for more details. |
---|
22 | * |
---|
23 | * You should have received a copy of the GNU General Public License |
---|
24 | * along with this program; if not, write to the Free Software |
---|
25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
26 | * |
---|
27 | * ------------------------------------------------------------------------- |
---|
28 | */ |
---|
29 | |
---|
30 | #ifndef LU_H |
---|
31 | #define LU_H |
---|
32 | |
---|
33 | #include <itpp/base/mat.h> |
---|
34 | |
---|
35 | |
---|
36 | namespace itpp { |
---|
37 | |
---|
38 | |
---|
39 | /*! \addtogroup matrixdecomp |
---|
40 | */ |
---|
41 | //!@{ |
---|
42 | /*! |
---|
43 | \brief LU factorisation of real matrix |
---|
44 | |
---|
45 | The LU factorization of the real matrix \f$\mathbf{X}\f$ of size \f$n \times n\f$ is given |
---|
46 | by |
---|
47 | \f[ |
---|
48 | \mathbf{X} = \mathbf{P}^T \mathbf{L} \mathbf{U} , |
---|
49 | \f] |
---|
50 | where \f$\mathbf{L}\f$ and \f$\mathbf{U}\f$ are lower and upper triangular matrices |
---|
51 | and \f$\mathbf{P}\f$ is a permutation matrix. |
---|
52 | |
---|
53 | The interchange permutation vector \a p is such that \a k and \a p(k) should be |
---|
54 | changed for all \a k. Given this vector a permuation matrix can be constructed using the |
---|
55 | function |
---|
56 | \code |
---|
57 | bmat permuation_matrix(const ivec &p) |
---|
58 | \endcode |
---|
59 | |
---|
60 | If \a X is an \a n by \a n matrix \a lu(X,L,U,p) computes the LU decomposition. |
---|
61 | \a L is a lower trangular, \a U an upper triangular matrix. |
---|
62 | \a p is the interchange permutation vector such that \a k and \a p(k) should be |
---|
63 | changed for all \a k. |
---|
64 | |
---|
65 | Returns true is calculation succeeds. False otherwise. |
---|
66 | */ |
---|
67 | bool lu(const mat &X, mat &L, mat &U, ivec &p); |
---|
68 | |
---|
69 | |
---|
70 | /*! |
---|
71 | \brief LU factorisation of real matrix |
---|
72 | |
---|
73 | The LU factorization of the complex matrix \f$\mathbf{X}\f$ of size \f$n \times n\f$ is given |
---|
74 | by |
---|
75 | \f[ |
---|
76 | \mathbf{X} = \mathbf{P}^T \mathbf{L} \mathbf{U} , |
---|
77 | \f] |
---|
78 | where \f$\mathbf{L}\f$ and \f$\mathbf{U}\f$ are lower and upper triangular matrices |
---|
79 | and \f$\mathbf{P}\f$ is a permutation matrix. |
---|
80 | |
---|
81 | The interchange permutation vector \a p is such that \a k and \a p(k) should be |
---|
82 | changed for all \a k. Given this vector a permuation matrix can be constructed using the |
---|
83 | function |
---|
84 | \code |
---|
85 | bmat permuation_matrix(const ivec &p) |
---|
86 | \endcode |
---|
87 | |
---|
88 | If \a X is an \a n by \a n matrix \a lu(X,L,U,p) computes the LU decomposition. |
---|
89 | \a L is a lower trangular, \a U an upper triangular matrix. |
---|
90 | \a p is the interchange permutation vector such that elements \a k and row \a p(k) should be |
---|
91 | interchanged. |
---|
92 | |
---|
93 | Returns true is calculation succeeds. False otherwise. |
---|
94 | */ |
---|
95 | bool lu(const cmat &X, cmat &L, cmat &U, ivec &p); |
---|
96 | |
---|
97 | |
---|
98 | //! Makes swapping of vector b according to the inerchange permutation vector p. |
---|
99 | void interchange_permutations(vec &b, const ivec &p); |
---|
100 | |
---|
101 | //! Make permutation matrix P from the interchange permutation vector p. |
---|
102 | bmat permutation_matrix(const ivec &p); |
---|
103 | //!@} |
---|
104 | |
---|
105 | } // namespace itpp |
---|
106 | |
---|
107 | #endif // #ifndef LU_H |
---|