Sum of all diagonal elements is equal to sum of square of each element of the matrix.
i.e.,
A = \left[ {\matrix{
{{a_1}} & {{a_2}} & {{a_3}} \cr
{{b_1}} & {{b_2}} & {{b_3}} \cr
{{c_1}} & {{c_2}} & {{c_3}} \cr
} } \right]
then
tr(A.AT)
=a12+a22+a32+b12+b22+b32+c12+c22+c32
ai,bi,ci∈{−1,0,1} for
Exactly three of them are zero and rest are 1 or
1.
Total number of possible matrices
9C3×26
=69×8×7×64