jnt.FFT.ComplexFloat2DFFT Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sspace-wordsi Show documentation
Show all versions of sspace-wordsi Show documentation
The S-Space Package is a collection of algorithms for building
Semantic Spaces as well as a highly-scalable library for designing new
distributional semantics algorithms. Distributional algorithms process text
corpora and represent the semantic for words as high dimensional feature
vectors. This package also includes matrices, vectors, and numerous
clustering algorithms. These approaches are known by many names, such as
word spaces, semantic spaces, or distributed semantics and rest upon the
Distributional Hypothesis: words that appear in similar contexts have
similar meanings.
The newest version!
package jnt.FFT;
/** Computes the FFT of 2 dimensional complex, single precision data.
* The data is stored in a 1-dimensional array in Row-Major order.
* The physical layout in the array data, of the mathematical data d[i,j] is as follows:
*
* Re(d[i,j]) = data[i*rowspan + 2*j]
* Im(d[i,j]) = data[i*rowspan + 2*j + 1]
*
* where rowspan
must be at least 2*ncols (it defaults to 2*ncols).
* The transformed data is returned in the original data array in
* wrap-around order along each dimension.
*
* @author Bruce R. Miller [email protected]
* @author Contribution of the National Institute of Standards and Technology,
* @author not subject to copyright.
*/
public class ComplexFloat2DFFT {
int nrows;
int ncols;
ComplexFloatFFT rowFFT, colFFT;
/** Create an FFT for transforming nrows*ncols points of Complex, double precision
* data. */
public ComplexFloat2DFFT(int nrows, int ncols) {
this.nrows = nrows;
this.ncols = ncols;
rowFFT = new ComplexFloatFFT_Mixed(ncols);
colFFT = (nrows == ncols ? rowFFT : new ComplexFloatFFT_Mixed(nrows));
}
protected void checkData(float data[], int rowspan){
if (rowspan < 2*ncols)
throw new IllegalArgumentException("The row span "+rowspan+
"is shorter than the row length "+2*ncols);
if (nrows*rowspan > data.length)
throw new IllegalArgumentException("The data array is too small for "+
nrows+"x"+rowspan+" data.length="+data.length);}
/** Compute the Fast Fourier Transform of data leaving the result in data.
* The array data must be dimensioned (at least) 2*nrows*ncols, consisting of
* alternating real and imaginary parts. */
public void transform(float data[]) {
transform(data,2*ncols); }
/** Compute the Fast Fourier Transform of data leaving the result in data.
* The array data must be dimensioned (at least) 2*nrows*ncols, consisting of
* alternating real and imaginary parts. */
public void transform(float data[], int rowspan) {
checkData(data,rowspan);
for(int i=0; iwraparound format */
public float[] toWraparoundOrder(float data[]){
return data; }
/** Return data in wraparound order.
* rowspan is used to traverse data; the new array is in
* packed (rowspan = 2*ncols) format.
* @see wraparound format */
public float[] toWraparoundOrder(float data[], int rowspan){
if (rowspan == 2*ncols) return data;
float newdata[] = new float[2*nrows*ncols];
for(int i=0; i