Hummingbird Flight Software
Flight software for the Hummingbird FCU quadcopter flight controller. Designed to run on the Teensy 4.1. Developed with VSCode+PlatformIO.
Classes | Macros
matrices.h File Reference
#include <Arduino.h>
#include "hummingbird_config.h"

Go to the source code of this file.

Classes

class  Matrix
 A matrix object is definied by it's rows and columns. More...
 

Macros

#define MATRIX_ELEMENT(MAT, i, j, rows, cols)   *(MAT + i*cols + j)
 A matrix object is definied by it's rows and columns. More...
 

Macro Definition Documentation

◆ MATRIX_ELEMENT

#define MATRIX_ELEMENT (   MAT,
  i,
  j,
  rows,
  cols 
)    *(MAT + i*cols + j)

A matrix object is definied by it's rows and columns.

When a matrix object is created, the array is allocated on the heap (RAM2 for Teensy 4.1) with the C++ 'new' keyword as an array of pointers. See the following resource to learn more.

https://www.techiedelight.com/dynamic-memory-allocation-in-c-for-2d-3d-array/ https://dev.to/drakargx/c-contiguous-allocation-of-2-d-arrays-446m Macro to extract the value in matrix "MAT" at "MAT(i, j)" with dims. "(rows, cols)." Matrices are stored as a long 1D array, so this macro makes 2D array indexing a bit easier. IT IS UP TO THE USER TO ENSURE THAT THE INDICES DO NOT EXCEED THE MATRIX DIMENSIONS!

Parameters
MATMatrix variable name
iRow index
jColumn index
rowsNumber of rows in the matrix
colsNumber of cols in the matrix