Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lecopivo/EigenLean
Lean 4 interface to Eigen
https://github.com/lecopivo/EigenLean
eigen3 lean4
Last synced: about 1 month ago
JSON representation
Lean 4 interface to Eigen
- Host: GitHub
- URL: https://github.com/lecopivo/EigenLean
- Owner: lecopivo
- Created: 2022-04-24T15:38:07.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-08-24T22:48:08.000Z (over 1 year ago)
- Last Synced: 2024-08-05T10:14:38.562Z (5 months ago)
- Topics: eigen3, lean4
- Language: C++
- Homepage:
- Size: 22.5 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.org
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_srcExample 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=.