|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjfftw.DataArray
public abstract class DataArray
Abstract Class type to manipulate hold data for FFTW methods.
Internally the data is held as an interleaved
double[]
array as used by the FFTW library
by this class take care of most of the
array indexing and access problems via its supplied methods.
This is however at the cost of some efficiency.
Users wanting to take simple one-off FFT should use this
classes, and the extending classes RealDataArray
and ComplexDataArray
rather than the lower level FFTW
classes.
Field Summary | |
---|---|
protected int |
conversionFlag
Flag for Complex to double conversion, initially defaults to Complex.MODULUS |
protected int |
currentWidth
Current width span of data, this will alter under FFTs of real data. |
protected double[] |
dataBuffer
Internal data buffer holding the data in double[] array |
protected int |
depth
Depth or third size of the data array |
protected PrintStream |
errorStream
PrintStream on which errors are printed. |
protected static FFTW |
fftw
Static FFTW object used for taking the ffts, this is loaded statically once and pass shared to all instances. |
protected int |
height
Height or secondary size of data array. |
protected int |
space
Space flag initially defaults to FFTW.REAL |
protected int |
width
Width or primary size of the data array. |
Constructor Summary | |
---|---|
DataArray()
|
Method Summary | |
---|---|
void |
add(DataArray d)
Method to add a specified DataArray to the current DataArray, both must be the same size. |
void |
add(int i,
Complex c)
Method to add a Complex to an element in
one-dimensions. |
abstract void |
add(int i,
double a)
Method to add a real double to an element in
one-dimensions. |
abstract void |
add(int i,
double a,
double b)
Method to add a complex to an element in one-dimensions. |
void |
add(int i,
int j,
Complex c)
Method to add a Complex to an element in
two-dimensions. |
void |
add(int i,
int j,
double a)
Method to add a real double to an element in
two-dimensions. |
void |
add(int i,
int j,
int k,
Complex c)
Method to add a Complex to an element in
three-dimensions. |
void |
add(int i,
int j,
int k,
double a)
Method to add a real double to an element in
three-dimensions. |
void |
centreFourier()
Method to form centred Fourier using applying checker pattern to shift DC the centre of the array. |
abstract void |
checker()
Abstract method to apply a checker pattern to shift the centre |
void |
clear()
Method to clear the databuffer by setting all elements to zero. |
void |
conjugate()
Method to take conjugate of the whole DataBuffer. |
abstract void |
conjugate(int i)
Method to form the Complex conjugate of an element in one-dimensions. |
void |
conjugate(int i,
int j)
Method to form the Complex conjugate of an element in two-dimensions. |
void |
conjugate(int i,
int j,
int k)
Method to form the Complex conjugate of an element in three-dimensions. |
abstract void |
fourier()
Abstract method to form the un-shifted Fourier transform |
abstract Complex |
getComplex(int i)
Method to get the value of Complex element in one-dimensions case. |
Complex |
getComplex(int i,
int j)
Method to get the value of a Complex element in two-dimensions. |
Complex |
getComplex(int i,
int j,
int k)
Method to get the value of a Complex element in three-dimensions |
int |
getConversion()
Method to get the current Complex to double conversion flag. |
int |
getCurrentWidth()
Method to get the current width data width. |
double[] |
getDataBuffer()
Method to get the current internal dataBuffer as a double[]. |
int |
getDepth()
Method to get the data depth (tertiary direction). |
abstract double |
getDouble(int i)
Method to get value of double element in one-dimension. |
double |
getDouble(int i,
int j)
Method to get value of double element in two-dimensions. |
double |
getDouble(int i,
int j,
int k)
Method to get value of double element in three-dimensions |
FFTW |
getFFTW()
Method to return the underlying FFTW class. |
int |
getHeight()
Method to get the data height (secondary direction). |
boolean |
getNormalisation()
Method to get the normalisation flag. |
RealDataArray |
getRealDataArray()
Get the current DataArray are a RealDataArray using the internal conversion flag |
RealDataArray |
getRealDataArray(int conversion)
Get the current DataArray as a RealData array using the specified conversion flag. |
int |
getSpace()
Method to get the current space description flag. |
String |
getType()
Method to get the type (actually the class name) as a String. |
int |
getWidth()
Method to get the data width (primary direction). |
boolean |
isComplex()
Method to determine if the current data is Complex. |
int |
length()
Method to get the length of the internal double[] dataBuffer |
void |
mult(Complex c)
Method to multiply the whole DataArray by a Complex. |
void |
mult(DataArray d)
Method to multiply the current DataArray by a specified DataArray which must be of the same size, the result overwriting the contents of the current DataArray. |
void |
mult(double a)
Method to muliply the whole DataArray by a scalar |
void |
mult(double a,
double b)
Method to multiply the whole DataArray by a complex specifed as two doubles. |
void |
mult(int i,
Complex c)
Method to multiply an element by a Complex in
one-dimension. |
abstract void |
mult(int i,
double a)
Method to multiple an element by a double in
one-dimensions. |
abstract void |
mult(int i,
double a,
double b)
Method to multiply an element by a Complex in one-dimension. |
void |
mult(int i,
int j,
Complex c)
Method to multiply an element by a Complex
in two-dimension. |
void |
mult(int i,
int j,
double a)
Method to multiple an element by a double in
two-dimensions. |
void |
mult(int i,
int j,
int k,
Complex c)
Method to multiply an element by a Complex in
three-dimension. |
void |
mult(int i,
int j,
int k,
double a)
Method to multiple an element by a double in
three-dimensions. |
void |
multConjugate(DataArray d)
Method to multiply the current DataArray by the Complex Conjugate of specified DataArray which must be of the same size the result overwriting the contents of the current DataArray. |
protected void |
normaliseDB()
Protected method to normalise the data buffer |
RealDataArray |
powerSpectrum(boolean logPower)
Method to get the PowerSpectrum as a RealDataArray In data is in real space, then it is automatically Fourier transformed using centreFourier . |
void |
setComplex(int i,
Complex c)
Method to set an element with a Complex in one
dimensions. |
abstract void |
setComplex(int i,
double a,
double b)
Method to set an element with a complex specified as two doubles in one-dimension. |
void |
setComplex(int i,
int j,
Complex c)
Method to set an element with a Complex in two-dimensions. |
void |
setComplex(int i,
int j,
double a,
double b)
Method to set an element with a complex in two-dimensions |
void |
setComplex(int i,
int j,
int k,
Complex c)
Method to set an element with a Complex in
three-dimensions. |
void |
setComplex(int i,
int j,
int k,
double a,
double b)
Method to set an element with a Complex point in three-dimension. |
void |
setConversion(int flag)
Method to set default conversion from Complex to double. |
void |
setDataBuffer(double[] db)
Method to set the internal dataBuffer to specified double[] array. |
void |
setDimensions(int w,
int h,
int d)
Method to set the sizes, not normally called directly since there is no interval sanity checking. |
abstract void |
setDouble(int i,
double value)
Method to set element with a double in one-dimension. |
void |
setDouble(int i,
int j,
double value)
Method to set element with a double in two-dimensions. |
void |
setDouble(int i,
int j,
int k,
double value)
Method to set element with a double in three-dimensions. |
void |
setNormalisation(boolean b)
Method to control auto normalisation on inverse flag, which is by default set to true . |
void |
setSpace(int s)
Method to set the space. |
boolean |
sizeMatch(DataArray d)
Method to test if specified DataArray is of the same size at the current DataArray |
String |
toString()
Default toString method to report information about DataArray . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static FFTW fftw
protected PrintStream errorStream
System.err
protected double[] dataBuffer
protected int conversionFlag
Complex.MODULUS
protected int width
protected int currentWidth
protected int height
protected int depth
protected int space
FFTW.REAL
Constructor Detail |
---|
public DataArray()
Method Detail |
---|
public int length()
double[]
dataBuffer
int
length of dataBufferpublic String getType()
String
typepublic double[] getDataBuffer()
Take great care using this with RealDataArray
since the internal dataBuffer is re-located by its
fourier()
method.
double[]
the internal dataBufferRealDataArray
,
fourier()
public void setDataBuffer(double[] db)
double[]
array.
Warning there is no internal sanity checking here. Really check you know what you are doing before using this. If you are programming at this level your really should be using the direct FFTW classes!
db
- the dataBufferpublic void setSpace(int s)
FFTW.REAL
.
If using RealDataArray
class take extreme care
using this; remember it does not change the data format, just the
space designation flag.
s
- FFTW.REAL
or FFTW.FOURIER
public void setDimensions(int w, int h, int d)
Not normally called by users, use with extreme care. If sizes do not match the data buffer you will get rubbish or will crash your JRE, you have been warned!
w
- the widthh
- the heightd
- the depthpublic int getSpace()
int
Space code, either FFTW.REAL
or FFTW.FOURIER
public int getWidth()
int
the widthgetCurrentWidth()
public int getCurrentWidth()
RealDataArray
objects.
int
the current width.getWidth()
public int getHeight()
int
the heightpublic int getDepth()
int
the depthpublic int getConversion()
int
conversion flagpublic void setConversion(int flag)
Complex.MODULUS
flag
- the conversion flag.public void setNormalisation(boolean b)
true
.
b
- the flagpublic boolean getNormalisation()
boolean
the normalisation flagpublic boolean isComplex()
RealDataArray
in real space.
boolean
- true if data is Complexpublic FFTW getFFTW()
Warning the FFTW class is loaded as static so changes to this will affect all instances.
public String toString()
DataArray
. This
includes type, width, height, depth and current space.
toString
in class Object
String
information String.public abstract double getDouble(int i)
i
- the element indexpublic double getDouble(int i, int j)
i
- primary indexj
- secondary index
ArrayIndexOutOfBoundsException
- exception if
out of data bounds.public double getDouble(int i, int j, int k)
i
- primary indexj
- secondary indexk
- third index
ArrayIndexOutOfBoundsException
- exception if
out of data bounds.public abstract Complex getComplex(int i)
i
- the element indexpublic Complex getComplex(int i, int j)
i
- primary indexj
- secondary index
ArrayIndexOutOfBoundsException
- exception if
out of data bounds.public Complex getComplex(int i, int j, int k)
i
- primary indexj
- secondary indexk
- third index
ArrayIndexOutOfBoundsException
- exception if
out of data bounds.public void clear()
public abstract void setDouble(int i, double value)
i
- the element indexvalue
- the valuepublic void setDouble(int i, int j, double value)
i
- primary indexj
- secondary indexvalue
- the value
ArrayIndexOutOfBoundsException
- exception if
out of data bounds.public void setDouble(int i, int j, int k, double value)
i
- primary indexj
- secondary indexk
- third indexvalue
- the value
ArrayIndexOutOfBoundsException
- exception if
out of data bounds.public abstract void setComplex(int i, double a, double b)
i
- the element indexa
- the real partb
- the imaginary partpublic void setComplex(int i, Complex c)
Complex
in one
dimensions.
i
- the elementc
- the Complex valuepublic void setComplex(int i, int j, double a, double b)
i
- primary indexj
- secondary indexa
- the real partb
- the imaginary part
ArrayIndexOutOfBoundsException
- exception if
out of data bounds.public void setComplex(int i, int j, Complex c)
Complex
in two-dimensions.
i
- primary indexj
- secondary indexc
- the Complex value
ArrayIndexOutOfBoundsException
- exception if
out of data bounds.public void setComplex(int i, int j, int k, double a, double b)
i
- primary indexj
- secondary indexk
- third indexa
- the real partb
- the imaginary part
ArrayIndexOutOfBoundsException
- exception if
out of data bounds.public void setComplex(int i, int j, int k, Complex c)
Complex
in
three-dimensions.
i
- primary indexj
- secondary indexk
- third indexc
- the Complex value
ArrayIndexOutOfBoundsException
- exception if
out of data bounds.public abstract void add(int i, double a)
double
to an element in
one-dimensions.
i
- the element indexa
- to be addedpublic abstract void mult(int i, double a)
double
in
one-dimensions.
i
- the element indexa
- the multiplierpublic void add(int i, int j, double a)
double
to an element in
two-dimensions.
i
- the primary indexj
- the secondary indexa
- to be added
ArrayIndexOutOfBoundsException
- exception if
out of data bounds.public void mult(int i, int j, double a)
double
in
two-dimensions.
i
- the primary indexj
- the secondary indexa
- the multiplier
ArrayIndexOutOfBoundsException
- exception if
out of data bounds.public void add(int i, int j, int k, double a)
double
to an element in
three-dimensions.
i
- the primary indexj
- the secondary indexk
- the third indexa
- to be added
ArrayIndexOutOfBoundsException
- exception if
out of data bounds.public void mult(int i, int j, int k, double a)
double
in
three-dimensions.
i
- the primary indexj
- the secondary indexk
- the third indexa
- the multiplier
ArrayIndexOutOfBoundsException
- exception if
out of data bounds.public abstract void add(int i, double a, double b)
i
- the element indexa
- the real partb
- the imaginary partspublic abstract void mult(int i, double a, double b)
i
- the element indexa
- the real partb
- the imaginary partspublic void add(int i, Complex c)
Complex
to an element in
one-dimensions.
i
- the element indexc
- to be addedpublic void mult(int i, Complex c)
Complex
in
one-dimension.
i
- the element indexc
- the multiplierpublic void add(int i, int j, Complex c)
Complex
to an element in
two-dimensions.
i
- the primary indexj
- the secondary indexc
- to be addedpublic void mult(int i, int j, Complex c)
Complex
in two-dimension.
i
- the primary indexj
- the secondary indexc
- the multiplierpublic void add(int i, int j, int k, Complex c)
Complex
to an element in
three-dimensions.
i
- the primary indexj
- the secondary indexk
- the third indexc
- to be addedpublic void mult(int i, int j, int k, Complex c)
Complex
in
three-dimension.
i
- the primary indexj
- the secondary indexk
- the third indexc
- the multiplierpublic void mult(double a)
a
- the scalarpublic void mult(double a, double b)
a
- the real partb
- the imaginary.public void mult(Complex c)
c
- the Complex multiplier.public abstract void conjugate(int i)
i
- the element indexpublic void conjugate(int i, int j)
i
- first element indexj
- second element index
ArrayIndexOutOfBoundsException
- exception if
out of data bounds.public void conjugate(int i, int j, int k)
i
- first element indexj
- second element indexk
- the third index
ArrayIndexOutOfBoundsException
- exception if
out of data bounds.public void conjugate()
public abstract void fourier()
public abstract void checker()
public void centreFourier()
This will only work for even dimensions, if called with data
of odd size, an error message will be printed and the
normal fourier()
will be taken.
public RealDataArray getRealDataArray(int conversion)
If the current DataArray is RealDataArray
in real space
then the current DataArray is returned, else a new ReadDataArray
of the correct dimensions is returned.
conversion
- the conversion flag
RealDataArray
the converted Real arraypublic RealDataArray getRealDataArray()
RealDataArray
the converted Real arraypublic RealDataArray powerSpectrum(boolean logPower)
centreFourier
.
After this call the current DataArray
will be in Fourier space.
logPower
- if true the log power formed, else modulus squared used.
RealDataArray
the power spectrum.public boolean sizeMatch(DataArray d)
boolean
true if match, false otherwise.public void add(DataArray d)
This will work for all conbinations expect for current DataArray being Real and specifed DataArray being Complex.
Internally this uses direct array access so it much more efficient than loops with setter/getters.
d
- the DataArray to be added.public void mult(DataArray d)
This will work for all conbinations expect for current DataArray being Real and specifed DataArray being Complex.
Internal this uses uses direct array access so it much more efficient than loops with setter/getters.
d
- the DataArraypublic void multConjugate(DataArray d)
If the current or specifed DataArray(s) are real, then this method is identical
to mult(DataArray)
d
- the DataArraymult(DataArray)
protected void normaliseDB()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |