Add LU decomposition with partial pivoting#53
Conversation
Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com>
Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com>
|
Were the workflows run ? |
|
@copilot Did the CI run on this PR? Why not? |
There was a problem hiding this comment.
Pull request overview
This PR implements LU decomposition with partial pivoting using LAPACK's dgetrf on the JVM platform, following the established pattern for linear algebra operations in vecxt. The implementation correctly handles both square and rectangular matrices, including singular cases, and provides comprehensive test coverage.
- Adds JVM implementation using LAPACK's dgetrf routine with proper error handling
- Provides JS/Native placeholders following the project's cross-platform structure
- Includes 15 comprehensive tests covering basic cases, edge cases, rectangular matrices, and mathematical invariants
- Updates the cheatsheet with usage examples comparing to NumPy/MATLAB
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| vecxt/src-jvm/lu.scala | JVM implementation using LAPACK dgetrf, extracting L and U matrices with while loops for performance, properly converting 1-based LAPACK pivots to 0-based |
| vecxt/src-js-native/lu.scala | Placeholder for JS/Native platforms following established pattern |
| vecxt/src/all.scala | Exports LU module for user access |
| vecxt/test/src-jvm/lu.test.scala | Comprehensive test suite with 15 tests validating correctness through mathematical invariants and edge cases |
| site/docs/cheatsheet.md | Updated with LU decomposition usage example for cross-reference with NumPy and MATLAB |
| * - U: Upper triangular matrix | ||
| * - P: Permutation array | ||
| */ | ||
| inline def lu(m: Matrix[Double]): (L: Matrix[Double], U: Matrix[Double], P: Array[Int]) = ??? |
There was a problem hiding this comment.
The placeholder signature is missing the BoundsCheck parameter that the JVM implementation has. To maintain consistency with other decomposition functions (e.g., eig, solve), add the bounds check parameter:
inline def lu(m: Matrix[Double])(using inline bc: BoundsCheck): (L: Matrix[Double], U: Matrix[Double], P: Array[Int]) = ???| inline def lu(m: Matrix[Double]): (L: Matrix[Double], U: Matrix[Double], P: Array[Int]) = ??? | |
| inline def lu(m: Matrix[Double])(using inline bc: BoundsCheck): (L: Matrix[Double], U: Matrix[Double], P: Array[Int]) = ??? |
The CI workflows are configured to exclude branches matching However, the CI should run on the pull request itself once it's opened, as the workflow is triggered by All tests have been run locally and pass:
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Implements LU factorization using LAPACK's
dgetrfon JVM, with placeholders for JS/Native platforms.Implementation
vecxt/src-jvm/lu.scala): LAPACKdgetrfwrapper returning named tuple(L, U, P)where P is the pivot array. Handles square and rectangular matrices, including singular cases.vecxt/src-js-native/lu.scala): Placeholder following SVD/Cholesky patternvecxt/src/all.scala): Addedexport vecxt.LU.*Tests
15 test cases in
vecxt/test/src-jvm/lu.test.scalacovering:Usage
Updated cheatsheet with comparison to NumPy/MATLAB.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.