ToeplitzMatrices.jl
ToeplitzMatrices.jl copied to clipboard
Unable to invert Toeplitz matrices
julia> using FFTW
julia> using ToeplitzMatrices
julia> y = SymmetricToeplitz([1, 2, 3])
3×3 SymmetricToeplitz{Int64}:
1 2 3
2 1 2
3 2 1
julia> inv(y)
ERROR: MethodError: no method matching ldiv!(::ToeplitzMatrices.ToeplitzFactorization{Float64, SymmetricToeplitz{Float64}, ComplexF64, FFTW.cFFTWPlan{ComplexF64, -1, true, 1, UnitRange{Int64}}}, ::Matrix{Float64})
Closest candidates are:
ldiv!(::Any, ::ChainRulesCore.AbstractThunk) at ~/.julia/packages/ChainRulesCore/ctmSK/src/tangent_types/thunks.jl:90
ldiv!(::LinearAlgebra.SymTridiagonal, ::AbstractVecOrMat; shift) at /usr/share/julia/stdlib/v1.8/LinearAlgebra/src/tridiag.jl:280
ldiv!(::LinearAlgebra.Diagonal, ::AbstractVecOrMat) at /usr/share/julia/stdlib/v1.8/LinearAlgebra/src/diagonal.jl:425
...
Stacktrace:
[1] inv(A::SymmetricToeplitz{Int64})
@ LinearAlgebra /usr/share/julia/stdlib/v1.8/LinearAlgebra/src/generic.jl:1039
[2] top-level scope
@ REPL[6]:1
This is pretty weird; inversion should be able to fall back on the generic algorithm, even if the Toeplitz-specific algorithms haven't been implemented yet.
I'm not a developer of this package but since cholesky() is implemented you can do this inv(cholesky(y)).
Perhaps that should be the fallback for SymmetricToeplitz, though there might be more considerations happening from https://github.com/JuliaLinearAlgebra/ToeplitzMatrices.jl/pull/64#issue-1093189849
Only would work for positive definite… we’d want an LDLt factorisation