Changeset 2204 for trunk/psLib/src/fft
- Timestamp:
- Oct 26, 2004, 2:57:34 PM (22 years ago)
- Location:
- trunk/psLib/src/fft
- Files:
-
- 2 edited
-
psImageFFT.c (modified) (18 diffs)
-
psVectorFFT.c (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/fft/psImageFFT.c
r1983 r2204 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-10- 06 21:31:30$7 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-10-27 00:57:31 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 11 11 */ 12 12 #include <unistd.h> 13 #include <stdbool.h>14 13 #include <string.h> 15 14 #include <complex.h> … … 27 26 #define PS_FFTW_PLAN_RIGOR FFTW_ESTIMATE 28 27 29 static bool p_fftwWisdomImported = false;28 static psBool p_fftwWisdomImported = false; 30 29 31 30 psImage* psImageFFT(psImage* out, const psImage* in, psFftDirection direction) 32 31 { 33 unsigned intnumCols;34 unsigned intnumRows;32 psU32 numCols; 33 psU32 numRows; 35 34 psElemType type; 36 35 fftwf_plan plan; … … 77 76 78 77 // n.b. FFTW can perform a in-place transform at the same rate or faster than out-of-place. 79 intsign = ((direction & PS_FFT_FORWARD) != 0) ? FFTW_FORWARD : FFTW_BACKWARD;78 psS32 sign = ((direction & PS_FFT_FORWARD) != 0) ? FFTW_FORWARD : FFTW_BACKWARD; 80 79 out = psImageCopy(out, in, PS_TYPE_C32); 81 80 plan = fftwf_plan_dft_2d(numCols, numRows, … … 118 117 { 119 118 psElemType type; 120 unsigned intnumCols;121 unsigned intnumRows;119 psU32 numCols; 120 psU32 numRows; 122 121 123 122 if (in == NULL) { … … 140 139 141 140 out = psImageRecycle(out, numCols, numRows, PS_TYPE_F32); 142 for ( unsigned introw = 0; row < numRows; row++) {141 for (psU32 row = 0; row < numRows; row++) { 143 142 outRow = out->data.F32[row]; 144 143 inRow = in->data.C32[row]; 145 144 146 for ( unsigned intcol = 0; col < numCols; col++) {145 for (psU32 col = 0; col < numCols; col++) { 147 146 outRow[col] = crealf(inRow[col]); 148 147 } … … 153 152 154 153 out = psImageRecycle(out, numCols, numRows, PS_TYPE_F64); 155 for ( unsigned introw = 0; row < numRows; row++) {154 for (psU32 row = 0; row < numRows; row++) { 156 155 outRow = out->data.F64[row]; 157 156 inRow = in->data.C64[row]; 158 157 159 for ( unsigned intcol = 0; col < numCols; col++) {158 for (psU32 col = 0; col < numCols; col++) { 160 159 outRow[col] = creal(inRow[col]); 161 160 } … … 179 178 { 180 179 psElemType type; 181 unsigned intnumCols;182 unsigned intnumRows;180 psU32 numCols; 181 psU32 numRows; 183 182 184 183 if (in == NULL) { … … 203 202 204 203 out = psImageRecycle(out, numCols, numRows, PS_TYPE_F32); 205 for ( unsigned introw = 0; row < numRows; row++) {204 for (psU32 row = 0; row < numRows; row++) { 206 205 outRow = out->data.F32[row]; 207 206 inRow = in->data.C32[row]; 208 207 209 for ( unsigned intcol = 0; col < numCols; col++) {208 for (psU32 col = 0; col < numCols; col++) { 210 209 outRow[col] = cimagf(inRow[col]); 211 210 } … … 216 215 217 216 out = psImageRecycle(out, numCols, numRows, PS_TYPE_F64); 218 for ( unsigned introw = 0; row < numRows; row++) {217 for (psU32 row = 0; row < numRows; row++) { 219 218 outRow = out->data.F64[row]; 220 219 inRow = in->data.C64[row]; 221 220 222 for ( unsigned intcol = 0; col < numCols; col++) {221 for (psU32 col = 0; col < numCols; col++) { 223 222 outRow[col] = cimag(inRow[col]); 224 223 } … … 241 240 { 242 241 psElemType type; 243 unsigned intnumCols;244 unsigned intnumRows;242 psU32 numCols; 243 psU32 numRows; 245 244 246 245 if (real == NULL || imag == NULL) { … … 282 281 out = psImageRecycle(out, numCols, numRows, PS_TYPE_C32); 283 282 284 for ( unsigned introw = 0; row < numRows; row++) {283 for (psU32 row = 0; row < numRows; row++) { 285 284 outRow = out->data.C32[row]; 286 285 realRow = real->data.F32[row]; 287 286 imagRow = imag->data.F32[row]; 288 287 289 for ( unsigned intcol = 0; col < numCols; col++) {288 for (psU32 col = 0; col < numCols; col++) { 290 289 outRow[col] = realRow[col] + I * imagRow[col]; 291 290 } … … 297 296 298 297 out = psImageRecycle(out, numCols, numRows, PS_TYPE_C64); 299 for ( unsigned introw = 0; row < numRows; row++) {298 for (psU32 row = 0; row < numRows; row++) { 300 299 outRow = out->data.C64[row]; 301 300 realRow = real->data.F64[row]; 302 301 imagRow = imag->data.F64[row]; 303 302 304 for ( unsigned intcol = 0; col < numCols; col++) {303 for (psU32 col = 0; col < numCols; col++) { 305 304 outRow[col] = realRow[col] + I * imagRow[col]; 306 305 } … … 324 323 { 325 324 psElemType type; 326 unsigned intnumCols;327 unsigned intnumRows;325 psU32 numCols; 326 psU32 numRows; 328 327 329 328 if (in == NULL) { … … 346 345 347 346 out = psImageRecycle(out, numCols, numRows, PS_TYPE_C32); 348 for ( unsigned introw = 0; row < numRows; row++) {347 for (psU32 row = 0; row < numRows; row++) { 349 348 outRow = out->data.C32[row]; 350 349 inRow = in->data.C32[row]; 351 350 352 for ( unsigned intcol = 0; col < numCols; col++) {351 for (psU32 col = 0; col < numCols; col++) { 353 352 outRow[col] = crealf(inRow[col]) - I * cimagf(inRow[col]); 354 353 } … … 359 358 360 359 out = psImageRecycle(out, numCols, numRows, PS_TYPE_C64); 361 for ( unsigned introw = 0; row < numRows; row++) {360 for (psU32 row = 0; row < numRows; row++) { 362 361 outRow = out->data.C64[row]; 363 362 inRow = in->data.C64[row]; 364 363 365 for ( unsigned intcol = 0; col < numCols; col++) {364 for (psU32 col = 0; col < numCols; col++) { 366 365 outRow[col] = creal(inRow[col]) - I * cimag(inRow[col]); 367 366 } … … 384 383 { 385 384 psElemType type; 386 unsigned intnumCols;387 unsigned intnumRows;388 intnumElementsSquared;385 psU32 numCols; 386 psU32 numRows; 387 psS32 numElementsSquared; 389 388 390 389 if (in == NULL) { … … 405 404 406 405 out = psImageRecycle(out, numCols, numRows, PS_TYPE_F32); 407 for ( unsigned introw = 0; row < numRows; row++) {406 for (psU32 row = 0; row < numRows; row++) { 408 407 outRow = out->data.F32[row]; 409 408 inRow = in->data.C32[row]; 410 409 411 for ( unsigned intcol = 0; col < numCols; col++) {410 for (psU32 col = 0; col < numCols; col++) { 412 411 real = crealf(inRow[col]); 413 412 imag = cimagf(inRow[col]); … … 422 421 423 422 out = psImageRecycle(out, numCols, numRows, PS_TYPE_F64); 424 for ( unsigned introw = 0; row < numRows; row++) {423 for (psU32 row = 0; row < numRows; row++) { 425 424 outRow = out->data.F64[row]; 426 425 inRow = in->data.C64[row]; 427 426 428 for ( unsigned intcol = 0; col < numCols; col++) {427 for (psU32 col = 0; col < numCols; col++) { 429 428 real = creal(inRow[col]); 430 429 imag = cimag(inRow[col]); -
trunk/psLib/src/fft/psVectorFFT.c
r2080 r2204 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1.2 6$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-10- 13 20:46:57$7 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-10-27 00:57:31 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 27 27 #define P_FFTW_PLAN_RIGOR FFTW_ESTIMATE 28 28 29 static bool p_fftwWisdomImported = false;29 static psBool p_fftwWisdomImported = false; 30 30 31 31 psVector* psVectorFFT(psVector* out, const psVector* in, psFftDirection direction) 32 32 { 33 unsigned intnumElements;33 psU32 numElements; 34 34 psElemType type; 35 35 fftwf_plan plan; … … 85 85 86 86 if ((direction & PS_FFT_REAL_RESULT) != 0) { 87 for ( inti = 0; i < numElements; i++) {87 for (psS32 i = 0; i < numElements; i++) { 88 88 out->data.F32[i] = out->data.C32[i]; 89 89 } … … 98 98 { 99 99 psElemType type; 100 unsigned intnumElements;100 psU32 numElements; 101 101 102 102 if (in == NULL) { … … 127 127 outVec = out->data.F32; 128 128 129 for ( unsigned inti = 0; i < numElements; i++) {129 for (psU32 i = 0; i < numElements; i++) { 130 130 outVec[i] = crealf(inVec[i]); 131 131 } … … 138 138 outVec = out->data.F64; 139 139 140 for ( unsigned inti = 0; i < numElements; i++) {140 for (psU32 i = 0; i < numElements; i++) { 141 141 outVec[i] = creal(inVec[i]); 142 142 } … … 158 158 { 159 159 psElemType type; 160 unsigned intnumElements;160 psU32 numElements; 161 161 162 162 if (in == NULL) { … … 187 187 outVec = out->data.F32; 188 188 189 for ( unsigned inti = 0; i < numElements; i++) {189 for (psU32 i = 0; i < numElements; i++) { 190 190 outVec[i] = cimagf(inVec[i]); 191 191 } … … 198 198 outVec = out->data.F64; 199 199 200 for ( unsigned inti = 0; i < numElements; i++) {200 for (psU32 i = 0; i < numElements; i++) { 201 201 outVec[i] = cimag(inVec[i]); 202 202 } … … 218 218 { 219 219 psElemType type; 220 unsigned intnumElements;220 psU32 numElements; 221 221 222 222 if (real == NULL || imag == NULL) { … … 254 254 outVec = out->data.C32; 255 255 256 for ( unsigned inti = 0; i < numElements; i++) {256 for (psU32 i = 0; i < numElements; i++) { 257 257 outVec[i] = realVec[i] + I * imagVec[i]; 258 258 } … … 266 266 outVec = out->data.C64; 267 267 268 for ( unsigned inti = 0; i < numElements; i++) {268 for (psU32 i = 0; i < numElements; i++) { 269 269 outVec[i] = realVec[i] + I * imagVec[i]; 270 270 } … … 286 286 { 287 287 psElemType type; 288 unsigned intnumElements;288 psU32 numElements; 289 289 290 290 if (in == NULL) { … … 316 316 outVec = out->data.C32; 317 317 318 for ( unsigned inti = 0; i < numElements; i++) {318 for (psU32 i = 0; i < numElements; i++) { 319 319 outVec[i] = crealf(inVec[i]) - I * cimagf(inVec[i]); 320 320 } … … 327 327 outVec = out->data.C64; 328 328 329 for ( unsigned inti = 0; i < numElements; i++) {329 for (psU32 i = 0; i < numElements; i++) { 330 330 outVec[i] = creal(inVec[i]) - I * cimag(inVec[i]); 331 331 } … … 347 347 { 348 348 psElemType type; 349 unsigned intoutNumElements;350 unsigned intinNumElements;351 unsigned intinHalfNumElements;352 unsigned intinNumElementsSquared;349 psU32 outNumElements; 350 psU32 inNumElements; 351 psU32 inHalfNumElements; 352 psU32 inNumElementsSquared; 353 353 354 354 if (in == NULL) { … … 378 378 379 379 // from ADD: P_j = (|C_j|^2+|C_N-j|^2)/N^2, where j = 1,2,...,(N/2-1) 380 for ( unsigned inti = 1; i < inHalfNumElements; i++) {380 for (psU32 i = 1; i < inHalfNumElements; i++) { 381 381 inAbs1 = cabsf(inVec[i]); 382 382 inAbs2 = cabsf(inVec[inNumElements - i]); … … 402 402 403 403 // from ADD: P_j = (|C_j|^2+|C_N-j|^2)/N^2, where j = 1,2,...,(N/2-1) 404 for ( unsigned inti = 1; i < inHalfNumElements; i++) {404 for (psU32 i = 1; i < inHalfNumElements; i++) { 405 405 inAbs1 = cabs(inVec[i]); 406 406 inAbs2 = cabs(inVec[inNumElements - i]);
Note:
See TracChangeset
for help on using the changeset viewer.
