I have an array with most of the elements are zero.
A = [ 1,0,2
2,3,0
0,0,4 ]
I want to save this as
rowid[0] colid[0] 1
rowid[0] colid[2] 2
rowid[1] colid[0] 2
rowid[1] colid[1] 3
rowid[2] colid[2] 4
here rowid and colid are arrays which maps the array indices to the actual entries in an original file.
How can I do this without using a for loop ?.
argwhere.with your own line formatting."rowid[0]"etc. ?savetxtcould be used a fancier format such asfmt='row[%d] col[%d] %d'