14 #include <Eigen/Cholesky>
17 using namespace Eigen;
22 const LinearMatrixComponent& linear_matrix_component,
23 const Ref<const MatrixXd>& noise_covariance_matrix,
24 const unsigned int seed
26 LTIMeasurementModel(MatrixXd::Zero(linear_matrix_component.second.size(), linear_matrix_component.first), noise_covariance_matrix),
27 generator_(std::mt19937_64(seed)),
28 distribution_(std::normal_distribution<double>(0.0, 1.0)),
29 gauss_rnd_sample_([&] {
return (distribution_)(generator_); })
31 for (std::size_t i = 0; i < linear_matrix_component.second.size(); ++i)
33 const std::size_t& component_index = linear_matrix_component.second[i];
35 if (component_index < linear_matrix_component.first)
36 H_(i, component_index) = 1.0;
38 throw std::runtime_error(std::string(
"ERROR::LINEARMODEL::CTOR\nERROR:\n\tIndex component out of bound.\nLOG:\n\tProvided: ") + std::to_string(component_index) +
". Index bound: " + std::to_string(linear_matrix_component.first) +
".");
41 LDLT<MatrixXd> chol_ldlt(R_);
42 sqrt_R_ = (chol_ldlt.transpositionsP() * MatrixXd::Identity(R_.rows(), R_.cols())).transpose() * chol_ldlt.matrixL() * chol_ldlt.vectorD().real().cwiseSqrt().asDiagonal();
46 LinearModel::LinearModel(
const LinearMatrixComponent& linear_matrix_component,
const Ref<const MatrixXd>& noise_covariance_matrix) :
47 LinearModel(linear_matrix_component, noise_covariance_matrix, 1)
53 MatrixXd rand_vectors(2, num);
54 for (
int i = 0; i < rand_vectors.size(); i++)
57 MatrixXd noise_sample =
sqrt_R_ * rand_vectors;
59 return std::make_pair(
true, std::move(noise_sample));
65 return std::make_pair(
true,
R_);