Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lecopivo/EigenLean

Lean 4 interface to Eigen
https://github.com/lecopivo/EigenLean

eigen3 lean4

Last synced: 2 months ago
JSON representation

Lean 4 interface to Eigen

Awesome Lists containing this project

README

        

* Lean 4 interface to Eigen

Proof of concept for interfacing Eigen's linear solvers in Lean 4.

To compile and build examples:
#+begin_src lean
lake build dense sparse
#+end_src

Example of solving simple 2x2 system with LDLT:
#+begin_src lean
def main : IO Unit := do
let A : Matrix 2 2 := ⟨FloatArray.mk #[2,1,1,2], by native_decide⟩
let b : Matrix 2 1 := ⟨FloatArray.mk #[1,1], by native_decide⟩
IO.println A
IO.println b
IO.println (A.ldlt.solve b)
#+end_src
To run the example =./build/bin/dense=.

Example of initializing sparse matrix:
#+begin_src lean
def main : IO Unit := do
let entries : Array (Triplet 2 2) := (#[(0,0,1.0), (1,1,-1.0), (0,1, 2.0)] : Array (Nat×Nat×Float))
let B := SparseMatrix.mk entries
IO.println B.toDense
#+end_src
To run the example =./build/bin/sparse=.