qrupdate-ng 1.2.0
Loading...
Searching...
No Matches
zch1up.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 Cholesky factorization after a rank-1 modification.
21!>
22!> \par Definition:
23! =============
24!> \verbatim
25!> subroutine zch1up(n,R,ldr,u,w)
26!>
27!> .. Scalar Arguments ..
28!> integer n, ldr
29!> ..
30!> .. Array Arguments ..
31!> double complex R(ldr,*), u(*)
32!> double precision w(*)
33!> ..
34!> \endverbatim
35!>
36!> \par Purpose:
37! =============
38!> \verbatim
39!>
40!> ZCH1UP updates the Cholesky factorization of a hermitian
41!> positive definite matrix A after a rank-1 modification. Given an
42!> upper triangular matrix R that is a Cholesky factor of A, i.e.,
43!> A = R'*R, where R' denotes the conjugate transpose of R, this
44!> ZCH1UP updates R -> R1 so that R1'*R1 = A + u*u', where u is
45!> a given vector.
46!>
47!> The update is performed by applying a sequence of Givens rotations
48!> to restore the upper triangular structure of R. On exit, u
49!> contains the rotation sines and w contains the rotation cosines
50!> used in the transformation.
51!> \endverbatim
52!>
53!> \param[in] n
54!> \verbatim
55!> n is INTEGER
56!> The order of matrix R. n >= 0.
57!> \endverbatim
58!>
59!> \param[in,out] R
60!> \verbatim
61!> R is COMPLEX*16 array, dimension (ldr,n)
62!> On entry, the upper triangular matrix R, the Cholesky
63!> factor of A. On exit, the updated upper triangular
64!> matrix R1, the Cholesky factor of A + u*u'.
65!> \endverbatim
66!>
67!> \param[in] ldr
68!> \verbatim
69!> ldr is INTEGER
70!> The leading dimension of the array R. ldr >= n.
71!> \endverbatim
72!>
73!> \param[in,out] u
74!> \verbatim
75!> u is COMPLEX*16 array, dimension (n)
76!> On entry, the vector determining the rank-1 update.
77!> On exit, u contains the rotation sines used to
78!> transform R to R1.
79!> \endverbatim
80!>
81!> \param[out] w
82!> \verbatim
83!> w is DOUBLE PRECISION array, dimension (n)
84!> On exit, w contains the cosine parts of the Givens
85!> rotations used to transform R to R1.
86!> \endverbatim
87!>
88!> \ingroup choldecomp
89subroutine zch1up(n,R,ldr,u,w)
90 use iso_fortran_env
91 integer, intent(in) :: n, ldr
92 complex(real64), intent(inout) :: R(ldr,*), u(*)
93 real(real64), intent(out) :: w(*)
94 external zlartg
95 complex(real64) rr,ui,t
96 integer i,j
97
98 do i = 1,n
99 ! apply stored rotations, column-wise
100 ui = conjg(u(i))
101 do j = 1,i-1
102 t = w(j)*r(j,i) + u(j)*ui
103 ui = w(j)*ui - conjg(u(j))*r(j,i)
104 r(j,i) = t
105 end do
106 ! generate next rotation
107 call zlartg(r(i,i),ui,w(i),u(i),rr)
108 r(i,i) = rr
109 end do
110end subroutine
subroutine zch1up(n, r, ldr, u, w)
Updates a Cholesky factorization after a rank-1 modification.
Definition zch1up.f90:90