-
Notifications
You must be signed in to change notification settings - Fork 35
Log k #1072
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
Log k #1072
Conversation
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.
Pull request overview
This PR introduces the rtepack::logK function to compute the logarithm of a Mueller matrix and convert it back to a Propagation matrix. This functionality is needed for porting Monte Carlo scattering code to ARTS3, where computing the logarithm of transmission matrices is essential for polarized light handling.
Key changes:
- Implements
rtepack::logKfunction using Cayley-Hamilton theorem to invert the matrix exponential - Refactors
tran::operator()for improved maintainability by extracting common subexpressions - Adds utility functions
det,tr, andmidtrfor Mueller matrices - Includes comprehensive Python test suite with multiple test cases
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
src/core/rtepack/rtepack_transmission.cc |
Implements the logK function and refactors tran::operator() for better readability |
src/core/rtepack/rtepack_transmission.h |
Declares the new logK function signature |
src/core/rtepack/rtepack_mueller_matrix.h |
Adds det, tr, and midtr utility functions; refactors inv to use det |
src/python_interface/py_rtepack.cpp |
Exposes logK function and tran class to Python with documentation |
tests/python/math/logK.py |
Adds test suite covering various propagation matrix configurations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
I was having a look at porting some of the scattering code (monte carlo) to ARTS3, just to get a feel of the amount of work. It relies on being able to take the logarithm of the transmission - which is easy when you consider purely unpolarized light but gets difficult elsewise. So I add here a rtepack::logK function, which turns a Mueller matrix into a Propagation matrix.
The method is documented in the code. A test is added to catch if it breaks.
While it is of course possible to call this method with any 4x4 matrix, it is not generic but expects to be able to unwind the exponential mechanisms completely. Quick tests shows this method generally performs better than scipy.linalg.logm