The main diagonal of a square matrix can be extracted in the Wolfram Language using Tr[m, List].
Main Diagonal
See also
DiagonalCite this as:
Weisstein, Eric W. "Main Diagonal." From MathWorld--A Wolfram Web Resource. https://mathworld.wolfram.com/MainDiagonal.html