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