MatrixTmplDef.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 
00023 #ifndef _MatrixTmplDef_
00024 #define _MatrixTmplDef_
00025 
00026 namespace CLAM
00027 {
00028 
00029         template <class T>
00030         MatrixTmpl<T>::MatrixTmpl()
00031         {
00032                 mpMatrixBuffer=new Array<T>;
00033                 mNumRows = 0;
00034                 mNumColumns = 0;
00035                 mpMatrixBuffer->SetSize(0);
00036         }
00037 
00038         template <class T>
00039         MatrixTmpl<T>::~MatrixTmpl()
00040         {
00041                 if(mpMatrixBuffer)
00042                 {
00043                         delete mpMatrixBuffer;
00044                         mpMatrixBuffer=NULL;
00045                 }
00046         }
00047 
00048 
00049         template <class T>
00050         MatrixTmpl<T>::MatrixTmpl(unsigned int dim1, unsigned int dim2)
00051         {
00052                 mpMatrixBuffer=new Array<T>(dim1*dim2);
00053                 mNumRows = dim1;
00054                 mNumColumns = dim2;
00055                 mpMatrixBuffer->SetSize(mNumRows*mNumColumns);
00056         }
00057 
00058         template <class T>
00059         MatrixTmpl<T>::MatrixTmpl(const MatrixTmpl<T>& originalMatrix)
00060         {
00061                 mpMatrixBuffer=new Array<T> (originalMatrix.GetNumElements());
00062                 *this = originalMatrix; 
00063         }
00064 
00065         // Print the matrix
00066         template <class T>
00067         void MatrixTmpl<T>::Print() const
00068         {
00069                 for (unsigned int i=0; i<mNumRows; i++)
00070                 {
00071                         for (unsigned int j=0; j<mNumColumns; j++)
00072                                 {
00073                                         std::cout.width(10L);
00074                                         std::cout << (*this)(i,j) << " ";
00075                                         std::cout.fill();
00076                                 } 
00077                         std::cout << std::endl;
00078                 }
00079         }
00080 
00081 
00082         template <class T>
00083         inline std::istream& operator >> (std::istream & stream, MatrixTmpl<T> & a)
00084         {
00085                 // @todo
00086                 return stream;
00087         }
00088         
00089         template <class T>
00090         inline std::ostream& operator << (std::ostream & stream, const MatrixTmpl<T> & a)
00091         {
00092                 // @todo
00093                 return stream;
00094         }
00095 
00096 } // namespace CLAM
00097 
00098 
00099 #endif // _MatrixTmplDef_
00100 
Generated by  doxygen 1.6.3