9 #ifndef transform_gaussian_H 10 #define transform_gaussian_H 46 template <
class VECTORLIKE1,
class MATLIKE1,
class USERPARAM,
class VECTORLIKE2,
47 class VECTORLIKE3,
class MATLIKE2>
49 const VECTORLIKE1& x_mean,
const MATLIKE1& x_cov,
51 const VECTORLIKE1&
x,
const USERPARAM& fixed_param, VECTORLIKE3&
y),
52 const USERPARAM& fixed_param, VECTORLIKE2& y_mean, MATLIKE2& y_cov,
53 const bool* elem_do_wrap2pi =
nullptr,
const double alpha = 1e-3,
54 const double K = 0,
const double beta = 2.0)
57 const size_t Nx = x_mean.size();
58 const double lambda =
alpha *
alpha * (Nx + K) - Nx;
59 const double c = Nx + lambda;
62 const double Wi = 0.5 /
c;
63 std::vector<double> W_mean(1 + 2 * Nx, Wi), W_cov(1 + 2 * Nx, Wi);
64 W_mean[0] = lambda /
c;
65 W_cov[0] = W_mean[0] + (1 -
alpha *
alpha + beta);
69 const bool valid = x_cov.chol(L);
71 throw std::runtime_error(
72 "transform_gaussian_unscented: Singular covariance matrix in " 81 VECTORLIKE1 X = x_mean;
82 functor(X, fixed_param, Y[0]);
86 for (
size_t i = 0; i < Nx; i++)
88 L.extractRowAsCol(i, delta);
91 functor(X, fixed_param, Y[
row++]);
94 functor(X, fixed_param, Y[
row++]);
99 Y, y_cov, y_mean, &W_mean, &W_cov, elem_do_wrap2pi);
114 template <
class VECTORLIKE1,
class MATLIKE1,
class USERPARAM,
class VECTORLIKE2,
115 class VECTORLIKE3,
class MATLIKE2>
117 const VECTORLIKE1& x_mean,
const MATLIKE1& x_cov,
119 const VECTORLIKE1&
x,
const USERPARAM& fixed_param, VECTORLIKE3&
y),
120 const USERPARAM& fixed_param, VECTORLIKE2& y_mean, MATLIKE2& y_cov,
121 const size_t num_samples = 1000,
128 samples_x, num_samples, x_cov, &x_mean);
131 for (
size_t i = 0; i < num_samples; i++)
132 functor(samples_x[i], fixed_param, samples_y[i]);
136 out_samples_y->clear();
137 samples_y.swap(*out_samples_y);
152 template <
class VECTORLIKE1,
class MATLIKE1,
class USERPARAM,
class VECTORLIKE2,
153 class VECTORLIKE3,
class MATLIKE2>
155 const VECTORLIKE1& x_mean,
const MATLIKE1& x_cov,
157 const VECTORLIKE1&
x,
const USERPARAM& fixed_param, VECTORLIKE3&
y),
158 const USERPARAM& fixed_param, VECTORLIKE2& y_mean, MATLIKE2& y_cov,
159 const VECTORLIKE1& x_increments)
163 functor(x_mean, fixed_param, y_mean);
165 Eigen::Matrix<double, VECTORLIKE3::RowsAtCompileTime,
166 VECTORLIKE1::RowsAtCompileTime>
169 x_mean, std::function<
void(
170 const VECTORLIKE1&
x,
const USERPARAM& fixed_param,
171 VECTORLIKE3&
y)>(functor),
172 x_increments, fixed_param, H);
173 H.multiply_HCHt(x_cov, y_cov);
GLclampf GLclampf GLclampf alpha
This file implements miscelaneous matrix and matrix/vector operations, and internal functions in mrpt...
void jacob_numeric_estimate(const VECTORLIKE &x, std::function< void(const VECTORLIKE &x, const USERPARAM &y, VECTORLIKE3 &out)> functor, 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=nullptr)
Computes covariances and mean of any vector of containers.
void drawGaussianMultivariateMany(VECTOR_OF_VECTORS &ret, size_t desiredSamples, const COVMATRIX &cov, const typename VECTOR_OF_VECTORS::value_type *mean=nullptr)
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.
void covariancesAndMeanWeighted(const VECTOR_OF_VECTORS &elements, MATRIXLIKE &covariances, VECTORLIKE &means, const VECTORLIKE2 *weights_mean, const VECTORLIKE3 *weights_cov, const bool *elem_do_wrap2pi=nullptr)
Computes covariances and mean of any vector of containers, given optional weights for the different s...
GLenum GLenum GLvoid * row
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
std::vector< TYPE1, Eigen::aligned_allocator< TYPE1 > > vector_t