Changeset 314
- Timestamp:
- Mar 29, 2004, 7:40:01 PM (22 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
archive/pslib/include/psFFT.h (modified) (2 diffs)
-
doc/pslib/psLibSDRS.tex (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/pslib/include/psFFT.h
r257 r314 1 1 #if !defined(PS_FFT_H) 2 2 #define PS_FFT_H 3 4 #include <fftw3.h> 3 5 4 6 /** \file psFFT.h … … 12 14 */ 13 15 14 /** Return Fourier Transform of an array */ 15 psComplexArray * 16 psRealFFT(psComplexArray *restrict out, //!< Output array to be returned; may be NULL 17 const psFloatArray *restrict myArray //!< Input array 16 /** Details on FFT implementation (private). Example shown is for FFTW */ 17 typedef struct { 18 fftw_plan plan; //!< FFTW plan on how to do the FFT 19 char *filename; //!< File name for FFTW plan 20 } p_psFFTDetails; 21 22 /** Fast Fourier Transform */ 23 typedef struct { 24 p_psFFTDetails *details; //!< Details on FFT implementation (private) 25 int nx, ny; //!< Size in x and y 26 float **real; //!< Data in real space 27 void *fourier; //!< Data in fourier space; implementation dependent 28 } psFFT; 29 30 /** Constructor */ 31 psFFT * 32 psFFTAlloc(psImage *image //!< Image to transform 33 ); 34 35 /** Constructor for 1D case */ 36 psFFT * 37 psFFTAlloc1D(const psFloatArray *arr //!< Array to transform 38 ); 39 40 /** Destructor. Returns the data in the real space as an image. */ 41 psImage * 42 psFFTFree(psImage *out, //!< Image to write the data to, or NULL 43 psFFT *restrict fft //!< FFT to destroy 18 44 ); 19 45 20 /** Return [inverse?] Fourier Transform of a complex array. May NOT be done in-place (restrict-ed) */ 21 psComplexArray * 22 psComplexFFT(psComplexArray *restrict out, //!< Output array to be returned; may be NULL 23 const psComplexArray *restrict myArray, //!< Input array 24 int sign //!< +1 or -1 to indicate direction of FT 25 ); 46 /** Forward FFT: from real to fourier space */ 47 psFFT * 48 psFFTForwardTransform(psFFT *fft //!< FFT to apply (input and output) 49 ); 26 50 27 /** Return Power spectrum of a array */ 28 psFloatArray * 29 psPowerSpec(psFloatArray *restrict out, //!< Output array to be returned 30 const psFloatArray *restrict myArray //!< Input array 51 /** Reverse FFT: from fourier to real space */ 52 psFFT * 53 psFFTReverseTransform(psFFT *fft //!< FFT to apply (input and output) 54 ); 55 56 /** Apply filter function in fourier space */ 57 psFFT * 58 psFFTFilter(psFFT *fft, //!< FFT to use (input and output) 59 float (*filterFunc)(int kx, int ky) //!< External filter function 31 60 ); 61 62 /** Apply complex filter function */ 63 psFFT * 64 psFFTFilterComplex(psFFT *fft, //!< FFT to use (input and output) 65 float (*realFilterFunc)(int kx, int ky), //!< External filter function, real part 66 float (*imagFilterFunc)(int kx, int ky) //!< External filter function, imaginary part 67 ); 68 69 /** Calculate cross-correlation function */ 70 psFFT * 71 psFFTCrossCorrelate(psFFT *out //!< Output FFT (or NULL) 72 const psFFT *fft1, const psFFT *fft2 //!< FFTs to use in cross-correlation 73 ); 74 75 /** Calculate power spectrum */ 76 psFFT * 77 psFFTPowerSpec(psFFT *fft //!< FFT to use (input and output) 78 ); 79 80 /** Multiply two Fourier transforms, as for convolution */ 81 psFFT * 82 psFFTMultiplyFT(psFFT *out, //!< Output FFT (or NULL) 83 const psFFT *fft1, const psFFT *fft2 //!< FFTs to multiply 84 ); 85 86 /* Convert the real data in the FFT struct to an image again */ 87 psImage * 88 psFFTGetImage(psImage *out, //!< Image to write to (or NULL) 89 const psFFT *fft //!< FFT to get image from 90 ); 91 92 /** Convert the Fourier transform data in the FFT struct to an image of complex numbers */ 93 psImage * 94 psFFTGetFT(psImage *out, //!< Image to write to (or NULL) 95 const psFFT *fft //!< FFT to get Fourier transform from 96 ); 32 97 33 98 /* \} */ // End of MathGroup Functions 34 99 35 100 #endif 101 102 -
trunk/doc/pslib/psLibSDRS.tex
r313 r314 1 %%% $Id: psLibSDRS.tex,v 1.1 3 2004-03-29 22:13:13price Exp $1 %%% $Id: psLibSDRS.tex,v 1.14 2004-03-30 05:40:01 price Exp $ 2 2 \documentclass[panstarrs]{panstarrs} 3 3 %\documentclass[panstarrs]{panstarrs} … … 1437 1437 1438 1438 We require the ability to calculate the (fast) fourier transforms of 1439 both floating-point and complex floating-point type arrays, as well as 1440 the power spectrum. The APIs are: 1441 1442 \begin{verbatim} 1443 /** Return Fourier Transform of an array */ 1444 psComplexArray * 1445 psRealFFT(psComplexArray *restrict out, //!< Output array to be returned; may be NULL 1446 const psFloatArray *restrict myArray //!< Input array 1447 ); 1448 \end{verbatim} 1449 1450 \begin{verbatim} 1451 /** Return [inverse?] Fourier Transform of a complex array. May NOT be done in-place (restrict-ed) */ 1452 psComplexArray * 1453 psComplexFFT(psComplexArray *restrict out, //!< Output array to be returned; may be NULL 1454 const psComplexArray *restrict myArray, //!< Input array 1455 int sign //!< +1 or -1 to indicate direction of FT 1456 ); 1457 \end{verbatim} 1458 1459 \begin{verbatim} 1460 /** Return Power spectrum of a array */ 1461 psFloatArray * 1462 psPowerSpec(psFloatArray *restrict out, //!< Output array to be returned 1463 const psFloatArray *restrict myArray //!< Input array 1464 ); 1439 floating-point two-dimensional arrays (including one-dimensional 1440 arrays as a limiting case), and use these to perform filtering, and 1441 calculate the power spectrum and cross-correlation. We expect that 1442 these will be implemented through wrapping an external library. We 1443 define a FFT type: 1444 1445 \begin{verbatim} 1446 /** Fast Fourier Transform */ 1447 typedef struct { 1448 p_psFFTDetails *details; //!< Details on FFT implementation (private) 1449 int nx, ny; //!< Size in x and y 1450 float **real; //!< Data in real space 1451 void *fourier; //!< Data in fourier space; implementation dependent 1452 } psFFT; 1453 \end{verbatim} 1454 1455 The \code{p_psFFTDetails *details} entry allows us to wrap the 1456 external library in the event that it carries information around from 1457 one transform to the next (as is the case for FFTW). The intent is 1458 that every function that employs a FFT will act on a \code{psFFT}. A 1459 user will create a \code{psFFT} by stuffing it with the real data, 1460 perform operations in Fourier space using the \code{psFFT}, and then 1461 extract the output as an image when done. 1462 1463 We specify two constructors --- one for use with images, and the other 1464 for use with a one-dimensional array. The destructor returns an image 1465 that includes the real space data. 1466 1467 \begin{verbatim} 1468 /** Constructor */ 1469 psFFT * 1470 psFFTAlloc(psImage *image //!< Image to transform 1471 ); 1472 1473 /** Constructor for 1D case */ 1474 psFFT * 1475 psFFTAlloc1D(const psFloatArray *arr //!< Array to transform 1476 ); 1477 1478 /** Destructor. Returns the data in the real space as an image. */ 1479 psImage * 1480 psFFTFree(psImage *out, //!< Image to write the data to, or NULL 1481 psFFT *restrict fft //!< FFT to destroy 1482 ); 1483 \end{verbatim} 1484 1485 The forward and reverse Fourier transforms may be calculated: 1486 1487 \begin{verbatim} 1488 /** Forward FFT: from real to fourier space */ 1489 psFFT * 1490 psFFTForwardTransform(psFFT *fft //!< FFT to apply 1491 ); 1492 1493 /** Reverse FFT: from fourier to real space */ 1494 psFFT * 1495 psFFTReverseTransform(psFFT *fft //!< FFT to apply 1496 ); 1497 \end{verbatim} 1498 1499 The data in Fourier space may be filtered using functions that return 1500 a multiplicative factor for a given position in Fourier space: 1501 1502 \begin{verbatim} 1503 /** Apply filter function in fourier space */ 1504 psFFT * 1505 psFFTFilter(psFFT *fft, //!< FFT to use (input and output) 1506 float (*filterFunc)(int kx, int ky) //!< External filter function 1507 ); 1508 1509 /** Apply complex filter function */ 1510 psFFT * 1511 psFFTFilterComplex(psFFT *fft, //!< FFT to use (input and output) 1512 float (*realFilterFunc)(int kx, int ky), //!< External filter function, real part 1513 float (*imagFilterFunc)(int kx, int ky) //!< External filter function, imaginary part 1514 ); 1515 \end{verbatim} 1516 1517 The cross-correlation function may be calculated from two Fourier transforms, 1518 and returns a new \code{psFFT}: 1519 1520 \begin{verbatim} 1521 /** Calculate cross-correlation function */ 1522 psFFT * 1523 psFFTCrossCorrelate(psFFT *out //!< Output FFT (or NULL) 1524 psFFT *fft1, psFFT *fft2 //!< FFTs to use in cross-correlation 1525 ); 1526 \end{verbatim} 1527 1528 The power spectrum is calculated from the Fourier transform: 1529 1530 \begin{verbatim} 1531 /** Calculate power spectrum */ 1532 psFFT * 1533 psFFTPowerSpec(psFFT *fft //!< FFT to use (input and output) 1534 ); 1535 \end{verbatim} 1536 1537 In convolution, two Fourier transforms are multiplied. 1538 1539 \begin{verbatim} 1540 /** Multiply two Fourier transforms, as for convolution */ 1541 psFFT * 1542 psFFTMultiplyFT(psFFT *out, //!< Output FFT (or NULL) 1543 const psFFT *fft1, const psFFT *fft2 //!< FFTs to multiply 1544 ); 1545 \end{verbatim} 1546 1547 And finally, the user may extract both the real data and the complex 1548 Fourier space data (without needing to destroy the \code{psFFT}). 1549 1550 \begin{verbatim} 1551 /* Convert the real data in the FFT struct to an image again */ 1552 psImage * 1553 psFFTGetImage(psImage *out, //!< Image to write to (or NULL) 1554 const psFFT *fft //!< FFT to get image from 1555 ); 1556 1557 /** Convert the Fourier transform data in the FFT struct to an image of complex numbers */ 1558 psImage * 1559 psFFTGetFT(psImage *out, //!< Image to write to (or NULL) 1560 const psFFT *fft //!< FFT to get Fourier transform from 1561 ); 1465 1562 \end{verbatim} 1466 1563
Note:
See TracChangeset
for help on using the changeset viewer.
