-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathnan.f90
85 lines (82 loc) · 2.27 KB
/
nan.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
81
82
83
84
85
module nan_lib
implicit none
interface nan
module procedure d0_nan,d1_nan,d2_nan,d3_nan, z0_nan,z1_nan,z2_nan,z3_nan
end interface
contains
logical pure function d0_nan(x) result (isnan)
double precision,intent(in) :: x
isnan=.not.((x.lt.0.d0).or.(x.ge.0.d0))
end function
logical pure function d1_nan(x) result (isnan)
double precision,intent(in) :: x(:)
integer :: n,i
n=size(x)
do i=1,n
isnan=.not.((x(i).lt.0.d0).or.(x(i).ge.0.d0))
if(isnan)return
end do
end function
logical pure function d2_nan(x) result (isnan)
double precision,intent(in) :: x(:,:)
integer :: m,n,i,j
m=size(x,1);n=size(x,2)
do j=1,n
do i=1,m
isnan=.not.((x(i,j).lt.0.d0).or.(x(i,j).ge.0.d0))
if(isnan)return
end do
end do
end function
logical pure function d3_nan(x) result (isnan)
double precision,intent(in) :: x(:,:,:)
integer :: m,n,p,i,j,k
m=size(x,1);n=size(x,2);p=size(x,3)
do k=1,p
do j=1,n
do i=1,m
isnan=.not.((x(i,j,k).lt.0.d0).or.(x(i,j,k).ge.0.d0))
if(isnan)return
end do
end do
end do
end function
logical pure function z0_nan(x) result (isnan)
double complex,intent(in) :: x
isnan=.not.( ((real(x).lt.0.d0).or.(real(x).ge.0.d0)) .and. ((imag(x).lt.0.d0).or.(imag(x).ge.0.d0)) )
end function
logical pure function z1_nan(x) result (isnan)
double complex,intent(in) :: x(:)
integer :: n,i
n=size(x)
do i=1,n
isnan=.not.( ((real(x(i)).lt.0.d0).or.(real(x(i)).ge.0.d0)) .and. ((imag(x(i)).lt.0.d0).or.(imag(x(i)).ge.0.d0)) )
if(isnan)return
end do
end function
logical pure function z2_nan(x) result (isnan)
double complex,intent(in) :: x(:,:)
integer :: m,n,i,j
m=size(x,1);n=size(x,2)
do j=1,n
do i=1,m
isnan=.not.( ((real(x(i,j)).lt.0.d0).or.(real(x(i,j)).ge.0.d0)) .and. ((imag(x(i,j)).lt.0.d0).or.(imag(x(i,j)).ge.0.d0)) )
if(isnan)return
end do
end do
end function
logical pure function z3_nan(x) result (isnan)
double complex,intent(in) :: x(:,:,:)
integer :: m,n,p,i,j,k
m=size(x,1);n=size(x,2);p=size(x,3)
do k=1,p
do j=1,n
do i=1,m
isnan=.not.( ((real(x(i,j,k)).lt.0.d0).or.(real(x(i,j,k)).ge.0.d0)) .and. &
((imag(x(i,j,k)).lt.0.d0).or.(imag(x(i,j,k)).ge.0.d0)) )
if(isnan)return
end do
end do
end do
end function
end module