bundles / numpy 2.4.4 / numpy / matlib / ones
function
numpy.matlib:ones
source: /numpy/matlib.py :66
Signature
def ones ( shape , dtype = None , order = C ) Summary
Matrix of ones.
Extended Summary
Return a matrix of given shape and type, filled with ones.
Parameters
shape: {sequence of ints, int}Shape of the matrix
dtype: data-type, optionalThe desired data-type for the matrix, default is np.float64.
order: {'C', 'F'}, optionalWhether to store matrix in C- or Fortran-contiguous order, default is 'C'.
Returns
out: matrixMatrix of ones of given shape, dtype, and order.
Notes
If shape has length one i.e. (N,), or is a scalar N, out becomes a single row matrix of shape (1,N).
Examples
np.matlib.ones((2,3))
✗np.matlib.ones(2)
✗See also
- matlib.zeros
Zero matrix.
- ones
Array of ones.
Aliases
-
numpy.matlib.ones