This repository has been archived by the owner on Sep 12, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new
lu
function for tensors, extending theLinearAlgebra.lu
function (resolve #3). The newlu
function returns the LU decomposition of aTensor
, where the tensor can be recovered by contracting the permutation tensorP
, the tensorL
, and tensorU
. The tensorsL
andU
are reshaped versions of the original lower and upper triangular matrices obtained during the decomposition process, respectively.This implementation is inspired by the LU decomposition in the
scipy
library, as it returns the permutation tensorP
allowing the original tensorA
to be recovered with the contractionA = P * L * U
. This contrasts withLinearAlgebra
, where the permutation vectorp
is returned, and the original matrix can be recovered withP' * A = L * U
(whereP'
is the permutation matrix built fromp
).Please let me know if there are any concerns or issues with extending the
LinearAlgebra
library in this manner.We have also added tests for this new function.
Example
A usage example of the
lu
function: