Skip to content

Commit e85f8ea

Browse files
committed
modification suggested by Andrzej
1 parent 3629935 commit e85f8ea

File tree

3 files changed

+94
-8
lines changed

3 files changed

+94
-8
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
^\\.git
22
^\\.gitignore
33
inst/doc/auto
4+
testScript
45
aclocal.log
56
autom4te.cache/
67
^config.log

R/fftwtools.R

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,19 @@ fftw_r2c_2d <- function(data, HermConj=1) {
217217

218218
nR <- dim(data)[1]
219219
nC <- dim(data)[2]
220-
nRc <- floor(nR/2) +1
220+
221+
nRdiv2 <- nR/2
222+
nRc <- floor(nRdiv2) +1
223+
idxRowAppend <- ceiling(nRdiv2):2
221224

222-
isEven <- 1 - (nR %% 2)
223-
idxRowAppend <- NULL
225+
## isEven <- 1 - (nR %% 2)
226+
## idxRowAppend <- NULL
224227

225-
if(isEven) {
226-
idxRowAppend <- (nRc -1):2
227-
} else {
228-
idxRowAppend <- nRc:2
229-
}
228+
## if(isEven) {
229+
## idxRowAppend <- (nRc -1):2
230+
## } else {
231+
## idxRowAppend <- nRc:2
232+
## }
230233

231234
##correct for the fact the c call is column-major
232235

testScript/fftwtoolsTest.R

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
library("fftwtools")
2+
3+
fftw_r2c_2d_raw <- function(data) {
4+
5+
## can be done with two mvfft's t(mvfft(t(mvfft(a))))
6+
## == mvfft(t(mvfft(t(a))))
7+
8+
data <- as.matrix(data)
9+
10+
nR <- dim(data)[1]
11+
nC <- dim(data)[2]
12+
nRc <- floor(nR/2) +1
13+
##idxRowAppend <- (nRc - (nRc %% 2)):2
14+
15+
##correct for the fact the c call is column-major
16+
17+
out <- .C("fft_r2c_2d", as.integer(nC), as.integer(nR),
18+
as.double(data), res=matrix(as.complex(0), nRc , nC))
19+
out$res
20+
}
21+
22+
23+
fft2d <- function(X) {
24+
mvfft(t(mvfft(t(X))))
25+
}
26+
27+
x1 = matrix(1:10, 5, 2)
28+
x2 = matrix(1:12, 6, 2)
29+
30+
x=c(1, 2, 3, 9, 8, 5, 1, 2, 9, 8, 7, 2)
31+
x= t(matrix(x, nrow=4))
32+
33+
fftw_c2c_2d(fftw_c2c_2d(x), inverse=1)/12
34+
fftw_c2c_2d(fftw_c2c_2d(x1), inverse=1)/10
35+
fftw_c2c_2d(fftw_c2c_2d(x2), inverse=1)/12
36+
37+
fftw_c2c_2d(fftw_c2c_2d(t(x)), inverse=1)/12
38+
fftw_c2c_2d(fftw_c2c_2d(t(x1)), inverse=1)/10
39+
fftw_c2c_2d(fftw_c2c_2d(t(x2)), inverse=1)/12
40+
41+
42+
fftw_c2c_2d(fftw_r2c_2d(x), inverse=1)/12
43+
fftw_c2c_2d(fftw_r2c_2d(x1), inverse=1)/10
44+
fftw_c2c_2d(fftw_r2c_2d(x2), inverse=1)/12
45+
46+
fftw_c2c_2d(fftw_r2c_2d(t(x)), inverse=1)/12
47+
fftw_c2c_2d(fftw_r2c_2d(t(x1)), inverse=1)/10
48+
fftw_c2c_2d(fftw_r2c_2d(t(x2)), inverse=1)/12
49+
50+
51+
fftw_c2c_2d(x)
52+
fftw_r2c_2d(x)
53+
fftw_c2c_2d(t(x))
54+
fftw_r2c_2d(t(x))
55+
56+
fftw_r2c_2d_raw (t(x))
57+
res <- fftw_r2c_2d_raw (t(x))
58+
59+
60+
fftw_c2c_2d(x1)
61+
fftw_r2c_2d(x1)
62+
fftw_c2c_2d(t(x1))
63+
fftw_r2c_2d(t(x1))
64+
65+
fftw_c2c_2d(x2)
66+
fftw_r2c_2d(x2)
67+
fftw_c2c_2d(t(x2))
68+
fftw_r2c_2d(t(x2))
69+
70+
## looks good but ....
71+
72+
## consider this mvfftw_r2c
73+
mvfftw(x)
74+
mvfftw_r2c(x)
75+
76+
mvfft(x1)
77+
mvfftw_r2c(x1)
78+
mvfft(x2)
79+
mvfftw_r2c(x2)
80+
81+
82+
## looks good March 17

0 commit comments

Comments
 (0)