7 !! Solution of a system of linear equations Ax=b with tridiagonal matrix A.
11 !! Copyright 2009-2013 Ralf Greve
15 !! This file is part of SICOPOLIS.
17 !! SICOPOLIS is free software: you can redistribute it and/or modify
18 !! it under the terms of the GNU General Public License as published by
19 !! the Free Software Foundation, either version 3 of the License, or
20 !! (at your option) any later version.
22 !! SICOPOLIS is distributed in the hope that it will be useful,
23 !! but WITHOUT ANY WARRANTY; without even the implied warranty of
24 !! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 !! GNU General Public License for more details.
27 !! You should have received a copy of the GNU General Public License
28 !! along with SICOPOLIS. If not, see <http://www.gnu.org/licenses/>.
30 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
33 !> Solution of a system of linear equations Ax=b with tridiagonal matrix A.
34 !! @param[in] a0 a0(j) is element A_(j,j-1) of Matrix A
35 !! @param[in] a1 a1(j) is element A_(j,j) of Matrix A
36 !! @param[in] a2 a2(j) is element A_(j,j+1) of Matrix A
37 !! @param[in] b inhomogeneity vector
38 !! @param[in] nzeilen size of matrix A (indices run from 0 (!!!) to nzeilen)
39 !! @param[out] x Solution vector.
40 !<------------------------------------------------------------------------------
41 subroutine tri_sle(a0, a1, a2, x, b, nzeilen)
47 real(dp),
dimension(0:*) :: a0, a1, a2, x, b
48 real(dp),
allocatable,
dimension(:) :: help_x
49 integer(i4b) :: nzeilen
56 a1(n) = a1(n) - a0(n)/a1(n-1)*a2(n-1)
60 b(n) = b(n) - a0(n)/a1(n-1)*b(n-1)
73 allocate(help_x(0:nzeilen))
75 help_x(0) = b(nzeilen)/a1(nzeilen)
78 help_x(n) = b(nzeilen-n)/a1(nzeilen-n) &
79 -a2(nzeilen-n)/a1(nzeilen-n)*help_x(n-1)
83 x(n) = help_x(nzeilen-n)