JuliaApproximation / ContinuumArrays.jl

A package for representing quasi arrays with continuous indices
MIT License
27 stars 5 forks source link

Continous Linear Algebra #124

Open freemin7 opened 2 years ago

freemin7 commented 2 years ago

I was introduced as Continous Linear Algebra by Nick Trefethen which demonstrated the issue of using monomials a basis using chebfun, so i expected similar functionality from ApproxFun which is apperently better addressed here.

I was failing to get a result for rank([ 1 sin(x)^2 cos(x)^2]) which would be 2 but there is a lot more that can be done with continous linear algebra.

dlfivefifty commented 2 years ago

Note there isn't that much to do to support rank:

julia> P = Legendre();

julia> x = axes(P,1);

julia> A = [one(x) sin.(x).^2 cos.(x).^2]; 

julia> rank((P \ A).args[2])
2

Note the use of Legendre is immaterial here (P = ChebyshevT() work the same), but I used it as I was thinking of qr(::AbstractQuasiMatrix).

So we need the following:

# In ContinuumArrays.jl
LinearAlgebra.rank(A::AbstractQuasiMatrix) = _rank(axes(A,1), A) 

# In ClassicalOrthogonalPolynomials.jl
_rank(::Inclusion{<:Any,<:ChebyshevInterval}, A) = rank(Legendre{eltype(A)}() \ A)

# In ArrayLayouts.jl
LinearAlgebra.svdvals(A::LayoutMatrix) = _svdvals(MemoryLayout(A), A)

# In LazyArrays.jl
_svdvals(::PaddedLayout, A) = svdvals(paddeddata(A)) # TODO: data is too small

A similar setup would for QR, just need to overload _qr(::PaddedLayout, A).

Unfortunately I don't have time to do this ATM.