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

[FEATURE REQUEST] Least Squares solver #559

Open
furbrain opened this issue Nov 9, 2022 · 1 comment
Open

[FEATURE REQUEST] Least Squares solver #559

furbrain opened this issue Nov 9, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@furbrain
Copy link

furbrain commented Nov 9, 2022

I'd like to implement a least squares solver, similar to https://numpy.org/doc/stable/reference/generated/numpy.linalg.lstsq.html

I can do it now with the following

from ulab import numpy as np
from ulab import scipy as spy

# ... 
# generate our matrices a and b to solve, finding x where ax = b
#

q,r = np.linalg.qr(a)
x = spy.linalg.solve_triangular(r,np.dot(q.T,b))

What I'd like is a simple convenience function to access this algorithm. For context, I'm writing
code to enable calibrating a magnetometer - this involves fitting a cloud of points to a rotated ellipsoid, and then fitting another
cloud of points to a plane. I've got the algorithm working on my laptop using the lstsq function, but now I want to use it
in an embedded device, using ulab.

@furbrain furbrain added the enhancement New feature or request label Nov 9, 2022
@v923z
Copy link
Owner

v923z commented Nov 9, 2022

I'm not sure I follow your argument. If I understand correctly, then

q,r = np.linalg.qr(a)
x = spy.linalg.solve_triangular(r,np.dot(q.T,b))

does what you need. If that is the case, what do you mean by convenience function?

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

No branches or pull requests

2 participants