-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathhaar.f90
49 lines (47 loc) · 1.06 KB
/
haar.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
subroutine predict(vec, N, direction )
implicit none
real vec(*)
integer N !must be power of 2
integer direction !0:forward 1:inverse
!local variables
integer half
integer cnt,i,j
real predictVal
half = N/2
cnt = 0
do i=1,half
predictVal = vec(i)
j = i + half
if(direction == 0) then
vec(j) = vec(j) - predictVal
else if (direction == 1) then
vec(j) = vec(j) + predictVal
else
print*,"haar::predict: bad direction value"
stop
endif
enddo
end subroutine
subroutine update( vec, N, direction )
implicit none
real vec(*)
integer N !must be power of 2
integer direction !0:forward 1:inverse
!local variables
integer half
integer cnt,i,j
real updateVal
half = N/2
do i=1,half
j = i + half
updateVal = vec(j) / 2.0
if (direction == 0) then
vec(i) = vec(i) + updateVal;
else if (direction ==1) then
vec(i) = vec(i) - updateVal
else
print*,"update: bad direction value"
stop
endif
enddo
end subroutine