> > > But when I give in > julia> spdiagm(x, 1, length(x), length(x)) > ERROR: BoundsError > in sparse at sparse/csparse.jl:50 > in spdiagm at sparse/sparsematrix.jl:2133 > in spdiagm at sparse/sparsematrix.jl:2141 > > I get the above error. Any leads on this would be great. Thanks. >
You need to use length(x)+1. If you have an MxM matrix, then the k-th diagonal has M-k entries. You are supplying M entries for the 1st diagonal, which is too many.