For a solution to a similar problem to this see the following comment; How to build this sparsematrix in Julia - #9 by acxz