59 #include "sll_working_precision.h"
78 #define SWP(aval,bval) swp=(aval); aval=(bval); bval=swp
163 sll_real64,
dimension(:) :: a
164 sll_int32,
intent(in) :: n
165 sll_int32,
intent(out),
dimension(1:n) :: ipiv
166 sll_real64,
intent(out),
dimension(1:7*n),
target :: cts
170 sll_real64 :: s11, s12, s13, s14, s15
171 sll_real64 :: s21, s22, s23, s24, s25
172 sll_real64 :: s31, s32, s33, s34, s35
173 sll_real64 :: t1, t2, t3, swp
175 sll_real64,
pointer :: d(:)
176 sll_real64,
pointer :: u(:)
177 sll_real64,
pointer :: v(:)
178 sll_real64,
pointer :: q(:)
179 sll_real64,
pointer :: r(:)
180 sll_real64,
pointer :: l(:)
181 sll_real64,
pointer :: m(:)
205 v => cts(2*n + 1:3*n)
206 q => cts(3*n + 1:4*n)
207 r => cts(4*n + 1:5*n)
208 l => cts(5*n + 1:6*n)
209 m => cts(6*n + 1:7*n)
215 #define aa(ii,jj) a(2*((ii)-1)+(jj)+1)
218 s11 = aa(1, 1); s12 = aa(1, 2); s13 = aa(1, 0)
219 s21 = aa(2, 1); s22 = aa(2, 2); s23 = aa(2, 3)
220 s31 = aa(3, 4); s32 = aa(3, 2); s33 = aa(3, 3)
222 s11 = aa(1, 1); s12 = aa(1, 2); s13 = 0.0_f64; s14 = aa(1, 0)
223 s21 = aa(2, 1); s22 = aa(2, 2); s23 = aa(2, 3); s24 = 0.0_f64
224 s31 = aa(4, 5); s32 = 0.0_f64; s33 = aa(4, 3); s34 = aa(4, 4)
226 s11 = aa(1, 1); s12 = aa(1, 2); s13 = 0.0_f64; s14 = 0.0_f64; s15 = aa(1, 0)
227 s21 = aa(2, 1); s22 = aa(2, 2); s23 = aa(2, 3); s24 = 0.0_f64; s25 = 0.0_f64
228 s31 = aa(n, n + 1); s32 = 0.0_f64; s33 = 0.0_f64; s34 = aa(n, n - 1); s35 = aa(n, n)
233 if (i .lt. n - 3)
then
256 if ((t1 < t2) .or. (t1 < t3))
then
277 if (s11 == 0.0_f64) print *,
'zero determinant'
291 d(i) = s11; u(i) = s12; v(i) = s13; q(i) = s14; r(i) = s15
297 if (i < (n - 4))
then
298 s11 = s22; s12 = s23; s13 = 0.0_f64; s14 = s24; s15 = s25
299 s21 = aa(i + 2, i + 1); s22 = aa(i + 2, i + 2); s23 = aa(i + 2, i + 3); s24 = 0.0_f64; s25 = 0.0_f64
300 s31 = s32; s32 = s33; s33 = 0.0_f64; s34 = s34; s35 = s35
302 s11 = s22; s12 = s23; s13 = s24; s14 = s25;
303 s21 = aa(i + 2, i + 1); s22 = aa(i + 2, i + 2); s23 = aa(i + 2, i + 3); s24 = 0.0_f64
304 s31 = s32; s32 = s33; s33 = s34; s34 = s35
306 else if (i == (n - 3))
then
327 if ((t1 < t2) .or. (t1 < t3))
then
348 if (s11 == 0.0_f64) print *,
'Zero determinant'
359 d(i) = s11; u(i) = s12; v(i) = s13; r(i) = s14
365 s11 = s22; s12 = s23; s13 = s24
366 s21 = aa(i + 2, i + 1); s22 = aa(i + 2, i + 2); s23 = aa(i + 2, i + 3)
367 s31 = s32; s32 = s33; s33 = s34
368 else if (i == n - 2)
then
389 if ((t1 < t2) .or. (t1 < t3))
then
406 if (s11 == 0.0_f64) print *,
'zero determinant'
415 d(i) = s11; u(i) = s12; v(i) = s13
425 else if (i == n - 1)
then
456 if (s11 == 0.0_f64) print *,
'Zero determinant'
462 d(i) = s11; u(i) = s12
491 if (s11 == 0.0_f64) print *,
'zero determinant'
534 sll_int32,
intent(in) :: n
535 sll_real64,
dimension(1:7*n),
target :: cts
536 sll_int32,
dimension(1:n),
intent(in) :: ipiv
537 sll_real64,
target :: b(n)
538 sll_real64,
target :: x(n)
539 sll_real64,
pointer,
dimension(:) :: bptr
540 sll_real64,
pointer,
dimension(:) :: xptr
544 sll_real64,
pointer :: d(:)
545 sll_real64,
pointer :: u(:)
546 sll_real64,
pointer :: v(:)
547 sll_real64,
pointer :: q(:)
548 sll_real64,
pointer :: r(:)
549 sll_real64,
pointer :: l(:)
550 sll_real64,
pointer :: m(:)
554 v => cts(2*n + 1:3*n)
555 q => cts(3*n + 1:4*n)
556 r => cts(4*n + 1:5*n)
557 l => cts(5*n + 1:6*n)
558 m => cts(6*n + 1:7*n)
567 if (.not.
associated(xptr,
target=bptr))
then
577 swp(x(i), x(ipiv(i)))
578 x(i + 1) = x(i + 1) - l(i)*x(i)
579 x(n) = x(n) - m(i)*x(i)
586 x(i) = (x(i) - u(i)*x(i + 1))/d(i)
591 x(i) = (x(i) - (u(i)*x(i + 1) + v(i)*x(i + 2) + &
592 q(i)*x(n - 1) + r(i)*x(n)))/d(i)
609 sll_int32,
intent(in) :: n
610 sll_real64,
dimension(1:7*n),
target :: cts
611 sll_int32,
dimension(1:n),
intent(in) :: ipiv
612 sll_comp64,
target :: b(n)
613 sll_comp64,
target :: x(n)
614 sll_comp64,
pointer,
dimension(:) :: bptr
615 sll_comp64,
pointer,
dimension(:) :: xptr
618 sll_real64,
pointer :: d(:)
619 sll_real64,
pointer :: u(:)
620 sll_real64,
pointer :: v(:)
621 sll_real64,
pointer :: q(:)
622 sll_real64,
pointer :: r(:)
623 sll_real64,
pointer :: l(:)
624 sll_real64,
pointer :: m(:)
628 v => cts(2*n + 1:3*n)
629 q => cts(3*n + 1:4*n)
630 r => cts(4*n + 1:5*n)
631 l => cts(5*n + 1:6*n)
632 m => cts(6*n + 1:7*n)
638 if (.not.
associated(xptr,
target=bptr))
then
648 swp(x(i), x(ipiv(i)))
649 x(i + 1) = x(i + 1) - cmplx(l(i), 0.0_f64, kind=f64)*x(i)
650 x(n) = x(n) - cmplx(m(i), 0.0, f64)*x(i)
655 x(i) = x(i)/cmplx(d(i), 0.0, f64)
657 x(i) = (x(i) - cmplx(u(i), 0.0, f64)*x(i + 1))/cmplx(d(i), 0.0, f64)
660 x(i) = (x(i) - (cmplx(u(i), 0.0, f64)*x(i + 1) + cmplx(v(i), 0.0, f64)*x(i + 2) + &
661 cmplx(q(i), 0.0, f64)*x(n - 1) + cmplx(r(i), 0.0, f64)*x(n)))/cmplx(d(i), 0.0, kind=f64)
Solve tridiagonal system (double or complex)
Tridiagonal system solver.
subroutine, public sll_s_setup_cyclic_tridiag(a, n, cts, ipiv)
Give the factorization of the matrix in argument.
subroutine, public sll_s_solve_cyclic_tridiag_double(cts, ipiv, b, n, x)
Solves tridiagonal system.
subroutine solve_cyclic_tridiag_complex(cts, ipiv, b, n, x)
Complex version of sll_s_solve_cyclic_tridiag_double.