kvector.hpp
Go to the documentation of this file.
1 // This file is part of kfilter.
2 // kfilter is a C++ variable-dimension extended kalman filter library.
3 //
4 // Copyright (C) 2004 Vincent Zalzal, Sylvain Marleau
5 // Copyright (C) 2001, 2004 Richard Gourdeau
6 // Copyright (C) 2004 GRPR and DGE's Automation sector
7 // �cole Polytechnique de Montr�al
8 //
9 // Code adapted from algorithms presented in :
10 // Bierman, G. J. "Factorization Methods for Discrete Sequential
11 // Estimation", Academic Press, 1977.
12 //
13 // This library is free software; you can redistribute it and/or
14 // modify it under the terms of the GNU Lesser General Public
15 // License as published by the Free Software Foundation; either
16 // version 2.1 of the License, or (at your option) any later version.
17 //
18 // This library is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 // Lesser General Public License for more details.
22 //
23 // You should have received a copy of the GNU Lesser General Public
24 // License along with this library; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 
27 #ifndef KVECTOR_HPP
28 #define KVECTOR_HPP
29 
32 
33 #include <vector>
34 #include <string>
35 #include <iostream>
36 
37 #include <kfilter/ktypes.hpp>
38 
39 namespace Kalman {
40 
42 
71  template<typename T, K_UINT_32 BEG, bool DBG>
72  class KVector {
73  public:
74 
75  typedef T type;
76 
77  enum { beg = BEG
78  };
79 
81 
82 
84  inline KVector();
85 
87  inline explicit KVector(K_UINT_32 n);
88 
90  inline KVector(K_UINT_32 n, const T& a);
91 
93  inline KVector(K_UINT_32 n, const T* v);
94 
96  inline KVector(const KVector& v);
97 
99  inline ~KVector();
100 
102 
104 
105 
107  inline T& operator()(K_UINT_32 i);
108 
110  inline const T& operator()(K_UINT_32 i) const;
111 
113  inline K_UINT_32 size() const;
114 
116 
118  inline void resize(K_UINT_32 n);
119 
121  inline KVector& operator=(const T& a);
122 
124  inline KVector& operator=(const KVector& v);
125 
127  inline void assign(K_UINT_32 n, const T* v);
128 
130  inline void swap(KVector& v);
131 
133 
134 
136  inline void get(std::istream& is);
137 
139  inline void put(std::ostream& os) const;
140 
142 
143  private:
144  std::vector<T> vimpl_;
145 
147 
151  T* v_;
153  };
154 
156  template<typename T, K_UINT_32 BEG, bool DBG>
157  inline std::istream& operator>>(std::istream& is,
159 
161  template<typename T, K_UINT_32 BEG, bool DBG>
162  inline std::ostream& operator<<(std::ostream& os,
163  const KVector<T, BEG, DBG>& v);
164 
166  typedef unsigned short KVectorContext;
167 
170 
172  KVectorContext createKVectorContext(std::string elemDelim = " ",
173  std::string startDelim = "",
174  std::string endDelim = "",
175  unsigned prec = 4);
176 
179 }
180 
181 #include <kfilter/kvector_impl.hpp>
182 
183 #endif
void put(std::ostream &os) const
Writes a vector to a stream.
KVectorContext createKVectorContext(std::string elemDelim=" ", std::string startDelim="", std::string endDelim="", unsigned prec=4)
Creates a vector printing context.
Definition: kstatics.cpp:85
Starting index of vector, either 0 or 1.
Definition: kvector.hpp:77
void resize(K_UINT_32 n)
Resizes the vector. Resulting vector contents are undefined.
KVector & operator=(const T &a)
Assigns a copy of a to all elements of the vector.
Minimalist vector template class.
Definition: kvector.hpp:72
T type
Type of objects contained in the vector.
Definition: kvector.hpp:75
unsigned short KVectorContext
Handle type to a vector printing context.
Definition: kvector.hpp:166
Contains the implementation of the KVector template class.
T * v_
Pointer to start of vimpl_ array.
Definition: kvector.hpp:151
unsigned long int K_UINT_32
Unsigned 32-bits integral type.
Definition: ktypes.hpp:68
void swap(KVector &v)
Constant-time swap function between two vectors.
KVectorContext selectKVectorContext(KVectorContext c)
Selects a vector printing context as the current context.
Definition: kstatics.cpp:103
T & operator()(K_UINT_32 i)
Returns the i'th element.
KVectorContext DEFAULT_VECTOR_CONTEXT
Default vector printing context object.
Definition: kstatics.cpp:64
Contains type definitions specific to each platform.
K_UINT_32 n_
Number of elements in vimpl_.
Definition: kvector.hpp:152
std::ostream & operator<<(std::ostream &os, const KMatrix< T, BEG, DBG > &M)
Writes a matrix to a stream.
std::vector< T > vimpl_
Underlying vector implementation.
Definition: kvector.hpp:144
void assign(K_UINT_32 n, const T *v)
Copies an array of n instances of T.
K_UINT_32 size() const
Returns the vector size.
~KVector()
Destructor.
std::istream & operator>>(std::istream &is, KMatrix< T, BEG, DBG > &M)
Reads a matrix from a stream.
KVector()
Default constructor. Creates an empty vector.


kfilter
Author(s): Jorge Almeida, Vincent Zalzal, Sylvain Marleau, Richard Gourdeau
autogenerated on Mon Mar 2 2015 01:31:45