Skip to content

Commit 4458b88

Browse files
committed
fix test
1 parent 7ae0510 commit 4458b88

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

test/linalg/test_linalg_solve.fypp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,30 +129,30 @@ module test_linalg_solve
129129
end subroutine test_${ri}$_solve
130130

131131
!> 2x2 Complex linear system
132-
!> https://math.stackexchange.com/questions/1996540/solving-linear-equation-systems-with-complex-coefficients-and-variables
133132
subroutine test_2x2_${ri}$_solve(error)
134133
type(error_type), allocatable, intent(out) :: error
135134

136135
type(linalg_state_type) :: state
136+
137+
${rt}$, parameter :: i = (0.0_${rk}$,1.0_${rk}$)
137138

138139
${rt}$ :: A(2,2), b(2), res(2), x(2)
139-
integer(ilp) :: i
140140

141141
! Fill in linear system
142-
A(1,:) = [(+1.0_${rk}$,+1.0_${rk}$),(-1.0_${rk}$,0.0_${rk}$)]
143-
A(2,:) = [(+1.0_${rk}$,-1.0_${rk}$),(+1.0_${rk}$,1.0_${rk}$)]
142+
A(1,:) = [ 1+2*i, 2-i]
143+
A(2,:) = [ 2+i , i]
144144

145-
b = [(0.0_${rk}$,1.0_${rk}$),(1.0_${rk}$,0.0_${rk}$)]
145+
b = [1,-1]
146146

147147
! Exact result
148-
res = [(0.5_${rk}$,0.5_${rk}$),(0.0_${rk}$,0.0_${rk}$)]
148+
res = [(-0.28_${rk}$,-0.04_${rk}$),(0.36_${rk}$,0.48_${rk}$)]
149149

150150
x = solve(a,b,err=state)
151-
151+
152152
call check(error,state%ok(),state%print())
153153
if (allocated(error)) return
154154

155-
call check(error, all(abs(x-res)<max(tiny(0.0_${rk}$),abs(res)*epsilon(0.0_${rk}$))), 'results match expected')
155+
call check(error, all(abs(x-res)<abs(res)*sqrt(epsilon(0.0_${rk}$))), 'results match expected')
156156
if (allocated(error)) return
157157

158158

0 commit comments

Comments
 (0)