Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rectangular Jacobian matrices support #10

Closed
tversteeg opened this issue Jul 23, 2021 · 3 comments
Closed

Rectangular Jacobian matrices support #10

tversteeg opened this issue Jul 23, 2021 · 3 comments

Comments

@tversteeg
Copy link
Contributor

Thanks for the highly underrated library, it's very nice to use.

It would be nice to be able to return a non-square Jacobian matrix from the LeastSquaresProblem::jacobian() function. Whenever I try it I get a termination: WrongDimension("jacobian") as part of the report.

At least a mention of this limitation in the documentation would be nice.

Also, for my understanding: is this a mathematical limitation, a missing implementation, or am I doing something wrong?

@vadixidav
Copy link
Member

Thank you for reporting your issue. You should be able to use LeastSquaresProblem with non-square matrices, which is something we use it for in Rust CV, so if it is having an issue with non-square matrices right now then I will definitely look at that.

Before I do that, I would like you to double check something. Notably, you need to make sure that your residuals have M rows, your params have N rows, and your Jacobian is MxN (rows x colums). Our example in the documentation likely isn't clear on this since it uses a square matrix, so it could be more clear by using a non-square matrix in the documentation.

If you check the above and that all seems correct, let me know, and I can investigate further. If you have a code sample that fails, I would appreciate that as well, but simply verifying for me that those things are true should be helpful. Thanks!

@tversteeg
Copy link
Contributor Author

Thanks a lot, the problem was that the residuals I returned was the same size as the parameters. So I had 2 residuals, 2 parameters but a 2x1 Jacobian.

Maybe a message in the form of expected $x residuals but got $y would be better instead of the simple jacobian string that's returned currently?

@vadixidav
Copy link
Member

Opened #11 to improve this error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants