Java源码示例:edu.mines.jtk.dsp.FftComplex

示例1
public static void main(String[] args) {
  for (int niter=0; niter<5; ++niter) {
    for (int nfft=1; nfft<=720720;) {
      int nfftSmall = FftComplex.nfftSmall(nfft);
      int nfftFast = FftComplex.nfftFast(nfft);
      double timeSmall = time(nfftSmall);
      if (nfftFast==nfftSmall) {
        System.out.printf("nsmall=%d tsmall=%.14f\n",nfftSmall,timeSmall);
      } else {
        double timeFast = (nfftFast>nfftSmall)?time(nfftFast):timeSmall;
        System.out.printf("nsmall=%d tsmall=%.14f tfast=%.14f\n",
          nfftSmall,timeSmall,timeFast);
        if (timeSmall<timeFast)
          System.out.println("*** WARNING: tsmall<tfast! ***");
      }
      nfft = 1+nfftSmall;
    }
  }
}
 
示例2
public static FloatArray3D[] zeroPadImages(final FloatArray3D img1, final FloatArray3D img2)
{
	final int width = Math.max(img1.width, img2.width);
	final int height = Math.max(img1.height, img2.height);
	final int depth = Math.max(img1.depth, img2.depth);

	final int widthFFT = FftReal.nfftFast(width);
	final int heightFFT = FftComplex.nfftFast(height);
	final int depthFFT = FftComplex.nfftFast(depth);

	final FloatArray3D[] result = new FloatArray3D[2];

	result[0] = zeroPad(img1, widthFFT, heightFFT, depthFFT);
	img1.data = null;

	result[1] = zeroPad(img2, widthFFT, heightFFT, depthFFT);
	img2.data = null;

	return result;
}
 
示例3
public static FloatArray2D[] zeroPadImages(FloatArray2D img1, FloatArray2D img2)
{
	int width = Math.max(img1.width, img2.width);
	int height = Math.max(img1.height, img2.height);

	int widthFFT = FftReal.nfftFast(width);
	int heightFFT = FftComplex.nfftFast(height);

	FloatArray2D[] result = new FloatArray2D[2];

	result[0] = zeroPad(img1, widthFFT, heightFFT);
	img1.data = null;
	img1 = null;

	result[1] = zeroPad(img2, widthFFT, heightFFT);
	img2.data = null;
	img2 = null;

	return result;
}
 
示例4
public static FloatArray2D pffft2D(FloatArray2D values, boolean scale)
{
	int height = values.height;
	int width = values.width;
	int complexWidth = (width / 2 + 1) * 2;

	FloatArray2D result = new FloatArray2D(complexWidth, height);

	//do fft's in x direction
	float[] tempIn = new float[width];
	float[] tempOut;

	FftReal fft = new FftReal(width);

	for (int y = 0; y < height; y++)
	{
		tempOut = new float[complexWidth];

		for (int x = 0; x < width; x++)
			tempIn[x] = values.get(x, y);

		fft.realToComplex( -1, tempIn, tempOut);

		if (scale)
			fft.scale(width, tempOut);

		for (int x = 0; x < complexWidth; x++)
			result.set(tempOut[x], x, y);
	}

	// do fft's in y-direction on the complex numbers
	tempIn = new float[height * 2];

	FftComplex fftc = new FftComplex(height);

	for (int x = 0; x < complexWidth / 2; x++)
	{
		tempOut = new float[height * 2];

		for (int y = 0; y < height; y++)
		{
			tempIn[y * 2] = result.get(x * 2, y);
			tempIn[y * 2 + 1] = result.get(x * 2 + 1, y);
		}

		fftc.complexToComplex( -1, tempIn, tempOut);

		for (int y = 0; y < height; y++)
		{
			result.set(tempOut[y * 2], x * 2, y);
			result.set(tempOut[y * 2 + 1], x * 2 + 1, y);
		}
	}

	return result;
}
 
示例5
public static FloatArray2D pffftInv2D(FloatArray2D values, int nfft)
{
	int height = values.height;
	int width = nfft;
	int complexWidth = (width / 2 + 1) * 2;

	FloatArray2D result = new FloatArray2D(width, height);

	// do inverse fft's in y-direction on the complex numbers
	float[] tempIn = new float[height * 2];
	float[] tempOut;

	FftComplex fftc = new FftComplex(height);

	for (int x = 0; x < complexWidth / 2; x++)
	{
		tempOut = new float[height * 2];

		for (int y = 0; y < height; y++)
		{
			tempIn[y * 2] = values.get(x * 2, y);
			tempIn[y * 2 + 1] = values.get(x * 2 + 1, y);
		}

		fftc.complexToComplex(1, tempIn, tempOut);

		for (int y = 0; y < height; y++)
		{
			values.set(tempOut[y * 2], x * 2, y);
			values.set(tempOut[y * 2 + 1], x * 2 + 1, y);
		}
	}

	//do inverse fft's in x direction
	tempIn = new float[complexWidth];

	FftReal fft = new FftReal(width);

	for (int y = 0; y < height; y++)
	{
		tempOut = new float[width];

		for (int x = 0; x < complexWidth; x++)
			tempIn[x] = values.get(x, y);

		fft.complexToReal(1, tempIn, tempOut);

		fft.scale(width, tempOut);

		for (int x = 0; x < width; x++)
			result.set(tempOut[x], x, y);
	}

	return result;
}