GestureRecognitionToolkit  Version: 1.0 Revision: 04-03-15
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
MatrixDouble.h
1 /*
2 GRT MIT License
3 Copyright (c) <2012> <Nicholas Gillian, Media Lab, MIT>
4 
5 Permission is hereby granted, free of charge, to any person obtaining a copy of this software
6 and associated documentation files (the "Software"), to deal in the Software without restriction,
7 including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
9 subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included in all copies or substantial
12 portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15 LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
18 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 */
20 
21 #ifndef GRT_MATRIX_DOUBLE_HEADER
22 #define GRT_MATRIX_DOUBLE_HEADER
23 
24 #include "Matrix.h"
25 #include "MinMax.h"
26 #include <iostream>
27 #include <string>
28 #include <vector>
29 #include <algorithm>
30 #include <cmath>
31 #include "DebugLog.h"
32 #include "ErrorLog.h"
33 #include "WarningLog.h"
34 #include "GRTTypedefs.h"
35 #include "FileParser.h"
36 #include "ErrorLog.h"
37 
38 using namespace std;
39 
40 namespace GRT{
41 
42 class MatrixDouble : public Matrix<double>{
43 public:
47  MatrixDouble();
48 
55  MatrixDouble(const unsigned int rows,const unsigned int cols);
56 
62  MatrixDouble(const MatrixDouble &rhs);
63 
69  MatrixDouble(const Matrix<double> &rhs);
70 
74  virtual ~MatrixDouble();
75 
82  MatrixDouble& operator=(const MatrixDouble &rhs);
83 
90  MatrixDouble& operator=(const Matrix<double> &rhs);
91 
98  MatrixDouble& operator=(const vector< VectorDouble > &rhs);
99 
107  //virtual bool resize(const unsigned int rows,const unsigned int cols);
108 
115  bool save(const string &filename) const;
116 
126  bool load(const string &filename,const char seperator = ',');
127 
134  bool saveToCSVFile(const string &filename) const;
135 
143  bool loadFromCSVFile(const string &filename,const char seperator = ',');
144 
151  bool print(const string title="") const;
152 
158  bool transpose();
159 
165  bool scale(const double minTarget,const double maxTarget);
166 
172  bool scale(const vector< MinMax > &ranges,const double minTarget,const double maxTarget);
173 
181  bool znorm(const double alpha = 0.001);
182 
188  MatrixDouble multiple(const double value) const;
189 
197  VectorDouble multiple(const VectorDouble &b) const;
198 
206  MatrixDouble multiple(const MatrixDouble &b) const;
207 
218  bool multiple(const MatrixDouble &a,const MatrixDouble &b,const bool aTranspose = false);
219 
229  bool add(const MatrixDouble &b);
230 
240  bool add(const MatrixDouble &a,const MatrixDouble &b);
241 
249  bool subtract(const MatrixDouble &b);
250 
260  bool subtract(const MatrixDouble &a,const MatrixDouble &b);
261 
267  double getMinValue() const;
268 
274  double getMaxValue() const;
275 
281  VectorDouble getMean() const;
282 
288  VectorDouble getStdDev() const;
289 
295  MatrixDouble getCovarianceMatrix() const;
296 
302  std::vector< MinMax > getRanges() const;
303 
309  double getTrace() const;
310 
311 protected:
312 
313  double stringToDouble(const std::string &value){
314  std::stringstream s( value );
315  double d;
316  s >> d;
317  return d;
318  }
319 
320  WarningLog warningLog;
321  ErrorLog errorLog;
322 
323 };
324 
325 } //End of namespace GRT
326 
327 #endif //GRT_MATRIX_DOUBLE_HEADER
Definition: AdaBoost.cpp:25
The Matrix class is a basic class for storing any type of data. This class is a template and can ther...