Here, we are first using the numpy.random.randint() function to create an nxn matrix that contains random integers. The generated random integers will be within the range [low, high). And the size argument specifies the size of the created matrix. For example, size=(n, n) specifies that the created matrix will have n rows and n columns.
Now, we are using the numpy.tril() function to create a lower triangular matrix from A. The argument k=0 specifies that all the elements above the principal diagonal will be made zero. And the elements across or below the principal diagonal are copied from A to the created lower triangular matrix.
The output of the mentioned program will be:
A: [[5 5 6] [4 8 8] [9 2 3]] The Lower Triangular Matrix L: [[5 0 0] [4 8 0] [9 2 3]]






0 Comments