CEBL  2.1
IncrementalSVD.hpp
Go to the documentation of this file.
1 /*
2 * CEBL : CSU EEG Brain-Computer Interface Lab
3 *
4 * Author: Jeshua Bratman - jeshuabratman@gmail.com
5 *
6 * This file is part of CEBL.
7 *
8 * CEBL is free software; you can redistribute it and/or modify it.
9 * We only ask that if you use our code that you cite the source in
10 * your project or publication.
11 *
12 * EEG Group (www.cs.colostate.edu/eeg)
13 * Department of Computer Science
14 * Colorado State University
15 *
16 */
17 
18 #ifndef SVD_H
19 #define SVD_H
20 //relative to cebl source dir
21 #include "../model/Feature.hpp"
22 
23 namespace CEBL
24 {
25 
26  //return structure from svdUpdateRank
27  struct SVDState
28  {
29  ublas::matrix<double> U;
30  ublas::vector<double> s;
31  };
32 
33  //SVD feature
34 
35  class IncrementalSVD : public Feature
36  {
37  private:
38  int n_lags;
39 
40  ublas::matrix<double> buffer;
41  bool bufferEmpty;
42 
43  bool svd_state_set;
44  SVDState svd_state;
45  double lambda;
46 
48  ublas::matrix<double> ISVD(ublas::matrix<double> data);
49 
50  SVDState SVDUpdateRank(ublas::matrix<double> sample, SVDState state, double lambda);
51 
52  //PUBLIC
53  public:
55 
57  std::map<std::string, CEBL::Param> getParamsList();
58  void setParamsList( std::map<std::string, CEBL::Param> &);
59 
61  ublas::matrix<double> use(const ublas::matrix<double> &);
62 
64  void reset();
65 
66 
67  //saving and loading
68  map<string, SerializedObject> save() const;
69  void load(map<string, SerializedObject> objects);
70 
71  };
72 }
73 
74 #endif