I'm very interested in programming complicated matrix operations in Arduino Due, but with the simplicity offered in Octave and Matlab. For example, the Kalman gain matrix (one of many implementations) is:

K = Pp * H' * inv(H * Pp * H' + R);

Implementing the equation above in standard C would be very complicated, very messy, and difficult to read. In Matlab or Octave, the code is literally the above equation. I literally copied it from one my programs. This syntax is known as vector programming - it's a huge time saver. Various libraries exist (links below) that allow such syntax in C. Is it possible to include such a library for the Due? Has anyone done this? Thank you. The answer is yes with the Eigen C++ library ( http://eigen.tuxfamily.org ).

Don't put too much hope in those two library especially Eigen. They are big packages not written for micro-controller.

I don't know much of the other but Eigen in is a very big library with complex inside dependency and even if you use only a very small subset of its functionality it will be very difficult to remove enough things to make it fit in the Due memory.Better to look for math library specialized for micro controller where algorithm are chosen for their size.

One or two people have experimented with Python on Arduinos, possibly easier now we have the Due. Might be worth looking at if someone could get it going with the 'numpy' library (now a serious contender to Matlab).

I tested the matrix inversion on the Arduino-Due and the results match Octave and Matlab results.

Again, MatrixMath does not do overloaded operations for binary matrix math, as does "Eigen". I'm more of an Octave and Matlab power user, and not well versed with C++ overhead programming (classes, makefiles, links, etc.). I have not linked Eigen2 to Arduino.

stimmer - Did you compile Eigen2 in the Arduino IDE? If you provide instructions in how to do that, I'd be happy to test it out and compare with Matlab.

All I did was to follow the instructions supplied with Eigen 2, and all they said was to put a symlink to the Eigen subdirectory in an include directory (there are several, I chose g++_arm_none_eabi/arm-none-eabi/include). I didn't test thoroughly but overloaded operators and inversion worked on a 3x3 matrix.

All I did was to follow the instructions supplied with Eigen 2, and all they said was to put a symlink to the Eigen subdirectory in an include directory (there are several, I chose g++_arm_none_eabi/arm-none-eabi/include).

I tried Eigen 3 but got an internal compiler error. Eigen 2 seems to work OK though (but file sizes are rather large, ~170K)

I tried Eigen3 and it does compile properly, and the file size is only 29K compared with Eigen2 at 170K. I'm using Windows7, so the installation was relatively straightforward - no esoteric linux stuff required.

Defining matrices in Eigen3 is cleaner, and more matrix decomp options are available compared to Eigen2.

Eigen is a C++ library enabling Matlab and Octave-like matrix programming. Eigen works very well with the Arduino Due. As a Matlab user that appreciates minimalism, the Eigen library is written as plain header files. So no makefiles, no binary files, nothing to compile upfront, no 20th century nonsense.

Important development regarding Eigen3. The Arduino/Eigen setup on Windows 7 seems to produce internal compiler errors when using matrices larger than 4x4. After struggling late at night with this, I found a solution. To add Eigen to the Arduino IDE (1.5.1r2) for Due, follow these instructions and try my example in step-6: (applies to Windows 7)

Step-4: -> Eigen is written in C++, so header files do not include the *.h extension.-> The Arduino IDE expects a *.h extension for it to appear in Sketch/Import Library pull-down menu.-> So download "Eigen312.h" from this thread and copy to this precise location:...\arduino-1.5.1r2\hardware\arduino\sam\libraries\Eigen-> Notice "Eigen312.h" goes in the Eigen subdirectory-> Normally, all that is needed in "Eigen312.h" is a call to the main Eigen Core header as follows: #include <Core>However, the Arduino and AVR libraries interfere with Eigen for matrices larger than 4x4; this results in internal compiler errors. So @rpavlik came up with a bunch of #define statements that prevents this, and are conveniently included in "Eigen312.h".

Step-5:-> Again, make sure you download "Eigen312.h" and copy to the Eigen subdirectory!

Step-6:-> Run example code below demonstrating the Kalman gain equation using 6x6 matrices. Not as clean as Matlab or Octave, but not too shabby.-> I wrote a function called print_mtxf that serially prints matrices; it's included in the example below.