The format for alist matrices (binary matrices) is explained in http://www.inference.phy.cam.ac.uk/mackay/codes/alist.html The q-ary matrices use exactly the same format, except for one additional integer per non-zero entry in the matrix For example, here are the first few lines of a q-ary parity matrix file: http://www.inference.phy.cam.ac.uk/mackay/codes/GFQmatrices/q4.sp.9000.6000.4500.1.gz 9000 6000 4 3 4 2 2 2 ... 4 4 3 ... 1 1 3001 1 0 0 2 2 3002 2 0 0 3 1 3003 1 0 0 4 1 3004 2 0 0 The first three lines embody the information about the column weights and row weights. The third number on line 1 says what the value of q is in GF(q). (q=4) Line 4 details the entries in column 1: there is an entry at row 1, and one at row 3001. Both these entries are field element number 1. (The two zeroes are space-fillers.) In column 2, there is a "2" in row 2 and a "2" in row 3002. etc.