Java icon indicating copy to clipboard operation
Java copied to clipboard

feat: Add LU decomposition algorithm for matrices using Doolittle's algorithm

Open Raghu0703 opened this issue 2 weeks ago • 1 comments

Description

This PR implements the LU decomposition algorithm for square matrices as requested in issue #6833.

Changes

  • Implements LU decomposition using Doolittle's method
  • Decomposes square matrix A into L (lower) and U (upper) triangular matrices
  • Includes comprehensive test cases with edge case handling
  • Time complexity: O(n³), Space complexity: O(n²)
  • Resolves #6833

Algorithm Details

  • Purpose: Decomposes a square matrix A into L × U where:
    • L is a lower triangular matrix with 1s on diagonal
    • U is an upper triangular matrix
  • Use cases: Solving linear equations, computing determinants, finding matrix inverses
  • Method: Doolittle's algorithm
  • Time Complexity: O(n³)
  • Space Complexity: O(n²)

Testing

  • ✅ Basic 3x3 matrix decomposition (from issue example)
  • ✅ Identity matrix decomposition
  • ✅ 2x2 matrix decomposition
  • ✅ Non-square matrix error handling
  • ✅ Empty matrix error handling
  • ✅ Singular matrix error handling

Checklist

  • [x] I have read CONTRIBUTING.md.
  • [x] This pull request is all my own work -- I have not plagiarized it.
  • [x] All filenames are in PascalCase.
  • [x] All functions and variable names follow Java naming conventions.
  • [x] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • [x] All new code is formatted with clang-format -i --style=file path/to/your/file.java

Closes #6833

Raghu0703 avatar Nov 24 '25 06:11 Raghu0703