Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added schur complement and block decompositions #20406

Merged
merged 6 commits into from Nov 28, 2020

Conversation

naveensaigit
Copy link
Contributor

Added Schur Complement, Generalized Schur Complement and LDU, UDL and LU Block Decompositions

References to other Issues or PRs

Fixes #20401

Release Notes

  • matrices
    • Added function to calculate Generalized Schur Complement for Block Matrices
    • Added functions to compute LDU, UDL and LU decompositions for Block Matrices

@sympy-bot
Copy link

sympy-bot commented Nov 10, 2020

Hi, I am the SymPy bot (v161). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

  • matrices
    • Added function to calculate Generalized Schur Complement for Block Matrices (#20406 by @naveensaigit)

    • Added functions to compute LDU, UDL and LU decompositions for Block Matrices (#20406 by @naveensaigit)

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.8.

Click here to see the pull request description that was parsed.
Added Schur Complement, Generalized Schur Complement and LDU, UDL and LU Block Decompositions

#### References to other Issues or PRs
Fixes #20401 

#### Release Notes
<!-- BEGIN RELEASE NOTES -->
* matrices
  * Added function to calculate Generalized Schur Complement for Block Matrices
  * Added functions to compute LDU, UDL and LU decompositions for Block Matrices
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@naveensaigit
Copy link
Contributor Author

@oscarbenjamin I could add this too - #19336 (comment)

@naveensaigit
Copy link
Contributor Author

There's a slight problem while building the docs since both Matrix and BlockMatrix have LUdecomposition. How can I resolve this?

@sylee957
Copy link
Member

You have some problems with the references in the docs.

>>> X.schur()
-C*A**(-1)*B + D
>>> X.schur('D')
A - B*D**(-1)*C
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing a string like this seems like an odd interface. Would it be possible for the schur function to check whether the matrices are invertible and choose which form to use based on that? Otherwise I think that there could be a better way to specify which matrix to invert over.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if there are multiple matrices which are invertible? Maybe we could use the position of the block matrix, i.e. (0,0) for 'A', (0,1) for 'B ' and so on

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oscarbenjamin Any thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oscarbenjamin Please review this when you get some time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oscarbenjamin Please look into this too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, although it looks an overkill for use block matrix only to get 2x2 schur complements, I believe that we can make any other place to comprehend schur complements as some result of noncommutative matrix computation later, if there is.

@naveensaigit
Copy link
Contributor Author

You have some problems with the references in the docs.

I removed the references but I think its failing because of same function names. Or is it something else?

@sylee957
Copy link
Member

The references for LUdecomposition in the overall docs should be modified like MatrixBase.LUdecomposition

@naveensaigit
Copy link
Contributor Author

The references for LUdecomposition in the overall docs should be modified like MatrixBase.LUdecomposition

The references seem to be fixed, but it says no object found for the references to the functions I have added

@sylee957
Copy link
Member

Maybe the path should be like matrices.expressions.blockmatrix.BlockMatrix than matrices.expressions.BlockMatrix

I have seen that the docstring for sympy.matrices.dense.diag is using the reference for BlockMatrix like that, so it’s more likely that that works, but I can’t guarantee

@codecov
Copy link

codecov bot commented Nov 15, 2020

Codecov Report

Merging #20406 (7d11e3c) into master (65e7294) will decrease coverage by 0.031%.
The diff coverage is 72.307%.

@@              Coverage Diff              @@
##            master    #20406       +/-   ##
=============================================
- Coverage   75.771%   75.739%   -0.032%     
=============================================
  Files          673       673               
  Lines       174110    174179       +69     
  Branches     41106     41118       +12     
=============================================
- Hits        131925    131923        -2     
- Misses       36467     36527       +60     
- Partials      5718      5729       +11     

@sylee957
Copy link
Member

What is the difference between LDUdecomposition and UDLdecomposition?

@naveensaigit
Copy link
Contributor Author

naveensaigit commented Nov 15, 2020

LDUdecomposition gives matrices L(Lower Diagonal),D(Diagonal) and U(Upper Diagonal) such that Matrix = L * D * U. UDLdecomposition gives matrices U,D,L (same definition as above), but Matrix = U * D * L.
See https://en.wikipedia.org/wiki/Block_LU_decomposition

@sylee957
Copy link
Member

If there are no subtle difference than giving permuted output, how should they be in different API?

@naveensaigit
Copy link
Contributor Author

If there are no subtle difference than giving permuted output, how should they be in different API?

The definition of U,D,L stays the same, but the matrices would differ. The matrices L,D,U obtained from LDUdecomposition and L,D,U obtained from UDLdecomposition would be different

@sylee957
Copy link
Member

Okay I see they were just implemented with respect to what wikipedia says.

@naveensaigit
Copy link
Contributor Author

Okay I see they were just implemented with respect to what wikipedia says.

Yes, I tried to find more literature on block decompositions, but couldn't find much. The closed form expressions are only available for 2x2 matrices as is the definition of Schur complement

@sylee957 sylee957 merged commit 187a842 into sympy:master Nov 28, 2020
@naveensaigit naveensaigit deleted the blockmat branch November 30, 2020 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Schur complement and Block LU decomposition
5 participants