free login bet at home esports_login bonus latest casino no deposit bonus codes 2019_Welfare offer betdaq api call limits

Sat, 21 Jan 2017 07:24:07 -0800

On 21.01.2017 16:10, wrote:
> Is there a simple way to fill in diagonal elements in an array for other
> than main diagonal?
> As far as I can see, the diagxxx functions that have offset can only
> read and not inplace modify, and the functions for modifying don't have
> offset and only allow changing the main diagonal.
> Usecase: creating banded matrices (2-D arrays) similar to toeplitz.

you can construct index arrays or boolean masks to index using the
np.tri* functions.

a = np.arange(5*5).reshape(5,5)
band = np.tri(5, 5, 1, dtype=np.bool) & ~np.tri(5, 5, -2, dtype=np.bool)
a[band] = -1
NumPy-Discussion mailing list
free online betting

Reply via email to