Sum a dimension N square matrix main and anti diagonal values.
Given the Matrix:
[ [ 1, 2, 3, 4]
, [ 5, 6, 7, 8]
, [ 9, 10, 11, 12]
, [13, 14, 15, 16]
]
The main diagonal is:
[ [ 1, , , ]
, [ , 6, , ]
, [ , , 11, ]
, [ , , , 16]
]
And the anti diagonal is:
[ [ , , , 4]
, [ , , 7, ]
, [ , 10, , ]
, [13, , , ]
]
Take and sum these values.
Be careful! Non-square matrices should not return the sum.