111
numpy.matlib.ones()
This function is used to return a new matrix with the values initialized to ones.
Syntax
Parameters
It accepts the following parameters.
- shape: It is the Tuple defining the shape of the matrix.
- dtype: It is the data type of the matrix.
- order: It is the insertion order of the matrix.
Return
A matrix is returned with all the entries initialized to 1.
Example
Output:
[[1. 1. 1.] [1. 1. 1.] [1. 1. 1.]]
Example: initializing integer values
Output:
[[1 1 1] [1 1 1] [1 1 1]]
Example: specifying Insertion order
Output:
[[1 1 1] [1 1 1] [1 1 1]]
Next Topicnumpy.matlib.zeros()