jfftw.real.nd
Class Plan

java.lang.Object
  |
  +--jfftw.real.nd.Plan
All Implemented Interfaces:
Plan

public class Plan
extends java.lang.Object
implements Plan

Corresponds to an FFTW rfftwnd_plan (plan for real multi-dimensional transforms) structure. A plan is a choice of algorithm to optimally compute transforms for a given size of data. Once you have a Plan you can use it to compute a number of transforms for data of the same size. Creating a plan results in collection of much information, that will be reused at succeding creation of plans.

N-dimensional data is thought of by FFTW as a continuous line of M units of data, where M is the product of the N dimensions. Unfortunately multi-dimensional arrays in Java are done the way discussed in the FFTW documentation in the topic 'Dynamic Arrays in C--The Wrong Way'.

The suggested way is to pass a single one dimensional array to transform(double[]), as described in the FFTW documentation.

In the real multi-dimensional case the dimensions of the half-complex data are the same as those of the real, only the last dimension is changed to (d/2+1). Of course this way you get the size of the complex array which still has to be doubled to get the size of the interlaced double array. See FFTW documentation on 'Array Dimensions for Real Multi-dimensional Transforms' for a more complete explanation on array dimensions.

We represent a complex array of length N as a real (double) array of length 2*N, where the (2*i)th element (of the real array) corresponds to the real part of the ith element (of the complex array) and the (2*i+1)th element (of the real array) corresponds to the imaginary part of the ith element (of the complex array).

For more information see the FFTW documentation. The FFTW library is work of MIT. The jfftw package is work of Daniel Darabos (cyhawk@sch.bme.hu). Both have GPL licenses.


Field Summary
 
Fields inherited from interface jfftw.Plan
BACKWARD, COMPLEX_TO_REAL, ESTIMATE, FORWARD, IN_PLACE, MEASURE, READONLY, REAL_TO_COMPLEX, USE_WISDOM
 
Constructor Summary
Plan(int[] dim)
          Constructs a real-to-complex (see REAL_TO_COMPLEX) Plan for the given dimensions dim based on estimations (see ESTIMATE).
Plan(int[] dim, int dir)
          Constructs a Plan for the given dimensions dim and direction dir based on estimations (see ESTIMATE).
Plan(int[] dim, int dir, int flags)
          Constructs a Plan for the given dimensions dim, direction dir and initialization flags.
Plan(int width, int height, int dir)
          Constructs a Plan for the given width and height (two dimensional) and direction dir based on estimations (see ESTIMATE).
Plan(int width, int height, int depth, int dir)
          Constructs a Plan for the given width, height and depth (three dimensional) and direction dir based on estimations (see ESTIMATE).
 
Method Summary
protected  void finalize()
          Destroys the rfftwnd_plan structure.
 double[] transform(double[] in)
          Calculates the Fourier transform of in.
 void transform(int howmany, double[] in, int istride, int idist, double[] out, int ostride, int odist)
          Calculates multiple Fourier transforms.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Plan

public Plan(int[] dim,
            int dir,
            int flags)
Constructs a Plan for the given dimensions dim, direction dir and initialization flags.

Parameters:
dim - Array of dimensions. They are expected to be in the order described in the FFTW documentation (row-major, or C-style).
dir - One of Plan.REAL_TO_COMPLEX and Plan.COMPLEX_TO_REAL.
flags - One of Plan.ESTIMATE (default) and Plan.MEASURE optionally OR'ed with Plan.USE_WISDOM, Plan.IN_PLACE and Plan.READONLY. Any other flag constants from fftw.h might be working, but jfftw has not been tested with them.
Throws:
java.lang.RuntimeException - if the double type of Java is not of the same size as fftw_real. (If this is the case, the library will need to be modified and recompiled. If FFTW was compiled with FFTW_ENABLE_FLOAT all double types should be changed to float in the Java and native source -- or recompile FFTW without FFTW_ENABLE_FLOAT.)

Plan

public Plan(int[] dim,
            int dir)
Constructs a Plan for the given dimensions dim and direction dir based on estimations (see ESTIMATE). Same as Plan( dim, dir, Plan.ESTIMATE ).

Parameters:
dir - One of Plan.REAL_TO_COMPLEX and Plan.COMPLEX_TO_REAL.
Throws:
java.lang.RuntimeException - if the double type of Java is not of the same size as fftw_real. (If this is the case, the library will need to be modified and recompiled. If FFTW was compiled with FFTW_ENABLE_FLOAT all double types should be changed to float in the Java and native source -- or recompile FFTW without FFTW_ENABLE_FLOAT.)

Plan

public Plan(int[] dim)
Constructs a real-to-complex (see REAL_TO_COMPLEX) Plan for the given dimensions dim based on estimations (see ESTIMATE). Same as Plan( dim, Plan.REAL_TO_COMPLEX, Plan.ESTIMATE ).

Throws:
java.lang.RuntimeException - if the double type of Java is not of the same size as fftw_real. (If this is the case, the library will need to be modified and recompiled. If FFTW was compiled with FFTW_ENABLE_FLOAT all double types should be changed to float in the Java and native source -- or recompile FFTW without FFTW_ENABLE_FLOAT.)

Plan

public Plan(int width,
            int height,
            int dir)
Constructs a Plan for the given width and height (two dimensional) and direction dir based on estimations (see ESTIMATE).

Parameters:
dir - One of Plan.REAL_TO_COMPLEX and Plan.COMPLEX_TO_REAL.
Throws:
java.lang.RuntimeException - if the double type of Java is not of the same size as fftw_real. (If this is the case, the library will need to be modified and recompiled. If FFTW was compiled with FFTW_ENABLE_FLOAT all double types should be changed to float in the Java and native source -- or recompile FFTW without FFTW_ENABLE_FLOAT.)

Plan

public Plan(int width,
            int height,
            int depth,
            int dir)
Constructs a Plan for the given width, height and depth (three dimensional) and direction dir based on estimations (see ESTIMATE).

Parameters:
dir - One of Plan.REAL_TO_COMPLEX and Plan.COMPLEX_TO_REAL.
Throws:
java.lang.RuntimeException - if the double type of Java is not of the same size as fftw_real. (If this is the case, the library will need to be modified and recompiled. If FFTW was compiled with FFTW_ENABLE_FLOAT all double types should be changed to float in the Java and native source -- or recompile FFTW without FFTW_ENABLE_FLOAT.)
Method Detail

finalize

protected void finalize()
Destroys the rfftwnd_plan structure.

Overrides:
finalize in class java.lang.Object

transform

public double[] transform(double[] in)
Calculates the Fourier transform of in.

(See FFTW documentation for details. The functions behind it are rfftwnd_one_real_to_complex and rfftw_one_complex_to_real.)

Specified by:
transform in interface Plan
Throws:
java.lang.IndexOutOfBoundsException - if in is not of the size that was passed to the constructor (or not double the size in case of complex-to-real transforms).

transform

public void transform(int howmany,
                      double[] in,
                      int istride,
                      int idist,
                      double[] out,
                      int ostride,
                      int odist)
Calculates multiple Fourier transforms.

(See FFTW documentation for details. The function behind it is rfftwnd, the arguments are mapped to rfftwnd's arguments of the same name.)

Specified by:
transform in interface Plan
Throws:
java.lang.IndexOutOfBoundsException - if in or out are not of proper size.