Class matrice

cs_flaky Messages postés 1 Date d'inscription lundi 12 mai 2003 Statut Membre Dernière intervention 14 mai 2004 - 14 mai 2004 à 17:45
cs_djl Messages postés 3011 Date d'inscription jeudi 26 septembre 2002 Statut Membre Dernière intervention 27 novembre 2004 - 14 mai 2004 à 19:33
Slt à tous
J'utilise une classe "matrice" (celle de nicolas aunai, téléchargée sur le site) qui fonctionne très bien. Mais j'ai du mal à manipuler l'objet : je voudrais réaliser dans mon prgm principal des fonctions qui renvoient des matrices ( remplissage de matrice, sys de cramer)

Quelqu'un sait-il comment je dois déclarer ma fonction, en dehors de la class matrice pour que celle ci fonctionne et me renvoie une matrice ?

voici la def de la class :

#ifndef _MATRIX_H_
#define _MATRIX_H_
#include
#include "erreur.h"

using namespace std;

class Matrice
{
private:
typedef double *ligne;
ligne *lignes;
unsigned int n; // Nombre de lignes (1er paramètre)
unsigned int m; // Nombre de colonnes (2ème paramètre)
//void echange(double &a, double &b) const;
Matrice supligne(const Matrice &mat, unsigned int lig, unsigned int col) const;
double det(const Matrice &mat) const;
float expo(unsigned int n) const;

public:
//les constructeurs/destructeur
Matrice();
Matrice(unsigned int nl, unsigned int nc);
Matrice(unsigned int nl, unsigned int nc, double valeur);
Matrice(const Matrice &source);
~Matrice(void);
//les operateurs
Matrice &operator=(const Matrice &mat);
double &operator()(unsigned int i, unsigned int j);
Matrice operator+(const Matrice &mat) const;
Matrice operator-(const Matrice &mat) const;
Matrice operator*(const Matrice &mat) const;
Matrice operator*(const double nb) const;
friend Matrice operator*(const double nb,const Matrice &mat);
Matrice & operator*=(const Matrice &mat);
Matrice & operator*=(const double nb);
Matrice & operator+=(const Matrice &mat);
Matrice & operator-=(const Matrice &mat);
Matrice & operator/=(const double);
Matrice operator/(const double) const;
//accesseur et manipulations
Matrice t();
double trace() const;
double det() const;
Matrice co() const;
Matrice inverse() const;
int dim() const;
unsigned int nb_colones() const;
unsigned int nb_lignes() const;
double norme();



};
#endif

merci à vous

1 réponse

cs_djl Messages postés 3011 Date d'inscription jeudi 26 septembre 2002 Statut Membre Dernière intervention 27 novembre 2004 7
14 mai 2004 à 19:33
Matrice func()
{
Matrice m;
...

return Matrice;
}

si ca ca renvoi pas une matrice :D
0
Rejoignez-nous