qrupdate-ng
1.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
dqrdec.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 dqrdec(m,n,k,Q,ldq,R,ldr,j,w)
26
!>
27
!> .. Scalar Arguments ..
28
!> integer m, n, k, ldq, ldr, j
29
!> ..
30
!> .. Array Arguments ..
31
!> double precision Q(ldq,*)
32
!> double precision R(ldr,*)
33
!> double precision w(*)
34
!> ..
35
!> \endverbatim
36
!>
37
!> \par Purpose:
38
! =============
39
!> \verbatim
40
!>
41
!> DQRDEC updates a QR factorization after deleting a column. i.e.,
42
!> given an m-by-k orthogonal matrix Q, an k-by-n upper trapezoidal
43
!> matrix R and index j in the range 1:n+1, DQRDEC updates the
44
!> matrix Q -> Q1 and R -> R1 so that Q1 remains orthogonal, R1 is upper
45
!> trapezoidal, and Q1*R1 = [A(:,1:j-1) A(:,j+1:n)], where A = Q*R.
46
!> (real 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
!> either k = m (full Q) or k = n < m (economical form,
66
!> basis dimension will decrease).
67
!> \endverbatim
68
!>
69
!> \param[in,out] Q
70
!> \verbatim
71
!> Q is DOUBLE PRECISION array, dimension (ldq,*)
72
!> On entry, the orthogonal 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 DOUBLE PRECISION 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] w
102
!> \verbatim
103
!> w is DOUBLE PRECISION array, dimension (*)
104
!> A workspace vector of size k-j.
105
!> \endverbatim
106
!>
107
!> \ingroup qrdecomp
108
subroutine
dqrdec
(m,n,k,Q,ldq,R,ldr,j,w)
109
use
iso_fortran_env
110
use
qrupdate_error
111
integer
,
intent(in)
:: m, n, k, ldq, ldr, j
112
real
(real64),
intent(inout)
:: Q(ldq,*)
113
real
(real64),
intent(inout)
:: R(ldr,*)
114
real
(real64),
intent(out)
:: w(*)
115
external
dcopy,dqhqr,dqrot
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
(
'DQRDEC'
,info)
136
return
137
end if
138
! delete the j-th column.
139
do
i = j,n-1
140
call
dcopy(k,r(1,i+1),1,r(1,i),1)
141
end do
142
! retriangularize.
143
if
(j < k)
then
144
call
dqhqr
(k+1-j,n-j,r(j,j),ldr,w,r(1,n))
145
! apply rotations to Q.
146
call
dqrot
(
'F'
,m,min(k,n)+1-j,q(1,j),ldq,w,r(1,n))
147
end if
148
end subroutine
qrupdate_error::qrupdate_xerror
subroutine qrupdate_xerror(srname, info)
Dispatches error reporting to the handler.
Definition
qrupdate_error.f90:89
dqrot
subroutine dqrot(dir, m, n, q, ldq, c, s)
Applies a sequence of Givens rotations from the right to a matrix.
Definition
dqrot.f90:101
dqrdec
subroutine dqrdec(m, n, k, q, ldq, r, ldr, j, w)
Updates a QR factorization after deleting a column.
Definition
dqrdec.f90:109
dqhqr
subroutine dqhqr(m, n, r, ldr, c, s)
Reduces an upper Hessenberg matrix to upper trapezoidal form.
Definition
dqhqr.f90:90
qrupdate_error
Module for custom error handling.
Definition
qrupdate_error.f90:24
src
dqrdec.f90
Generated by
1.17.0