24 #ifndef _MEAN_ATOMIC_HPP_ 25 #define _MEAN_ATOMIC_HPP_ 27 #include <boost/numeric/ublas/vector_proxy.hpp> 41 virtual int init(
size_t input_dim)
46 void setParameters(
const vectord &theta)
48 if(theta.size() != n_params)
50 throw std::invalid_argument(
"Wrong number of mean function parameters");
55 vectord getParameters() {
return mParameters;};
56 size_t nParameters() {
return n_params;};
57 size_t nFeatures() {
return n_features;};
72 int init(
size_t input_dim)
79 double getMean (
const vectord& x) {
return 0.0; };
80 vectord getFeatures(
const vectord& x) {
return zvectord(1); };
87 int init(
size_t input_dim)
94 double getMean (
const vectord& x) {
return 1.0; };
95 vectord getFeatures(
const vectord& x) {
return svectord(1,1.0); };
104 int init(
size_t input_dim)
106 n_inputs = input_dim;
111 double getMean (
const vectord& x) {
return mParameters(0); };
112 vectord getFeatures(
const vectord& x) {
return svectord(1,1.0); };
121 int init(
size_t input_dim)
123 n_inputs = input_dim;
124 n_params = input_dim;
125 n_features = input_dim;
128 double getMean (
const vectord& x)
129 {
return boost::numeric::ublas::inner_prod(x,mParameters); };
130 vectord getFeatures(
const vectord& x) {
return x; };
139 int init(
size_t input_dim)
141 n_inputs = input_dim;
142 n_params = input_dim + 1;
143 n_features = input_dim + 1;
146 void setParameters(
const vectord& params)
148 if(params.size() != n_params)
150 throw std::invalid_argument(
"Wrong number of mean function parameters");
153 mConstParam = params(0);
154 mParameters = boost::numeric::ublas::project(params,
155 boost::numeric::ublas::range(1, params.size()));
158 double getMean (
const vectord& x)
159 {
return boost::numeric::ublas::inner_prod(x,mParameters) + mConstParam; };
161 vectord getFeatures(
const vectord& x)
163 using boost::numeric::ublas::range;
164 using boost::numeric::ublas::project;
165 vectord res(x.size()+1);
167 project(res,range(1,res.size())) = x;
Abstract class for an atomic kernel.
Namespace of the library interface.
Interface for mean functors.
Mean (parametric) functions.
Linear combination function.
Linear combination plus constant function.