First page Back Continue Last page Overview Graphics

Diagonal Matrices: Alternative Way

numpy.eye(rows, cols=None, k=0, dtype=<type 'float'>)

Returns a 2-D array with ones on the k-th diagonal and zeros elsewhere. The shape is (rows, rows) if cols is None otherwise (rows, cols).

If k is equal to 0 (the default) the main diagonal will be set to 1, a positive value of k refers to an upper diagonal, and a negative value to a lower diagonal.

k=

-1 0 1