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)
| 36 | |
| 37 | @set_module('numpy') |
| 38 | def asmatrix(data, dtype=None): |
| 39 | """ |
| 40 | Interpret the input as a matrix. |
| 41 | |
| 42 | Unlike `matrix`, `asmatrix` does not make a copy if the input is already |
| 43 | a matrix or an ndarray. Equivalent to ``matrix(data, copy=False)``. |
| 44 | |
| 45 | Parameters |
| 46 | ---------- |
| 47 | data : array_like |
| 48 | Input data. |
| 49 | dtype : data-type |
| 50 | Data-type of the output matrix. |
| 51 | |
| 52 | Returns |
| 53 | ------- |
| 54 | mat : matrix |
| 55 | `data` interpreted as a matrix. |
| 56 | |
| 57 | Examples |
| 58 | -------- |
| 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') |