30 #ifndef MCL_3DL_NOISE_GENERATORS_MULTIVARIATE_NOISE_GENERATOR_H 31 #define MCL_3DL_NOISE_GENERATORS_MULTIVARIATE_NOISE_GENERATOR_H 37 #include <Eigen/Eigenvalues> 43 template <
typename FLT_TYPE>
48 using Matrix = Eigen::Matrix<FLT_TYPE, Eigen::Dynamic, Eigen::Dynamic>;
49 using Vector = Eigen::Matrix<FLT_TYPE, Eigen::Dynamic, 1>;
51 template <
typename MEAN_TYPE,
typename COV_TYPE>
56 for (
int i = 0; i <
mean_vec_.size(); ++i)
63 template <
typename COV_TYPE>
67 Matrix cov_matrix(dim, dim);
68 for (
size_t i = 0; i < dim; ++i)
70 for (
size_t j = 0; j < dim; ++j)
72 cov_matrix(i, j) = covariance[j + i * dim];
75 const Eigen::SelfAdjointEigenSolver<Matrix> eigen_solver(cov_matrix);
76 norm_transform_ = eigen_solver.eigenvectors() * eigen_solver.eigenvalues().cwiseSqrt().asDiagonal();
79 template <
typename RANDOM_ENGINE>
80 std::vector<FLT_TYPE>
operator()(RANDOM_ENGINE& engine)
const 84 std::normal_distribution<FLT_TYPE> nd(0.0, 1.0);
85 for (
size_t j = 0; j < dim; ++j)
87 random[j] = nd(engine);
90 return std::vector<FLT_TYPE>(sample_noise.data(), sample_noise.data() + dim);
100 #endif // MCL_3DL_NOISE_GENERATORS_MULTIVARIATE_NOISE_GENERATOR_H std::vector< FLT_TYPE > operator()(RANDOM_ENGINE &engine) const
std::vector< FLT_TYPE > mean_
Eigen::Matrix< FLT_TYPE, Eigen::Dynamic, Eigen::Dynamic > Matrix
size_t getDimension() const
Eigen::Matrix< FLT_TYPE, Eigen::Dynamic, 1 > Vector
MultivariateNoiseGenerator(const MEAN_TYPE &mean, const COV_TYPE &covariance)
void setMean(const T &mean)
void setCovariance(const COV_TYPE &covariance)
IMETHOD void random(Vector &a)