IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++ Discussion :

Tableau de nombres complexes


Sujet :

C++

  1. #1
    Nouveau candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2015
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Avril 2015
    Messages : 1
    Par défaut 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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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);

  2. #2
    Expert éminent

    Femme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    5 202
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 5 202
    Par défaut
    un tableau requiert que le type soit constructible par défaut.
    Sauf si tous tes 512*512 éléments sont explicitement construit.

    Utilise vector, et ton problème sera résolu

Discussions similaires

  1. nombre complexes en C
    Par hicham.jakjoud dans le forum C
    Réponses: 4
    Dernier message: 23/10/2006, 16h51
  2. [Nombre Complexe]affichage formatte
    Par parsy dans le forum Langage
    Réponses: 2
    Dernier message: 20/08/2005, 00h36
  3. Les nombres complexe et delphi
    Par wikers dans le forum Langage
    Réponses: 3
    Dernier message: 04/08/2005, 11h47
  4. [LG]Nombres complexes et forme polaire
    Par chavernac dans le forum Langage
    Réponses: 3
    Dernier message: 28/03/2005, 18h36

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo