Skip to content

Conversation

@riclarsson
Copy link
Contributor

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

Copy link
Contributor

Copilot AI left a 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::logK function using Cayley-Hamilton theorem to invert the matrix exponential
  • Refactors tran::operator() for improved maintainability by extracting common subexpressions
  • Adds utility functions det, tr, and midtr for 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.

@riclarsson riclarsson merged commit ceea982 into atmtools:main Dec 17, 2025
8 checks passed
@riclarsson riclarsson deleted the logK branch December 17, 2025 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant