36#ifdef SEPARATE_REGRESSION_RECONSTRUCTION
37 std::vector<std::vector<Projection>> projections;
41 Matrix parameters = Matrix::Zero(output.rows(), input.rows());
44 for (
int d = 0; d < output.rows(); d++)
47#ifdef SEPARATE_REGRESSION_RECONSTRUCTION
48 projections.push_back(std::vector<Projection>());
52 Vector output_d = output.row(d);
56 Matrix identity = Matrix::Identity(input.rows(), input.rows());
58 for (
int k = 0; k < input.rows(); k++)
61 Vector u = input_d * output_d;
62 Vector s = input_d.transpose() * u;
63 Real q = s.dot(output_d) / s.dot(s);
64 output_d = output_d -
q * s;
65 Real mean_error = output_d.array().abs().mean();
66 Vector p = (input_d * s) / (s.dot(s));
68 input_d = input_d - p * s.transpose();
70#ifdef SEPARATE_REGRESSION_RECONSTRUCTION
71 projections[d].push_back(Projection(p, u,
q));
75 s = identity.transpose() * u;
76 parameters.row(d) +=
q * s.transpose();
77 identity -= p * s.transpose();
80 if (mean_error < threshold)
Matrix KBM_IMPORT_EXPORT solve(const Matrix &input, const Matrix output, Real threshold)
Solves a linear system of equations using the partial least squares algorithm.