What is a lower triangular matrix?
A lower triangular matrix is a square matrix in which all the elements above the principal diagonal are zero. For example, the matrix A given below is a lower triangular matrix.
So, if ai,j is the element in the ith row and jth column of the matrix A, then we can say that the square matrix A is a lower triangular matrix if the following condition holds true:
So, the square matrix B given below is a 3×3 lower triangular matrix.
How to create a lower triangular matrix using Python NumPy?
We can use the following Python code to create a lower triangular matrix using NumPy.
import numpy n = 3 A = numpy.random.randint(low=1, high=10, size=(n, n)) L = numpy.tril(A, k=0) print("A: \n", A) print("The Lower Triangular Matrix L: \n", L)
…
0 Comments