-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add support for calculating eigenvalues and eigenvectors #170
Conversation
Codecov Report
@@ Coverage Diff @@
## master #170 +/- ##
==========================================
+ Coverage 85.95% 86.15% +0.20%
==========================================
Files 12 13 +1
Lines 1289 1315 +26
==========================================
+ Hits 1108 1133 +25
- Misses 181 182 +1
Continue to review full report at Codecov.
|
Ah, I was forgetting to add methods for |
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.
This is cool.
Out of curiousity, what do you think you might do with it?
Do we support log
yet?
λs = eigvals(R) | ||
vs = eigvecs(R) |
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.
How much work is repeated here?
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.
Sorry, I didn't quite understand the question.
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 meant, some of the calculation going into the eigenvalues is probably being recalculated in eigvecs
. Not the way it is currently written but it usual that it falls out that way.
I doubt it has a massive performance impact here.
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.
Ah, I've updated code and avoid converting to AngleAxis
twice.
Before performance update
julia> R = rand(RotMatrix{3})
3×3 RotMatrix3{Float64} with indices SOneTo(3)×SOneTo(3):
0.196251 -0.948589 0.248325
0.979358 0.202123 -0.00188397
-0.0484051 0.243568 0.968675
julia> @benchmark eigen(R)
BenchmarkTools.Trial: 10000 samples with 434 evaluations.
Range (min … max): 234.707 ns … 2.399 μs ┊ GC (min … max): 0.00% … 89.78%
Time (median): 238.424 ns ┊ GC (median): 0.00%
Time (mean ± σ): 246.933 ns ± 73.440 ns ┊ GC (mean ± σ): 1.26% ± 3.77%
▃▆█▆▅▃▁▁▁▁ ▁▁▁ ▁ ▁
████████████▇█▇▇▆▆▇▆▆▅█████▆▆▅▇▇▇█████▇▆▆▅▆▆▇▇▇▇▅▅▅▄▅▄▄▃▄▄▃▄ █
235 ns Histogram: log(frequency) by time 315 ns <
Memory estimate: 208 bytes, allocs estimate: 1.
After performance update
julia> R = rand(RotMatrix{3})
3×3 RotMatrix3{Float64} with indices SOneTo(3)×SOneTo(3):
-0.81819 -0.492907 -0.295987
-0.287214 -0.0955672 0.953087
-0.49807 0.864818 -0.0633776
julia> @benchmark eigen(R)
BenchmarkTools.Trial: 10000 samples with 700 evaluations.
Range (min … max): 179.454 ns … 929.644 ns ┊ GC (min … max): 0.00% … 80.02%
Time (median): 183.104 ns ┊ GC (median): 0.00%
Time (mean ± σ): 187.316 ns ± 40.447 ns ┊ GC (mean ± σ): 1.17% ± 4.40%
▃▇██▇▆▄▃▄▄▃▂▁ ▂
███████████████▆▆▅▆▄▁▃▁▃▁▁▁▁▃▁▁▁▃▁▁▁▁▁▁▃▁▁▃▃▄▄▅▃▄▆▇▇▇▇▇███▇█▇ █
179 ns Histogram: log(frequency) by time 232 ns <
Memory estimate: 208 bytes, allocs estimate: 1.
I don't have applications of eigenvalues of rotations for now. Just for fun:smile:
I thought the return value type should be Lie algebra and this should be done after solving #30. But, I realized that we just need to return |
I've added the methods for 2d rotations, and I think this is ready to merge. |
Before this PR
After this PR