Changeset 3356 in Sophya for trunk/SophyaPI/DemoPIApp


Ignore:
Timestamp:
Oct 23, 2007, 12:17:19 PM (18 years ago)
Author:
ansari
Message:

adaptation fft2d.cc pour faire du r_4 ET r_8 (au choix defini par define TF) - Reza 23/10/2007

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/DemoPIApp/fft2d.cc

    r2600 r3356  
     1#define TF r_8
     2
    13int nlig = 128; int ncol = 128;     
    2 TMatrix<r_8> in(nlig,ncol);         
     4TMatrix<TF> in(nlig,ncol);         
    35int l,c;                             
    46for(l=40; l<80; l++)                 
    57  for(c=40; c<80; c++) {             
    68    double r2 = (l-60.5)*(l-60.5)+(c-60.5)*(c-60.5);   
    7     in(l,c) = 30.*exp(-r2/9.);       
     9    in(l,c) = (TF)30.*exp(-r2/9.);       
    810}                               
    911//  Le dernier argument de RandomSequence est le sigma du bruit   
    1012//  Si on veut rajouter du bruit, decommenter les 3 lignes suivantes 
    11   TMatrix<r_8> noise(nlig,ncol);                               
     13  TMatrix<TF> noise(nlig,ncol);                               
    1214  noise = RandomSequence(RandomSequence::Gaussian, 0., 0.5);     
    1315  in += noise;                                                 
    14 TMatrix< complex<r_8> > fftin;       
     16TMatrix< complex<TF> > fftin;       
    1517FFTWServer ffts;                     
    1618ffts.setNormalize(true);             
     
    2527//  dans la seconde moitie du tableau en numero de ligne       
    2628int kx, ky;                                     
    27 TMatrix< complex<r_8> > fftfb(fftin.NRows(), fftin.NCols());           
    28 TMatrix< complex<r_8> > fftfd(fftin.NRows(), fftin.NCols());           
     29TMatrix< complex<TF> > fftfb(fftin.NRows(), fftin.NCols());           
     30TMatrix< complex<TF> > fftfd(fftin.NRows(), fftin.NCols());           
    2931// fb : Filtrage brutal , fd :  Filtrage doux
    3032for(ky=0; ky<fftin.NRows(); ky++)             
     
    3436    if (ky > fftin.NRows()/2) kyy = fftin.NRows()-ky;
    3537    double kr = sqrt((double)kx*kx+kyy*kyy);             
    36     complex<double> att;
     38    complex<TF> att;
    3739    // Filtrage brutal  fonction en escalier
    38     if (kr < 10)  att = complex<double>(0.5, 0.);
     40    if (kr < 10)  att = complex<TF>((TF)0.5, (TF)0.);
    3941    else att = complex<double>(1., 0.);
    4042    fftfb(ky, kx) = fftin(ky, kx) * att ;   
    4143    // Filtrage doux sous forme de 1-exp(-alpha k_r)
    42     att = complex<double>(1.-exp(-kr*0.1), 0.);   
     44    att = complex<TF>((TF)(1.-exp(-kr*0.1)), (TF)0.);   
    4345    fftfd(ky, kx) = fftin(ky, kx) * att ;   
    4446  }
    45 TMatrix<r_8> infb(nlig,ncol);         
    46 TMatrix<r_8> infd(nlig,ncol);         
     47TMatrix<TF> infb(nlig,ncol);         
     48TMatrix<TF> infd(nlig,ncol);         
    4749// FFTBackward -- Attention, le tableau des coefficient de Fourier
    4850// est modifie - On en fait une copie
    49 TMatrix< complex<r_8> > fftf(fftin.NRows(), fftin.NCols());   
     51TMatrix< complex<TF> > fftf(fftin.NRows(), fftin.NCols());   
    5052// Pour le filtre brutal
    5153fftf = fftfb;
Note: See TracChangeset for help on using the changeset viewer.