Open furbrain opened 2 years ago
You can actually add python
stuff as demonstrated in https://github.com/v923z/micropython-ulab/tree/master/snippets. I think this would be a brilliant addition, if you care to create a PR.
It might make sense to re-implement at least part of this in C. A lot is happening here, and I have the feeling that this is probably expensive.
I can certainly create a PR, but the stuff in snippets doesn't seem to be being built into ulab firmware - am I missing something?
No, you are not missing anything. The idea behind the snippets
was that people could easily add extra functions without having to recompile the firmware. But the functions are still added to the name space.
Having said that, I think that this function should be implemented in C. The nested loops are expensive in python
. I actually entertained the idea of adding the simplex method, but there seemed to be no demand for that, so I dropped it.
By the way, I wonder, whether
sim = np.empty((N + 1, N), dtype=x0.dtype)
is correct: what happens, if you start out with an integer type?
I don't really speak Micropython flavoured C, so I think I might struggle to translate this function. I'd be happy to tidy it up and add it as a snippet PR however - would you like me to do so?
I've just copied this from the scipy implementation, and then converted to use the ulab functions, so I don't really know what would happen with an integer type.
I don't really speak Micropython flavoured C, so I think I might struggle to translate this function. I'd be happy to tidy it up and add it as a snippet PR however - would you like me to do so?
Yes, I think it would be great. It would also ease a bit on the time pressure. I'm willing to do this properly in C, but if there was a not-so-performant python
implementation in the meantime, that would be very useful.
I've just copied this from the scipy implementation, and then converted to use the ulab functions, so I don't really know what would happen with an integer type.
I haven't tried it, either, but in the contraction step you are bound to leave the set of integers, I think.
Describe the solution you'd like I'd like to be able to do a multiparametric optimisation, ideally using the nelder-mead algorithm,as in scipy https://docs.scipy.org/doc/scipy/reference/optimize.minimize-neldermead.html.
I have rewritten the python code currently used in scipy, to be compatible with ulab (below) but there doesn't seem to be a way to include python code with ulab
Additional context This is some calibration code for a magnetometer. This is tweaking the final results by adding a radial basis function to the output of the magnetometer output, which can account for non-linearity in the sensor. I have this working on my laptop, but I'd like to be able to use it on an embedded device