20 real(dp),
intent(in) :: x(:)
21 real(dp),
allocatable,
dimension(:, :) :: q
23 real(dp) :: x_norm, y_norm
24 real(dp),
allocatable :: v(:)
25 real(dp),
allocatable :: w(:)
32 if (dabs(y_norm) <
dsame)
then
39 v(1) = -(y_norm**2) / (x(1) + x_norm)
66 real(dp),
intent(inout),
dimension(:, :) :: a
67 real(dp),
intent(out),
dimension(:, :),
allocatable :: p, qt
71 real(dp),
allocatable,
dimension(:, :) :: qi, pi
72 real(dp),
allocatable,
dimension(:) :: h
84 a(i:m, :) = matmul(pi, a(i:m, :))
85 p(:, i:m) = matmul(p(:, i:m), pi)
91 a(:, i + 1:n) = matmul(a(:, i + 1:n), qi)
92 qt(i + 1:n, :) = matmul(qi, qt(i + 1:n, :))
104 real(dp),
intent(in) :: a, b
105 real(dp),
dimension(2, 2) :: g
107 real(dp) :: c, s, h, d
109 if (abs(b) <
dprec)
then
137 real(dp),
intent(in),
dimension(:, :) :: a
140 integer(I4B) :: m, n, min_mn
141 real(dp) t11, t12, t21, t22
142 real(dp) dm, fmmin, fm, dn
143 real(dp) :: mean, product, mean_product, mu1, mu2
150 dn = a(min_mn, min_mn)
151 dm = a(min_mn - 1, min_mn - 1)
152 fm = a(min_mn - 1, min_mn)
154 fmmin = a(min_mn - 2, min_mn - 1)
159 t11 = dm**2 + fmmin**2
164 mean = (t11 + t22) / 2.0_dp
165 product = t11 * t22 - t12 * t21
166 mean_product = mean**2 - product
167 if (abs(mean_product) <
dem6)
then
168 mean_product = 0.0_dp
170 mu1 = mean - sqrt(mean_product)
171 mu2 = mean + sqrt(mean_product)
172 if (abs(t22 - mu1) < abs(t22 - mu2))
then
185 real(dp),
intent(inout),
dimension(:, :) :: a
186 real(dp),
intent(inout),
dimension(:, :) :: u, vt
188 integer(I4B) :: m, n, i, j
189 real(dp),
dimension(2, 2) :: g
190 real(dp) :: t11, t12, mu
201 t11 = a(1, 1)**2 - mu
202 t12 = a(1, 1) * a(1, 2)
209 a(:, i:j) = matmul(a(:, i:j), transpose(g))
210 vt(i:j, :) = matmul(g, vt(i:j, :))
214 a(i:j, :) = matmul(g, a(i:j, :))
215 u(:, i:j) = matmul(u(:, i:j), transpose(g))
232 real(dp),
intent(inout),
dimension(:, :) :: a
233 real(dp),
intent(inout),
dimension(:, :) :: u, vt
235 integer(I4B) :: m, n, i
236 real(dp),
dimension(2, 2) :: g
237 integer(I4B) :: zero_index
243 if (abs(a(i, i)) <
dprec)
then
249 if (zero_index == min(n, m))
then
251 do i = zero_index - 1, 1, -1
253 a(:, [i, zero_index]) = matmul(a(:, [i, zero_index]), transpose(g))
254 vt([i, zero_index], :) = matmul(g, vt([i, zero_index], :))
258 do i = zero_index + 1, n
260 a([zero_index, i], :) = matmul(transpose(g), a([zero_index, i], :))
261 u(:, [zero_index, i]) = matmul(u(:, [zero_index, i]), g)
271 real(dp),
intent(in) :: a(:, :)
274 integer(I4B) :: m, n, i
280 do i = 1, min(m, n) - 1
281 norm = max(norm, abs(a(i, i + 1)))
298 real(dp),
intent(in),
dimension(:, :) :: a
299 integer(I4B),
intent(out) :: p
300 integer(I4B),
intent(out) :: q
302 integer(I4B) :: m, n, j, min_mn
312 if (abs(a(j - 1, j)) >
dprec)
then
319 if (abs(a(j - 1, j)) <
dprec)
then
331 real(dp),
intent(in) :: a(:, :)
332 logical(LGP) :: has_zero
334 integer(I4B) :: m, n, i
341 if (abs(a(i, i)) <
dprec)
then
357 real(dp),
intent(inout),
dimension(:, :) :: a
358 real(dp),
intent(inout),
dimension(:, :),
allocatable :: qt
360 real(dp),
dimension(2, 2) :: g
361 integer(I4B) :: m, n, i
368 a(:, [i, m + 1]) = matmul(a(:, [i, m + 1]), transpose(g))
369 qt([i, m + 1], :) = matmul(g, qt([i, m + 1], :))
387 real(dp),
intent(inout),
dimension(:, :) :: a
389 integer(I4B) :: n, m, j
394 do j = 1, min(n, m) - 1
395 if (abs(a(j, j + 1)) <=
dprec * (abs(a(j, j)) + abs(a(j + 1, j + 1))))
then
420 pure subroutine svd(A, U, S, VT)
422 real(dp),
intent(in),
dimension(:, :) :: a
423 real(dp),
intent(out),
dimension(:, :),
allocatable :: u
424 real(dp),
intent(out),
dimension(:, :),
allocatable :: s
425 real(dp),
intent(out),
dimension(:, :),
allocatable :: vt
428 integer(I4B) :: max_itr
462 if (error <
dprec)
exit
This module contains simulation constants.
real(dp), parameter dsame
real constant for values that are considered the same based on machine precision
real(dp), parameter dem6
real constant 1e-6
real(dp), parameter dprec
real constant machine precision
real(dp), parameter done
real constant 1
This module defines variable data types.
pure real(dp) function, dimension(size(a), size(b)), public outer_product(A, B)
pure real(dp) function, dimension(:, :), allocatable, public eye(n)
pure real(dp) function compute_shift(A)
pure subroutine, public bidiagonal_decomposition(A, P, Qt)
pure subroutine find_nonzero_superdiagonal(A, p, q)
pure subroutine clean_superdiagonal(A)
pure logical(lgp) function has_zero_diagonal(A)
pure real(dp) function, dimension(:, :), allocatable house_holder_matrix(x)
pure subroutine make_matrix_square(A, Qt)
pure real(dp) function superdiagonal_norm(A)
pure subroutine, public svd(A, U, S, VT)
Singular Value Decomposition.
pure subroutine handle_zero_diagonal(A, U, VT)
pure real(dp) function, dimension(2, 2) givens_rotation(a, b)
pure subroutine, public bidiagonal_qr_decomposition(A, U, VT)