Interpret the input as a matrix. Unlike `matrix`, `asmatrix` does not make a copy if the input is already a matrix or an ndarray. Equivalent to ``matrix(data, copy=False)``. Parameters ---------- data : array_like Input data. dtype : data-type Data-type
(data, dtype=None)
| 35 | |
| 36 | @set_module('numpy') |
| 37 | def asmatrix(data, dtype=None): |
| 38 | """ |
| 39 | Interpret the input as a matrix. |
| 40 | |
| 41 | Unlike `matrix`, `asmatrix` does not make a copy if the input is already |
| 42 | a matrix or an ndarray. Equivalent to ``matrix(data, copy=False)``. |
| 43 | |
| 44 | Parameters |
| 45 | ---------- |
| 46 | data : array_like |
| 47 | Input data. |
| 48 | dtype : data-type |
| 49 | Data-type of the output matrix. |
| 50 | |
| 51 | Returns |
| 52 | ------- |
| 53 | mat : matrix |
| 54 | `data` interpreted as a matrix. |
| 55 | |
| 56 | Examples |
| 57 | -------- |
| 58 | >>> import numpy as np |
| 59 | >>> x = np.array([[1, 2], [3, 4]]) |
| 60 | |
| 61 | >>> m = np.asmatrix(x) |
| 62 | |
| 63 | >>> x[0,0] = 5 |
| 64 | |
| 65 | >>> m |
| 66 | matrix([[5, 2], |
| 67 | [3, 4]]) |
| 68 | |
| 69 | """ |
| 70 | return matrix(data, dtype=dtype, copy=False) |
| 71 | |
| 72 | |
| 73 | @set_module('numpy') |
searching dependent graphs…