9 #include "sll_assert.h"
10 #include "sll_errors.h"
17 use schur_complement,
only: &
18 schur_complement_solver, &
19 schur_complement_fac, &
20 schur_complement_slv, &
23 use iso_fortran_env,
only: &
41 real(
wp),
allocatable :: q(:, :)
42 type(schur_complement_solver) :: schur
62 integer,
intent(in) :: n
63 integer,
intent(in) :: kl
64 integer,
intent(in) :: ku
66 character(len=*),
parameter :: &
67 this_sub_name =
"sll_t_spline_matrix_periodic_banded % init"
72 sll_assert(ku + 1 + kl <= n)
76 sll_error(this_sub_name,
"Schur complement solver requires kl=ku.")
86 allocate (self%q(ku + 1 + kl, n))
94 integer,
intent(in) :: i
95 integer,
intent(in) :: j
96 real(wp),
intent(in) :: a_ij
100 sll_assert(1 <= i .and. i <= self%n)
101 sll_assert(1 <= j .and. j <= self%n)
108 if (d > self%n/2) then; d = d - self%n;
else &
109 if (d < -self%n/2) then; d = d + self%n;
end if
112 sll_assert(d >= -self%kl)
113 sll_assert(d <= self%ku)
116 self%q(self%ku + 1 - d, j) = a_ij
133 call schur_complement_fac(self%schur, self%n, self%kl, self%q)
140 real(wp),
intent(inout) :: bx(:)
142 sll_assert(
size(bx) == self%n)
144 call schur_complement_slv(self%schur, self%n, self%kl, self%q, bx)
151 integer,
optional,
intent(in) :: unit
152 character(len=*),
optional,
intent(in) :: fmt
155 integer,
parameter :: unit_default = output_unit
156 character(len=*),
parameter :: fmt_default =
'es9.1'
161 character(len=32) :: fmt_loc
164 if (
present(unit))
then
167 unit_loc = unit_default
170 if (
present(fmt))
then
173 fmt_loc = fmt_default
177 write (fmt_loc,
'(a)')
"("//trim(fmt_loc)//
")"
182 d = modulo(j - i + self%kl, self%n) - self%kl
183 if (-self%kl <= d .and. d <= self%ku)
then
184 write (unit_loc, fmt_loc, advance=
'no') self%q(self%ku + 1 - d, j)
186 write (unit_loc, fmt_loc, advance=
'no') 0.0_wp
201 if (
allocated(self%q))
deallocate (self%q)
202 if (
allocated(self%schur%bb))
call schur_complement_free(self%schur)
Abstract class for small matrix library with basic operations: set matrix element,...
Derived type for periodic banded matrices.
subroutine s_spline_matrix_periodic_banded__init(self, n, kl, ku)
subroutine s_spline_matrix_periodic_banded__write(self, unit, fmt)
integer, parameter wp
Working precision.
subroutine s_spline_matrix_periodic_banded__set_element(self, i, j, a_ij)
subroutine s_spline_matrix_periodic_banded__factorize(self)
subroutine s_spline_matrix_periodic_banded__free(self)
subroutine s_spline_matrix_periodic_banded__solve_inplace(self, bx)
Module to select the kind parameter.
integer, parameter, public f64
f64 is the kind type for 64-bit reals (double precision)