GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
crsf2csf.f
Go to the documentation of this file.
1c Copyright (C) 2010-2025 The Octave Project Developers
2c
3c See the file COPYRIGHT.md in the top-level directory of this
4c distribution or <https://octave.org/copyright/>.
5c
6c This file is part of Octave.
7c
8c Octave is free software: you can redistribute it and/or modify it
9c under the terms of the GNU General Public License as published by
10c the Free Software Foundation, either version 3 of the License, or
11c (at your option) any later version.
12c
13c Octave is distributed in the hope that it will be useful, but
14c WITHOUT ANY WARRANTY; without even the implied warranty of
15c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16c GNU General Public License for more details.
17c
18c You should have received a copy of the GNU General Public License
19c along with Octave; see the file COPYING. If not, see
20c <https://www.gnu.org/licenses/>.
21c
22
23 subroutine crsf2csf(n,t,u,c,s)
24 integer n
25 complex t(n,n),u(n,n)
26 real c(n-1),s(n-1)
27 real x,y,z
28 integer j
29 do j = 1,n-1
30 c(j) = 1
31 end do
32 j = 1
33 do while (j < n)
34c apply previous rotations to rows
35 call crcrot1(j,t(1,j),c,s)
36
37 y = t(j+1,j)
38 if (y /= 0) then
39c 2x2 block, form Givens rotation [c, i*s; i*s, c]
40 z = t(j,j+1)
41 c(j) = sqrt(z/(z-y))
42 s(j) = sqrt(y/(y-z))
43c apply new rotation to t(j:j+1,j)
44 call crcrot1(2,t(j,j),c(j),s(j))
45c apply all rotations to t(1:j+1,j+1)
46 call crcrot1(j+1,t(1,j+1),c,s)
47c apply new rotation to columns j,j+1
48 call crcrot2(j+1,t(1,j),t(1,j+1),c(j),s(j))
49c zero subdiagonal entry, skip next row
50 t(j+1,j) = 0
51 j = j + 2
52 else
53 j = j + 1
54 end if
55 end do
56
57c apply rotations to last column if needed
58 if (j == n) then
59 call crcrot1(j,t(1,j),c,s)
60 end if
61
62c apply stored rotations to all columns of u
63 do j = 1,n-1
64 if (c(j) /= 1) then
65 call crcrot2(n,u(1,j),u(1,j+1),c(j),s(j))
66 end if
67 end do
68
69 end subroutine
70
71 subroutine crcrot1(n,x,c,s)
72c apply rotations to a column from the left
73 integer n
74 complex x(n), t
75 real c(n-1),s(n-1)
76 integer i
77 do i = 1,n-1
78 if (c(i) /= 1) then
79 t = x(i)*c(i) - x(i+1)*cmplx(0,s(i))
80 x(i+1) = x(i+1)*c(i) - x(i)*cmplx(0,s(i))
81 x(i) = t
82 endif
83 end do
84 end subroutine
85
86 subroutine crcrot2(n,x,y,c,s)
87c apply a single rotation from the right to a pair of columns
88 integer n
89 complex x(n),y(n),t
90 real c, s
91 integer i
92 do i = 1,n
93 t = x(i)*c + y(i)*cmplx(0,s)
94 y(i) = y(i)*c + x(i)*cmplx(0,s)
95 x(i) = t
96 end do
97 end subroutine
double complex cmplx
Definition Faddeeva.cc:227
subroutine crsf2csf(n, t, u, c, s)
Definition crsf2csf.f:24
subroutine crcrot1(n, x, c, s)
Definition crsf2csf.f:72
subroutine crcrot2(n, x, y, c, s)
Definition crsf2csf.f:87