How to derive a general formula about the number of n*n nonsingular matrix under one constraint?

23 Views Asked by At

If there is an n-by-n matrix, each element in the matrix can only be 1 or 0. We assume that an n-by-n matrix is nonsingular, then we do the two's complement at only the diagonal of the matrix. After I do the two's complement at the diagonal, an n-by-n matrix is still nonsingular. How many numbers of this kind of matrices can be found in an n-by-n matrix??? Can we derive a general formula?? If n=2, I can derive the number of this kind of matrices is 2, n=3, the number of this kind of matrices is 48. But I have no idea whether it exists a general formula when we expand to the n-dimensional matrix.