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

overload 3 arg * to perform quad, and X_A_Xt #127

Open
oxinabox opened this issue Mar 1, 2021 · 0 comments
Open

overload 3 arg * to perform quad, and X_A_Xt #127

oxinabox opened this issue Mar 1, 2021 · 0 comments

Comments

@oxinabox
Copy link
Contributor

oxinabox commented Mar 1, 2021

quad(a, x)          # compute x' * a * x when `x` is a vector.
X_A_Xt(a, x)        # compute `x * a * x'` for a matrix `x`.

Right now, to take advantage of quad and X_A_Xt the user must ask for them directly.
Which is annoying because the user might not know they are dealing with a PDMat.
If the user wrote x' * a * x then it would not hit these methods.

But we could fix this via something like:

function Base.(:*)(x::Union{Adjoint{<:AbstractVector}, Transpose{<:AbstractVector},  a::AbstractPDMat, y::AbstractVector)
    if partent(x) == y
        quad(a, x)
    else
        invoke(...)  # call the generic `*`
    end
end

And similar for X_A_Xt

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

No branches or pull requests

1 participant