snark
gaussian_process.h
1 // This file is part of snark, a generic and flexible library
2 // for robotics research.
3 //
4 // Copyright (C) 2011 The University of Sydney
5 //
6 // snark is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 3 of the License, or (at your option) any later version.
10 //
11 // snark is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14 // for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with snark. If not, see <http://www.gnu.org/licenses/>.
18 
19 #ifndef SNARK_GAUSSIAN_PROCESS_
20 #define SNARK_GAUSSIAN_PROCESS_
21 
22 #include <boost/function.hpp>
23 #include <Eigen/Core>
24 #include <Eigen/Eigen>
25 
26 namespace snark{
27 
30 {
31  public:
33  typedef boost::function< double ( const Eigen::VectorXd&, const Eigen::VectorXd& ) > covariance;
34 
36  gaussian_process( const Eigen::MatrixXd& domains
37  , const Eigen::VectorXd& targets
39  , double self_covariance = 0 );
40 
42  void evaluate( const Eigen::MatrixXd& domains
43  , Eigen::VectorXd& means
44  , Eigen::VectorXd& variances ) const;
45 
47  std::pair< double, double > evaluate( const Eigen::MatrixXd& domain ) const;
48 
49  private:
50  Eigen::MatrixXd domains_;
51  Eigen::VectorXd targets_;
52  covariance covariance_;
53  double self_covariance_;
54  double offset_;
55  Eigen::MatrixXd K_;
56  Eigen::LLT< Eigen::MatrixXd > L_;
57  Eigen::VectorXd alpha_;
58 };
59 
60 } // namespace snark{
61 
62 #endif // #ifndef SNARK_GAUSSIAN_PROCESS_