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

Implemented function returning Wilkinson Matrix #20922

Merged
merged 3 commits into from Feb 9, 2021
Merged

Conversation

ks147
Copy link
Contributor

@ks147 ks147 commented Feb 7, 2021

Brief description of what is fixed or changed

Implemented function returning Wilkinson matrix

Release Notes

  • matrices
    • Added function returning Wilkinson matrix

@sympy-bot
Copy link

sympy-bot commented Feb 7, 2021

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 returning Wilkinson matrix (#20922 by @ks147)

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.
#### Brief description of what is fixed or changed
Implemented function returning Wilkinson matrix

#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
* matrices
  * Added function returning Wilkinson matrix
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@ks147
Copy link
Contributor Author

ks147 commented Feb 8, 2021

@sylee957, please review

@@ -1208,6 +1208,51 @@ def entry(i, j):
return kls.zero
return kls._new(size, size, entry)

@classmethod
def Wilkinson(kls, n):
Copy link
Member

@sylee957 sylee957 Feb 8, 2021

Choose a reason for hiding this comment

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

Suggested change
def Wilkinson(kls, n):
def wilkinson(kls, n):

I'd try to use lowercase for method names

wminus = diag([i for i in range(-n, n + 1)], unpack=True) + D + D.T
wplus = abs(diag([i for i in range(-n, n + 1)], unpack=True)) + D + D.T

return wminus, wplus
Copy link
Member

@sylee957 sylee957 Feb 8, 2021

Choose a reason for hiding this comment

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

As I'd noted in #20911, you should consider the class of the output to match the class of the method it's invoked from
So you should check the returns are in the following classes

MutableDenseMatrix.wilkinson -> MutableDenseMatrix
MutableSparseMatrix.wilkinson -> MutableSparseMatrix
ImmutableDenseMatrix.wilkinson -> ImmutableDenseMatrix
ImmutableSparseMatrix.wilkinson -> ImmutableSparseMatrix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've fixed this in latest commit.

>>> from sympy import MutableSparseMatrix, ImmutableDenseMatrix, ImmutableSparseMatrix, MutableDenseMatrix
>>> w_m, w_p = MutableDenseMatrix.wilkinson(1)
>>> type(w_m)
<class 'sympy.matrices.dense.MutableDenseMatrix'>
>>> w_m, w_p = MutableSparseMatrix.wilkinson(1)
>>> type(w_m)
<class 'sympy.matrices.sparse.MutableSparseMatrix'>
>>> w_m, w_p = ImmutableDenseMatrix.wilkinson(1)
>>> type(w_m)
<class 'sympy.matrices.immutable.ImmutableDenseMatrix'>
>>> w_m, w_p = ImmutableSparseMatrix.wilkinson(1)
>>> type(w_m)
<class 'sympy.matrices.immutable.ImmutableSparseMatrix'>

@sylee957 sylee957 merged commit 25fcde5 into sympy:master Feb 9, 2021
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.

None yet

3 participants