From: Johannes L. <a.u...@gm...> - 2006-10-11 08:35:47
|
> I'm just wondering if there is a way that i can increment all the values > along a diagonal? Assume you want to change mat. # min() only necessary for non-square matrices index = arange(min(mat.shape[0], mat.shape[1])) # add 1 to each diagonal element matrix[index, index] += 1 # add some other stuff matrix[index, index] += some_array_shaped_like_index HTH, Johannes |