Suppose that I have a matrix M:
M={ {0, 1, 1, 0, 1, 0}, {1, 0, 0, 1, 1, 1}, {1, 1, 0, 0, 1, 0}, {0, 1, 1, 0, 0, 0}, {1, 0, 0, 1, 0, 1}, {1, 1, 1, 1, 0, 0} }; I like to extract from M the symmetric matrix symM:
symM={ {0, 1, 1, 0, 1, 0}, {1, 0, 0, 1, 0, 1}, {1, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0}, {1, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0} }; I do not want to use Do or If commands. I like to implement matrix operations to extract the symmetric part of M.
EDIT 1
In general terms, matrix M is composed of 1 and 0 only, with the condition that the diagonal cells be zeros. My goal is to extract the matrix symM which should only include 1s in the non-zero reciprocal cells (or symmetric cells), otherwise zero.
Example, in the above example, M[[1,2]]=1 and M[[2,1]]=1, then both symM[[1,2]] and symM[[2,1]] should be 1. All other cells which are not qualified should be all zero.
I hope the question is clearer now. Thank you.
Scancan be used to collect the non-negative symmetric positions inM. $\endgroup$BitAnd[M, Transpose[M]]$\endgroup$