qrupdate-ng 1.2.0
Loading...
Searching...
No Matches
cqrqh.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 Converts an upper trapezoidal matrix to upper Hessenberg form.
21!>
22!> \par Definition:
23! =============
24!> \verbatim
25!> subroutine cqrqh(m,n,R,ldr,c,s)
26!>
27!> .. Scalar Arguments ..
28!> integer m, n, ldr
29!> ..
30!> .. Array Arguments ..
31!> complex R(ldr,*), s(*)
32!> real c(*)
33!> ..
34!> \endverbatim
35!>
36!> \par Purpose:
37! =============
38!> \verbatim
39!>
40!> CQRQH brings an m-by-n upper trapezoidal matrix R into upper
41!> Hessenberg form. Given an m-by-n upper trapezoidal matrix R,
42!> CQRQH applies min(m-1,n) inverse Givens rotations
43!> from the right to introduce subdiagonal elements, producing an
44!> upper Hessenberg matrix.
45!>
46!> On exit, c contains the cosine parts and s contains the sine
47!> parts of the Givens rotations used in the transformation.
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 array, dimension (ldr,n)
65!> On entry, the upper trapezoidal matrix R. On exit, the
66!> upper Hessenberg 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[in] c
76!> \verbatim
77!> c is REAL array, dimension (min(m-1,n))
78!> The cosine parts of the Givens rotations.
79!> \endverbatim
80!>
81!> \param[in] s
82!> \verbatim
83!> s is COMPLEX array, dimension (min(m-1,n))
84!> The sine parts of the Givens rotations.
85!> \endverbatim
86!>
87!> \ingroup qrdecomp
88subroutine cqrqh(m,n,R,ldr,c,s)
89 use iso_fortran_env
91 integer, intent(in) :: m, n, ldr
92 complex(real32), intent(inout) :: R(ldr,*)
93 complex(real32), intent(in) :: s(*)
94 real(real32), intent(in) :: c(*)
95 complex(real32) t
96 integer info,i,ii,j
97 ! quick return if possible.
98 if (m == 0 .or. m == 1 .or. n == 0) return
99 ! check arguments.
100 info = 0
101 if (m < 0) then
102 info = 1
103 else if (n < 0) then
104 info = 2
105 else if (ldr < m) then
106 info = 4
107 end if
108 if (info /= 0) then
109 call qrupdate_xerror('CQRQH',info)
110 return
111 end if
112 do i = 1,n
113 ! apply stored rotations, column-wise
114 ii = min(m-1,i)
115 t = r(ii+1,i)
116 do j = ii,1,-1
117 r(j+1,i) = c(j)*t - conjg(s(j))*r(j,i)
118 t = c(j)*r(j,i) + s(j)*t
119 end do
120 r(1,i) = t
121 end do
122end subroutine
subroutine qrupdate_xerror(srname, info)
Dispatches error reporting to the handler.
subroutine cqrqh(m, n, r, ldr, c, s)
Converts an upper trapezoidal matrix to upper Hessenberg form.
Definition cqrqh.f90:89
Module for custom error handling.