Diagonal

A matrix is said to be diagonal if all its non-diagonal elements are zero. In other words, a diagonal matrix is a square matrix where all the elements outside the main diagonal are zero. The main diagonal of a matrix is the set of elements that runs from the top-left corner to the bottom-right corner…