Would something like this work?
matrix X
loop i=1..5 -q
loop m = i+1..5 -q
#Do stuff
endloop
endloop
Logan