test.cpp
Go to the documentation of this file.
1 #include "stdlib.h"
2 #include "stdio.h"
3 
4 #include "MFile.h"
5 #include "kalman/ktypes.hpp"
6 #include "kalman/kvector.hpp"
7 #include "kalman/kmatrix.hpp"
8 
9 using namespace Kalman;
10 using namespace std;
11 
12 int main()
13 {
14  MFile mfile;
15  int i,j;
16 
17  KVector<double, 1, true> T, tmpVec;
18  KMatrix<double, 1, true> ReperesX, tmpMat;
19 
20  // Matlab format
21  selectKVectorContext(createKVectorContext(" ", "[ ", " ];", 4));
22  selectKMatrixContext(createKMatrixContext(" ", " ;\n ", "[ ", " ];", 4));
23  mfile.read("test.m");
24 
25  mfile.print();
26 
27  mfile.get("T", T);
28 
29  mfile.get("ReperesX", ReperesX);
30 
31  cout<<T<<endl<<endl;
32 
33  cout<<ReperesX<<endl<<endl;
34 
35  tmpVec.resize(10);
36 
37  for(i=1; i<=10; i++)
38  {
39  tmpVec(i)=i;
40  }
41 
42  tmpMat.resize(2,5);
43 
44  for(i=1; i<=2; i++)
45  {
46  for(j=1; j<=5; j++)
47  {
48  tmpMat(i,j)=i*5+j;
49  }
50  }
51 
52  mfile.add("tmpVec", tmpVec);
53 
54  mfile.add("tmpVec2", tmpVec, COLUMN_VECTOR);
55 
56  mfile.add("tmpMat", tmpMat);
57 
58  mfile.print();
59 
60  mfile.save("test2.m");
61 
62  return 0;
63 }
#define COLUMN_VECTOR
Definition: MFile.h:40
KVectorContext createKVectorContext(std::string elemDelim=" ", std::string startDelim="", std::string endDelim="", unsigned prec=4)
Creates a vector printing context.
Definition: kstatics.cpp:85
void resize(K_UINT_32 n)
Resizes the vector. Resulting vector contents are undefined.
Minimalist vector template class.
Definition: kvector.hpp:72
int save(char *filename)
Definition: MFile.cpp:182
int get(std::string name, Kalman::KVector< T, BEG, DBG > &tmpvector)
Definition: MFile_impl.hpp:9
int read(char *filename)
Definition: MFile.cpp:45
int main()
Definition: test.cpp:12
KMatrixContext createKMatrixContext(std::string elemDelim=" ", std::string rowDelim="\n", std::string startDelim="", std::string endDelim="", unsigned prec=4)
Creates a matrix printing context.
Definition: kstatics.cpp:144
int add(std::string name, Kalman::KVector< T, BEG, DBG > &tmpvector, int type=ROW_VECTOR)
Definition: MFile_impl.hpp:74
KVectorContext selectKVectorContext(KVectorContext c)
Selects a vector printing context as the current context.
Definition: kstatics.cpp:103
void print()
Definition: MFile.cpp:159
void resize(K_UINT_32 m, K_UINT_32 n)
Resizes the matrix. Resulting matrix contents are undefined.
Minimalist matrix template class.
Definition: kmatrix.hpp:72
KMatrixContext selectKMatrixContext(KMatrixContext c)
Selects a matrix printing context as the current context.
Definition: kstatics.cpp:164


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