Python Sum certaines postes de tableau


a = np.array([1,2,3,4])   # numpy array with 4 positions
indices = [0, 2]          # list of the indices to sum.

a[indices].sum()		  # returns a[0] + a[2]
Rui Coutinho