@@ -5,6 +5,7 @@ module test_specialmatrices
5
5
use testdrive, only : new_unittest, unittest_type, error_type, check, skip_test
6
6
use stdlib_kinds
7
7
use stdlib_linalg, only: hermitian
8
+ use stdlib_linalg_state, only: linalg_state_type
8
9
use stdlib_math, only: all_close
9
10
use stdlib_specialmatrices
10
11
implicit none
@@ -18,7 +19,8 @@ contains
18
19
type(unittest_type), allocatable, intent(out) :: testsuite(:)
19
20
20
21
testsuite = [ &
21
- new_unittest('tridiagonal', test_tridiagonal) &
22
+ new_unittest('tridiagonal', test_tridiagonal), &
23
+ new_unittest('tridiagonal error handling', test_tridiagonal_error_handling) &
22
24
]
23
25
end subroutine
24
26
@@ -65,6 +67,33 @@ contains
65
67
#:endfor
66
68
end subroutine
67
69
70
+ subroutine test_tridiagonal_error_handling(error)
71
+ !> Error handling
72
+ type(error_type), allocatable, intent(out) :: error
73
+ #:for k1, t1, s1 in (KINDS_TYPES)
74
+ block
75
+ integer, parameter :: wp = ${k1}$
76
+ integer, parameter :: n = 5
77
+ type(tridiagonal_${s1}$_type) :: A
78
+ ${t1}$, allocatable :: dl(:), dv(:), du(:)
79
+ type(linalg_state_type) :: state
80
+ integer :: i
81
+
82
+ !> Test constructor from arrays.
83
+ dl = [(1.0_wp, i = 1, n-2)] ; du = dl
84
+ dv = [(2.0_wp, i = 1, n)]
85
+ A = tridiagonal(dl, dv, du, state)
86
+ call check(error, state%ok(), .false.)
87
+ if (allocated(error)) return
88
+
89
+ !> Test contructor from constants.
90
+ A = tridiagonal(dl(1), dv(1), du(1), -n, state)
91
+ call check(error, state%ok(), .false.)
92
+ if (allocated(error)) return
93
+ end block
94
+ #:endfor
95
+ end subroutine
96
+
68
97
end module
69
98
70
99
0 commit comments