handling matrix data in python
- by Ovisek
I was trying to progressively subtract values of a 3D matrix. The matrix looks like:
ATOM 1223 ZX SOD A 11 2.11 -1.33 12.33
ATOM 1224 ZY SOD A 11 -2.99 -2.92 20.22
ATOM 1225 XH HEL A 12 -3.67 9.55 21.54
ATOM 1226 SS ARG A 13 -6.55 -3.09 42.11
...
here the last three columns are representing values for axes x,y,z respectively.
now I what I wanted to do is, take the values of x,y,z for 1st line and subtract with 2nd,3rd,4th line in a iterative way and print the values for each axes.
I was using:
for line in map(str.split,inp):
x = line[-3]
y = line[-2]
z = line[-1]
for separating the values, but how to do in iterative way. should I do it by using Counter.