Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mblum committed Jul 16, 2013
2 parents 4ca0f7a + 228e997 commit 019e42d
Show file tree
Hide file tree
Showing 56 changed files with 932 additions and 3,670 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Created by Manuel Blum on 2011-05-25.
# Copyright 2011 University of Freiburg.
# Copyright 2013 University of Freiburg.

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(libgp CXX C)

# if no option is given, standard is release
IF(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release)
ENDIF(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)

set(CMAKE_CXX_FLAGS_RELEASE "-DCLSQUARE -Wall -O2")
set(CMAKE_CXX_FLAGS_DEBUG "-DCLSQUARE -Wall -g")

PROJECT(libgp CXX C)
set(CMAKE_CXX_FLAGS_RELEASE "-DCLSQUARE -Wall -O2 -fPIC")
set(CMAKE_CXX_FLAGS_DEBUG "-DCLSQUARE -Wall -g -fPIC")

OPTION(BUILD_TESTS "Build tests" ON)
OPTION(BUILD_EXAMPLES "Build examples" ON)
Expand Down
12 changes: 8 additions & 4 deletions Sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ SET(LIBGP_SRC
src/cov_matern3_iso.cc
src/cov_matern5_iso.cc
src/cov_noise.cc
src/cov_rbf_cs.cc
src/cov_rq_iso.cc
src/cov_periodic_matern3_iso.cc
src/cov_se_ard.cc
src/cov_se_iso.cc
src/cov_sum.cc
src/cov_prod.cc
src/gp.cc
#src/gp_sparse.cc
src/gp_utils.cc
src/sampleset.cc
src/rprop.cc
src/input_dim_filter.cc
src/cg.cc
)

SET(LIBGP_INTERFACES
Expand All @@ -26,14 +28,16 @@ SET(LIBGP_INTERFACES
include/cov_matern3_iso.h
include/cov_matern5_iso.h
include/cov_noise.h
include/cov_rbf_cs.h
include/cov_rq_iso.h
include/cov_periodic_matern3_iso.h
include/cov_se_ard.h
include/cov_se_iso.h
include/cov_sum.h
include/cov_prod.h
include/gp.h
#include/gp_sparse.h
include/gp_utils.h
include/sampleset.h
include/rprop.h
include/input_dim_filter.h
include/cg.h
)
4 changes: 4 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# libgp - Gaussian process library for Machine Learning
# Copyright (c) 2013, Manuel Blum <[email protected]>
# All rights reserved.

ADD_EXECUTABLE(gpdense gp_example_dense.cc)
TARGET_LINK_LIBRARIES(gpdense gp)
2 changes: 1 addition & 1 deletion examples/gp_example_dense.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// libgp - Gaussian process library for Machine Learning
// Copyright (c) 2011, Manuel Blum <[email protected]>
// Copyright (c) 2013, Manuel Blum <[email protected]>
// All rights reserved.

#include "gp.h"
Expand Down
44 changes: 0 additions & 44 deletions examples/gp_example_sparse.cc

This file was deleted.

26 changes: 26 additions & 0 deletions include/cg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* cg.h
*
* Created on: Feb 22, 2013
* Author: Joao Cunha <[email protected]>
*/

#ifndef CG_H_
#define CG_H_

#include "gp.h"

namespace libgp
{

class CG
{
public:
CG();
virtual ~CG();
void maximize(GaussianProcess* gp, size_t n=100, bool verbose=1);
};

}

#endif /* CG_H_ */
175 changes: 87 additions & 88 deletions include/cov.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// libgp - Gaussian process library for Machine Learning
// Copyright (c) 2011, Manuel Blum <[email protected]>
// Copyright (c) 2013, Manuel Blum <[email protected]>
// All rights reserved.

#ifndef __COV_H__
Expand All @@ -13,94 +13,93 @@
namespace libgp
{

/** Covariance function base class.
* @author Manuel Blum
* @ingroup cov_group
* @todo implement more covariance functions */
class CovarianceFunction
{
public:
/** Constructor. */
CovarianceFunction() {};

/** Destructor. */
virtual ~CovarianceFunction() {};

/** Initialization method for atomic covariance functions.
* @param input_dim dimensionality of the input vectors */
virtual bool init(int input_dim)
{
return false;
};
/** Covariance function base class.
* @author Manuel Blum
* @ingroup cov_group
* @todo implement more covariance functions */
class CovarianceFunction
{
public:
/** Constructor. */
CovarianceFunction() {};

/** Destructor. */
virtual ~CovarianceFunction() {};

/** Initialization method for atomic covariance functions.
* @param input_dim dimensionality of the input vectors */
virtual bool init(int input_dim)
{
return false;
};

/** Initialization method for compound covariance functions.
* @param input_dim dimensionality of the input vectors
* @param first first covariance function of compound
* @param second second covariance function of compound */
virtual bool init(int input_dim, CovarianceFunction * first, CovarianceFunction * second)
{
return false;
};

virtual bool init(int input_dim, int filter, CovarianceFunction * covf)
{
return false;
};

/** Computes the covariance of two input vectors.
* @param x1 first input vector
* @param x2 second input vector
* @return covariance of x1 and x2 */
virtual double get(const Eigen::VectorXd &x1, const Eigen::VectorXd &x2) = 0;

/** Covariance gradient of two input vectors with respect to the hyperparameters.
* @param x1 first input vector
* @param x2 second input vector
* @param grad covariance gradient */
virtual void grad(const Eigen::VectorXd &x1, const Eigen::VectorXd &x2, Eigen::VectorXd &grad) = 0;

/** Update parameter vector.
* @param p new parameter vector */
virtual void set_loghyper(const Eigen::VectorXd &p);

/** Update parameter vector.
* @param p new parameter vector */
virtual void set_loghyper(const double p[]);

/** Get number of parameters for this covariance function.
* @return parameter vector dimensionality */
size_t get_param_dim();

/** Get input dimensionality.
* @return input dimensionality */
size_t get_input_dim();

/** Get log-hyperparameter of covariance function.
* @return log-hyperparameter */
Eigen::VectorXd get_loghyper();

/** Returns a string representation of this covariance function.
* @return string containing the name of this covariance function */
virtual std::string to_string() = 0;

/** Draw random target values from this covariance function for input X. */
Eigen::VectorXd draw_random_sample(Eigen::MatrixXd &X);

bool loghyper_changed;

protected:
/** Input dimensionality. */
size_t input_dim;

/** Size of parameter vector. */
size_t param_dim;

/** Parameter vector containing the log hyperparameters of the covariance function.
* The number of necessary parameters is given in param_dim. */
Eigen::VectorXd loghyper;

/** Initialization method for compound covariance functions.
* @param input_dim dimensionality of the input vectors
* @param first first covariance function of compound
* @param second second covariance function of compound */
virtual bool init(int input_dim, CovarianceFunction * first, CovarianceFunction * second)
{
return false;
};

/** Computes the covariance of two input vectors.
* @param x1 first input vector
* @param x2 second input vector
* @return covariance of x1 and x2 */
virtual double get(const Eigen::VectorXd &x1, const Eigen::VectorXd &x2) = 0;

/** Covariance gradient of two input vectors with respect to the hyperparameters.
* @param x1 first input vector
* @param x2 second input vector
* @param grad covariance gradient */
virtual void grad(const Eigen::VectorXd &x1, const Eigen::VectorXd &x2, Eigen::VectorXd &grad) = 0;

/** Update parameter vector.
* @param p new parameter vector */
virtual void set_loghyper(const Eigen::VectorXd &p);

/** Update parameter vector.
* @param p new parameter vector */
virtual void set_loghyper(const double p[]);

/** Get number of parameters for this covariance function.
* @return parameter vector dimensionality */
size_t get_param_dim();

/** Get input dimensionality.
* @return input dimensionality */
size_t get_input_dim();

/** Get log-hyperparameter of covariance function.
* @return log-hyperparameter */
Eigen::VectorXd get_loghyper();

/** Returns a string representation of this covariance function.
* @return string containing the name of this covariance function */
virtual std::string to_string() = 0;

/** Draw random target values from this covariance function for input X. */
Eigen::VectorXd draw_random_sample(Eigen::MatrixXd &X);

/** Get distance threshold of this covariance function. */
virtual double get_threshold();

/** Set distance threshold of this covariance function. */
virtual void set_threshold(double threshold);

bool loghyper_changed;

protected:
/** Input dimensionality. */
size_t input_dim;

/** Size of parameter vector. */
size_t param_dim;

/** Parameter vector containing the log hyperparameters of the covariance function.
* The number of necessary parameters is given in param_dim. */
Eigen::VectorXd loghyper;

};
};

}

Expand Down
2 changes: 1 addition & 1 deletion include/cov_factory.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// libgp - Gaussian process library for Machine Learning
// Copyright (c) 2011, Manuel Blum <[email protected]>
// Copyright (c) 2013, Manuel Blum <[email protected]>
// All rights reserved.

#ifndef __COV_FACTORY_H__
Expand Down
2 changes: 1 addition & 1 deletion include/cov_linear_ard.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// libgp - Gaussian process library for Machine Learning
// Copyright (c) 2011, Manuel Blum <[email protected]>
// Copyright (c) 2013, Manuel Blum <[email protected]>
// All rights reserved.

#ifndef __COV_LINEAR_ARD_H__
Expand Down
2 changes: 1 addition & 1 deletion include/cov_linear_one.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// libgp - Gaussian process library for Machine Learning
// Copyright (c) 2011, Manuel Blum <[email protected]>
// Copyright (c) 2013, Manuel Blum <[email protected]>
// All rights reserved.

#ifndef __COV_LINEAR_ONE__
Expand Down
2 changes: 1 addition & 1 deletion include/cov_matern3_iso.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// libgp - Gaussian process library for Machine Learning
// Copyright (c) 2011, Manuel Blum <[email protected]>
// Copyright (c) 2013, Manuel Blum <[email protected]>
// All rights reserved.

#ifndef __COV_MATERN3_ISO_H__
Expand Down
2 changes: 1 addition & 1 deletion include/cov_matern5_iso.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// libgp - Gaussian process library for Machine Learning
// Copyright (c) 2011, Manuel Blum <[email protected]>
// Copyright (c) 2013, Manuel Blum <[email protected]>
// All rights reserved.

#ifndef __COV_MATERN5_ISO_H__
Expand Down
2 changes: 1 addition & 1 deletion include/cov_noise.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// libgp - Gaussian process library for Machine Learning
// Copyright (c) 2011, Manuel Blum <[email protected]>
// Copyright (c) 2013, Manuel Blum <[email protected]>
// All rights reserved.

#ifndef __COV_NOISE_H__
Expand Down
Loading

0 comments on commit 019e42d

Please sign in to comment.