kmatrix.hpp

Go to the documentation of this file.
00001 // This file is part of kfilter.
00002 // kfilter is a C++ variable-dimension extended kalman filter library.
00003 //
00004 // Copyright (C) 2004        Vincent Zalzal, Sylvain Marleau
00005 // Copyright (C) 2001, 2004  Richard Gourdeau
00006 // Copyright (C) 2004        GRPR and DGE's Automation sector
00007 //                           École Polytechnique de Montréal
00008 //
00009 // Code adapted from algorithms presented in :
00010 //      Bierman, G. J. "Factorization Methods for Discrete Sequential
00011 //      Estimation", Academic Press, 1977.
00012 //
00013 // This library is free software; you can redistribute it and/or
00014 // modify it under the terms of the GNU Lesser General Public
00015 // License as published by the Free Software Foundation; either
00016 // version 2.1 of the License, or (at your option) any later version.
00017 //
00018 // This library is distributed in the hope that it will be useful,
00019 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021 // Lesser General Public License for more details.
00022 //
00023 // You should have received a copy of the GNU Lesser General Public
00024 // License along with this library; if not, write to the Free Software
00025 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 
00027 #ifndef KMATRIX_HPP
00028 #define KMATRIX_HPP
00029 
00032 
00033 #include <vector>
00034 #include <string>
00035 #include <iostream>
00036 
00037 #include "kalman/ktypes.hpp"
00038 
00039 namespace Kalman {
00040 
00042 
00071   template<typename T, K_UINT_32 BEG, bool DBG>
00072   class KMatrix {
00073   public:
00074 
00075     typedef T type;          
00076 
00077     enum { beg = BEG         
00078     };
00079 
00081 
00082 
00084     inline KMatrix();
00085 
00087     inline KMatrix(K_UINT_32 m, K_UINT_32 n);
00088 
00090     inline KMatrix(K_UINT_32 m, K_UINT_32 n, const T& a);
00091 
00093     inline KMatrix(K_UINT_32 m, K_UINT_32 n, const T* v);
00094 
00096     inline KMatrix(const KMatrix& M);
00097 
00099     inline ~KMatrix();
00100 
00102 
00104 
00105 
00107     inline T& operator()(K_UINT_32 i, K_UINT_32 j);
00108 
00110     inline const T& operator()(K_UINT_32 i, K_UINT_32 j) const;
00111 
00113     inline K_UINT_32 nrow() const;
00114 
00116     inline K_UINT_32 ncol() const;
00117 
00119 
00121     inline void resize(K_UINT_32 m, K_UINT_32 n);
00122 
00124     inline KMatrix& operator=(const T& a);
00125 
00127     inline KMatrix& operator=(const KMatrix& M);
00128 
00130     inline void assign(K_UINT_32 m, K_UINT_32 n, const T* v);
00131 
00133     inline void swap(KMatrix& M);
00134 
00136 
00137 
00139     inline void get(std::istream& is);
00140 
00142     inline void put(std::ostream& os) const;
00143 
00145 
00146   private:
00148 
00151     std::vector<T*> vimpl_;
00152     std::vector<T> Mimpl_;    
00153     
00155 
00160     T** M_;
00161     K_UINT_32 m_;             
00162     K_UINT_32 n_;             
00163 
00165     inline void init(K_UINT_32 m, K_UINT_32 n);
00166   };
00167 
00169   template<typename T, K_UINT_32 BEG, bool DBG>
00170   inline std::istream& operator>>(std::istream& is, 
00171                                   KMatrix<T, BEG, DBG>& M);
00172 
00174   template<typename T, K_UINT_32 BEG, bool DBG>
00175   inline std::ostream& operator<<(std::ostream& os, 
00176                                   const KMatrix<T, BEG, DBG>& M);
00177 
00179   typedef unsigned short KMatrixContext;
00180 
00182   extern KMatrixContext DEFAULT_MATRIX_CONTEXT;
00183 
00185   KMatrixContext createKMatrixContext(std::string elemDelim = " ", 
00186                                       std::string rowDelim = "\n",
00187                                       std::string startDelim = "", 
00188                                       std::string endDelim = "", 
00189                                       unsigned prec = 4);
00190 
00192   KMatrixContext selectKMatrixContext(KMatrixContext c);
00193 
00194 }
00195 
00196 #include "kalman/kmatrix_impl.hpp"
00197 
00198 #endif

Generated on Sat Jan 28 21:02:01 2006 for KFilter by  doxygen 1.4.5