Your current version doesn't seem to do anything for me (on SeaMonkey 2.33)
Maybe you switched the row/col order of the matrices while parsing the type 1 lines into a matrix?
Maybe you switched the row/col order of the matrices while parsing the type 1 lines into a matrix?