9 #ifndef transform_gaussian_H 10 #define transform_gaussian_H 38 template <
class VECTORLIKE1,
class MATLIKE1,
class USERPARAM,
class VECTORLIKE2,
class VECTORLIKE3,
class MATLIKE2>
40 const VECTORLIKE1 &x_mean,
41 const MATLIKE1 &x_cov,
42 void (*functor)(
const VECTORLIKE1 &
x,
const USERPARAM &fixed_param, VECTORLIKE3 &
y),
43 const USERPARAM &fixed_param,
46 const bool *elem_do_wrap2pi = NULL,
47 const double alpha = 1e-3,
49 const double beta = 2.0
53 const size_t Nx = x_mean.size();
55 const double c = Nx+lambda;
58 const double Wi = 0.5/
c;
59 std::vector<double> W_mean(1+2*Nx,Wi),W_cov(1+2*Nx,Wi);
65 const bool valid = x_cov.chol(L);
66 if (!valid)
throw std::runtime_error(
"transform_gaussian_unscented: Singular covariance matrix in Cholesky.");
72 VECTORLIKE1 X = x_mean;
73 functor(X,fixed_param,Y[0]);
77 for (
size_t i=0;i<Nx;i++)
79 L.extractRowAsCol(i,delta);
81 functor(X,fixed_param,Y[
row++]);
83 functor(X,fixed_param,Y[
row++]);
97 template <
class VECTORLIKE1,
class MATLIKE1,
class USERPARAM,
class VECTORLIKE2,
class VECTORLIKE3,
class MATLIKE2>
99 const VECTORLIKE1 &x_mean,
100 const MATLIKE1 &x_cov,
101 void (*functor)(
const VECTORLIKE1 &
x,
const USERPARAM &fixed_param,VECTORLIKE3 &
y),
102 const USERPARAM &fixed_param,
105 const size_t num_samples = 1000,
113 for (
size_t i=0;i<num_samples;i++)
114 functor(samples_x[i],fixed_param,samples_y[i]);
116 if (out_samples_y) { out_samples_y->clear(); samples_y.swap(*out_samples_y); }
126 template <
class VECTORLIKE1,
class MATLIKE1,
class USERPARAM,
class VECTORLIKE2,
class VECTORLIKE3,
class MATLIKE2>
128 const VECTORLIKE1 &x_mean,
129 const MATLIKE1 &x_cov,
130 void (*functor)(
const VECTORLIKE1 &
x,
const USERPARAM &fixed_param,VECTORLIKE3 &
y),
131 const USERPARAM &fixed_param,
134 const VECTORLIKE1 &x_increments
139 functor(x_mean,fixed_param,y_mean);
141 Eigen::Matrix<double,VECTORLIKE3::RowsAtCompileTime,VECTORLIKE1::RowsAtCompileTime> H;
143 H.multiply_HCHt(x_cov, y_cov);
GLclampf GLclampf GLclampf alpha
BASE_IMPEXP CRandomGenerator randomGenerator
A static instance of a CRandomGenerator class, for use in single-thread applications.
This file implements miscelaneous matrix and matrix/vector operations, and internal functions in mrpt...
void drawGaussianMultivariateMany(VECTOR_OF_VECTORS &ret, size_t desiredSamples, const COVMATRIX &cov, const typename VECTOR_OF_VECTORS::value_type *mean=NULL)
Generate a given number of multidimensional random samples according to a given covariance matrix...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLenum GLenum GLvoid * row
void covariancesAndMeanWeighted(const VECTOR_OF_VECTORS &elements, MATRIXLIKE &covariances, VECTORLIKE &means, const VECTORLIKE2 *weights_mean, const VECTORLIKE3 *weights_cov, const bool *elem_do_wrap2pi=NULL)
Computes covariances and mean of any vector of containers, given optional weights for the different s...
void jacob_numeric_estimate(const VECTORLIKE &x, void(*functor)(const VECTORLIKE &x, const USERPARAM &y, VECTORLIKE3 &out), const VECTORLIKE2 &increments, const USERPARAM &userParam, MATRIXLIKE &out_Jacobian)
Numerical estimation of the Jacobian of a user-supplied function - this template redirects to mrpt::m...
void covariancesAndMean(const VECTOR_OF_VECTORS &elements, MATRIXLIKE &covariances, VECTORLIKE &means, const bool *elem_do_wrap2pi=NULL)
Computes covariances and mean of any vector of containers.
std::vector< TYPE1, Eigen::aligned_allocator< TYPE1 > > vector_t