Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BoundsError when factorizing #4

Closed
cuihantao opened this issue Feb 9, 2022 · 2 comments
Closed

BoundsError when factorizing #4

cuihantao opened this issue Feb 9, 2022 · 2 comments

Comments

@cuihantao
Copy link

cuihantao commented Feb 9, 2022

I ran into a BoundsError when factorizing a sparse matrix, The MWE needs to use the attached CSV file storing the triplets. This might be a wrapper issue because UMFPACK can factorize it,
and a Python-based KLU wrapper provided in KVXOPT also works.

M.csv

Code

using SparseArrays, DataFrames, CSV, LinearAlgebra, KLU

function read_sparse_matrix(M)
    df = CSV.read(M, DataFrame)
    sparse(df[!, "I"], df[!, "J"], df[!, "V"])
end

A = read_sparse_matrix("M.csv")

lu(A) # works


KLU.klu(A)

Output:

BoundsError: attempt to access 431-element Vector{Int64} at index [431:432]

Stacktrace:
  [1] throw_boundserror(A::Vector{Int64}, I::Tuple{UnitRange{Int64}})
    @ Base ./abstractarray.jl:691
  [2] checkbounds
    @ ./abstractarray.jl:656 [inlined]
  [3] view(A::Vector{Int64}, I::UnitRange{Int64})
    @ Base ./subarray.jl:177
  [4] getproperty(klu::KLU.KLUFactorization{Float64, Int64}, s::Symbol)
    @ KLU ~/.julia/packages/KLU/Q4uVP/src/KLU.jl:351
  [5] getproperty(klu::KLU.KLUFactorization{Float64, Int64}, s::Symbol)
    @ KLU ~/.julia/packages/KLU/Q4uVP/src/KLU.jl:389
  [6] show(io::IOContext{IOBuffer}, mime::MIME{Symbol("text/plain")}, K::KLU.KLUFactorization{Float64, Int64})
    @ KLU ~/.julia/packages/KLU/Q4uVP/src/KLU.jl:409
  [7] limitstringmime(mime::MIME{Symbol("text/plain")}, x::KLU.KLUFactorization{Float64, Int64})
    @ IJulia ~/.julia/packages/IJulia/e8kqU/src/inline.jl:43
  [8] display_mimestring
    @ ~/.julia/packages/IJulia/e8kqU/src/display.jl:71 [inlined]
  [9] display_dict(x::KLU.KLUFactorization{Float64, Int64})
    @ IJulia ~/.julia/packages/IJulia/e8kqU/src/display.jl:102
 [10] #invokelatest#2
    @ ./essentials.jl:716 [inlined]
 [11] invokelatest
    @ ./essentials.jl:714 [inlined]
 [12] execute_request(socket::ZMQ.Socket, msg::IJulia.Msg)
    @ IJulia ~/.julia/packages/IJulia/e8kqU/src/execute_request.jl:112
 [13] #invokelatest#2
    @ ./essentials.jl:716 [inlined]
 [14] invokelatest
    @ ./essentials.jl:714 [inlined]
 [15] eventloop(socket::ZMQ.Socket)
    @ IJulia ~/.julia/packages/IJulia/e8kqU/src/eventloop.jl:8
 [16] (::IJulia.var"#15#18")()
    @ IJulia ./task.jl:423
@rayegun
Copy link
Member

rayegun commented Feb 9, 2022

Looks like an error with my printing/display set up. Can you confirm by doing klu(A);?

I'll try to fix it today.

@cuihantao
Copy link
Author

I guess you are right. It doesn't show any error with a semicolon.

@rayegun rayegun closed this as completed in e55885b Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants