qrupdate-ng
1.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
zchinx.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 inserting a row and column.
21
!>
22
!> \par Definition:
23
! =============
24
!> \verbatim
25
!> subroutine zchinx(n,R,ldr,j,u,rw,info)
26
!>
27
!> .. Scalar Arguments ..
28
!> integer n, j, ldr, info
29
!> ..
30
!> .. Array Arguments ..
31
!> double complex R(ldr,*), u(*), rw(*)
32
!> ..
33
!> \endverbatim
34
!>
35
!> \par Purpose:
36
! =============
37
!> \verbatim
38
!>
39
!> ZCHINX updates the Cholesky factorization of a hermitian
40
!> positive definite matrix A after inserting a row and column.
41
!> Given an upper triangular matrix R that is a Cholesky factor of
42
!> A, i.e., A = R'*R, where R' denotes the conjugate transpose of
43
!> R, ZCHINX updates R -> R1 so that R1'*R1 = A1, where
44
!> A1(jj,jj) = A, A1(j,:) = u', A1(:,j) = u, and
45
!> jj = [1:j-1, j+1:n+1].
46
!>
47
!> On exit, u is destroyed and R is extended by one row and column.
48
!> The insertion is performed by first solving R'*u = v, checking
49
!> positive definiteness, and then retriangularizing.
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 COMPLEX*16 array, dimension (ldr,n+1)
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 A1.
64
!> \endverbatim
65
!>
66
!> \param[in] ldr
67
!> \verbatim
68
!> ldr is INTEGER
69
!> The leading dimension of the array R. ldr >= n+1.
70
!> \endverbatim
71
!>
72
!> \param[in] j
73
!> \verbatim
74
!> j is INTEGER
75
!> The position of the inserted row and column.
76
!> 1 <= j <= n+1.
77
!> \endverbatim
78
!>
79
!> \param[in,out] u
80
!> \verbatim
81
!> u is COMPLEX*16 array, dimension (n+1)
82
!> On entry, the vector defining the inserted row/column.
83
!> On exit, u is destroyed.
84
!> \endverbatim
85
!>
86
!> \param[out] rw
87
!> \verbatim
88
!> rw is DOUBLE PRECISION array, dimension (n+1)
89
!> Workspace vector used to store rotation cosines during
90
!> the retriangularization.
91
!> \endverbatim
92
!>
93
!> \param[out] info
94
!> \verbatim
95
!> info is INTEGER
96
!> = 0: successful exit
97
!> = 1: the update would violate positive-definiteness
98
!> = 2: R is singular
99
!> = 3: the diagonal element of u is not real
100
!> \endverbatim
101
!>
102
!> \ingroup choldecomp
103
subroutine
zchinx
(n,R,ldr,j,u,rw,info)
104
use
iso_fortran_env
105
use
qrupdate_error
106
integer
,
intent(in)
:: n, j, ldr
107
complex(real64)
,
intent(inout)
:: R(ldr,*), u(*)
108
real
(real64),
intent(out)
:: rw(*)
109
integer
,
intent(out)
:: info
110
external
zcopy,dznrm2,ztrsv,zqrtv1,zqrqh
111
complex(real64)
t
112
real
(real64) dznrm2,rho
113
integer
i
114
! check arguments
115
info = 0
116
if
(n < 0)
then
117
info = -1
118
else
if
(j < 1 .or. j > n+1)
then
119
info = -4
120
end if
121
if
(info /= 0)
then
122
call
qrupdate_xerror
(
'ZCHINX'
,info)
123
return
124
end if
125
! shift vector.
126
t = u(j)
127
do
i = j,n
128
u(i) = u(i+1)
129
end do
130
! the diagonal element must be real.
131
if
(imag(t) /= 0d0)
goto
30
132
! check for singularity of R.
133
do
i = 1,n
134
if
(r(i,i) == 0d0)
goto
20
135
end do
136
! form R' \ u
137
call
ztrsv(
'U'
,
'C'
,
'N'
,n,r,ldr,u,1)
138
rho = dznrm2(n,u,1)
139
! check positive definiteness.
140
rho = dble(t) - rho**2
141
if
(rho <= 0d0)
goto
10
142
! shift columns
143
do
i = n,j,-1
144
call
zcopy(i,r(1,i),1,r(1,i+1),1)
145
r(i+1,i+1) = 0d0
146
end do
147
call
zcopy(n,u,1,r(1,j),1)
148
r(n+1,j) = sqrt(rho)
149
! retriangularize
150
if
(j < n+1)
then
151
! eliminate the introduced spike.
152
call
zqrtv1
(n+2-j,r(j,j),rw)
153
! apply rotations to R
154
call
zqrqh
(n+2-j,n+1-j,r(j,j+1),ldr,rw,r(j+1,j))
155
! zero spike.
156
do
i = j+1,n+1
157
r(i,j) = 0d0
158
end do
159
end if
160
! normal return.
161
return
162
! error returns.
163
10 info = 1
164
return
165
20 info = 2
166
return
167
30 info = 3
168
return
169
end subroutine
zchinx
subroutine zchinx(n, r, ldr, j, u, rw, info)
Updates a Cholesky factorization after inserting a row and column.
Definition
zchinx.f90:104
qrupdate_error::qrupdate_xerror
subroutine qrupdate_xerror(srname, info)
Dispatches error reporting to the handler.
Definition
qrupdate_error.f90:89
zqrtv1
subroutine zqrtv1(n, u, w)
Generates Givens rotations to eliminate all but the first element of a vector.
Definition
zqrtv1.f90:75
zqrqh
subroutine zqrqh(m, n, r, ldr, c, s)
Converts an upper trapezoidal matrix to upper Hessenberg form.
Definition
zqrqh.f90:86
qrupdate_error
Module for custom error handling.
Definition
qrupdate_error.f90:24
src
zchinx.f90
Generated by
1.17.0