24 #include "sll_memory.h"
25 #include "sll_working_precision.h"
41 sll_real64,
dimension(:),
pointer :: e1
42 sll_real64,
dimension(:),
pointer :: e2
43 sll_real64,
dimension(:),
pointer :: y
44 sll_real64,
dimension(:),
pointer :: z
45 sll_real64,
dimension(:),
pointer :: w
46 sll_real64,
dimension(:),
pointer :: solution
70 print *,
'Matrix size must be at least 3x3'
76 sll_allocate(plan, ierr)
80 sll_allocate(plan%e1(n), ierr)
81 sll_allocate(plan%e2(n), ierr)
82 sll_allocate(plan%y(n), ierr)
83 sll_allocate(plan%z(n), ierr)
84 sll_allocate(plan%w(n), ierr)
85 sll_allocate(plan%solution(n), ierr)
93 sll_real64,
dimension(:) :: f
95 sll_real64 :: s, t, p, l1, l2
96 sll_real64 :: d, d1, d2
98 sll_real64 :: sign_of_a = 0.0_f64
100 if (abs(a) <= 2.0_f64*(abs(b) + abs(c)))
then
101 print *,
'a, b, and c must be such that: |a| > 2(|b|+|c|)'
103 print *,
'Exiting...'
109 s = (a/2 + c)*(a/2 + c) - b*b
110 t = a*a/2 - b*b - 2*c*c
112 if (a /= 0.0_f64)
then
116 p = (a - 2*c)/4 + sign_of_a*sqrt(sign_of_a*(a - 2*c)* &
117 sqrt(s) + t)/2.0_f64 + sign_of_a*sqrt(s)/2.0_f64
133 d = 1.0_f64 + l1*l2*(plan%z(2) + plan%w(1)) + l2*l2*(plan%z(1) + plan%w(2)) + &
134 l1*l1*plan%z(1) + l2**4*(plan%z(1)*plan%w(2) - plan%z(2)*plan%w(1))
136 d1 = l2**4*(plan%y(1)*plan%w(2) - plan%y(2)*plan%w(1)) + &
137 (l1*l1 + l2*l2)*plan%y(1) + l1*l2*plan%y(2)
139 d2 = l2**4*(plan%y(2)*plan%z(1) - plan%y(1)*plan%z(2)) + &
140 l1*l2*plan%y(1) + l2*l2*plan%y(2)
143 plan%solution(i) = plan%y(i) - (d1*plan%z(i) + d2*plan%w(i))/d
151 sll_real64,
dimension(:) :: b
153 sll_real64,
dimension(n) :: x, y
157 y(2) = b(2) - l1*y(1)
160 tmp = b(i) - (l2*y(i - 2) + l1*y(i - 1))
161 if (abs(tmp) < 1e-30_f64)
then
168 x(n - 1) = y(n - 1) - l1*y(n)
170 tmp = y(i) - (l1*x(i + 1) + l2*x(i + 2))
171 if (abs(tmp) < 1e-30_f64)
then
186 sll_deallocate_array(plan%e1, ierr)
187 sll_deallocate_array(plan%e2, ierr)
188 sll_deallocate_array(plan%y, ierr)
189 sll_deallocate_array(plan%z, ierr)
190 sll_deallocate_array(plan%w, ierr)
191 sll_deallocate_array(plan%solution, ierr)
194 sll_deallocate_array(plan, ierr)
Toeplitz penta-diagonal system solver.
type(sll_t_penta_diagonal_solver) function, pointer new_penta_diagonal(n)
allocate the solveR
real(kind=f64) function, dimension(n) solve_subsystem(l1, l2, b, n)
subroutine solve_penta_diagonal(a, b, c, f, plan)
The solution will be set in plansolution.
subroutine delete_penta_diagonal(plan)
deallocat the solver
Initialize the penta diagonal solver.