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