Tableau de nombres complexes
Bonjour ,
J'essaie de creer un tableau avec des nombres complexes , le probleme c'est que mes nombres complexes sont generes dans une boucle for , et cela me rend l'erreur que pour utiliser 'complex<double>' mes arguments doivent etre constants , sauriez-vous comment remedier au probleme ?
Je vous joins mon code , et merci !!
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
BYTE *img;
int tmp_Width, tmp_Height, tmp_Depth;
Initialize_IMG_Buffer_With_Current_Setting(&img, &tmp_Width, &tmp_Height, &tmp_Depth);
Get_Current_Image(img);
BYTE *img_Buffer = new BYTE[tmp_Width * tmp_Height * tmp_Depth];
BYTE *img_Buffer1 = new BYTE[tmp_Width * tmp_Height * tmp_Depth];
complex<double> tab[512][512];
complex<double> tab2[512][512];
for(int m=0;m<tmp_Height;m++){
for(int l=0;l<tmp_Width;l++){
for(int n=0;n<tmp_Width/2;n++){
int i = m*tmp_Width*tmp_Depth + n*tmp_Depth;
int i2= m*tmp_Width*tmp_Depth + (n+tmp_Width/2)*tmp_Depth;
complex<double> wnl1=polar(cos((-4*PI*l*n)/512),sin((-4*PI*l*n)/512));
complex<double> wnl2=polar(cos((-2*PI-4*PI*l*n)/512),sin((-2*PI-4*PI*l*n)/512));
if(l%2==0){
tab[l][m]=tab[l][m]+(img[i]+img[i2])*wnl1;
}
else if(l%2==1){
tab[l][m]=tab[l][m]+(img[i]-img[i2])*wnl2;
}
}
}
}
for(int l=0;l<tmp_Width;l++){
for(int k=0;k<tmp_Height;k++){
for(int m=0;m<tmp_Heigt/2;m++){
complex<double> wmk3=(cos((-4*PI*k*m)/512),sin((-4*PI*k*m)/512));
complex<double> wmk4=(cos((-2*PI-4*PI*k*m)/512),sin((-2*PI-4*PI*k*m)/512));
if(k%2==0){
tab2[l][k]=tab2[l][k]+(tab[l][m]+tab[l][m+256])*wmk3;
}
else if(k%2==1){
tab2[l][k]=tab2[l][k]+(tab[l][m]-tab[l][m+256])*wmk4;
}
}
}
}
for(int k=0;k<tmp_Height;k++){
for(int l=0;l<tmp_Width;l++){
int i= k*tmp_Width*tmp_Depth + l*tmp_Depth;
int mod = (int)abs(tab2[l][k]);
int arg = (int)arg(tab2[l][k]);
img_Buffer[i]=mod;
img_Buffer1[i]=arg;
}
}
Display_Current_Image_Output(img_Buffer, tmp_Width, tmp_Height, tmp_Depth, _T("mod"));
Display_Current_Image_Output(img_Buffer1, tmp_Width, tmp_Height, tmp_Depth, _T("arg"));
Destroy_IMG_Buffer_With_Current_Setting(&img);
Destroy_IMG_Buffer_With_Current_Setting(&img_Buffer);
Destroy_IMG_Buffer_With_Current_Setting(&img_Buffer1); |