MNE-CPP  beta 1.0
fixdictmp.h
1 //=============================================================================================================
39 #ifndef FIXDICTMP_H
40 #define FIXDICTMP_H
41 
42 //*************************************************************************************************************
43 //=============================================================================================================
44 // STL INCLUDES
45 //=============================================================================================================
46 
47 #include <iostream>
48 #include <vector>
49 #include <math.h>
50 
51 //*************************************************************************************************************
52 //=============================================================================================================
53 // Utils INCLUDES
54 //=============================================================================================================
55 
56 #include <utils/mp/atom.h>
57 #include <utils/mp/adaptivemp.h>
58 #include <utils/utils_global.h>
59 
60 //*************************************************************************************************************
61 //=============================================================================================================
62 // Eigen INCLUDES
63 //=============================================================================================================
64 
65 #include <Eigen/Core>
66 #include <Eigen/SparseCore>
67 #include <unsupported/Eigen/FFT>
68 
69 //*************************************************************************************************************
70 //=============================================================================================================
71 // QT INCLUDES
72 //=============================================================================================================
73 
74 #include <QThread>
75 #include <QtConcurrent/QtConcurrent>
76 #include <QFuture>
77 #include <QFile>
78 #include <QStringList>
79 #include <QtXml/QtXml>
80 
81 //*************************************************************************************************************
82 //=============================================================================================================
83 // DEFINE NAMESPACE UTILSLIB
84 //=============================================================================================================
85 
86 namespace UTILSLIB
87 {
88 
89 //*************************************************************************************************************
90 //=============================================================================================================
91 // USED NAMESPACES
92 //=============================================================================================================
93 
94 using namespace Eigen;
95 using namespace std;
96 
97 //*************************************************************************************************************
98 
99 
101 {
102 
103 public:
104 
105  //=========================================================================================================
116  Dictionary();
117  //=========================================================================================================
128  ~Dictionary();
129  //=========================================================================================================
130 
131  QList<FixDictAtom> atoms;
132  AtomType type;
133  QString source;
134  QString atom_formula;
135  qint32 sample_count;
136 
137  qint32 atom_count();
138 
139  void clear();
140 
141 };//class
142 
143 
149 class UTILSSHARED_EXPORT FixDictMp : public QThread
150 {
151  Q_OBJECT
152 
153 public:
154 
155  typedef Eigen::VectorXd VectorXd;
156  typedef Eigen::MatrixXd MatrixXd;
157  typedef QList<GaborAtom> adaptive_atom_list;
158  typedef QList<FixDictAtom> fix_dict_atom_list;
159 
160  qreal signal_energy;
161  qreal current_energy;
162  qreal epsilon;
163  qint32 it;
164  qint32 max_iterations;
165  MatrixXd residuum;
166  QList<FixDictAtom> fix_dict_list;
167  QList<GaborAtom> adaptive_list;
168 
169  //=========================================================================================================
180  FixDictMp();
181  //=========================================================================================================
192  ~FixDictMp();
193 
194  //=========================================================================================================
195 
196  FixDictAtom correlation(Dictionary current_pdict, MatrixXd current_resid, qint32 boost);
197 
198  //=========================================================================================================
199 
200  //static void create_tree_dict(QString save_path);
201 
202  //=========================================================================================================
203 
204  //qreal create_molecules(VectorXd compare_atom, qreal phase, qreal modulation, quint32 translation, qint32 sample_count, GaborAtom* gabor_Atom, qreal scale);
205 
206  //=========================================================================================================
207 
209  {
210  Dictionary pdict;
211  MatrixXd current_resid;
212  qint32 boost;
213 
214  FixDictAtom parallel_correlation() const
215  {
216  FixDictAtom best_matching;
217  FixDictMp fix_dict_mp;
218  best_matching = fix_dict_mp.correlation(this->pdict, this->current_resid, this->boost);
219  return best_matching;
220  }
221  };
222 
223  QList<Dictionary> parse_xml_dict(QString path);
224 
225  //=========================================================================================================
226 
227  Dictionary fill_dict(const QDomNode &pdict);
228 
229  //=========================================================================================================
230 
231  QString create_display_text(FixDictAtom global_best_matching);
232 
233  //=========================================================================================================
234 
235  //static void build_molecule_xml_file(qint32 level_counter);
236 
237 
238 public slots:
239 
240  void matching_pursuit(MatrixXd signal, qint32 max_iterations, qreal epsilon, qint32 boost, QString path, qreal delta);
241  void recieve_input(MatrixXd signal, qint32 max_iterations, qreal epsilon, qint32 boost, QString path, qreal delta);
242 
243  //=========================================================================================================
244 
245 signals:
246 
247  void current_result(qint32 current_iteration, qint32 max_iteration, qreal current_energy, qreal max_energy, MatrixXd residuum,
248  adaptive_atom_list adaptive_atom_list, fix_dict_atom_list fix_dict_atom_list);
249 
250  void finished_calc();
251  void parse_in_thread();
252  void send_warning(qint32 warning);
253 
254 };//class
255 
256 //=========================================================================================================
257 
259 {
260  QDomNode node;
261 
262  Dictionary fill_dict_in_map() const
263  {
264  Dictionary add_to_map;
265  FixDictMp fix_dict_mp;
266  add_to_map = fix_dict_mp.fill_dict(this->node);
267  return add_to_map;
268  }
269 };
270 
271 //=========================================================================================================
272 
273 
274 
275 }//NAMESPACE
276 
277 #endif // FIXDICTMP_H
#define UTILSSHARED_EXPORT
Definition: utils_global.h:57
ADAPIVEMP class declaration, providing the implemetation of the Matching Pursuit Algorithm introduced...
FixDictAtom used in fix dict MP Algorithm.
Definition: atom.h:123
utils library export/import macros.
The fixdictMP class provides functions several calculating functions to run the Matching Pursuit Algo...
Definition: fixdictmp.h:149
ATOM class declaration, providing core features and parameters of Atoms used in Matching Pursiut Algo...