Closed SubMishMar closed 6 years ago
Why do you call sqrt
in the first place? Other than that, you probably need to insert a using std::sqrt
prior to its use.
I have tried std::sqrt, it does compile but the solver complains that the residual is not correct.
I use sqrt because I want to minimize x^2+3x+1 if I set the residual without sqrt, it will minimize x^2+3x+1 and it's not the same thing.
I use sqrt because I want to minimize x^2+3x+1 if I set the residual without sqrt, it will minimize x^2+3x+1 and it's not the same thing.
I'm sorry, but this does not make any sense.
@SubMishMar The nonlinear least squares minimizer cannot minimize arbitrary quadratic functions. It can only minimize functions that can be written as the sum of squares. If you want to minimize arbitrary functions, I recommend using the Gradient based solver.
@sandwichmaker Thanks for the clarification. Btw, Can I solve a linear system like Ax = b in ceres?
The tutorial lucidly explains how to minimize a simple quadratic function like 0.5(10-x)^2. But how can I do it for lets say 0.5(x^2 + 3*x + 1)? I modified the code as follows:
But I the following compilation error:
I understand that sqrt() normally doesnt take in templates as inputs but I dont know how to make this work. Any help will be appreciated. Thanks.