Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • $\begingroup$ Simpler indeed. But it will work only for binary matrices. Well, actually, it is still somewhat unclear, what the OP's usage spectrum and desired result in the general case is supposed to be. I interpreted it as if the OP wants to replace all nonsymmetric entries of the input matrix by zeroes. $\endgroup$ Commented Oct 28, 2018 at 16:19
  • $\begingroup$ @Henrik -- Agreed, I took the binary example suggested by the OP as indicating interest only in binary matrices. $\endgroup$ Commented Oct 28, 2018 at 16:25
  • $\begingroup$ @Henrik: I wanted to extract binary cells only: that is, if (i,j)==(j,i)==1, then keep them in the output matrix, otherwise place zeros to both cells. What you are saying in your comment is what I actually wanted: replace all non-symmetric entries of the input matrix with zeros. Is Bill's proposal equivalent to your proposal? I want to make sure this because in the original case with n=1000 I cannot check it visually. $\endgroup$ Commented Oct 28, 2018 at 16:37
  • 1
    $\begingroup$ A simple example for which bill's and my proposals lead to different output is the matrix M = {{1, 2},{1,1}}. In general it is preferrable to post also all assumptions on the input data already in the question. Moreover your question leave a lot room for interpretation. Please specify exactly what the desired output for a general input matrix should be. $\endgroup$ Commented Oct 28, 2018 at 16:38
  • $\begingroup$ @Henrik: I will edit the question in line with your comment. $\endgroup$ Commented Oct 28, 2018 at 17:47