Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
mppca.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#pragma once
9
11
12namespace momentum {
13
28template <typename T>
29struct MppcaT {
31 size_t d = 0;
32
34 size_t p = 0;
35
38 std::vector<std::string> names;
39
41 Eigen::MatrixX<T> mu;
42
45 std::vector<Eigen::MatrixX<T>> Cinv;
46
51 std::vector<Eigen::MatrixX<T>> L;
52
57 Eigen::VectorX<T> Rpre;
58
72 // TODO: Parameter is named `pi` here but `inPi` in the .cpp definition;
73 // align the names for clarity.
74 // TODO: `pi` is consumed only to compute `Rpre` and is not retained as a
75 // member. Document this or expose `pi` directly so callers can recover
76 // mixture weights without inverting the precomputation.
77 void set(
78 const VectorX<T>& pi,
79 const MatrixX<T>& mmu,
81 const VectorX<T>& sigma2);
82
88 template <typename T2>
89 [[nodiscard]] MppcaT<T2> cast() const;
90
97 [[nodiscard]] bool isApprox(const MppcaT<T>& mppcaT) const;
98};
99
100} // namespace momentum
Eigen::Matrix< T, Dynamic, Dynamic > MatrixX
Dynamic-size, column-major dense matrix.
Definition types.h:80
Vector< T, Dynamic > VectorX
Dynamic-size column vector. Common return type for solver residuals and parameter vectors.
Definition types.h:207
gsl::span< T > span
Span type alias using gsl::span (C++17 fallback).
Definition span_compat.h:54
constexpr T pi() noexcept
Returns the mathematical constant pi.
Definition constants.h:50
Mixture of Probabilistic Principal Component Analyzers (MPPCA).
Definition mppca.h:29
void set(const VectorX< T > &pi, const MatrixX< T > &mmu, momentum::span< const MatrixX< T > > W, const VectorX< T > &sigma2)
Initializes the model from raw mixture parameters and precomputes Cinv, L, and Rpre for fast log-like...
Definition mppca.cpp:17
std::vector< Eigen::MatrixX< float > > L
Definition mppca.h:51
std::vector< Eigen::MatrixX< float > > Cinv
Definition mppca.h:45
bool isApprox(const MppcaT< T > &mppcaT) const
Returns true if every member matches mppcaT exactly (d, p, names) or approximately (mu,...
Definition mppca.cpp:128
MppcaT< T2 > cast() const
Returns a copy of this model with all numeric data converted to scalar type T2.
Definition mppca.cpp:113
Eigen::VectorX< float > Rpre
Definition mppca.h:57
std::vector< std::string > names
Definition mppca.h:38
Eigen::MatrixX< float > mu
Definition mppca.h:41