Question

I have a square matrix, and , if I select two random elements in it, I am interested to determine two cases:

  1. If the two elements are situated on a diagonal parallel with the main diagonal
  2. If the two elements are situated on a diagonal parallel with the secondary diagonal.

I don''t really know if there is a fomula or not, but that is what I''m interested in. A formula that checks this two situations.

From what I''ve seen, two elements are on a diagonal parallel with main diagonal if the difference columnEl1-rowEl1 is equal with the difference columnEl2-rowEl2, and two elements are on a diagonal parallel with the secondary diagonal if the sum columnEl1+rowEl1 is equal with the sum columnEl2+rowEl2. But I don''t know if this applies in general or not.

Also, if this is valid for a square matrix, is it valid for non-square matrix as well?

Was it helpful?

Solution

The answer depends on how you number columns and rows (e.g. top-bottom or bottom-top), but yes, for one type of diagonal, colNb-rowNb should be invariant, and for the other, colNb+rowNb should be invariant; this holds for non-square matrices.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top