-
Notifications
You must be signed in to change notification settings - Fork 13
/
test64_.f90
80 lines (74 loc) · 1.93 KB
/
test64_.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
!testdpotr_test_gh_2691.f90 with _64 suffix and scipy_ prefix
subroutine garbage(okflag)
implicit none
integer, intent(out) :: okflag
double precision, dimension(3,3) :: a, a2
integer, parameter :: lwork = 100
double precision, dimension(lwork) :: work(lwork)
integer, dimension(3) :: ipiv
integer :: info, i, j
okflag = 1
! condition number =~ 19, well invertible
a(1,1) = 0.68534241
a(1,2) = 0.63723771
a(2,1) = 0.63723771
a(1,3) = 0.37423535
a(3,1) = 0.37423535
a(2,2) = 2.42926786
a(2,3) = 2.33541214
a(3,2) = 2.33541214
a(3,3) = 3.30327538
a2 = a
call scipy_dpotrf_64('L', 3, a, 3, info)
if (info.ne.0) then
okflag = 0
write(*,*) 'DPOTRF failed'
return
end if
do i = 1, 3
do j = 1, i
write(*,*) 'DPOTRF result', i, j, a(i,j)
end do
end do
do i = 1, 3
do j = i+1, 3
a(i,j) = 0
end do
end do
call scipy_dpotri_64('L', 3, a, 3, info)
if (info.ne.0) then
okflag = 0
write(*,*) 'DPOTRI failed'
return
end if
call scipy_dgetrf_64(3, 3, a2, 3, ipiv, info)
if (info.ne.0) then
okflag = 0
write(*,*) 'DGETRF failed'
return
end if
call scipy_dgetri_64(3, a2, 3, ipiv, work, lwork, info)
if (info.ne.0) then
okflag = 0
write(*,*) 'DGETRI failed'
return
end if
do i = 1, 3
do j = 1, i
write(*,*) i, j, a(i,j), a2(i,j)
if (abs(a(i,j) - a2(i,j)) > 1e-3 + 1e-3*abs(a(i,j))) then
okflag = 0
write(*,*) '# po/ge mismatch!'
end if
end do
end do
end subroutine
program main
integer :: okflag
call garbage(okflag)
if (okflag.eq.1) then
write(*,*) 'OK'
else
write(*,*) 'FAIL'
end if
end program