qrupdate-ng 1.2.0
Loading...
Searching...
No Matches
zchshx.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 symmetric shift of rows and columns.
21!>
22!> \par Definition:
23! =============
24!> \verbatim
25!> subroutine zchshx(n,R,ldr,i,j,w,rw)
26!>
27!> .. Scalar Arguments ..
28!> integer n, ldr, i, j
29!> ..
30!> .. Array Arguments ..
31!> double complex R(ldr,*), w(*)
32!> double precision rw(*)
33!> ..
34!> \endverbatim
35!>
36!> \par Purpose:
37! =============
38!> \verbatim
39!>
40!> ZCHSHX updates the Cholesky factorization of a hermitian
41!> positive definite matrix A after a symmetric shift of rows and
42!> columns. Given an upper triangular matrix R that is a Cholesky
43!> factor of A, i.e., A = R'*R, where R' denotes the conjugate
44!> transpose of R, ZCHSHX updates R -> R1 so that
45!> R1'*R1 = A(p,p), where p is the permutation
46!> [1:i-1, shift(i:j,-1), j+1:n] if i < j, or
47!> [1:j-1, shift(j:i,+1), i+1:n] if j < i.
48!> \endverbatim
49!>
50!> \param[in] n
51!> \verbatim
52!> n is INTEGER
53!> The order of matrix R. n >= 0.
54!> \endverbatim
55!>
56!> \param[in,out] R
57!> \verbatim
58!> R is COMPLEX*16 array, dimension (ldr,n)
59!> On entry, the upper triangular matrix R, the Cholesky
60!> factor of A. On exit, the updated upper triangular
61!> matrix R1, the Cholesky factor of A(p,p).
62!> \endverbatim
63!>
64!> \param[in] ldr
65!> \verbatim
66!> ldr is INTEGER
67!> The leading dimension of the array R. ldr >= n.
68!> \endverbatim
69!>
70!> \param[in] i
71!> \verbatim
72!> i is INTEGER
73!> The first index determining the range of the shift.
74!> 1 <= i <= n.
75!> \endverbatim
76!>
77!> \param[in] j
78!> \verbatim
79!> j is INTEGER
80!> The second index determining the range of the shift.
81!> 1 <= j <= n.
82!> \endverbatim
83!>
84!> \param[out] w
85!> \verbatim
86!> w is COMPLEX*16 array, dimension (n)
87!> Workspace vector used to store rotation sines during
88!> the retriangularization.
89!> \endverbatim
90!>
91!> \param[out] rw
92!> \verbatim
93!> rw is DOUBLE PRECISION array, dimension (n)
94!> Workspace vector used to store rotation cosines during
95!> the retriangularization.
96!> \endverbatim
97!>
98!> \ingroup choldecomp
99subroutine zchshx(n,R,ldr,i,j,w,rw)
100 use iso_fortran_env
102 integer, intent(in) :: n, ldr, i, j
103 complex(real64), intent(inout) :: R(ldr,*)
104 complex(real64), intent(out) :: w(*)
105 real(real64), intent(out) :: rw(*)
106 external zcopy,zqrtv1,zqrqh,zqhqr
107 integer info,l
108 ! quick return if possible.
109 if (n == 0 .or. n == 1) return
110 info = 0
111 ! check arguments.
112 if (n < 0) then
113 info = 1
114 else if (i < 1 .or. i > n) then
115 info = 4
116 else if (j < 1 .or. j > n) then
117 info = 5
118 end if
119 if (info /= 0) then
120 call qrupdate_xerror('ZCHSHX',info)
121 return
122 end if
123 if (i < j) then
124 ! shift columns
125 call zcopy(n,r(1,i),1,w,1)
126 do l = i,j-1
127 call zcopy(n,r(1,l+1),1,r(1,l),1)
128 end do
129 call zcopy(n,w,1,r(1,j),1)
130 ! retriangularize
131 call zqhqr(n+1-i,n+1-i,r(i,i),ldr,rw,w)
132 else if (j < i) then
133 ! shift columns
134 call zcopy(n,r(1,i),1,w,1)
135 do l = i,j+1,-1
136 call zcopy(n,r(1,l-1),1,r(1,l),1)
137 end do
138 call zcopy(n,w,1,r(1,j),1)
139 ! eliminate the introduced spike.
140 call zqrtv1(n+1-j,r(j,j),rw)
141 ! apply rotations to R
142 call zqrqh(n+1-j,n-j,r(j,j+1),ldr,rw,r(j+1,j))
143 ! zero spike.
144 do l = j+1,n
145 r(l,j) = 0d0
146 end do
147 end if
148end subroutine
subroutine zchshx(n, r, ldr, i, j, w, rw)
Updates a Cholesky factorization after a symmetric shift of rows and columns.
Definition zchshx.f90:100
subroutine qrupdate_xerror(srname, info)
Dispatches error reporting to the handler.
subroutine zqrtv1(n, u, w)
Generates Givens rotations to eliminate all but the first element of a vector.
Definition zqrtv1.f90:75
subroutine zqhqr(m, n, r, ldr, c, s)
Reduces an upper Hessenberg matrix to upper trapezoidal form.
Definition zqhqr.f90:91
subroutine zqrqh(m, n, r, ldr, c, s)
Converts an upper trapezoidal matrix to upper Hessenberg form.
Definition zqrqh.f90:86
Module for custom error handling.