-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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 Givens rotation #24535
Implemented Givens rotation #24535
Conversation
✅ Hi, I am the SymPy bot (v169). 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:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.12. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
@sylee957 Added the cross-references, implemented Not sure which other tests to implement, but there were already some tests before that I had introduced (comparing to the results of |
sympy/matrices/dense.py
Outdated
M[i-1, i-1] = c | ||
M[j-1, j-1] = c | ||
M[i-1, j-1] = s | ||
M[j-1, i-1] = -s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that 0 to n-1 indexing is more preferable because of having less complicated formula for indexing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I can change that tomorrow.
Isn't it better to keep it consistent with axis1, axis2 and axis3 though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, those methods are pretty much nominal, they have only a finite numbers of names, so they can be left as is.
However a program that generates infinite numbers of notations is more general and can be difficult to change in the future.
It is better to be consistent with python indexing, or sympy matrix indexing itself, or there would be other counter arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair, just changed it!
sympy/matrices/dense.py
Outdated
M = eye(dim) | ||
if i < j: | ||
i, j = j, i | ||
theta = -theta |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to calculate this formula?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the article they said "for i > j
", which is why I put it.
But now that I think about it, I think this has no effect indeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it and then the calls for rot_givens had to be changed.
It all still works, but I'm not sure which is the correct convention, should be better understood before merging in order not to create something that we can't change later on...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the previous implementation can be wrong because you attempt to change theta
but values of s = sin(theta)
is already computed above and ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops you're right!
sympy/matrices/dense.py
Outdated
R = \begin{bmatrix} | ||
\cos(\theta) & \sin(\theta) & 0\\ | ||
-\sin(\theta) & \cos(\theta) & 0\\ | ||
0 & 0 & 1 | ||
\end{bmatrix} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Math formula should also better be aligned for indentation
and have constant spacing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried align all of the &
, tell me if it's okay!
Does anyone know why? |
I've restarted it to see if is passes |
I think that the sphinx errors in https://github.com/sympy/sympy/actions/runs/3938511339/jobs/6737742971 should be fixed in some way though. |
Agreed, I'll try to investigate it. Do you have any idea of what might be causing it? |
This comment was marked as resolved.
This comment was marked as resolved.
It looks like |
Benchmark results from GitHub Actions Lower numbers are good, higher numbers are bad. A ratio less than 1 Significantly changed benchmark results (PR vs master) Significantly changed benchmark results (master vs previous release) before after ratio
[41d90958] [3450b757]
<sympy-1.11.1^0>
- 1.14±0.01ms 723±7μs 0.63 solve.TimeSparseSystem.time_linear_eq_to_matrix(10)
- 3.40±0.06ms 1.36±0.03ms 0.40 solve.TimeSparseSystem.time_linear_eq_to_matrix(20)
- 6.75±0.1ms 1.98±0.06ms 0.29 solve.TimeSparseSystem.time_linear_eq_to_matrix(30)
Full benchmark results can be found as artifacts in GitHub Actions |
Apparently you were right! All checks are passing now. |
Co-authored-by: (Lazard) S.Y. Lee <[email protected]>
References to other Issues or PRs
As discussed in #24529.
Brief description of what is fixed or changed
Implemented a method giving the Givens rotation, a generalization of rotation matrices in any number of dimensions.
Replace implementation in other rotation matrix methods by calls to this generalized function.
Release Notes
rot_givens
to compute givens rotation matrix.