create a code that will determine if a given input is(matrix) is a diagonal matrix, square matrix, or not

Recommended Answers

What the formula for that?

Jump to Post

All 2 Replies

What the formula for that?

Your first check should be to see if the matrix is square or not because only square matrices can also be diagonal matrices. Once you have determined that the matrix is square you than can start iterating through the elements to see if they are of value 0 or not. Only the elements a11 a22 a33 etc should be not equal to 0. You might also check out this link:
last part there which deals with matrices. Interesting there is the part of triangular matrices lower and upper which are playing into the diagonal matrices. I will keep checking these post to see how you are progressing.
Good luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.