Hello everyone,
I am having problem performing forward and backward sine tranforms with fftw package. The problem is that the repeated application of the sine transform does not return the original array (even after rescaling). The same package in python works perfectly fine. Please see the code below
program test
use, intrinsic :: iso_c_binding
include 'fftw3.f03'
! implicit none
type(C_PTR) :: plan5
integer(C_FFTW_R2R_KIND) :: RODFT00
integer(C_INT), parameter :: kk = 6
real(C_DOUBLE) :: cff
real(C_DOUBLE), dimension(kk) :: in1, out1
real(C_DOUBLE), dimension(kk) :: test_in, test_out, test_out1
plan5 = fftw_plan_r2r_1d(kk,in1,out1,RODFT00,FFTW_ESTIMATE)
cff = dble(2*(kk+1))
print*, 'cff = ', cff
test_in(1) = 1d0
test_in(2) = 2d0
test_in(3) = 3d0
test_in(4) = 4d0
test_in(5) = 5d0
test_in(6) = 6d0
print*, 'test_in', test_in
call fftw_execute_r2r(plan5,test_in,test_out)
print*, 'test_out', test_out
call fftw_execute_r2r(plan5,test_out,test_out1)
print*, 'test_out1', test_out1/cff
stop
end program test
The output of the program is
cff = 14.0000000000000
test_in 1.00000000000000 2.00000000000000 3.00000000000000
4.00000000000000 5.00000000000000 6.00000000000000
test_out 21.0000000000000 -3.00000000000000
-3.00000000000000 -3.00000000000000 1.73205080756888
5.19615242270663
test_out1 1.35201451644825 1.83800362911206
1.25256417034730 1.46684988463302 0.214285714285714
0.799725173050474
Anyone can help?
Thanks,
Mike