Skip to content

Commit 9afb581

Browse files
committed
updated 2
1 parent 9e200ee commit 9afb581

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

test/linalg/test_linalg_specialmatrices.fypp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module test_specialmatrices
66
use stdlib_kinds
77
use stdlib_linalg, only: hermitian
88
use stdlib_linalg_state, only: linalg_state_type
9-
use stdlib_math, only: all_close
9+
use stdlib_math, only: all_close, is_close
1010
use stdlib_specialmatrices
1111
implicit none
1212

@@ -156,21 +156,23 @@ contains
156156
type(tridiagonal_${s1}$_type) :: A
157157
${t1}$, allocatable :: Amat(:,:), dl(:), dv(:), du(:)
158158

159+
! 1x1 matrix has 0-sized off-diagonals and 1-sized diagonal
159160
allocate(dl(0), dv(1), du(0))
160161
dv(1) = 5.0_wp
161162
A = tridiagonal(dl, dv, du)
162163
Amat = dense(A)
163164

165+
! Check if it compiled and converted properly without segfaulting
164166
call check(error, size(Amat, 1) == 1, .true.)
165167
if (allocated(error)) return
166-
call check(error, all_close(Amat(1,1), 5.0_wp), .true.)
168+
call check(error, is_close(Amat(1,1), 5.0_wp), .true.)
167169
if (allocated(error)) return
168170
end block
169171
#:endfor
170172
end subroutine
171173

172174
subroutine test_tridiagonal_arithmetic(error)
173-
175+
!> Test arithmetic operations and optimization
174176
type(error_type), allocatable, intent(out) :: error
175177
#:for k1, t1, s1 in (KINDS_TYPES)
176178
block
@@ -189,19 +191,19 @@ contains
189191
A = tridiagonal(dl1, dv1, du1)
190192
B = tridiagonal(dl2, dv2, du2)
191193

192-
! Addition test
194+
! Addition test - use dense() to bypass private component restrictions
193195
C = A + B
194-
call check(error, all_close(C%dv, dv1 + dv2), .true.)
196+
call check(error, all_close(dense(C), dense(A) + dense(B)), .true.)
195197
if (allocated(error)) return
196198

197199
! Subtraction test
198200
C = A - B
199-
call check(error, all_close(C%du, du1 - du2), .true.)
201+
call check(error, all_close(dense(C), dense(A) - dense(B)), .true.)
200202
if (allocated(error)) return
201203

202204
! Scalar multiplication test
203205
C = 3.0_wp * A
204-
call check(error, all_close(C%dl, 3.0_wp * dl1), .true.)
206+
call check(error, all_close(dense(C), 3.0_wp * dense(A)), .true.)
205207
if (allocated(error)) return
206208
end block
207209
#:endfor

0 commit comments

Comments
 (0)