MCPcopy Create free account
hub / github.com/numpy/numpy / zeros

Function zeros

numpy/matlib.py:107–149  ·  view source on GitHub ↗

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')

Source from the content-addressed store, hash-verified

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

Callers 3

test_testOddFeaturesMethod · 0.90
test_testAverage2Method · 0.90
testZerosMethod · 0.50

Calls 1

__new__Method · 0.45

Tested by 3

test_testOddFeaturesMethod · 0.72
test_testAverage2Method · 0.72
testZerosMethod · 0.40