qrupdate-ng
1.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
sqrtv1.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 Generates Givens rotations to eliminate all but the first element of a vector.
21
!>
22
!> \par Definition:
23
! =============
24
!> \verbatim
25
!> subroutine sqrtv1(n,u,w)
26
!>
27
!> .. Scalar Arguments ..
28
!> integer n
29
!> ..
30
!> .. Array Arguments ..
31
!> real u(*), w(*)
32
!> ..
33
!> \endverbatim
34
!>
35
!> \par Purpose:
36
! =============
37
!> \verbatim
38
!>
39
!> SQRTV1 generates a sequence of n-1 Givens rotations that
40
!> eliminate all but the first element of a real vector u.
41
!> On entry, u contains the vector to be reduced. On exit,
42
!> u(1) contains the resulting element, u(2:n) contains the
43
!> rotation sines, and w contains the rotation cosines.
44
!>
45
!> The rotations are generated from the bottom up, so that the
46
!> first rotation eliminates u(n), the second eliminates u(n-1),
47
!> and so on.
48
!> \endverbatim
49
!>
50
!> \param[in] n
51
!> \verbatim
52
!> n is INTEGER
53
!> The length of the vector u. If n <= 0, the subroutine
54
!> returns immediately without modification.
55
!> \endverbatim
56
!>
57
!> \param[in,out] u
58
!> \verbatim
59
!> u is REAL array, dimension (n)
60
!> On entry, the vector to be reduced. On exit, u(1)
61
!> contains the remaining element, and u(2:n) contains
62
!> the sine parts of the Givens rotations.
63
!> \endverbatim
64
!>
65
!> \param[out] w
66
!> \verbatim
67
!> w is REAL array, dimension (n)
68
!> On exit, w contains the cosine parts of the Givens
69
!> rotations.
70
!> \endverbatim
71
!>
72
!> \ingroup givens
73
subroutine
sqrtv1
(n,u,w)
74
use
iso_fortran_env
75
integer
,
intent(in)
:: n
76
real
(real32),
intent(inout)
:: u(*)
77
real
(real32),
intent(out)
:: w(*)
78
external
slartg
79
real
(real32) rr,t
80
integer
i
81
! quick return if possible.
82
if
(n <= 0)
return
83
rr = u(n)
84
do
i = n-1,1,-1
85
call
slartg(u(i),rr,w(i),u(i+1),t)
86
rr = t
87
end do
88
u(1) = rr
89
end subroutine
sqrtv1
subroutine sqrtv1(n, u, w)
Generates Givens rotations to eliminate all but the first element of a vector.
Definition
sqrtv1.f90:74
src
sqrtv1.f90
Generated by
1.17.0