Banded matrix with ones in the lower triangular portion of the matrix

What do you need to do with the matrix? If all you need are matvecs and solves, then you could probably easily write a custom function for the multiplication that is efficient, and then use something like IterativeSolvers.jl to perform your solves with very little extra code. Something like this:

using IterativeSolvers 

struct MyMatrix
  B::(banded matrix object)
end

function lowertri_ones_apply(v)
  .... # easy to write in matrix-free form
end

function Base.:*(M::MyMatrix, v)
    M.B*v + lowertri_ones_apply(v)
end

function LinearAlgebra.mul!(M::MyMatrix, v)
  ... # should actually write THIS first, then make have * just make a copy and then call mul!.
end

eltype(M::MyMatrix) = ...

size(M::MyMatrix) = ...

function mysolve(M::MyMatrix, v; kwargs...)
  IterativeSolvers.gmres(M, v; kwargs...)
end

If you need more operations than that, maybe it isn’t so easy. But if those are the only operations you need, some custom approach like this would probably be pleasant and fast.

1 Like