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