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

Add PowLinearOperator for element-wise power operators #31

Open
quattro opened this issue Jun 27, 2023 · 1 comment
Open

Add PowLinearOperator for element-wise power operators #31

quattro opened this issue Jun 27, 2023 · 1 comment
Labels
feature New feature

Comments

@quattro
Copy link
Contributor

quattro commented Jun 27, 2023

Hi all,

I'm prototyping a PowLinearOperator for some internal projects that need to perform (g * g).mv(x) for LinearOperator g and vector x, and thought I'd collect some thoughts before proceeding.

If we restrict to positive integer scalars, then we can rely on the decomposition of (g * g).mv(x) == diag(g diag(x) g.T) [or recurse similarly for scalars > 2].

Would this be of general interest? If so, I'm happy to expand on the test suite and perform a pull req.

@patrick-kidger
Copy link
Owner

If I understand your definition correctly: thinking of the operator as a matrix, this is an elementwise power of each entry in the matrix?

That does seem nontrivial to implement for general operators, so I think this would make sense as a PR! Probably the main thing to be careful about is to avoid compile times increasing as the power increases. The recursion should be doing using a lax.scan to avoid this.

(And moreover it's probably also worth overriding MatrixLinearOperator.__pow__, which can be efficiently special-cased.)

@patrick-kidger patrick-kidger added the feature New feature label Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

No branches or pull requests

2 participants