stiko
Messages postés38Date d'inscriptionjeudi 29 juin 2006StatutMembreDernière intervention20 février 2008
-
26 juil. 2006 à 08:08
stiko
Messages postés38Date d'inscriptionjeudi 29 juin 2006StatutMembreDernière intervention20 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