I’m trying to read text files defining matrices of the form
q = Int[1 0 0 1; 0 1 1 1; 1 0 1 0; 0 0 1 1]
via julia matrix.jl
or julia -L matrix.jl
. It breaks down for matrices slightly larger than 1000x1000. For example, for 1020x1020 I get
/tmp$ julia -L matrix-1020.jl
Internal error: stack overflow in type inference of typed_hvcat(Type{Int64}, NTuple{1020, Int64}, Int64, Int64...).
This might be caused by recursion over very long tuples or argument lists.
Internal error: stack overflow in type inference of hvcat_fill!(Array{Int64, 2}, NTuple{1040400, Int64}).
This might be caused by recursion over very long tuples or argument lists.
How can one read such not really large matrices into Julia (without writing a function myself that parses matrices)?
For completeness, here is one way to create such matrices:
n = 1020
q = rand((0, 1), n, n)
f = open("matrix-$n.jl", "w")
print(f, "q = Int")
println(f, q)
close(f)
I did noticed this thread. It looks related, but I there doesn’t seem to be a solution.