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

Power method iterators #139

merged 3 commits into from Jul 25, 2017

Power method iterators #139

merged 3 commits into from Jul 25, 2017


Copy link

haampie commented Jul 11, 2017

As part of getting rid of KrylovSubspace and adding iterators as suggested in #129, here the fix for the power method.

There is a breaking change: the shift-and-invert matrix is not constructed in the method itself (and for good reason, otherwise you could just use RQI and get better convergence at the same computational costs per step). It is assumed the user provides a linear map B supporting A_mul_B!, which has the effect B * x = inv(A - σI) * x where σ is the shift. The only convenience invpowm gives over powm is that the eigenvalue is transformed for you.

For example:

using LinearMaps
σ = 1.0 + 1.3im
A = rand(Complex128, 50, 50)
F = lufact(A - UniformScaling(σ))
Fmap = LinearMap((y, x) -> A_ldiv_B!(y, F, x), 50, Complex128, ismutating = true)
λ, x = invpowm(Fmap, shift = σ, tol = 1e-4, maxiter = 200)

You might argue A_ldiv_B! should be used in invpowm, but the thing is someone could just as well have an explicit inverse matrix inv(A - σI), and then A_mul_B! should be used.

Lastly, the method now stores exactly 3 vectors, and those are pre-allocated; the current behaviour is allocating a new matrix each iteration, together with multiple new vectors.

@haampie haampie changed the title Feature iterator Power method iterators Jul 11, 2017
@haampie haampie force-pushed the haampie:feature-iterator branch from 7d06d4a to be0ce7f Jul 11, 2017
Copy link

codecov-io commented Jul 11, 2017

Codecov Report

Merging #139 into master will decrease coverage by 0.29%.
The diff coverage is 92.1%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #139     +/-   ##
- Coverage   84.97%   84.68%   -0.3%     
  Files          19       19             
  Lines        1478     1463     -15     
- Hits         1256     1239     -17     
- Misses        222      224      +2
Impacted Files Coverage Δ
src/simple.jl 91.04% <92.1%> (-2.86%) ⬇️
src/krylov.jl 43.13% <0%> (-1.97%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9e435ba...be0ce7f. Read the comment docs.

@haampie haampie force-pushed the haampie:feature-iterator branch 4 times, most recently from f2fb06d to af219bc Jul 11, 2017
@haampie haampie force-pushed the haampie:feature-iterator branch from af219bc to 0236d9f Jul 18, 2017
K = KrylovSubspace(A, 1)
x==nothing ? initrand!(K) : init!(K, x/norm(x))
function powm(A; kwargs...)

This comment has been minimized.


andreasnoack Jul 25, 2017 Member

Not related to this PR but we might want to consider renaming this function to something that looks less like a matrix power function.

@andreasnoack andreasnoack merged commit 8da9184 into JuliaMath:master Jul 25, 2017
1 of 2 checks passed
1 of 2 checks passed
coverage/coveralls Coverage decreased (-0.4%) to 84.306%
continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.