Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
drwnLinearTransform.h
1 /******************************************************************************
2 ** DARWIN: A FRAMEWORK FOR MACHINE LEARNING RESEARCH AND DEVELOPMENT
3 ** Distributed under the terms of the BSD license (see the LICENSE file)
4 ** Copyright (c) 2007-2015, Stephen Gould
5 ** All rights reserved.
6 **
7 ******************************************************************************
8 ** FILENAME: drwnLinearTransform.h
9 ** AUTHOR(S): Stephen Gould <stephen.gould@anu.edu.au>
10 ** Jiecheng Zhao <u5143437@anu.edu.au>
11 **
12 *****************************************************************************/
13 
14 #pragma once
15 
16 #include <vector>
17 #include <limits>
18 
19 #include "Eigen/Core"
20 
21 #include "drwnBase.h"
22 #include "drwnML.h"
23 
24 using namespace std;
25 using namespace Eigen;
26 
27 // drwnLinearTransform class ------------------------------------------------------
45 
47  private:
48  VectorXd _mu;
49  MatrixXd _projection;
50 
51  public:
55  drwnLinearTransform(const VectorXd& mu, const MatrixXd& projection);
59 
60  // access functions
61  const char *type() const { return "drwnLinearTransform"; }
62  drwnLinearTransform *clone() const { return new drwnLinearTransform(*this); }
63 
65  void set(const VectorXd& mu, const MatrixXd& projection);
67  void set(const MatrixXd& projection);
69  const VectorXd &translation() const { return _mu; }
71  const MatrixXd &projection() const { return _projection; }
72 
73  // i/o
74  void clear();
75  bool save(drwnXMLNode& node) const;
76  bool load(drwnXMLNode& node);
77 
78  // input/output size
80  int numInputs() const { return _projection.cols(); }
82  int numOutputs() const { return _projection.rows(); }
83 
84  // evaluation
86  void transform(const vector<double>& x, vector<double>& y) const;
87 };
int numInputs() const
feature vector size for the input space
Definition: drwnLinearTransform.h:80
Implements the interface for a generic feature transforms possibly with learned parameters, e.g., PCA (unsupervised) or LDA (supervised).
Definition: drwnFeatureTransform.h:31
virtual void transform(vector< double > &x) const
transforms a feature vector in-place
Definition: drwnFeatureTransform.cpp:57
const VectorXd & translation() const
get the translation vector
Definition: drwnLinearTransform.h:69
const char * type() const
returns object type as a string (e.g., Foo::type() { return "Foo"; })
Definition: drwnLinearTransform.h:61
int numOutputs() const
feature vector size for the output space
Definition: drwnLinearTransform.h:82
Implements a linear feature transform with externally settable parameters.
Definition: drwnLinearTransform.h:46
const MatrixXd & projection() const
get the projection matrix
Definition: drwnLinearTransform.h:71
drwnLinearTransform * clone() const
returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); } ...
Definition: drwnLinearTransform.h:62