qrupdate-ng 1.2.0
Loading...
Searching...
No Matches
cqrder.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 row.
21!>
22!> \par Definition:
23! =============
24!> \verbatim
25!> subroutine cqrder(m,n,Q,ldq,R,ldr,j,w,rw)
26!>
27!> .. Scalar Arguments ..
28!> integer m, n, ldq, ldr, j
29!> ..
30!> .. Array Arguments ..
31!> complex Q(ldq,*)
32!> complex R(ldr,*)
33!> complex w(*)
34!> real rw(*)
35!> ..
36!> \endverbatim
37!>
38!> \par Purpose:
39! =============
40!> \verbatim
41!>
42!> CQRDER updates a QR factorization after deleting a row. i.e., given
43!> an m-by-m unitary matrix Q, an m-by-n upper trapezoidal matrix R and
44!> index j in the range 1:m, CQRDER updates Q ->Q1 and an R ->
45!> R1 so that Q1 is again unitary, R1 upper trapezoidal, and Q1*R1 =
46!> [A(1:j-1,:); A(j+1:m,:)], where A = Q*R. (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,out] Q
62!> \verbatim
63!> Q is COMPLEX array, dimension (ldq,*)
64!> On entry, the unitary matrix Q. On exit, the
65!> updated matrix Q1.
66!> \endverbatim
67!>
68!> \param[in] ldq
69!> \verbatim
70!> ldq is INTEGER
71!> The leading dimension of Q. ldq >= m.
72!> \endverbatim
73!>
74!> \param[in,out] R
75!> \verbatim
76!> R is COMPLEX array, dimension (ldr,*)
77!> On entry, the original matrix R. On exit, the
78!> updated matrix R1.
79!> \endverbatim
80!>
81!> \param[in] ldr
82!> \verbatim
83!> ldr is INTEGER
84!> The leading dimension of R. ldr >= m.
85!> \endverbatim
86!>
87!> \param[in] j
88!> \verbatim
89!> j is INTEGER
90!> The position of the deleted row. 1 <= j <= m.
91!> \endverbatim
92!>
93!> \param[out] w
94!> \verbatim
95!> w is COMPLEX array, dimension (*)
96!> A workspace vector of size m.
97!> \endverbatim
98!>
99!> \param[out] rw
100!> \verbatim
101!> rw is REAL array, dimension (*)
102!> A real workspace vector of size m.
103!> \endverbatim
104!>
105!> \ingroup qrdecomp
106subroutine cqrder(m,n,Q,ldq,R,ldr,j,w,rw)
107 use iso_fortran_env
109 integer, intent(in) :: m, n, j, ldq, ldr
110 complex(real32), intent(inout) :: Q(ldq,*)
111 complex(real32), intent(inout) :: R(ldr,*)
112 complex(real32), intent(out) :: w(*)
113 real(real32), intent(out) :: rw(*)
114 external ccopy,cqrtv1,cqrot,cqrqh
115 integer info,i,k
116 ! quick return if possible.
117 if (m == 1) return
118 ! check arguments
119 info = 0
120 if (m < 1) then
121 info = 1
122 else if (j < 1 .or. j > m) then
123 info = 7
124 end if
125 if (info /= 0) then
126 call qrupdate_xerror('CQRDER',info)
127 return
128 end if
129 ! eliminate Q(j,2:m).
130 do k = 1,m
131 w(k) = conjg(q(j,k))
132 end do
133 call cqrtv1(m,w,rw)
134 ! apply rotations to Q.
135 call cqrot('B',m,m,q,ldq,rw,w(2))
136 ! form Q1.
137 do k = 1,m-1
138 if (j > 1) call ccopy(j-1,q(1,k+1),1,q(1,k),1)
139 if (j < m) call ccopy(m-j,q(j+1,k+1),1,q(j,k),1)
140 end do
141 ! apply rotations to R.
142 call cqrqh(m,n,r,ldr,rw,w(2))
143 ! form R1.
144 do k = 1,n
145 do i = 1,m-1
146 r(i,k) = r(i+1,k)
147 end do
148 end do
149end 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 cqrtv1(n, u, w)
Generates Givens rotations to eliminate all but the first element of a vector.
Definition cqrtv1.f90:75
subroutine cqrqh(m, n, r, ldr, c, s)
Converts an upper trapezoidal matrix to upper Hessenberg form.
Definition cqrqh.f90:89
subroutine cqrder(m, n, q, ldq, r, ldr, j, w, rw)
Updates a QR factorization after deleting a row.
Definition cqrder.f90:107
Module for custom error handling.