qrupdate-ng
1.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
zqrinr.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 inserting a new row.
21
!>
22
!> \par Definition:
23
! =============
24
!> \verbatim
25
!> subroutine zqrinr(m,n,Q,ldq,R,ldr,j,x,rw)
26
!>
27
!> .. Scalar Arguments ..
28
!> integer m, n, ldq, ldr, j
29
!> ..
30
!> .. Array Arguments ..
31
!> double complex Q(ldq,*)
32
!> double complex R(ldr,*)
33
!> double complex x(*)
34
!> double precision rw(*)
35
!> ..
36
!> \endverbatim
37
!>
38
!> \par Purpose:
39
! =============
40
!> \verbatim
41
!>
42
!> ZQRINR updates a QR factorization after inserting a new row. i.e.,
43
!> given an m-by-m unitary matrix Q, an m-by-n upper trapezoidal matrix
44
!> R and index j in the range 1:m+1, ZQRINR updates Q -> Q1 and
45
!> R -> R1 so that Q1 is again unitary, R1 upper trapezoidal, and Q1*R1
46
!> = [A(1:j-1,:); x; A(j: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*16 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+1.
72
!> \endverbatim
73
!>
74
!> \param[in,out] R
75
!> \verbatim
76
!> R is COMPLEX*16 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+1.
85
!> \endverbatim
86
!>
87
!> \param[in] j
88
!> \verbatim
89
!> j is INTEGER
90
!> The position of the new row in R1. 1 <= j <= m+1.
91
!> \endverbatim
92
!>
93
!> \param[in,out] x
94
!> \verbatim
95
!> x is COMPLEX*16 array, dimension (*)
96
!> On entry, the row being added. On exit, x is
97
!> destroyed.
98
!> \endverbatim
99
!>
100
!> \param[out] rw
101
!> \verbatim
102
!> rw is DOUBLE PRECISION array, dimension (*)
103
!> A real workspace vector of size min(m,n).
104
!> \endverbatim
105
!>
106
!> \ingroup qrdecomp
107
subroutine
zqrinr
(m,n,Q,ldq,R,ldr,j,x,rw)
108
use
iso_fortran_env
109
use
qrupdate_error
110
integer
,
intent(in)
:: m, n, j, ldq, ldr
111
complex(real64)
,
intent(inout)
:: Q(ldq,*), R(ldr,*), x(*)
112
real
(real64),
intent(out)
:: rw(*)
113
external
zcopy,zqhqr,zqrot
114
integer
info,i,k
115
! check arguments
116
info = 0
117
if
(n < 0)
then
118
info = 2
119
else
if
(j < 1 .or. j > m+1)
then
120
info = 7
121
end if
122
if
(info /= 0)
then
123
call
qrupdate_xerror
(
'ZQRINR'
,info)
124
return
125
end if
126
! permute the columns of Q1 and rows of R1 so that c the new row ends
127
! up being the topmost row of R1.
128
do
i = m,1,-1
129
if
(j > 1)
then
130
call
zcopy(j-1,q(1,i),1,q(1,i+1),1)
131
end if
132
q(j,i+1) = 0d0
133
if
(j <= m)
then
134
call
zcopy(m+1-j,q(j,i),1,q(j+1,i+1),1)
135
end if
136
end do
137
! set up the 1st column
138
do
i = 1,j-1
139
q(i,1) = 0d0
140
end do
141
q(j,1) = 1d0
142
do
i = j+1,m+1
143
q(i,1) = 0d0
144
end do
145
! set up the new matrix R1
146
do
k = 1,n
147
if
(k < m) r(m+1,k) = 0d0
148
do
i = min(m,k),1,-1
149
r(i+1,k) = r(i,k)
150
end do
151
r(1,k) = x(k)
152
end do
153
! retriangularize R
154
call
zqhqr
(m+1,n,r,ldr,rw,x)
155
! apply rotations to Q
156
call
zqrot
(
'F'
,m+1,min(m,n)+1,q,ldq,rw,x)
157
end subroutine
qrupdate_error::qrupdate_xerror
subroutine qrupdate_xerror(srname, info)
Dispatches error reporting to the handler.
Definition
qrupdate_error.f90:89
zqrot
subroutine zqrot(dir, m, n, q, ldq, c, s)
Applies a sequence of Givens rotations from the right to a matrix.
Definition
zqrot.f90:101
zqhqr
subroutine zqhqr(m, n, r, ldr, c, s)
Reduces an upper Hessenberg matrix to upper trapezoidal form.
Definition
zqhqr.f90:91
zqrinr
subroutine zqrinr(m, n, q, ldq, r, ldr, j, x, rw)
Updates a QR factorization after inserting a new row.
Definition
zqrinr.f90:108
qrupdate_error
Module for custom error handling.
Definition
qrupdate_error.f90:24
src
zqrinr.f90
Generated by
1.17.0