handling matrix data in python

Posted by Ovisek on Stack Overflow See other posts from Stack Overflow or by Ovisek
Published on 2012-06-07T04:36:55Z Indexed on 2012/06/07 4:40 UTC
Read the original article Hit count: 146

Filed under:

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.

© Stack Overflow or respective owner

Related posts about python