I am trying to solve a system of linear equations in the least-squares-style. Using armadillo and its solve function I want to calculate the three coefficients of a parabolic fit.
vec coeffs = solve(CtC, Ctb)
with CtC=
1.0e+009 *
+--------------------------------+
| 2.0878 0.0221 0.0002 |
| 0.0221 0.0002 0.0000 |
| 0.0002 0.0000 0.0000 |
+--------------------------------+
and Ctb=
+------------+
| -0.6163 |
| -0.0065 |
| -0.0001 |
+------------+
Apparently solve() does not manage to solve it, even Matlab warns:
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate.
RCOND = 1.303968e-022.
Is there any workaround or a more powerful/sophisticated method in armadillo or c++ in general? Thanks