9 void pinv(
const Eigen::MatrixXd& matrix_in, Eigen::MatrixXd& pseudo_inv,
10 const double& pinvtoler) {
11 Eigen::JacobiSVD<Eigen::MatrixXd> svd(
12 matrix_in, Eigen::ComputeThinU | Eigen::ComputeThinV);
13 Eigen::VectorXd singular_values;
14 Eigen::VectorXd singular_values_inv;
15 singular_values = svd.singularValues();
16 singular_values_inv.setZero(singular_values.size());
18 for (
int w = 0; w < singular_values.size(); ++w)
19 if (singular_values(w) > pinvtoler)
20 singular_values_inv(w) = 1 / singular_values(w);
21 pseudo_inv = svd.matrixV() * singular_values_inv.asDiagonal() *
22 svd.matrixU().transpose();
28 : order_(order), N_(N), dt_(dt), dt_zero_(true), first_run_(true), pt_(0) {
42 const std::vector<double>& el,
52 for (
unsigned int i = 0; i < esteem.size(); ++i) esteem.at(i) = el[i];
65 for (
unsigned int j = 0; j <
N_; ++j) {
67 if (idx >=
N_) idx = idx -
N_;
76 for (
unsigned int i = 0; i < dim; ++i) {
78 for (
unsigned int j = 0; j <
N_; ++j) {
80 if (idx >=
N_) idx = idx -
N_;
92 for (
unsigned int i = 0; i <
N_; ++i) {
96 for (
unsigned int j = 1; j <=
order_; ++j) {
101 Eigen::Map<Eigen::VectorXd> ytemp(&
x_[0],
N_, 1);
102 coeff_ =
R_.householderQr().solve(ytemp);
unsigned int N_
Window length.
unsigned int getWindowLength()
std::vector< double > time_list_
Time vector corresponding to each element in elem_list_.
double dt_
Sampling (control) time.
bool dt_zero_
Indicate that dt is zero (dt is invalid)
Eigen::VectorXd coeff_
Coefficients for the least squares solution.
void setWindowLength(const unsigned int &N)
unsigned int order_
Order of the polynomial estimator.
PolyEstimator(const unsigned int &order, const unsigned int &N, const double &dt)
unsigned int pt_
Circular index to each data and time element.
std::vector< double > t_
Time vector setting the lowest time to zero (for numerical stability).
void estimate(std::vector< double > &estimee, const std::vector< double > &data_element, const double &time)
virtual double getEsteeme()=0
std::vector< std::vector< double > > elem_list_
All the data (N elements of size dim)
void pinv(const Eigen::MatrixXd &matrix_in, Eigen::MatrixXd &pseudo_inv, const double &pinvtoler)