jfftw
Class FFTW

java.lang.Object
  extended by jfftw.FFTW
Direct Known Subclasses:
FFTWComplex, FFTWEngine, FFTWReal

public class FFTW
extends Object

Basic class for Java access to the fftw3 library to take Fourier Transforms or one-dimensional, two-dimensional or three-dimensional data held in double[] arrays.

This class set package defaults, manages the wisdom information and loads the sharable library. Actual numerical use of this package is via the extending classes FFTWReal and FFTWComplex

Note this class is not declared abstract since direct instances of this class can be used to manipulate the static library parameters.

If you are a novice used, dont start here, look at the DataArray, at its exteding classes. These allow you to take simple FFTs without understanding the complicated bits!


Field Summary
static int BACKWARD
          Flag for backward (on inverse) FFT
protected static PrintStream errorStream
          PrintStream for warning and error messages.
static int ESTIMATE
          Flag for quick and dirty plan search (fast, but not optimal)
static int EXHAUSTIVE
          Flag for exhaustive plan search (very slow)
static int FORWARD
          Flag for forward FFT
static int FOURIER
          Flag for Fourier space
static boolean loaded
          Boolean to determine in the sharable library has been loaded successfully.
static int PATIENT
          Flag for patient plan search (medium slow)
protected  int planFlag
          Integer to set to the current plan in use by the package.
static int REAL
          Flag for Real space
static boolean throwLoadException
          Public static boolen to determine if an excepction in thrown if the native library is missing.
static String version
          Version flag
 
Constructor Summary
FFTW()
          Default constructor, do nothing but load the sharable library.
FFTW(boolean systemWisdom)
          Constructor with flag to optionally load the system wisdom file.
FFTW(FFTW fft)
          Constructor to form a new FFTW, being a copy of the specified one.
FFTW(String wisdomFileName)
          Constructor to load specified wisdom file specified by name.
 
Method Summary
 void addPlanFlag(int addition)
          Method to add to the plan flag
 void clearWisdom()
          Void method to clear the wisdom information
 boolean exportWisdom(String fileName)
          Boolean method to export the current wisdom to a file.
 int getPlanFlag()
          Method to get the plan flag
 String getVersion()
          Method to get the version string
 String getWisdom()
          Method to get the wisdom information as a String
 boolean loadWisdom()
          Boolean method to load system wisdom file
 boolean loadWisdom(String fileName)
          Boolean method to load wisdom file from specified file by name.
 boolean loadWisdomFromString(String wisdom)
          Boolean method to load the wisdom froma local Java String
static String readWisdom(BufferedReader in)
          Static method to read a Wisdom file into a String from a BufferedReader
static String readWisdom(File file)
          Static method to read a Wisdom file into a String from a File
 void setErrorStream(PrintStream es)
          Method to reset the default errorStream for package.
 void setPlanFlag(int flag)
          Method to set the plan flag, default is ESTIMATE
 void setSystemWisdom(String fileName)
          Method to reset the system wisdom file location.
static boolean writeWisdom(String wisdom, File file)
          Static method to write wisdom String to a file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static final String version
Version flag

See Also:
Constant Field Values

REAL

public static final int REAL
Flag for Real space

See Also:
Constant Field Values

FOURIER

public static final int FOURIER
Flag for Fourier space

See Also:
Constant Field Values

FORWARD

public static final int FORWARD
Flag for forward FFT

See Also:
Constant Field Values

BACKWARD

public static final int BACKWARD
Flag for backward (on inverse) FFT

See Also:
Constant Field Values

EXHAUSTIVE

public static final int EXHAUSTIVE
Flag for exhaustive plan search (very slow)

See Also:
Constant Field Values

PATIENT

public static final int PATIENT
Flag for patient plan search (medium slow)

See Also:
Constant Field Values

ESTIMATE

public static final int ESTIMATE
Flag for quick and dirty plan search (fast, but not optimal)

Note: this is default for jttfw but NOT the normal FFTW default

See Also:
Constant Field Values

errorStream

protected static PrintStream errorStream
PrintStream for warning and error messages. Defaults to System.err.


planFlag

protected int planFlag
Integer to set to the current plan in use by the package. Defaults to FFTW.ESTIMATE.


throwLoadException

public static boolean throwLoadException
Public static boolen to determine if an excepction in thrown if the native library is missing. Setting this to false will allow the Java code to run but not any of the native library calls. Use this feature ONLY if you really understand what you are doing!


loaded

public static boolean loaded
Boolean to determine in the sharable library has been loaded successfully. (mainly used in testing).

Constructor Detail

FFTW

public FFTW()
Default constructor, do nothing but load the sharable library. The library is statically loaded so it will only load a single copy.


FFTW

public FFTW(FFTW fft)
Constructor to form a new FFTW, being a copy of the specified one. The PlanFlag is copied.

Parameters:
fft - the FFTW
Since:
1.1

FFTW

public FFTW(boolean systemWisdom)
Constructor with flag to optionally load the system wisdom file. If load fails there is a non-fatal warning.

Parameters:
systemWisdom - if true default system wisdom file

FFTW

public FFTW(String wisdomFileName)
Constructor to load specified wisdom file specified by name. If load fails there is a non-fatal warning.

Parameters:
wisdomFileName - the name of the wisdom file
Method Detail

getVersion

public String getVersion()
Method to get the version string

Returns:
String

setPlanFlag

public void setPlanFlag(int flag)
Method to set the plan flag, default is ESTIMATE

Since most jfftw call involve a one-off use of plans setting this of other options should be done with extreme care and understing of the implications.

Parameters:
flag - the plan flag

addPlanFlag

public void addPlanFlag(int addition)
Method to add to the plan flag

Parameters:
addition - the addition to add

getPlanFlag

public int getPlanFlag()
Method to get the plan flag

Returns:
int the plan flag

setErrorStream

public void setErrorStream(PrintStream es)
Method to reset the default errorStream for package. The default is System.err

Parameters:
es - the error PrintStream
Since:
1.2

setSystemWisdom

public void setSystemWisdom(String fileName)
Method to reset the system wisdom file location. Note this does not load the file.

Parameters:
fileName - name of default wisdom file

loadWisdom

public boolean loadWisdom()
Boolean method to load system wisdom file

Returns:
boolean true for success, false for failure

loadWisdom

public boolean loadWisdom(String fileName)
Boolean method to load wisdom file from specified file by name. Note this used the FFTW library direct "C" io and not via Java io interface. It thus can only real a file from the current local machine.

Parameters:
fileName - the wisdom file name
Returns:
boolean true for success, false for failure

loadWisdomFromString

public boolean loadWisdomFromString(String wisdom)
Boolean method to load the wisdom froma local Java String


clearWisdom

public void clearWisdom()
Void method to clear the wisdom information


exportWisdom

public boolean exportWisdom(String fileName)
Boolean method to export the current wisdom to a file. This uses the FFTW native library call so is via "C" io rather than the Java io interface. It can thus ONLY be written to a local file.

Parameters:
fileName - the output file name in a String.
Returns:
boolean true if successful, else false

getWisdom

public String getWisdom()
Method to get the wisdom information as a String

Returns:
String returns the FFTW wisdom entry in a formatted String.

readWisdom

public static String readWisdom(BufferedReader in)
Static method to read a Wisdom file into a String from a BufferedReader

Parameters:
in - the input reader.
Returns:
String the wisdom as a String

readWisdom

public static String readWisdom(File file)
Static method to read a Wisdom file into a String from a File

Parameters:
file - the wisdom file
Returns:
String the wisdom as a String

writeWisdom

public static boolean writeWisdom(String wisdom,
                                  File file)
Static method to write wisdom String to a file

Parameters:
wisdom - the wisdom String
file - the output file