- #ifndef _Matrix_H_ 
- #define _Matrix_H_ 
- #include <cassert> 
- #include <cstdlib> 
-   
- using namespace std; 
- namespace storage{ 
-     template<class Type> 
-         class Matrix 
-         { 
-             public: 
-                 /* constructor vacio 
-                  */ 
-                 inline Matrix(); 
-                 /* constructor copia 
-                  */ 
-                 inline Matrix(const Matrix &M); 
-                 /* constructor parametrizado 
-                  */ 
-                 inline Matrix(unsigned int nRows, unsigned int nCols); 
-                 /* destructor 
-                  */ 
-                 inline ~Matrix(); 
-                 /* redimensionar la matriz 
-                  */              
-                 inline void resize(unsigned int nRows, unsigned int nCols); 
-                 /* indica el numero de filas 
-                 */ 
-                 unsigned int getNRows() { return _nRows;} 
-                 /* indica el numero de columnas 
-                  */ 
-                 unsigned int getNCols() { return _nCols;} 
-                 /* retorna el valor indicado por las variables 
-                  */ 
-                 inline Type & get(unsigned int r,unsigned int c); 
-                 /* hace que la matriz sea la indentidad 
-                  */ 
-                 inline void setIdentity(); 
-                 /* operador de asignacion 
-                  */ 
-                 inline Matrix & operator=(const Matrix &M); 
-                 /* realiza la suma de dos matrices 
-                  */ 
-                 inline Matrix operator+(const Matrix &M); 
-                  
-                 
-         private: 
-             Type **_data; 
-             unsigned int _nRows; 
-             unsigned int _nCols; 
-         }; 
-   
-         
-   
- ////////////////////////// 
- // 
- ////////////////////////// 
- template<class Type> 
- Matrix<Type>::Matrix() 
- { 
-   _data=NULL; 
-   _nRows=0; 
-   _nCols=0; 
- } 
-   
- ////////////////////////// 
- // 
- ////////////////////////// 
- template<class Type> 
- Matrix<Type>::Matrix(const Matrix &M) 
- { 
-   int i=0,j=0; 
-   _data=NULL; 
-   resize(M._nRows, M._nCols); 
-    
-   for(i=0;i<_nRows;i++) 
-   { 
-     for(j=0;j<_nCols;j++) 
-     { 
-       _data[i][j]=M._data[i][j]; 
-     } 
-   } 
- } 
-   
- ////////////////////////// 
- // 
- ////////////////////////// 
- template<class Type> 
- Matrix<Type>::Matrix(unsigned int nRows, unsigned int nCols) 
- { 
-   _data=NULL; 
-   resize(nRows, nCols); 
- } 
-   
-   
- ////////////////////////// 
- // 
- ////////////////////////// 
- template<class Type> 
- Matrix<Type>::~Matrix() 
- { 
-   int i; 
-   if(_data!=NULL){ 
-     for(i=0;i<_nRows;i++){ 
-       delete []_data[i]; 
-     } 
-     delete []_data; 
-   } 
- } 
-   
- ////////////////////////// 
- // 
- ////////////////////////// 
- template<class Type> 
- void Matrix<Type>::resize(unsigned int nRows, unsigned int nCols) 
- { 
-   int i; 
-   if(_data!=NULL){ 
-     for(i=0;i<nRows;i++){ 
-       delete []_data[i]; 
-     } 
-     delete []_data; 
-   } 
-    
-   _nRows=nRows; 
-   _nCols=nCols; 
-   
-   _data=NULL; 
-     _data=new Type *[_nRows]; 
-     for(i=0;i<_nRows;i++) 
-       _data[i]=new Type[_nCols]; 
-   } 
- } 
-   
- ////////////////////////// 
- // 
- ////////////////////////// 
- template<class Type> 
- Type & Matrix<Type>::get(unsigned int r, unsigned int c) 
- { 
-   assert(0<r<_nRows); 
-   assert(0<r<_nCols); 
-   return _data[r][c]; 
- } 
-   
- ////////////////////////// 
- // 
- ////////////////////////// 
- template<class Type> 
- void Matrix<Type>::setIdentity() 
- { 
-   int i,j; 
-   for(i=0;i<_nRows;i++){ 
-     for(j=0;j<_nCols;j++){ 
-       if(i==j) 
-     _data[i][j]=1; 
-       else 
-     _data[i][j]=0; 
-     } 
-   } 
- } 
-   
- ////////////////////////// 
- // 
- ////////////////////////// 
- template<class Type> 
- Matrix<Type> & Matrix<Type>::operator=(const Matrix &M) 
- { 
-   int i,j; 
-   if(_nRows==M._nRows && _nCols==M._nCols) 
-   for(i=0;i<_nRows;i++) 
-     for(j=0;j<_nCols;j++) 
-       _data[i][j]=M._data[i][j]; 
-   return *this; 
- } 
-   
- ////////////////////////// 
- // 
- ////////////////////////// 
- template<class Type> 
- Matrix<Type> Matrix<Type>::operator+(const Matrix &M) 
- { 
-   assert(_nRows==M._nRows && _nCols==M._nCols); 
-   Matrix<Type> aux(M._nRows, M._nCols); 
-   int i,j; 
-   for(i=0;i<_nRows;i++){ 
-     for(j=0;j<_nCols;j++){ 
-       aux._data[i][j]=_data[i][j]+M._data[i][j]; 
-     } 
-   } 
-   return aux;//no se si esto se puede hacer 
- } 
- }; 
-   
-   
- #endif 
-