Close

How the heck do you invert a matrix in C?

A project log for Bike Computer with Flight Software

I want to track my bike rides and get some experience with CoreFlight

jacob-killeleaJacob Killelea 07/15/2019 at 03:005 Comments

I've starting writing the kalman algorithm in a CoreFlight app. It receives GPS data messages from another application that handles the serial parsing, and this one is supposed to run the kalman filter.

I've got most of it working right now, but I stuck on how to calculate the inverse of a matrix in C. I've been using the GSL library for the matrix math, since it supports BLAS functions and it makes it easy to write the code for an arbitrary matrix size, but I just can't figure out the inverse thing.

Discussions

Tyler wrote 07/15/2019 at 20:25 point

If you are using an ARM Cortex M chip, you can use the CMSIS DSP library. It is especially fast for 8/16 bit math because of the multiple data instructions: https://github.com/ARM-software/CMSIS_5/tree/develop/CMSIS/DSP/Source/MatrixFunctions

  Are you sure? yes | no

Jacob Killelea wrote 07/15/2019 at 20:45 point

This is a raspberry pi zero (CoreFlight requires a proper OS with a filesystem and whatnot), so I don't think that'll work for this.

  Are you sure? yes | no

Tyler wrote 07/15/2019 at 22:29 point

Good point. It still might be useful as a reference if you can't find a suitable library (https://github.com/ARM-software/CMSIS_5/blob/develop/CMSIS/DSP/Source/MatrixFunctions/arm_mat_inverse_f64.c)

Good luck.

  Are you sure? yes | no

Jacob Killelea wrote 07/15/2019 at 20:17 point

Thanks, I'll give that a shot.

  Are you sure? yes | no