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

Rename chbv -> chbmv; improved in-place treatment #23

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

acroy
Copy link
Owner

@acroy acroy commented Nov 24, 2017

As partly discussed in #20. Might still need some smoothing.

@mforets
Copy link
Contributor

mforets commented Nov 24, 2017

i was thinking if it's more efficient to directly replace the diagonal element of B from the previous one, avoiding copy!(B, A) each time. this is the idea concretely, but i haven't benchmarked it (yet):

function chbmv!{T<:Complex}(w::Vector{T}, A, vec::Vector{T}, fac=factorize)
    p = min(length(θ), length(α))
    t = [θ; θconj]
    a = 0.5 * [α; αconj]

    tmp_v = similar(vec)
    B = A - θ[1]*I
    scale!(copy!(tmp_v, vec), a[1])
    A_ldiv_B!(fac(B), tmp_v)
    copy!(scale!(w, α0), tmp_v)

    @inbounds for i = 2:2*p
        scale!(copy!(tmp_v, vec), a[i])
        for n=1:size(B,1)
            B[n,n] = B[n,n] + t[i-1] - t[i]
        end
        A_ldiv_B!(fac(B), tmp_v)
        w .+=  tmp_v
    end

    return w
end # chbmv!

@acroy
Copy link
Owner Author

acroy commented Nov 24, 2017

You are basically right. However if fac is changing B (like lufact!) we need a copy.

@mforets
Copy link
Contributor

mforets commented Nov 24, 2017

ok, i see. one would need to do A_ldiv_B!(fac(copy(B)), tmp_v), and in the end it's pretty much the same speed as doing a copy of A to B and then B[n,n] = A[n,n] - t[i].

@acroy acroy mentioned this pull request Jul 30, 2018
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.

2 participants