Return a new matrix of given shape and type, without initializing entries. Parameters ---------- shape : int or tuple of int Shape of the empty matrix. dtype : data-type, optional Desired output data-type. order : {'C', 'F'}, optional Whether to store mul
(shape, dtype=None, order='C')
| 23 | __all__ += np.__all__ |
| 24 | |
| 25 | def empty(shape, dtype=None, order='C'): |
| 26 | """Return a new matrix of given shape and type, without initializing entries. |
| 27 | |
| 28 | Parameters |
| 29 | ---------- |
| 30 | shape : int or tuple of int |
| 31 | Shape of the empty matrix. |
| 32 | dtype : data-type, optional |
| 33 | Desired output data-type. |
| 34 | order : {'C', 'F'}, optional |
| 35 | Whether to store multi-dimensional data in row-major |
| 36 | (C-style) or column-major (Fortran-style) order in |
| 37 | memory. |
| 38 | |
| 39 | See Also |
| 40 | -------- |
| 41 | numpy.empty : Equivalent array function. |
| 42 | matlib.zeros : Return a matrix of zeros. |
| 43 | matlib.ones : Return a matrix of ones. |
| 44 | |
| 45 | Notes |
| 46 | ----- |
| 47 | Unlike other matrix creation functions (e.g. `matlib.zeros`, |
| 48 | `matlib.ones`), `matlib.empty` does not initialize the values of the |
| 49 | matrix, and may therefore be marginally faster. However, the values |
| 50 | stored in the newly allocated matrix are arbitrary. For reproducible |
| 51 | behavior, be sure to set each element of the matrix before reading. |
| 52 | |
| 53 | Examples |
| 54 | -------- |
| 55 | >>> import numpy.matlib |
| 56 | >>> np.matlib.empty((2, 2)) # filled with random data |
| 57 | matrix([[ 6.76425276e-320, 9.79033856e-307], # random |
| 58 | [ 7.39337286e-309, 3.22135945e-309]]) |
| 59 | >>> np.matlib.empty((2, 2), dtype=np.int_) |
| 60 | matrix([[ 6600475, 0], # random |
| 61 | [ 6586976, 22740995]]) |
| 62 | |
| 63 | """ |
| 64 | return ndarray.__new__(matrix, shape, dtype, order=order) |
| 65 | |
| 66 | def ones(shape, dtype=None, order='C'): |
| 67 | """ |
searching dependent graphs…