#linear-algebra #squares #matrix #equation #solution #bare-metal #std

no-std lstsq

Return the least-squares solution to a linear matrix equation

6 releases (breaking)

0.6.0 Jun 24, 2024
0.5.0 Jan 16, 2023
0.4.0 May 2, 2022
0.3.0 Jan 2, 2022
0.1.0 Aug 5, 2021

#70 in Math

Download history 1211/week @ 2024-08-21 1504/week @ 2024-08-28 1553/week @ 2024-09-04 1970/week @ 2024-09-11 1502/week @ 2024-09-18 1922/week @ 2024-09-25 1666/week @ 2024-10-02 2269/week @ 2024-10-09 2214/week @ 2024-10-16 1731/week @ 2024-10-23 1674/week @ 2024-10-30 2916/week @ 2024-11-06 1887/week @ 2024-11-13 2100/week @ 2024-11-20 2295/week @ 2024-11-27 2133/week @ 2024-12-04

8,727 downloads per month
Used in 16 crates (9 directly)

MIT/Apache

10KB
74 lines

Crate lstsq for the Rust language

Crates.io Documentation Crate License Dependency status build

Return the least-squares solution to a linear matrix equation

About

The crate implements the linear least squares solution to a linear matrix equation.

Characteristics:

  • Linear algebra and types from the nalgebra crate.
  • Maximum compatibility with the numpy.linalg.lstsq Python library function.
  • No standard library is required (disable the default features to disable use of std) and no heap allocations. In other words, this can run on a bare-metal microcontroller with no OS.

Testing

Unit tests

To run the unit tests:

cargo test

Test for no_std

Since the thumbv7em-none-eabihf target does not have std available, we can build for it to check that our crate does not inadvertently pull in std. The unit tests require std, so cannot be run on a no_std platform. The following will fail if a std dependency is present:

# install target with: "rustup target add thumbv7em-none-eabihf"
cargo build --no-default-features --target thumbv7em-none-eabihf

Dependencies

~3MB
~62K SLoC