sta-peak/README.md
2024-06-02 22:36:04 +02:00

2.0 KiB

Performant Embedded Algebra Kit (PEAK)

Description

The Performant Embedded Algebra Kit (PEAK) is a lightweight and easy-to-use library for performing various algebraic operations.

Features

  • Matrix operations: Perform matrix addition, subtraction, multiplication, and inversion.
  • Kalman Filter implementations
    • basic Kalman Filter
    • Dynamic Kalman Filter, with variable delta t

Usage

Basics

The following example demonstrates the creation of matrices and basic operations on them.

#include <sta/math/linalg/matrix.hpp>
#include <sta/math/linalg/linalg.hpp>

// Create a 3x2 matrix with every entry initialized to 0:
sta::math::matrix m_0 = sta::math::matrix::zeros(3,2);

// Set specific entries in the matrix:
m_0.set(0, 1, 4); // set the entry in the first column and second column to 0
m_0.set(1, 0, 5);
//m_0.set(2, 2, 99); -> Column index out of range

// Display the matrix:
m_0.show_serial();

// Output:
// Matrix shape: (3 x 2)
// | 0.000000 | 4.000000 |
// | 5.000000 | 0.000000 |
// | 0.000000 | 0.000000 |

// Create a 3x2 matrix with every entry initialized to 10:
sta::math::matrix m_10 = sta::math::matrix::full(3,2,10); 

// Matrices of the same shape can be added together using the + operator:
sta::math::matrix m_a = m_0 + m_10;

// m_a:
// | 10.000000 | 14.000000 |
// | 15.000000 | 10.000000 |
// | 10.000000 | 10.000000 |

// Create an identity matrix of size 3 and multiply it by 5:
sta::math::matrix m_i = sta::math::matrix::eye(3) * 5;

// Set a specific entry in the identity matrix:
m_i.set(0, 2, 0.5);

// m_i:
// | 5.000000 | 0.000000 | 0.500000 |
// | 0.000000 | 5.000000 | 0.000000 |
// | 0.000000 | 0.000000 | 5.000000 |

// Matrices of the appropriate shape can be multiplied together using the * operator:
sta::math::matrix m_res = m_i * m_a;

// m_res:
// | 55.000000 | 75.000000 |
// | 75.000000 | 50.000000 |
// | 50.000000 | 50.000000 |

Limitations

As of now, only matrices with no more than 256 elements are supported.