qrupdate-ng
1.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
clu1up.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 an LU factorization after a rank-1 modification.
21
!>
22
!> \par Definition:
23
! =============
24
!> \verbatim
25
!> subroutine clu1up(m,n,L,ldl,R,ldr,u,v)
26
!>
27
!> .. Scalar Arguments ..
28
!> integer m, n, ldl, ldr
29
!> ..
30
!> .. Array Arguments ..
31
!> complex L(ldl,*), R(ldr,*), u(*), v(*)
32
!> ..
33
!> \endverbatim
34
!>
35
!> \par Purpose:
36
! =============
37
!> \verbatim
38
!>
39
!> CLU1UP updates an LU factorization after rank-1 modification.
40
!> Given an m-by-k lower-triangular matrix L with unit diagonal and
41
!> a k-by-n upper-trapezoidal matrix R, where k = min(m,n), this
42
!> CLU1UP updates L -> L1 and R -> R1 so that L1 is again
43
!> lower unit triangular, R1 upper trapezoidal, and
44
!> L1*R1 = L*R + u*v', where v' denotes the conjugate transpose of
45
!> v.
46
!>
47
!> The update is performed using the Bennett algorithm with
48
!> column-major access, which processes the leading k-by-k block
49
!> first and then finishes the trailing part of R if needed.
50
!> \endverbatim
51
!>
52
!> \param[in] m
53
!> \verbatim
54
!> m is INTEGER
55
!> The number of rows of the matrix L. m >= 0.
56
!> \endverbatim
57
!>
58
!> \param[in] n
59
!> \verbatim
60
!> n is INTEGER
61
!> The number of columns of the matrix R. n >= 0.
62
!> \endverbatim
63
!>
64
!> \param[in,out] L
65
!> \verbatim
66
!> L is COMPLEX array, dimension (ldl,k)
67
!> On entry, the unit lower triangular matrix L. On exit,
68
!> the updated unit lower triangular matrix L1.
69
!> \endverbatim
70
!>
71
!> \param[in] ldl
72
!> \verbatim
73
!> ldl is INTEGER
74
!> The leading dimension of the array L. ldl >= m.
75
!> \endverbatim
76
!>
77
!> \param[in,out] R
78
!> \verbatim
79
!> R is COMPLEX array, dimension (ldr,n)
80
!> On entry, the upper trapezoidal m-by-n matrix R.
81
!> On exit, the updated upper trapezoidal matrix R1.
82
!> \endverbatim
83
!>
84
!> \param[in] ldr
85
!> \verbatim
86
!> ldr is INTEGER
87
!> The leading dimension of the array R. ldr >= k,
88
!> where k = min(m,n).
89
!> \endverbatim
90
!>
91
!> \param[in,out] u
92
!> \verbatim
93
!> u is COMPLEX array, dimension (m)
94
!> On entry, the left m-vector defining the rank-1
95
!> modification. On exit, if k < m, u is destroyed;
96
!> otherwise, u contains the updated vector.
97
!> \endverbatim
98
!>
99
!> \param[in,out] v
100
!> \verbatim
101
!> v is COMPLEX array, dimension (n)
102
!> On entry, the right n-vector defining the rank-1
103
!> modification. On exit, v is destroyed.
104
!> \endverbatim
105
!>
106
!> \ingroup ludecomp
107
subroutine
clu1up
(m,n,L,ldl,R,ldr,u,v)
108
use
iso_fortran_env
109
use
qrupdate_error
110
integer
,
intent(in)
:: m, n, ldl, ldr
111
complex(real32)
,
intent(inout)
:: L(ldl,*)
112
complex(real32)
,
intent(inout)
:: R(ldr,*)
113
complex(real32)
,
intent(inout)
:: u(*)
114
complex(real32)
,
intent(inout)
:: v(*)
115
complex(real32)
ui,vi
116
integer
k,info,i,j
117
! quick return if possible.
118
k = min(m,n)
119
if
(k == 0)
return
120
! check arguments.
121
info = 0
122
if
(m < 0)
then
123
info = 1
124
else
if
(n < 0)
then
125
info = 2
126
else
if
(ldl < m)
then
127
info = 4
128
else
if
(ldr < k)
then
129
info = 6
130
endif
131
if
(info /= 0)
then
132
call
qrupdate_xerror
(
'CLU1UP'
,info)
133
return
134
end if
135
! The Bennett algorithm, modified for column-major access.
136
! The leading part.
137
do
i = 1,k
138
! prefetch
139
ui = u(i)
140
vi = v(i)
141
! delayed R update
142
do
j = 1,i-1
143
r(j,i) = r(j,i) + u(j)*vi
144
vi = vi - v(j)*r(j,i)
145
end do
146
! diagonal update
147
r(i,i) = r(i,i) + ui*vi
148
vi = vi/r(i,i)
149
! L update
150
do
j = i+1,m
151
u(j) = u(j) - ui*l(j,i)
152
l(j,i) = l(j,i) + u(j)*vi
153
end do
154
u(i) = ui
155
v(i) = vi
156
end do
157
! Finish the trailing part of R if needed.
158
do
i = k+1,n
159
vi = v(i)
160
do
j = 1,k
161
r(j,i) = r(j,i) + u(j)*vi
162
vi = vi - v(j)*r(j,i)
163
end do
164
v(i) = vi
165
end do
166
end subroutine
qrupdate_error::qrupdate_xerror
subroutine qrupdate_xerror(srname, info)
Dispatches error reporting to the handler.
Definition
qrupdate_error.f90:89
clu1up
subroutine clu1up(m, n, l, ldl, r, ldr, u, v)
Updates an LU factorization after a rank-1 modification.
Definition
clu1up.f90:108
qrupdate_error
Module for custom error handling.
Definition
qrupdate_error.f90:24
src
clu1up.f90
Generated by
1.17.0