qrupdate-ng
1.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
zqhqr.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 Reduces an upper Hessenberg matrix to upper trapezoidal form.
21
!>
22
!> \par Definition:
23
! =============
24
!> \verbatim
25
!> subroutine zqhqr(m,n,R,ldr,c,s)
26
!>
27
!> .. Scalar Arguments ..
28
!> integer m, n, ldr
29
!> ..
30
!> .. Array Arguments ..
31
!> double complex R(ldr,*), s(*)
32
!> double precision c(*)
33
!> ..
34
!> \endverbatim
35
!>
36
!> \par Purpose:
37
! =============
38
!> \verbatim
39
!>
40
!> ZQHQR reduces an m-by-n upper Hessenberg matrix R to upper
41
!> trapezoidal form. Given an m-by-n upper Hessenberg matrix R,
42
!> ZQHQR applies min(m-1,n) Givens rotations from the
43
!> left to eliminate the subdiagonal elements, producing an upper
44
!> trapezoidal matrix.
45
!>
46
!> On exit, c contains the cosine parts and s contains the sine
47
!> parts of the Givens rotations used in the reduction.
48
!> \endverbatim
49
!>
50
!> \param[in] m
51
!> \verbatim
52
!> m is INTEGER
53
!> The number of rows of the matrix R. m >= 0.
54
!> \endverbatim
55
!>
56
!> \param[in] n
57
!> \verbatim
58
!> n is INTEGER
59
!> The number of columns of the matrix R. n >= 0.
60
!> \endverbatim
61
!>
62
!> \param[in,out] R
63
!> \verbatim
64
!> R is COMPLEX*16 array, dimension (ldr,n)
65
!> On entry, the upper Hessenberg matrix R. On exit, the
66
!> updated upper trapezoidal matrix.
67
!> \endverbatim
68
!>
69
!> \param[in] ldr
70
!> \verbatim
71
!> ldr is INTEGER
72
!> The leading dimension of the array R. ldr >= m.
73
!> \endverbatim
74
!>
75
!> \param[out] c
76
!> \verbatim
77
!> c is DOUBLE PRECISION array, dimension (min(m-1,n))
78
!> On exit, the cosine parts of the Givens rotations used
79
!> to reduce R to upper trapezoidal form.
80
!> \endverbatim
81
!>
82
!> \param[out] s
83
!> \verbatim
84
!> s is COMPLEX*16 array, dimension (min(m-1,n))
85
!> On exit, the sine parts of the Givens rotations used
86
!> to reduce R to upper trapezoidal form.
87
!> \endverbatim
88
!>
89
!> \ingroup qrdecomp
90
subroutine
zqhqr
(m,n,R,ldr,c,s)
91
use
iso_fortran_env
92
use
qrupdate_error
93
integer
,
intent(in)
:: m, n, ldr
94
complex(real64)
,
intent(inout)
:: R(ldr,*)
95
real
(real64),
intent(out)
:: c(*)
96
complex(real64)
,
intent(out)
:: s(*)
97
external
zlartg
98
complex(real64)
t
99
integer
info,i,ii,j
100
! quick return if possible.
101
if
(m == 0 .or. m == 1 .or. n == 0)
return
102
! check arguments.
103
info = 0
104
if
(m < 0)
then
105
info = 1
106
else
if
(n < 0)
then
107
info = 2
108
else
if
(ldr < m)
then
109
info = 4
110
end if
111
if
(info /= 0)
then
112
call
qrupdate_xerror
(
'ZQHQR'
,info)
113
return
114
end if
115
do
i = 1,n
116
! apply stored rotations, column-wise
117
t = r(1,i)
118
ii = min(m,i)
119
do
j = 1,ii-1
120
r(j,i) = c(j)*t + s(j)*r(j+1,i)
121
t = c(j)*r(j+1,i) - conjg(s(j))*t
122
end do
123
if
(ii < m)
then
124
! generate next rotation
125
call
zlartg(t,r(ii+1,i),c(i),s(i),r(ii,i))
126
r(ii+1,i) = 0d0
127
else
128
r(ii,i) = t
129
end if
130
end do
131
end subroutine
qrupdate_error::qrupdate_xerror
subroutine qrupdate_xerror(srname, info)
Dispatches error reporting to the handler.
Definition
qrupdate_error.f90:89
zqhqr
subroutine zqhqr(m, n, r, ldr, c, s)
Reduces an upper Hessenberg matrix to upper trapezoidal form.
Definition
zqhqr.f90:91
qrupdate_error
Module for custom error handling.
Definition
qrupdate_error.f90:24
src
zqhqr.f90
Generated by
1.17.0