Return a matrix of given shape and type, filled with zeros. Parameters ---------- shape : int or sequence of ints Shape of the matrix dtype : data-type, optional The desired data-type for the matrix, default is float. order : {'C', 'F'}, optional Whe
(shape, dtype=None, order='C')
| 109 | return a |
| 110 | |
| 111 | def zeros(shape, dtype=None, order='C'): |
| 112 | """ |
| 113 | Return a matrix of given shape and type, filled with zeros. |
| 114 | |
| 115 | Parameters |
| 116 | ---------- |
| 117 | shape : int or sequence of ints |
| 118 | Shape of the matrix |
| 119 | dtype : data-type, optional |
| 120 | The desired data-type for the matrix, default is float. |
| 121 | order : {'C', 'F'}, optional |
| 122 | Whether to store the result in C- or Fortran-contiguous order, |
| 123 | default is 'C'. |
| 124 | |
| 125 | Returns |
| 126 | ------- |
| 127 | out : matrix |
| 128 | Zero matrix of given shape, dtype, and order. |
| 129 | |
| 130 | See Also |
| 131 | -------- |
| 132 | numpy.zeros : Equivalent array function. |
| 133 | matlib.ones : Return a matrix of ones. |
| 134 | |
| 135 | Notes |
| 136 | ----- |
| 137 | If `shape` has length one i.e. ``(N,)``, or is a scalar ``N``, |
| 138 | `out` becomes a single row matrix of shape ``(1,N)``. |
| 139 | |
| 140 | Examples |
| 141 | -------- |
| 142 | >>> import numpy.matlib |
| 143 | >>> np.matlib.zeros((2, 3)) |
| 144 | matrix([[0., 0., 0.], |
| 145 | [0., 0., 0.]]) |
| 146 | |
| 147 | >>> np.matlib.zeros(2) |
| 148 | matrix([[0., 0.]]) |
| 149 | |
| 150 | """ |
| 151 | a = ndarray.__new__(matrix, shape, dtype, order=order) |
| 152 | a.fill(0) |
| 153 | return a |
| 154 | |
| 155 | def identity(n, dtype=None): |
| 156 | """ |
searching dependent graphs…