MCPcopy Index your code
hub / github.com/numpy/numpy / eye

Function eye

numpy/matlib.py:191–231  ·  view source on GitHub ↗

Return a matrix with ones on the diagonal and zeros elsewhere. Parameters ---------- n : int Number of rows in the output. M : int, optional Number of columns in the output, defaults to `n`. k : int, optional Index of the diagonal: 0 refers to the ma

(n, M=None, k=0, dtype=float, order='C')

Source from the content-addressed store, hash-verified

189 return b
190
191def eye(n, M=None, k=0, dtype=float, order='C'):
192 """
193 Return a matrix with ones on the diagonal and zeros elsewhere.
194
195 Parameters
196 ----------
197 n : int
198 Number of rows in the output.
199 M : int, optional
200 Number of columns in the output, defaults to `n`.
201 k : int, optional
202 Index of the diagonal: 0 refers to the main diagonal,
203 a positive value refers to an upper diagonal,
204 and a negative value to a lower diagonal.
205 dtype : dtype, optional
206 Data-type of the returned matrix.
207 order : {'C', 'F'}, optional
208 Whether the output should be stored in row-major (C-style) or
209 column-major (Fortran-style) order in memory.
210
211 Returns
212 -------
213 I : matrix
214 A `n` x `M` matrix where all elements are equal to zero,
215 except for the `k`-th diagonal, whose values are equal to one.
216
217 See Also
218 --------
219 numpy.eye : Equivalent array function.
220 identity : Square identity matrix.
221
222 Examples
223 --------
224 >>> import numpy.matlib
225 >>> np.matlib.eye(3, k=1, dtype=np.float64)
226 matrix([[0., 1., 0.],
227 [0., 0., 1.],
228 [0., 0., 0.]])
229
230 """
231 return asmatrix(np.eye(n, M=M, k=k, dtype=dtype, order=order))
232
233def rand(*args):
234 """

Callers

nothing calls this directly

Calls 1

asmatrixFunction · 0.90

Tested by

no test coverage detected