# About maximum length of matrix can be use for matrix invertsion on atmega32

what is the maximum length for matrix can be used for matrix inversion on atmega32,for example,can we implement matrix inversion for 15x15 matrix on atmega32? And if it can be done on atmega32..does this will make the atmega32 to be slower? I want to implement kalamn filter 15 states for euler angles estimation...the data of the matrix will be floating point..

• This is not a very well defined question. Did you have a particular application in mind (so it can be optimized) or do you need a general matrix inversion algorithm? What do you mean by “would this make the ATMega32 slower”? No, the ATMega32 would remain just as fast. Your code might become slower, but that depends on question #1: what do you need this for? – StarCat Sep 7 '20 at 6:15
• What data type do you store in the matrix? How is the matrix defined? Please show us some code. – the busybee Sep 7 '20 at 6:30
• I want to implement kalamn filter 15 states for euler angles estimation...the data of the matrix will be floating point.. – user255471 Sep 7 '20 at 6:38
• I want to implement kalamn filter 15 states for euler angles estimation...the data of the matrix will be floating point.. – user255471 Sep 7 '20 at 6:39
• does this will make the atmega32 to be slower? - slower than what? It would certainly be slower than not inverting any matrices, of course. – Nick Gammon Sep 7 '20 at 7:07

## 1 Answer

Floats in the Arduino IDE are normally 4 bytes. So you can work out with a calculator that your matrix will take at least 15 x 15 x 4 bytes (900 bytes). That is out of a total of 2048 bytes of RAM on the Atmega32.

That may seem to be enough RAM, but other things, like the libraries, will also take RAM. I did an answer to a question about RAM a while back. Even a very simple sketch (in this case) took 346 bytes.

Also, your library, or whatever-it-is you are using for matrix inversion, may require RAM for variables, etc.

My suggestion would be to make your code invert a very small matrix (eg. 1 x 1) and see how much RAM that uses. Then you can extrapolate out fairly simply to how much would be needed for a larger matrix.