JuliaApproximation / ApproxFunBase.jl

Core functionality of ApproxFun
MIT License
12 stars 13 forks source link

Stackoverflow when applying adjoint of blockbanded operator on function #659

Closed Jilhg closed 1 month ago

Jilhg commented 1 month ago

I get an stackoverflow error when I try to apply an adjoint of a blockbanded operator on a function. For instance

Op=Derivative(Chebyshev())⊗Derivative(Chebyshev())
f=Fun(sin)⊗Fun(sin)
Op*f # works fine
Op'*f # Stackoverflow

I believe this is due to blockbandwidths(P::AdjointOperator) not being implemented for adjoint operators (while bandwidths(P::AdjointOperator) is implemented in OperatorLayout.jl) and thus the operator is not considered blockbanded. Indeed

println(ApproxFunBase.blockbandwidths(Op)) # (-2, 2)
println(ApproxFunBase.blockbandwidths(Op')) # (ℵ₀, ℵ₀)

The following implementation did the job for me:

ApproxFunBase.blockbandwidths(A::AdjointOperator) = reverse(ApproxFunBase.blockbandwidths(A.op))
println(ApproxFunBase.blockbandwidths(Op')) # (2,-2)

and Op'*f works.

jishnub commented 1 month ago

Would you mind submitting a PR?