qrupdate-ng 1.2.0
Loading...
Searching...
No Matches
cqrdec.f90
Go to the documentation of this file.
1! Copyright (C) 2008, 2009 VZLU Prague, a.s., Czech Republic, Jaroslav Hajek <highegg@gmail.com>
2! Copyright (C) 2026 Martin Köhler <koehlerm(AT)mpi-magdeburg.mpg.de>
3!
4! This file is part of qrupdate-ng.
5!
6! qrupdate is free software; you can redistribute it and/or modify
7! it under the terms of the GNU General Public License as published by
8! the Free Software Foundation; either version 3 of the License, or
9! (at your option) any later version.
10!
11! This program is distributed in the hope that it will be useful,
12! but WITHOUT ANY WARRANTY; without even the implied warranty of
13! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14! GNU General Public License for more details.
15!
16! You should have received a copy of the GNU General Public License
17! along with this software; see the file COPYING. If not, see
18! <http://www.gnu.org/licenses/>.
19!
20!> \brief Updates a QR factorization after deleting a column.
21!>
22!> \par Definition:
23! =============
24!> \verbatim
25!> subroutine cqrdec(m,n,k,Q,ldq,R,ldr,j,rw)
26!>
27!> .. Scalar Arguments ..
28!> integer m, n, k, ldq, ldr, j
29!> ..
30!> .. Array Arguments ..
31!> complex Q(ldq,*)
32!> complex R(ldr,*)
33!> real rw(*)
34!> ..
35!> \endverbatim
36!>
37!> \par Purpose:
38! =============
39!> \verbatim
40!>
41!> CQRDEC updates a QR factorization after deleting a column. i.e.,
42!> given an m-by-k unitary matrix Q, an k-by-n upper trapezoidal matrix
43!> R and index j in the range 1:n+1, CQRDEC updates the matrix
44!> Q -> Q1 and R -> R1 so that Q1 remains unitary, R1 is upper
45!> trapezoidal, and Q1*R1 = [A(:,1:j-1) A(:,j+1:n)], where A = Q*R.
46!> (complex version)
47!> \endverbatim
48!>
49!> \param[in] m
50!> \verbatim
51!> m is INTEGER
52!> The number of rows of the matrix Q. m >= 0.
53!> \endverbatim
54!>
55!> \param[in] n
56!> \verbatim
57!> n is INTEGER
58!> The number of columns of the matrix R. n >= 0.
59!> \endverbatim
60!>
61!> \param[in] k
62!> \verbatim
63!> k is INTEGER
64!> The number of columns of Q, and rows of R. Must be
65!> (full Q) or k = n < m (economical form, basis dimension will
66!> decrease).
67!> \endverbatim
68!>
69!> \param[in,out] Q
70!> \verbatim
71!> Q is COMPLEX array, dimension (ldq,*)
72!> On entry, the unitary m-by-k matrix Q. On exit,
73!> the updated matrix Q1.
74!> \endverbatim
75!>
76!> \param[in] ldq
77!> \verbatim
78!> ldq is INTEGER
79!> The leading dimension of Q. ldq >= m.
80!> \endverbatim
81!>
82!> \param[in,out] R
83!> \verbatim
84!> R is COMPLEX array, dimension (ldr,*)
85!> On entry, the original matrix R. On exit, the
86!> updated matrix R1.
87!> \endverbatim
88!>
89!> \param[in] ldr
90!> \verbatim
91!> ldr is INTEGER
92!> The leading dimension of R. ldr >= k.
93!> \endverbatim
94!>
95!> \param[in] j
96!> \verbatim
97!> j is INTEGER
98!> The position of the deleted column in R. 1 <= j <= n.
99!> \endverbatim
100!>
101!> \param[out] rw
102!> \verbatim
103!> rw is REAL array, dimension (*)
104!> A real workspace vector of size k-j.
105!> \endverbatim
106!>
107!> \ingroup qrdecomp
108subroutine cqrdec(m,n,k,Q,ldq,R,ldr,j,rw)
109 use iso_fortran_env
111 integer, intent(in) :: m, n, k, ldq, ldr, j
112 complex(real32), intent(inout) :: Q(ldq,*)
113 complex(real32), intent(inout) :: R(ldr,*)
114 real(real32), intent(out) :: rw(*)
115 external ccopy,cqhqr,cqrot
116 integer info,i
117 ! quick return if possible.
118 if (m == 0 .or. n == 0 .or. j == n) return
119 ! check arguments.
120 info = 0
121 if (m < 0) then
122 info = 1
123 else if (n < 0) then
124 info = 2
125 else if (k /= m .and. (k /= n .or. n >= m)) then
126 info = 3
127 else if (ldq < m) then
128 info = 5
129 else if (ldr < k) then
130 info = 7
131 else if (j < 1 .or. j > n+1) then
132 info = 8
133 end if
134 if (info /= 0) then
135 call qrupdate_xerror('CQRDEC',info)
136 return
137 end if
138 ! delete the j-th column.
139 do i = j,n-1
140 call ccopy(k,r(1,i+1),1,r(1,i),1)
141 end do
142 ! retriangularize.
143 if (j < k) then
144 call cqhqr(k+1-j,n-j,r(j,j),ldr,rw,r(1,n))
145 ! apply rotations to Q.
146 call cqrot('F',m,min(k,n)+1-j,q(1,j),ldq,rw,r(1,n))
147 end if
148end subroutine
subroutine qrupdate_xerror(srname, info)
Dispatches error reporting to the handler.
subroutine cqrot(dir, m, n, q, ldq, c, s)
Applies a sequence of Givens rotations from the right to a matrix.
Definition cqrot.f90:101
subroutine cqrdec(m, n, k, q, ldq, r, ldr, j, rw)
Updates a QR factorization after deleting a column.
Definition cqrdec.f90:109
subroutine cqhqr(m, n, r, ldr, c, s)
Reduces an upper Hessenberg matrix to upper trapezoidal form.
Definition cqhqr.f90:91
Module for custom error handling.