#linear-algebra #matrix #squares #solution #equation #default #linalg

no-std lstsq

Return the least-squares solution to a linear matrix equation

5 releases (breaking)

0.5.0 Jan 16, 2023
0.4.0 May 2, 2022
0.3.0 Jan 2, 2022
0.2.0 Aug 10, 2021
0.1.0 Aug 5, 2021

#307 in Math

Download history 995/week @ 2023-12-14 334/week @ 2023-12-21 255/week @ 2023-12-28 482/week @ 2024-01-04 772/week @ 2024-01-11 815/week @ 2024-01-18 1089/week @ 2024-01-25 825/week @ 2024-02-01 835/week @ 2024-02-08 816/week @ 2024-02-15 997/week @ 2024-02-22 1413/week @ 2024-02-29 1553/week @ 2024-03-07 1201/week @ 2024-03-14 934/week @ 2024-03-21 659/week @ 2024-03-28

4,602 downloads per month
Used in 9 crates (7 directly)

MIT/Apache

10KB
76 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
~60K SLoC