1
$\begingroup$

I am aware of a symmetric matrix type in uBLAS as ublas::symmetric_matrix matrix. Is there an equivalent for this in Eigen library that can be used to construct one or do we need to explicitly check if a matrix is symmetric or not which could be a time expensive solution (O(n^2)). Any guidance is appreciated.

$\endgroup$
2
  • $\begingroup$ For now, I did something like this if (m.selfadjointView<Upper>() == m.selfadjointView<Lower>()) {} else {} If there is a better way, please let me know. $\endgroup$ Commented Dec 14, 2021 at 15:47
  • $\begingroup$ Typically, if you need a symmetric matrix you just completely ignore the upper or lower triangle of the matrix. You can fill the non-referenced triangle with NaNs for all you care. If you want to use a linear algebra routine that does not support implicitly symmetric matrices, then you would fill the other triangle like so: m = m.selfadjointView<Lower>(); $\endgroup$
    – Charlie S
    Commented Dec 14, 2021 at 19:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.