Page 1 of 1

### Installing NumPy on the Pyboard

Posted: Thu Jun 30, 2016 11:52 am
Hello,

I want to install Numpy on my Pyboard so that I can use the handy numpy.linalg.det() function to find a matrix determinant. I was wondering if this is possible and if it is how is it done.

Thanks.

### Re: Installing NumPy on the Pyboard

Posted: Thu Jun 30, 2016 12:39 pm
There is no way to run numpy on the pyboard, since it is not ported to micropython and most likely never will be. Numpy is huge compared to micropython and it would make no sens to run it on a microcontroller.
What you might want to do, is to study the functions you need from numpy and try to implement them by yourself. But be aware, a uC and a PC are two different things. You need to estimate if a uC would be capable of performing the tasks you plan to do.
Furthermore, many algorithms have dedicated counterparts which work better on uC but are more limited in general.

### Re: Installing NumPy on the Pyboard

Posted: Thu Jun 30, 2016 5:45 pm
Thanks for the clarification concerning microcontrollers and numpy.

I ended up determining the matrix determinant expression by hand and ran it on my matrix (I'm handling a 4x4 matrix made up of 4 lists and no zeros in any of them) and it worked. It did take a while to find but at the end it's just a long addition so it's well in the microcontroller's capabilities.

Thanks again for the help.

### Re: Installing NumPy on the Pyboard

Posted: Sat Mar 24, 2018 7:58 pm
[quote=Iyassou post_id=11775 time=1467287560 user_id=1808]
Hello,

I want to install Numpy on my Pyboard so that I can use the handy numpy.linalg.det() function to find a matrix determinant. I was wondering if this is possible and if it is how is it done.

Thanks.
[/quote]

I knew that numpy would not exist for MicroPython but I was also a bit naive thinking there would be at least some basic "number-crunching" tools available. Even the built-in `array` object does not allow basic vectorization techniques such as element-wise multiplication.

Looks like @jlawson has written a fairly powerful module for 2D matrix operations - see this forum post: viewtopic.php?f=15&t=1169

It looks like a great piece of work but I think it is all written in Python (as opposed to machine code) so it is more of a convenience tool than a 'speed-up' option - e.g. for vectorization of large computations.

Surely someone will work on an implementation of numpy arrays and some basic functionality at some point?

E.g.:
- ndarray with dim, shape, size, dtype attributes and slicing capability (views)

And maybe the following commonly-used numpy array methods:
- mean, sum, max, argmax, min, argmin, dot, transpose, all, any, ravel/flatten, reshape, copy

(I wish I had the skills to do it but happy to assist if this is a project someone is working on).