qrupdate-ng
1.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
sch1dn.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 Downdates a Cholesky factorization after a rank-1 modification.
21
!>
22
!> \par Definition:
23
! =============
24
!> \verbatim
25
!> subroutine sch1dn(n,R,ldr,u,w,info)
26
!>
27
!> .. Scalar Arguments ..
28
!> integer n, ldr, info
29
!> ..
30
!> .. Array Arguments ..
31
!> real R(ldr,*), u(*), w(*)
32
!> ..
33
!> \endverbatim
34
!>
35
!> \par Purpose:
36
! =============
37
!> \verbatim
38
!>
39
!> SCH1DN downdates 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, SCH1DN
43
!> downdates R -> R1 so that R1.'*R1 = A - u*u.', where u is a
44
!> given vector.
45
!>
46
!> The downdate is performed by applying a sequence of hyperbolic
47
!> rotations to restore the upper triangular structure of R. On
48
!> exit, u contains the rotation sines and w contains the rotation
49
!> cosines 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 downdate.
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
84
!> rotations used to transform R to R1.
85
!> \endverbatim
86
!>
87
!> \param[out] info
88
!> \verbatim
89
!> info is INTEGER
90
!> = 0: successful exit
91
!> = 1: the update would violate positive-definiteness
92
!> = 2: R is singular
93
!> \endverbatim
94
!>
95
!> \ingroup choldecomp
96
subroutine
sch1dn
(n,R,ldr,u,w,info)
97
use
iso_fortran_env
98
use
qrupdate_error
99
integer
,
intent(in)
:: n, ldr
100
real
(real32),
intent(inout)
:: R(ldr,*), u(*)
101
real
(real32),
intent(out)
:: w(*)
102
integer
,
intent(out)
:: info
103
external
strsv,slartg,snrm2
104
real
(real32) snrm2,rho,rr,ui,t
105
integer
i,j
106
! quick return if possible.
107
if
(n == 0)
return
108
! check arguments.
109
info = 0
110
if
(n < 0)
then
111
info = -1
112
else
if
(ldr < n)
then
113
info = -3
114
end if
115
if
(info /= 0)
then
116
call
qrupdate_xerror
(
'SCH1DN'
,-info)
117
return
118
end if
119
! check for singularity of R.
120
do
i = 1,n
121
if
(r(i,i) == 0e0)
goto
20
122
end do
123
! form R' \ u
124
call
strsv(
'U'
,
'T'
,
'N'
,n,r,ldr,u,1)
125
rho = snrm2(n,u,1)
126
! check positive definiteness
127
rho = 1 - rho**2
128
if
(rho <= 0e0)
goto
10
129
rho = sqrt(rho)
130
! eliminate R' \ u
131
do
i = n,1,-1
132
ui = u(i)
133
! generate next rotation
134
call
slartg(rho,ui,w(i),u(i),rr)
135
rho = rr
136
end do
137
! apply rotations
138
do
i = n,1,-1
139
ui = 0e0
140
do
j = i,1,-1
141
t = w(j)*ui + u(j)*r(j,i)
142
r(j,i) = w(j)*r(j,i) - u(j)*ui
143
ui = t
144
end do
145
end do
146
! normal return
147
return
148
! error returns
149
10 info = 1
150
return
151
20 info = 2
152
return
153
end subroutine
sch1dn
subroutine sch1dn(n, r, ldr, u, w, info)
Downdates a Cholesky factorization after a rank-1 modification.
Definition
sch1dn.f90:97
qrupdate_error::qrupdate_xerror
subroutine qrupdate_xerror(srname, info)
Dispatches error reporting to the handler.
Definition
qrupdate_error.f90:89
qrupdate_error
Module for custom error handling.
Definition
qrupdate_error.f90:24
src
sch1dn.f90
Generated by
1.17.0