1 #ifndef HOPS_DEGENERATEMULTIVARIATEGAUSSIAN_HPP
2 #define HOPS_DEGENERATEMULTIVARIATEGAUSSIAN_HPP
4 #include <Eigen/Cholesky>
8 #define _USE_MATH_DEFINES
22 std::vector<long> inactive = std::vector<long>(0));
31 std::optional<MultivariateGaussian> gaussian;
32 std::vector<long> inactive;
34 void removeRow(Eigen::MatrixXd &matrix,
unsigned int rowToRemove)
const {
35 unsigned int numRows = matrix.rows() - 1;
36 unsigned int numCols = matrix.cols();
38 if (rowToRemove < numRows) {
39 matrix.block(rowToRemove, 0, numRows - rowToRemove, numCols) = matrix.bottomRows(numRows - rowToRemove);
42 matrix.conservativeResize(numRows, numCols);
45 void removeColumn(Eigen::MatrixXd &matrix,
unsigned int colToRemove)
const {
46 unsigned int numRows = matrix.rows();
47 unsigned int numCols = matrix.cols() - 1;
49 if (colToRemove < numCols) {
50 matrix.block(0, colToRemove, numRows, numCols - colToRemove) = matrix.rightCols(numCols - colToRemove);
53 matrix.conservativeResize(numRows, numCols);
56 void removeRow(Eigen::VectorXd &vector,
unsigned int rowToRemove)
const {
57 unsigned int numRows = vector.rows() - 1;
59 if (rowToRemove < numRows) {
60 vector.segment(rowToRemove, numRows - rowToRemove) = vector.tail(numRows - rowToRemove);
63 vector.conservativeResize(numRows);
66 void stripInactive(Eigen::MatrixXd &matrix)
const {
67 for (
auto &i : inactive) {
69 removeColumn(matrix, i);
73 void stripInactive(Eigen::VectorXd &vector)
const {
74 for (
auto &i : inactive) {
82 std::vector<long> inactive) :
83 inactive(std::move(inactive)) {
85 stripInactive(covariance);
93 return gaussian.value().computeNegativeLogLikelihood(_x);
96 std::optional<MatrixType>
99 return gaussian.value().computeExpectedFisherInformation(x);
102 std::optional<VectorType>
106 return gaussian.value().computeLogLikelihoodGradient(_x);
110 #endif //HOPS_DEGENERATEMULTIVARIATEGAUSSIAN_HPP