Skip to content

feat(maths): add LU decomposition algorithm using Doolittle method#7426

Closed
MD-Mushfiqur123 wants to merge 1 commit into
TheAlgorithms:masterfrom
MD-Mushfiqur123:add-lu-decomposition-java
Closed

feat(maths): add LU decomposition algorithm using Doolittle method#7426
MD-Mushfiqur123 wants to merge 1 commit into
TheAlgorithms:masterfrom
MD-Mushfiqur123:add-lu-decomposition-java

Conversation

@MD-Mushfiqur123
Copy link
Copy Markdown
Contributor

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Java files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in its comments that points to Wikipedia or another similar explanation.
  • The build runs successfully with \mvn clean verify.

LU Decomposition (Doolittle Algorithm)

Decomposes a square matrix A into a lower triangular matrix L and an upper triangular matrix U such that A = L * U.

What This Adds

LUDecomposition.java - Main algorithm implementation:

  • \decompose()\ - Performs LU factorization using the Doolittle algorithm with combined L/U storage
  • \getLowerMatrix()\ - Extracts L (unit lower triangular) from combined matrix
  • \getUpperMatrix()\ - Extracts U (upper triangular) from combined matrix
  • \solve()\ - Solves Ax = b via forward and back substitution

LUDecompositionTest.java - Unit tests:

  • Tests for 3x3 and 2x2 matrix decomposition
  • Identity matrix decomposition
  • Non-square matrix rejection
  • Singular matrix detection
  • Linear system solving (2x2 and 3x3)

Algorithm

The Doolittle algorithm computes L and U iteratively:

  • U[k][j] = A[k][j] - sum(L[k][s] * U[s][j]) for s < k
  • L[i][k] = (A[i][k] - sum(L[i][s] * U[s][k])) / U[k][k] for s < k

Time: O(n^3) decomposition, O(n^2) solve | Space: O(n^2)

Reference

https://en.wikipedia.org/wiki/LU_decomposition

@MD-Mushfiqur123 MD-Mushfiqur123 force-pushed the add-lu-decomposition-java branch from 3f8bb42 to ed55d22 Compare May 19, 2026 01:38
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

This pull request has been automatically closed because its workflows or checks failed and it has been inactive for more than 14 days. Please fix the workflows and reopen if you'd like to continue. Merging from main/master alone does not count as activity.

@github-actions github-actions Bot closed this Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant