qrupdate-ng 1.2.0
Loading...
Searching...
No Matches
zlu1up.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 zlu1up(m,n,L,ldl,R,ldr,u,v)
26!>
27!> .. Scalar Arguments ..
28!> integer m, n, ldl, ldr
29!> ..
30!> .. Array Arguments ..
31!> double complex L(ldl,*), R(ldr,*), u(*), v(*)
32!> ..
33!> \endverbatim
34!>
35!> \par Purpose:
36! =============
37!> \verbatim
38!>
39!> ZLU1UP 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!> ZLU1UP 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
45!> of 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*16 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*16 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*16 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*16 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
107subroutine zlu1up(m,n,L,ldl,R,ldr,u,v)
108 use iso_fortran_env
110 integer, intent(in) :: m, n, ldl, ldr
111 complex(real64), intent(inout) :: L(ldl,*), R(ldr,*)
112 complex(real64), intent(inout) :: u(*), v(*)
113 complex(real64) ui,vi
114 integer k,info,i,j
115 ! quick return if possible.
116 k = min(m,n)
117 if (k == 0) return
118 ! check arguments.
119 info = 0
120 if (m < 0) then
121 info = 1
122 else if (n < 0) then
123 info = 2
124 else if (ldl < m) then
125 info = 4
126 else if (ldr < k) then
127 info = 6
128 endif
129 if (info /= 0) then
130 call qrupdate_xerror('ZLU1UP',info)
131 return
132 end if
133 ! The Bennett algorithm, modified for column-major access.
134 ! The leading part.
135 do i = 1,k
136 ! prefetch
137 ui = u(i)
138 vi = v(i)
139 ! delayed R update
140 do j = 1,i-1
141 r(j,i) = r(j,i) + u(j)*vi
142 vi = vi - v(j)*r(j,i)
143 end do
144 ! diagonal update
145 r(i,i) = r(i,i) + ui*vi
146 vi = vi/r(i,i)
147 ! L update
148 do j = i+1,m
149 u(j) = u(j) - ui*l(j,i)
150 l(j,i) = l(j,i) + u(j)*vi
151 end do
152 u(i) = ui
153 v(i) = vi
154 end do
155 ! Finish the trailing part of R if needed.
156 do i = k+1,n
157 vi = v(i)
158 do j = 1,k
159 r(j,i) = r(j,i) + u(j)*vi
160 vi = vi - v(j)*r(j,i)
161 end do
162 v(i) = vi
163 end do
164end subroutine
subroutine qrupdate_xerror(srname, info)
Dispatches error reporting to the handler.
subroutine zlu1up(m, n, l, ldl, r, ldr, u, v)
Updates an LU factorization after a rank-1 modification.
Definition zlu1up.f90:108
Module for custom error handling.