CLAM-Development  1.4.0
MatrixTmplDef.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 
23 #ifndef _MatrixTmplDef_
24 #define _MatrixTmplDef_
25 
26 namespace CLAM
27 {
28 
29  template <class T>
31  {
32  mpMatrixBuffer=new Array<T>;
33  mNumRows = 0;
34  mNumColumns = 0;
35  mpMatrixBuffer->SetSize(0);
36  }
37 
38  template <class T>
40  {
41  if(mpMatrixBuffer)
42  {
43  delete mpMatrixBuffer;
44  mpMatrixBuffer=NULL;
45  }
46  }
47 
48 
49  template <class T>
50  MatrixTmpl<T>::MatrixTmpl(unsigned int dim1, unsigned int dim2)
51  {
52  mpMatrixBuffer=new Array<T>(dim1*dim2);
53  mNumRows = dim1;
54  mNumColumns = dim2;
55  mpMatrixBuffer->SetSize(mNumRows*mNumColumns);
56  }
57 
58  template <class T>
60  {
61  mpMatrixBuffer=new Array<T> (originalMatrix.GetNumElements());
62  *this = originalMatrix;
63  }
64 
65  // Print the matrix
66  template <class T>
67  void MatrixTmpl<T>::Print() const
68  {
69  for (unsigned int i=0; i<mNumRows; i++)
70  {
71  for (unsigned int j=0; j<mNumColumns; j++)
72  {
73  std::cout.width(10L);
74  std::cout << (*this)(i,j) << " ";
75  std::cout.fill();
76  }
77  std::cout << std::endl;
78  }
79  }
80 
81 
82  template <class T>
83  inline std::istream& operator >> (std::istream & stream, MatrixTmpl<T> & a)
84  {
85  // @todo
86  return stream;
87  }
88 
89  template <class T>
90  inline std::ostream& operator << (std::ostream & stream, const MatrixTmpl<T> & a)
91  {
92  // @todo
93  return stream;
94  }
95 
96 } // namespace CLAM
97 
98 
99 #endif // _MatrixTmplDef_
100