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

A'x falls back on generic mul #52

Open
baggepinnen opened this issue Jul 16, 2020 · 1 comment
Open

A'x falls back on generic mul #52

baggepinnen opened this issue Jul 16, 2020 · 1 comment

Comments

@baggepinnen
Copy link
Contributor

Currently, A'x where A::Toeplitz falls back onto a generic and slow method. By defining

function LinearAlgebra.Adjoint(A::Toeplitz{T}) where T
    At = Toeplitz(A.vr, A.vc)
end

the problem is mitigated and the optimized method for mul! is used. Still, if A'x occurs in a loop, the initialization of the Toeplitz object occurs each iteration, which is suboptimal since it performs some allocations and plans an FFT etc. Ideas on how to solve the problem in general is appreciated.

In the meantime, would you be up for a PR that adds the definition above?

@dlfivefifty
Copy link
Member

Sounds great! Though you should never overload a type constructor (Adjoint) to return a different type, unless you really have good reasons: it is confusing for users. Instead, overload the function adjoint.

Note if a user is worried about A' being expansive, they can move that out of the loop.

Down the line, this package may move to a trait-based setup using ArrayLayouts.jl, (as BandedMatrices.jl and BlockArrays.jl have). This would allow Adjoint(Toeplitz(A.vr, A.vc)) to conform to a ToeplitzLayout interface. Though that's a ways off from materialising.

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

2 participants