I have a scipy.sparse.linalg.LinearOperator object. I'd like to check if its associated matrix is symmetric without actually instantiating the matrix in the most computationally efficient way possible. Does anybody know a good way to do this?

  • 1
    $\begingroup$ Let's call your operator $A$. Can't you check $A \mathbf{e}_i - A^T \mathbf{e}_i$, for $\mathbf{e}_i$ the columns of the identity matrix? $\endgroup$
    – nicoguaro
    Apr 9 at 17:54
  • 4
    $\begingroup$ Better to compare $x^T(Ay)$ and $y^T(Ax)$ for $x,y$ (sufficiently many) random vectors. (I assume that $A$ is too large to check all unit vectors.) $\endgroup$ Apr 9 at 18:28
  • $\begingroup$ @ChristianClason, yes. That was my other option, but I was expecting a reply with the size of the system. $\endgroup$
    – nicoguaro
    Apr 10 at 18:32
  • $\begingroup$ Sorry for the late response. The size of the system is arbitrary (likely range of somewhere between 100x100 - 100,000x100,000), but I want to be as scalable as possible. Thanks for the responses! I'll do some profiling $\endgroup$
    – Alex L
    Apr 11 at 1:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.