Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65661404
fftransform_fftw.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Jun 5, 09:06
Size
3 KB
Mime Type
text/x-c
Expires
Fri, Jun 7, 09:06 (2 d)
Engine
blob
Format
Raw Data
Handle
18108699
Attached To
rTAMAAS tamaas
fftransform_fftw.cpp
View Options
/**
*
* @author Lucas Frérot <lucas.frerot@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2016 EPFL (Ecole Polytechnique Fédérale de
* Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
* Solides)
*
* Tamaas is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Tamaas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Tamaas. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "fftransform_fftw.hh"
__BEGIN_TAMAAS__
template
<
typename
T
,
UInt
dim
>
FFTransformFFTW
<
T
,
dim
>::
FFTransformFFTW
(
Grid
<
T
,
dim
>
&
real
,
GridHermitian
<
T
,
dim
>
&
spectral
)
:
FFTransform
<
T
,
dim
>
(
real
,
spectral
),
forward_plan
(
NULL
),
backward_plan
(
NULL
)
{
TAMAAS_ASSERT
(
real
.
getNbComponents
()
==
spectral
.
getNbComponents
(),
"components for FFTW do not match"
);
// Data pointers
Real
*
in
=
const_cast
<
Real
*>
(
this
->
real
.
getInternalData
());
fftw_complex
*
out
=
reinterpret_cast
<
fftw_complex
*>
(
this
->
spectral
.
getInternalData
());
int
components
=
real
.
getNbComponents
();
// fftw parameters
int
rank
=
dim
;
// dimension of fft
const
int
*
n
=
reinterpret_cast
<
const
int
*>
(
real
.
sizes
());
// size of individual fft
int
howmany
=
components
;
// how many fft to compute
int
idist
=
1
,
odist
=
1
;
// components are next to each other in memory
int
istride
=
components
,
ostride
=
components
;
int
*
inembeded
=
NULL
,
*
onembeded
=
NULL
;
// row major
forward_plan
=
fftw_plan_many_dft_r2c
(
rank
,
n
,
howmany
,
in
,
inembeded
,
istride
,
idist
,
out
,
onembeded
,
ostride
,
odist
,
FFTW_ESTIMATE
);
backward_plan
=
fftw_plan_many_dft_c2r
(
rank
,
n
,
howmany
,
out
,
onembeded
,
ostride
,
odist
,
in
,
inembeded
,
istride
,
idist
,
FFTW_ESTIMATE
);
}
/* -------------------------------------------------------------------------- */
template
<
typename
T
,
UInt
dim
>
FFTransformFFTW
<
T
,
dim
>::~
FFTransformFFTW
()
{
fftw_destroy_plan
(
forward_plan
);
fftw_destroy_plan
(
backward_plan
);
}
/* -------------------------------------------------------------------------- */
template
<
typename
T
,
UInt
dim
>
void
FFTransformFFTW
<
T
,
dim
>::
forwardTransform
()
{
fftw_execute
(
forward_plan
);
}
/* -------------------------------------------------------------------------- */
template
<
typename
T
,
UInt
dim
>
void
FFTransformFFTW
<
T
,
dim
>::
backwardTransform
()
{
fftw_execute
(
backward_plan
);
this
->
normalize
();
}
/* -------------------------------------------------------------------------- */
template
class
FFTransformFFTW
<
Real
,
2
>
;
__END_TAMAAS__
Event Timeline
Log In to Comment