IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 13, 2004, 10:46:57 AM (22 years ago)
Author:
desonia
Message:

modified psVectorFFT to support PS_FFT_REAL_RESULT.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/fft/psVectorFFT.c

    r1864 r2080  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-09-23 18:31:49 $
     7 *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-10-13 20:46:57 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4343    type = in->type.type;
    4444
    45     if ((type != PS_TYPE_F32) && (type != PS_TYPE_C32)) {
    46         char* typeStr;
    47         PS_TYPE_NAME(typeStr,type);
    48         psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorFFT",
    49                    PS_ERR_BAD_PARAMETER_TYPE, true,
    50                    PS_ERRORTEXT_psVectorFFT_IMAGE_TYPE_UNSUPPORTED,
    51                    typeStr);
    52         psFree(out);
    53         return NULL;
    54     }
    55 
    56     if ((type != PS_TYPE_C32) && (direction == PS_FFT_REVERSE)) {
    57         char* typeStr;
    58         PS_TYPE_NAME(typeStr,type);
    59         psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorFFT",
    60                    PS_ERR_BAD_PARAMETER_TYPE, true,
    61                    PS_ERRORTEXT_psVectorFFT_REVERSE_NOT_COMPLEX,
    62                    typeStr);
    63         psFree(out);
    64         return NULL;
    65 
    66     }
    67 
    68     if ((type != PS_TYPE_F32) && (direction == PS_FFT_FORWARD)) {
    69         char* typeStr;
    70         PS_TYPE_NAME(typeStr,type);
    71         psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorFFT",
    72                    PS_ERR_BAD_PARAMETER_TYPE, true,
    73                    PS_ERRORTEXT_psVectorFFT_FORWARD_NOT_REAL,
    74                    typeStr);
    75         psFree(out);
    76         return NULL;
    77     }
    78 
    7945    /* make sure the system-level wisdom information is imported. */
    8046    if (!p_fftwWisdomImported) {
     
    8551    numElements = in->n;
    8652
    87     out = psVectorRecycle(out, numElements, PS_TYPE_C32);
     53    out = psVectorCopy(out, in, PS_TYPE_C32);
    8854    out->n = numElements;
    8955
    90     if (type == PS_TYPE_F32) {
    91         // need to convert to complex
    92         psC32* outVec = out->data.C32;
    93         psF32* inVec = in->data.F32;
    94 
    95         for (unsigned int i = 0; i < numElements; i++) {
    96             outVec[i] = inVec[i];
    97         }
    98     } else {
    99         psC32* outVec = out->data.C32;
    100         psC32* inVec = in->data.C32;
    101 
    102         for (unsigned int i = 0; i < numElements; i++) {
    103             outVec[i] = inVec[i];
    104         }
    105     }
    106 
    107     plan = fftwf_plan_dft_1d(numElements,
    108                              (fftwf_complex *) out->data.C32,
    109                              (fftwf_complex *) out->data.C32, direction, P_FFTW_PLAN_RIGOR);
     56    if ((direction & PS_FFT_FORWARD) != 0) {
     57        plan = fftwf_plan_dft_1d(numElements,
     58                                 (fftwf_complex *) out->data.C32,
     59                                 (fftwf_complex *) out->data.C32, FFTW_FORWARD, P_FFTW_PLAN_RIGOR);
     60    } else if ((direction & PS_FFT_REVERSE) != 0) {
     61        plan = fftwf_plan_dft_1d(numElements,
     62                                 (fftwf_complex *) out->data.C32,
     63                                 (fftwf_complex *) out->data.C32, FFTW_BACKWARD, P_FFTW_PLAN_RIGOR);
     64    } else {
     65        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorFFT",
     66                   PS_ERR_BAD_PARAMETER_VALUE, true,
     67                   PS_ERRORTEXT_psVectorFFT_DIRECTION_NOTSET);
     68        psFree(out);
     69        return NULL;
     70    }
    11071
    11172    /* check if a plan exists now */
     
    12283
    12384    fftwf_destroy_plan(plan);
     85
     86    if ((direction & PS_FFT_REAL_RESULT) != 0) {
     87        for (int i = 0; i < numElements; i++) {
     88            out->data.F32[i] = out->data.C32[i];
     89        }
     90        out->type.type = PS_TYPE_F32;
     91        out->data.V = psRealloc(out->data.V,PSELEMTYPE_SIZEOF(PS_TYPE_F32)*out->nalloc);
     92    }
    12493
    12594    return out;
Note: See TracChangeset for help on using the changeset viewer.