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 :

Multiplication de matrices polynomiales


Sujet :

C++

  1. #21
    Membre chevronné
    Avatar de poukill
    Profil pro
    Inscrit en
    Février 2006
    Messages
    2 155
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Février 2006
    Messages : 2 155
    Points : 2 107
    Points
    2 107
    Par défaut
    Citation Envoyé par eltentor
    polynome produit(polynome & P1,polynome et P2)
    {
    n = 1;
    polynome P3;
    while(n1<=N+1)
    {
    n2 = 1;
    while(n2<=N+1)
    {
    n3 = (n1+n2-1);
    P3[n3] = P3[n3] + (P1[n1]*P2[n2]);
    n2++;
    }
    n1++;
    }
    }
    Ca, ça risque pas de marcher... & serait mieux je pense

  2. #22
    Futur Membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    31
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 31
    Points : 6
    Points
    6
    Par défaut
    désolé je suis trop c** mais je ne sais toujours pas comment faire j'ai beau réfléchir je ne trouve pas ou le mettre l'instance

  3. #23
    Rédacteur

    Avatar de Matthieu Brucher
    Profil pro
    Développeur HPC
    Inscrit en
    Juillet 2005
    Messages
    9 810
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : Développeur HPC
    Secteur : Industrie

    Informations forums :
    Inscription : Juillet 2005
    Messages : 9 810
    Points : 20 970
    Points
    20 970
    Par défaut
    Par exemple à la place de P3[i, j], tu mets P3.mat[i][j]
    Et aussi regarde ici http://c.developpez.com/faq/cpp/

  4. #24
    Futur Membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    31
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 31
    Points : 6
    Points
    6
    Par défaut
    le plus gros probleme je croi est qu'il ne comprend pas quand je défini les types matrice et polynome

  5. #25
    Rédacteur

    Avatar de Matthieu Brucher
    Profil pro
    Développeur HPC
    Inscrit en
    Juillet 2005
    Messages
    9 810
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : Développeur HPC
    Secteur : Industrie

    Informations forums :
    Inscription : Juillet 2005
    Messages : 9 810
    Points : 20 970
    Points
    20 970
    Par défaut
    Non, il comprend très bien, en revanche, tu ne connais pas suffisemment le C++
    Par exemple, les indices d'un tableau de taille n vont de 0 à n-1

  6. #26
    Futur Membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    31
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 31
    Points : 6
    Points
    6
    Par défaut
    sais tu ce que signifi
    1>c:\documents and settings\vmartinet.tesa-prd\bureau\code.cpp(19) : error C2676: binary '[' : 'Polynome' does not define this operator or a conversion to a type acceptable to the predefined operator

  7. #27
    Futur Membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    31
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 31
    Points : 6
    Points
    6
    Par défaut
    a j'ai compris enfin l'instance .
    voila les modif de mon programme.
    désolé pour le flood..
    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
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
     
    #include <iostream>
    using namespace std;
     
    const int N = 4;
    struct Polynome
    {
    	int poly [N];
    };
    struct Matrice
    {
    	Polynome mat [N][N];
    };
    Polynome somme(Polynome & P1,Polynome & P2)
    {
    	int n = 0;
    	Polynome P3;
    	while(n<=N+1)
    	{
    		P3.poly[n] = P1.poly[n] + P2.poly[n];
    		n++;
    	}
    	return(P3);
    }
     
    Polynome produit(Polynome & P1,Polynome & P2)
    {
    	int n1 = 0;
    	Polynome P3;
    	int n3 =0;
    	int n2;
    	while(n1<=N)
    	{
    		n2 = 0;
    		while(n2<=N)
    		{
    			n3 = (n1+n2+1);
    			P3.poly[n3] = P3.poly[n3] + (P1.poly[n1]*P2.poly[n2]);
    			n2++;
    		}
    	n1++;
    	}
    }
    Matrice principal(Matrice & M1, Matrice & M2)
    {
    	int n ;
    	int N ;
    	int n3 = 1 ;
    	int m3;
    	Matrice M3 ;
    	while(n3<=n)
    	{
    		 m3 = 1;
    		while(m3<=n)
    		{
    			int m1 = 1 ;
    			int n2 = 1 ;
     
    			while(m1<=n)
    			{
    				M3.mat[n3,m3] = somme(M3.mat[n3,m3],produit(M1.mat[n3,m1],M2.mat[n2,m3]));
    				m1++;
    				n2==;
    			}
    			m3++;
    		}
    		n3++;
    	}
    	return(M3)
    }
    et voila les erreurs.

    1>c:\documents and settings\vmartinet.tesa-prd\bureau\code.cpp(60) : error C2664: 'produit' : cannot convert parameter 1 from 'Polynome [4]' to 'Polynome &'
    1>c:\documents and settings\vmartinet.tesa-prd\bureau\code.cpp(60) : error C2664: 'somme' : cannot convert parameter 1 from 'Polynome [4]' to 'Polynome &'
    1>c:\documents and settings\vmartinet.tesa-prd\bureau\code.cpp(62) : error C2059: syntax error : ';'
    1>c:\documents and settings\vmartinet.tesa-prd\bureau\code.cpp(69) : error C2143: syntax error : missing ';' before '}'

  8. #28
    Rédacteur

    Avatar de Matthieu Brucher
    Profil pro
    Développeur HPC
    Inscrit en
    Juillet 2005
    Messages
    9 810
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : Développeur HPC
    Secteur : Industrie

    Informations forums :
    Inscription : Juillet 2005
    Messages : 9 810
    Points : 20 970
    Points
    20 970
    Par défaut
    Pour les 2 dernières, tu commenceras par regarder ce qui est écrit, et pour les 2 premières, tu reliras mon post précédent.

  9. #29
    Futur Membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    31
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 31
    Points : 6
    Points
    6
    Par défaut
    ben je veux bien mais meme en cherchan je trouve rien et j'ai une new erreur
    c'est a cause de ce que tu as di a propos de la taille des tableau ?

    c:\documents and settings\vmartinet.tesa-prd\bureau\code.cpp(61) : error C2664: 'produit' : cannot convert parameter 1 from 'Polynome [4]' to 'Polynome'
    1> No constructor could take the source type, or constructor overload resolution was ambiguous

  10. #30
    Rédacteur

    Avatar de Matthieu Brucher
    Profil pro
    Développeur HPC
    Inscrit en
    Juillet 2005
    Messages
    9 810
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : Développeur HPC
    Secteur : Industrie

    Informations forums :
    Inscription : Juillet 2005
    Messages : 9 810
    Points : 20 970
    Points
    20 970
    Par défaut
    Ce n'est pas une nouvelle erreur, simplement le fait que tu ne lis pas correctement mes messages !
    Comment on récupère un élément dans un tableau multidimensionnel ? [] permet de récupérer une dimension, l'opérateur ',' permet d'exécuter plusieurs opérations, mais 4,3, ça signifie 3. Pour récupérer la 4ème colonne de la 3ème ligne, c'est qqch genre [4][3]

  11. #31
    Futur Membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    31
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 31
    Points : 6
    Points
    6
    Par défaut
    merci et dsl c'est bon je l'ai corrigé
    mais maintenan j'ai une erreur de link..

    Compiling...
    1>code.cpp
    1>Linking...
    1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
    1>C:\Documents and Settings\VMARTINET.TESA-PRD\Mes documents\Visual Studio 2005\Projects\newone\Debug\newone.exe : fatal error LNK1120: 1 unresolved externals
    1>Build log was saved at "file://c:\Documents and Settings\VMARTINET.TESA-PRD\Mes documents\Visual Studio 2005\Projects\newone\newone\Debug\BuildLog.htm"
    1>newone - 2 error(s), 0 warning(s)

  12. #32
    Rédacteur

    Avatar de Matthieu Brucher
    Profil pro
    Développeur HPC
    Inscrit en
    Juillet 2005
    Messages
    9 810
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : Développeur HPC
    Secteur : Industrie

    Informations forums :
    Inscription : Juillet 2005
    Messages : 9 810
    Points : 20 970
    Points
    20 970
    Par défaut
    Elle est où ta fonction main ?

  13. #33
    Futur Membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    31
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 31
    Points : 6
    Points
    6
    Par défaut
    ben en fait je n'en ai pas
    fodrai ke je rentre 2 matrice a l'ordi
    et ke je renvoi le résultat mais je ne sais pas le faire

  14. #34
    Rédacteur

    Avatar de Matthieu Brucher
    Profil pro
    Développeur HPC
    Inscrit en
    Juillet 2005
    Messages
    9 810
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : Développeur HPC
    Secteur : Industrie

    Informations forums :
    Inscription : Juillet 2005
    Messages : 9 810
    Points : 20 970
    Points
    20 970
    Par défaut
    ...
    Tout programme C ou C++ est lancé par l'appel de sa fonction main. Donc tu dois la créer, voilà tout ! ensuite tu mets dedans ce que tu veux pour pour appeler correctement ta fonction.

  15. #35
    Futur Membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    31
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 31
    Points : 6
    Points
    6
    Par défaut
    autre question alors, désolé de te prendre du temps
    mais comment je peut crée un matrice polynomiale pour faire l'exemple?
    et quelle est la commande pour écrire un truc a l'écran ?

  16. #36
    Rédacteur

    Avatar de Matthieu Brucher
    Profil pro
    Développeur HPC
    Inscrit en
    Juillet 2005
    Messages
    9 810
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : Développeur HPC
    Secteur : Industrie

    Informations forums :
    Inscription : Juillet 2005
    Messages : 9 810
    Points : 20 970
    Points
    20 970
    Par défaut
    Tu as regardé un peu la FAQ C++ ? Il y a des exemples d'affichage.
    Tu as appris comment le C++ ?

  17. #37
    Futur Membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    31
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 31
    Points : 6
    Points
    6
    Par défaut
    ben j'ai apris le c++ a mon iut informatique mais la je suis en 2em année et on la vite fait étudié en 1er année
    je regarde le faq et si j'ai un pb je repost

  18. #38
    Rédacteur

    Avatar de Matthieu Brucher
    Profil pro
    Développeur HPC
    Inscrit en
    Juillet 2005
    Messages
    9 810
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : Développeur HPC
    Secteur : Industrie

    Informations forums :
    Inscription : Juillet 2005
    Messages : 9 810
    Points : 20 970
    Points
    20 970
    Par défaut
    On t'a donc quand même appris comment faire un programme qui s'exécute en cours ? Donc reprends cette partie là

  19. #39
    Futur Membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    31
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 31
    Points : 6
    Points
    6
    Par défaut
    voila j'ai pas mal avancé dans le programme mais j'ai un nouveau probleme
    au moment du retour d'un polynome dans la fonction produit il y a une erreur
    Run-Time Check Failure #2 - Stack around the variable 'P3' was corrupted



    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
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
     
    #include <iostream>
    using namespace std;
     
    const int N = 2;
    const int M = 2*N;
    struct Polynome
    {
    	int poly [M];
    };
    struct Matrice
    {
    	Polynome mat [N][N];
    };
    Polynome somme(Polynome P1,Polynome P2)
    {
    	int n = 0;
    	Polynome P3;
    	while(n<=M-1)
    	{
    		P3.poly[n] = P1.poly[n] + P2.poly[n];
    		n++;
    	}
    	return(P3);
    }
     
    Polynome produit(Polynome P1,Polynome P2)
    {
    	int n1 = 0;
    	Polynome P3;
    	int n3 =0;
    	int n2;
    	while(n1<=N)
    	{
    		n2 = 0;
    		while(n2<=N)
    		{
    			n3 = (n1+n2);
    			P3.poly[n3] =P1.poly[n1]*P2.poly[n2];
    			n2++;
    		}
    	n1++;
    	}
    	return(P3);
    }
    Matrice principal(Matrice M1, Matrice M2)
    {
    	int n = 0;
    	int n3 = 0 ;
    	int m3;
    	Matrice M3 ;
    	int i = 0;
    	int j = 0;
    	int k = 0;
    	while (i <= N)
    	{
    			j=0;
    			while (j <= N)
    			{
    					k=0;
    					while (k <= M)
    					{
     
    							M3.mat[i][j].poly[k] = 0;
    							k++;
    					}
    					j++;		
    			}
    			i++;
    	}
    	while(n3<=N)
    	{
    		 m3 = 0;
    		while(m3<=N)
    		{
    			int m1 = 0 ;
    			int n2 = 0 ;
     
    			while(m1<=N)
    			{
    				M3.mat[n3][m3] = somme(M3.mat[n3][m3],produit(M1.mat[n3][m1],M2.mat[n2][m3]));
    				m1++;
    				n2++;
    			}
    			m3++;
    		}
    		n3++;
    	}
    	return(M3);
    }
     
    void main()
    {
    	Matrice M1 ;
    	Matrice M2 ;
    	int i = 0;
    	int j = 0;
    	int k = 0;
    	while (i <= N)
    	{
    			j=0;
    			while (j <= N)
    			{
    					k=0;
    					while (k <= M)
    					{
     
    							M1.mat[i][j].poly[k] = 1;
    							k++;
    					}
    					j++;		
    			}
    			i++;
    	}
    	i = 0;
    	j = 0;
    	k = 0;
    	while (i <= N)
    	{
    			j=0;
    			while (j <= N)
    			{
    					k=0;
    					while (k <= M)
    					{
     
    							(M2.mat[i][j].poly[k]) = 1;
    							k++;
    					}
    					j++;		
    			}
    			i++;
    	}
     
    	Matrice M3 ;
    	M3 = principal(M1,M2);
    	i = 0;
    	j = 0;
    	k = 0;
     
    	while (i <= N)
    	{
    			j=0;
    			while (j <= N)
    			{
    					k=0;
    					while (k <= M)
    					{
     
    							cout<<(M3.mat[i][j].poly[k]);
    							k++;
    					}
    			j++;		
    			}
    	i++;
    	}
    }

  20. #40
    Rédacteur

    Avatar de Matthieu Brucher
    Profil pro
    Développeur HPC
    Inscrit en
    Juillet 2005
    Messages
    9 810
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : Développeur HPC
    Secteur : Industrie

    Informations forums :
    Inscription : Juillet 2005
    Messages : 9 810
    Points : 20 970
    Points
    20 970
    Par défaut
    Tu as regardé l'exécution au débuggeur ?

+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 3 PremièrePremière 123 DernièreDernière

Discussions similaires

  1. Boost : multiplications de matrice 1000*1000 lentes
    Par bossonm dans le forum Boost
    Réponses: 20
    Dernier message: 12/08/2008, 18h21
  2. Multiplication de matrices
    Par Vince71 dans le forum MATLAB
    Réponses: 3
    Dernier message: 22/04/2008, 15h57
  3. multiplication de matrices
    Par dev0077 dans le forum C++
    Réponses: 4
    Dernier message: 06/10/2007, 15h30
  4. Qt/OpenGL et multiplication de matrice
    Par MDiabolo dans le forum OpenGL
    Réponses: 6
    Dernier message: 30/03/2006, 11h08
  5. [LG]multiplication de matrices
    Par dreamdam dans le forum Langage
    Réponses: 11
    Dernier message: 17/07/2004, 11h02

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