numpy.matlib.identity()This function is used to return an identity matrix of the given size. An identity matrix is the one with diagonal elements initializes to 1 and all other elements to zero. SyntaxParametersIt accepts the following parameters.
ReturnIt returns an identity matrix of the specified size and specified data type. ExampleOutput: [[1. 0. 0. 0.] [0. 1. 0. 0.] [0. 0. 1. 0.] [0. 0. 0. 1.]] Example: Identity matrix with integer valuesOutput: [[1 0 0 0] [0 1 0 0] [0 0 1 0] [0 0 0 1]] Next Topicnumpy.matlib.ones() |