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

preconditioning #7

Merged
merged 3 commits into from
Oct 19, 2023
Merged

preconditioning #7

merged 3 commits into from
Oct 19, 2023

Conversation

filtron
Copy link
Owner

@filtron filtron commented Oct 12, 2023

add preconditoned version of cholesky computation as per feature request.

Copy link
Collaborator

@nathanaelbosch nathanaelbosch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for adding this! I think it might make sense to also add a preconditioned version of the transition matrix A to complete this PR?

@filtron
Copy link
Owner Author

filtron commented Oct 13, 2023

Great, thanks for adding this! I think it might make sense to also add a preconditioned version of the transition matrix A to complete this PR?

Hm.... should they both be using the same preconditioner? and also should both functions compute the preconditioner?
If yes to the former that seems like a lot of superfluous computations for the standard use case...
One alternative is to make functions

transition_matrix_and_cov_cholf_1d 
transition_matrix_and_cov_cholf_precond_1d

@nathanaelbosch
Copy link
Collaborator

nathanaelbosch commented Oct 13, 2023

should they both be using the same preconditioner?

This is what the "Stable Implementation ..." paper does at least.

should both functions compute the preconditioner?

Probably not as that would lead to duplication? So maybe either have one function for A, Q, P each, or as you suggest one function that computes both the transition matrix and covariance. I don't know what the best version is; I think that personally in ProbNumDiffEq.jl I would still use my own preconditioner implementation (here) to update them in-place at each step, so for me it would not matter too much which you choose.

@filtron
Copy link
Owner Author

filtron commented Oct 13, 2023

So maybe the way to go is to have functions

precond
transition_matrix_precond_1d
cov_cholf_precond_1d

where the latter two only return preconditioned matrices, the correct matrices can then be obtained by multiplying with

precond(ndiff, dt, ReverseTaylor()) |> Diagonal 

@filtron
Copy link
Owner Author

filtron commented Oct 13, 2023

@nathanaelbosch

A slight problem with the above of course is that the routines dont know with eltype to use for the arrays.
I therefore changed the call signatures to

transition_matrix_precond_1d(ndiff::Integer, T, ::ReverseTaylor)
transition_cov_cholf_precond_1d(ndiff::Integer, T, ::ReverseTaylor)

where T is the element type desired for the output arrays.
Another alternative is of course to make the user supply arrays to be written into with the desired eltype. Thoughts?

src/iwp.jl Outdated
@@ -82,6 +82,20 @@ function _transition_matrix_1d(ndiff::Integer, dt::T, ::ReverseTaylor) where {T<
end


precond(ndiff::Integer, dt::Real, ::ReverseTaylor) = @. sqrt(dt) * dt^(0:ndiff) / factorial(0:ndiff)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular reason for why this doesn't output a Diagonal directly? Then all the functiosns return matrices.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could certainly return a Diagonal matrix instead. But now, weekend.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nathanaelbosch fine now?

@nathanaelbosch nathanaelbosch linked an issue Oct 13, 2023 that may be closed by this pull request
Copy link
Collaborator

@nathanaelbosch nathanaelbosch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I think the implementation could be made slightly more efficient, at least from what I recall I replaced some parts to compute products cumulatively instead of calling factorial and things like that, but the result is much less readable, so I'd say this is perfectly fine :) Thanks a lot!

@filtron filtron merged commit 1e3b166 into main Oct 19, 2023
3 checks passed
@filtron filtron deleted the preconditioning branch October 19, 2023 19:10
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.

Implement a preconditioned version as suggested by Krämer et al.
2 participants