Advertisement
Guest User

Untitled

a guest
Jan 1st, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 0.80 KB | None | 0 0
  1.     function readMatrix( matrixAFile::AbstractString; vectorBFile=nothing)
  2.         open(matrixAFile, "r") do f
  3.             line = strip(readline(f), ['\n', '\t'])
  4.             line = split(line, " ")
  5.        
  6.             n = parse(Int, line[1])
  7.             l = parse(Int, line[2])
  8.  
  9.             I = Int64[]
  10.             J = Int64[]
  11.             V = Float64[]  
  12.  
  13.             index = 1
  14.             while !eof(f)
  15.                 line = strip(readline(f), ['\n'])
  16.                 line = split(line, " ")
  17.  
  18.                 push!(I, parse(Int64, line[1]))
  19.                 push!(J, parse(Int64, line[2]))
  20.                 push!(V, parse(Float64, line[3]))
  21.  
  22.                 index = index + 1
  23.             end
  24. println(V)
  25.             S = sparse(I,J,V)
  26.         println(S)
  27.  
  28.         end #open
  29.     end #readMatrix
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement