Robot Simulator of the Robotics Group for Self-Organization of Control: sparsematrix.h Source File

# sparsematrix.h

Go to the documentation of this file.

    00001 /***************************************************************************
    00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
    00003  *    Georg Martius  <georg dot martius at web dot de>                     *
    00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
    00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
    00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
    00007  *                                                                         *
    00008  *   This program is free software; you can redistribute it and/or modify  *
    00009  *   it under the terms of the GNU General Public License as published by  *
    00010  *   the Free Software Foundation; either version 2 of the License, or     *
    00011  *   (at your option) any later version.                                   *
    00012  *                                                                         *
    00013  *   This program is distributed in the hope that it will be useful,       *
    00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
    00016  *   GNU General Public License for more details.                          *
    00017  *                                                                         *
    00018  *   You should have received a copy of the GNU General Public License     *
    00019  *   along with this program; if not, write to the                         *
    00020  *   Free Software Foundation, Inc.,                                       *
    00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
    00022  *                                                                         *
    00023  ***************************************************************************/
    00024 #ifndef __SPARSEMATRIX_H_
    00025 #define __SPARSEMATRIX_H_
    00026
    00027 #include "sparsearray.h"
    00028
    00029 namespace matrix
    00030 {
    00031
    00032   /**
    00033    * sparse matrix which uses an HashTable
    00034    * first (fast implemented) version
    00035    * @author guettler
    00036    */
    00037   template<typename I, typename D> class SparseMatrix : public matrix::SparseArray<I, D>
    00038   {
    00039   public:
    00040      SparseMatrix(I m, I n) : SparseArray<I, D>(m*n), m(m), n(n) {}
    00041
    00042      virtual ~SparseMatrix() {}
    00043
    00044      virtual inline D val(I row, I column) const { return (*this)[row*m+column]; }
    00045
    00046      virtual inline D& val(I row, I column) { return (*this)[row*m+column]; }
    00047
    00048      virtual inline I getM() { return m; }
    00049      virtual inline I getN() { return n; }
    00050
    00051    protected:
    00052      I m;
    00053      I n;
    00054   };
    00055
    00056 }
    00057
    00058 #ifdef UNITTEST
    00059 #include "sparsematrix.tests.hpp"
    00060 #endif
    00061
    00062 #endif /* __SPARSEMATRIX_H_ */