sprint 1-alpha
sprint/math/fixed_matrix.h
00001 /******************************************************************************
00002 *   sprint::static_matrix
00003 *
00004 *   Copyright (C) 2004-2011  Paolo Medici <www.pmx.it>
00005 *
00006 *  This library is free software; you can redistribute it and/or
00007 *  modify it under the terms of the GNU Lesser General Public
00008 *  License as published by the Free Software Foundation; either
00009 *  version 2.1 of the License, or (at your option) any later version.
00010 *
00011 *  This library 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 GNU
00014 *  Lesser General Public License for more details.
00015 *
00016 *  You should have received a copy of the GNU Lesser General Public
00017 *  License along with this library; if not, write to the Free Software
00018 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019 *
00020 *******************************************************************************/
00021 #ifndef _FIXEDSIZE_MATRIX_H
00022 #define _FIXEDSIZE_MATRIX_H
00023 
00024 #include "matrix_common.h"
00025 
00026 namespace sprint {
00027 
00029 template<class T, unsigned int nr, unsigned int nc>
00030 class fmatrix {
00031         T m_data[nc * nr];
00032         
00033         static const unsigned int m_nc = nc;
00034         static const unsigned int m_nr = nr;
00035 
00036     public:     
00037         typedef T data_type;
00038         
00039         public:
00040                 fmatrix() { }
00041                 ~fmatrix() { }
00042                 
00043                 inline T & operator() (unsigned int r, unsigned int c) { return m_data[r * nc + c]; }
00044                 inline const T & operator()  (unsigned int r, unsigned int c) const { return m_data[r * nc + c]; }
00045                 
00046                 inline unsigned int rows() const { return m_nr; }
00047                 inline unsigned int cols() const { return m_nc; }
00048                 
00049                 inline T * values() { return &m_data[0]; }
00050                 inline const T * values() const { return &m_data[0]; }          
00051                 
00052 };
00053 
00054 
00055 }
00056 
00057 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines