how to write a matrix to a file in python with this format?
Question: I need to write a matrix to a file with this format `(i, j, a[i,j])` row by
row, but I don't know how to get it. I tried with: `np.savetxt(f, A,
fmt='%1d', newline='\n')`, but it write only matrix values and don't write i,
j!


Answer: 
    import numpy as np
    
    a = np.arange(12).reshape(4,3)
    a_with_index = np.array([idx+(val,) for idx, val in np.ndenumerate(a)])
    np.savetxt('/tmp/out', a_with_index, fmt='%d')
    

writes to /tmp/out the contents

    
    
    0 0 0
    0 1 10
    0 2 20
    1 0 30
    1 1 40
    1 2 50
    2 0 60
    2 1 70
    2 2 80
    3 0 90
    3 1 100
    3 2 110
    

