Matrix of ones. Return a matrix of given shape and type, filled with ones. Parameters ---------- shape : {sequence of ints, int} Shape of the matrix dtype : data-type, optional The desired data-type for the matrix, default is np.float64. order : {'C', '
(shape, dtype=None, order='C')
| 64 | return ndarray.__new__(matrix, shape, dtype, order=order) |
| 65 | |
| 66 | def ones(shape, dtype=None, order='C'): |
| 67 | """ |
| 68 | Matrix of ones. |
| 69 | |
| 70 | Return a matrix of given shape and type, filled with ones. |
| 71 | |
| 72 | Parameters |
| 73 | ---------- |
| 74 | shape : {sequence of ints, int} |
| 75 | Shape of the matrix |
| 76 | dtype : data-type, optional |
| 77 | The desired data-type for the matrix, default is np.float64. |
| 78 | order : {'C', 'F'}, optional |
| 79 | Whether to store matrix in C- or Fortran-contiguous order, |
| 80 | default is 'C'. |
| 81 | |
| 82 | Returns |
| 83 | ------- |
| 84 | out : matrix |
| 85 | Matrix of ones of given shape, dtype, and order. |
| 86 | |
| 87 | See Also |
| 88 | -------- |
| 89 | ones : Array of ones. |
| 90 | matlib.zeros : Zero matrix. |
| 91 | |
| 92 | Notes |
| 93 | ----- |
| 94 | If `shape` has length one i.e. ``(N,)``, or is a scalar ``N``, |
| 95 | `out` becomes a single row matrix of shape ``(1,N)``. |
| 96 | |
| 97 | Examples |
| 98 | -------- |
| 99 | >>> np.matlib.ones((2,3)) |
| 100 | matrix([[1., 1., 1.], |
| 101 | [1., 1., 1.]]) |
| 102 | |
| 103 | >>> np.matlib.ones(2) |
| 104 | matrix([[1., 1.]]) |
| 105 | |
| 106 | """ |
| 107 | a = ndarray.__new__(matrix, shape, dtype, order=order) |
| 108 | a.fill(1) |
| 109 | return a |
| 110 | |
| 111 | def zeros(shape, dtype=None, order='C'): |
| 112 | """ |
searching dependent graphs…