Gérer mieux la memoire

stiko Messages postés 38 Date d'inscription jeudi 29 juin 2006 Statut Membre Dernière intervention 20 février 2008 - 26 juil. 2006 à 08:08
stiko Messages postés 38 Date d'inscription jeudi 29 juin 2006 Statut Membre Dernière intervention 20 février 2008 - 26 juil. 2006 à 11:10


salut,j'utilise une classe faite en C++ pour les calculs matriciels de grand taille la classe est le suivant:c'est le fichier .h[code]/* Matrix.h*/#ifndef __TMATRIX H__ #define __TMATRIX H__   #include #include using namespace std;  class TMatrixException /* Exception class for TFloatMatix */ {     public:       enum Exception       {            DIM_TOO_SMALL ,            NOT_SAME_DIM ,            NOT_SQUARE ,            NOT_MULTIPLICABLE,           NOT_UNI_COLUMN      };         TMatrixException(Exception);       Exception Err; };   template class TMatrix {     public:       /* ---------------------- Attributes --------------------------- */       T *M;                              /* Linear matrix data storage */       T **P;                            /* Pointers on each rows */       int dimR;                        /* Number of rows ( column size ) */       int dimC;                       /* Number of columns ( row size ) */               /* ----------------------- Builders --------------------------- */       TMatrix(int );                             /* for square matrix */       TMatrix(int dimRow=10, int dimCol=1);        /* Default, For NxM matrix */       TMatrix(const TMatrix&);               /* Copy */       ~TMatrix();                             /* de-allocate memory */         /* -------------------- Utils procedures ----------------------- */       void clear();                            /* Reset to 0 all elements */       void destroy();                          /* de-allocate memory */       TMatrix resize(int,int);             /* Set a new dimension */       void resize(int dim=2);                /* The same, for square */       void in(T*);                         /* Input data in a matrix */       ostream& out(ostream&) const;          /* Display matrix on std::out */        /* ------------- Functions and procedure on this object ------- */       TMatrix ones();      TMatrix zeros();      TMatrix cofactor();                  /* Return cofactor matrix */       T cofactor(int, int);               /* 1 element cofactor */       T determinant();                  /* Determinant of a matrix */       void transpose();                   /* Transpose a matrix*/      TMatrix transpose1();          /* Transpose a matrix that returns a Mtarix*/       void reverse();                /* Reverse a matrix */       void TC();                    /* Transpose and cofactor matrix */       TMatrix mean();           /* mean value of array*/      T norm();                      /*matrix norms*/      TMatrix fill( const TMatrix&  ,const int ) ;     /* ---------------------- Operators ---------------------------- */       TMatrix& operator=(const TMatrix&);            TMatrix operator-()                  ;       TMatrix operator+(const TMatrix&) ;       TMatrix operator-(const TMatrix&) ;       TMatrix operator*(const TMatrix&) ;       TMatrix operator*(const T);       TMatrix operator*=(const T);       TMatrix operator*=(const TMatrix&  );      TMatrix operator/(const T );      TMatrix colonne(const int );      T det3x3();                            /* return the determinant of a 3x3 matrix */       T det2x2();                            /* return the determinant of a 2x2 matrix */       TMatrix mul(const TMatrix&);  /* Multiply two matrices */ };   template ostream& operator> (istream&, TMatrix&); #endif //===========================================================================/codec'est le programme .CPP[code]   // DernierMatrice11-7-06.cpp : définit le point d'entrée pour l'application console.//#include "stdafx.h"#include #include #include #include #include #include "Matrix.h" using namespace std;TMatrixException::TMatrixException(Exception e) : Err(e) {     if (e==DIM_TOO_SMALL)     {         cout

2 réponses

turnerom Messages postés 492 Date d'inscription samedi 10 juillet 2004 Statut Membre Dernière intervention 12 janvier 2012 1
26 juil. 2006 à 10:10
Salut,










| est ce vous avez des idées pour mieux gerer la mémoire et pour mininmiser le temps necessaire pour le calculs?


--> Utilise [nt2.sourceforge.net nt2] qui fait ca de manière très optimisé !

TuRn3r
0
stiko Messages postés 38 Date d'inscription jeudi 29 juin 2006 Statut Membre Dernière intervention 20 février 2008
26 juil. 2006 à 11:10
je travaille sous VS2003, pour l instant on peut pas faire un link entre NT2 et VS2003.
0
Rejoignez-nous