Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sparsematrix.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 #ifndef __SPARSEMATRIX_H_
25 #define __SPARSEMATRIX_H_
26 
27 #include "sparsearray.h"
28 
29 namespace matrix
30 {
31 
32  /**
33  * sparse matrix which uses an HashTable
34  * first (fast implemented) version
35  * @author guettler
36  */
37  template<typename I, typename D> class SparseMatrix : public matrix::SparseArray<I, D>
38  {
39  public:
40  SparseMatrix(I m, I n) : SparseArray<I, D>(m*n), m(m), n(n) {}
41 
42  virtual ~SparseMatrix() {}
43 
44  virtual inline D val(I row, I column) const { return (*this)[row*m+column]; }
45 
46  virtual inline D& val(I row, I column) { return (*this)[row*m+column]; }
47 
48  virtual inline I getM() { return m; }
49  virtual inline I getN() { return n; }
50 
51  protected:
52  I m;
53  I n;
54  };
55 
56 }
57 
58 #ifdef UNITTEST
59 #include "sparsematrix.tests.hpp"
60 #endif
61 
62 #endif /* __SPARSEMATRIX_H_ */
virtual D val(I row, I column) const
Definition: sparsematrix.h:44
SparseMatrix(I m, I n)
Definition: sparsematrix.h:40
virtual ~SparseMatrix()
Definition: sparsematrix.h:42
I n
Definition: sparsematrix.h:53
I m
Definition: sparsematrix.h:52
unsigned int I
type for matrix indices
Definition: matrix.h:36
virtual D & val(I row, I column)
Definition: sparsematrix.h:46
virtual I getM()
Definition: sparsematrix.h:48
Definition: sparsearray.h:45
sparse matrix which uses an HashTable first (fast implemented) version
Definition: sparsematrix.h:37
virtual I getN()
Definition: sparsematrix.h:49
double D
type for matrix elements
Definition: matrix.h:38