Adding a conditional conjugateIf<bool>() method would allow to simplify the implementation of some of our solver code. For instance, in PartialPivLU, we have code like: if (Conjugate) { dst = m_lu.template triangularView<Upper>().adjoint().solve(rhs); m_lu.template triangularView<UnitLower>().adjoint().solveInPlace(dst); } else { dst = m_lu.template triangularView<Upper>().transpose().solve(rhs); m_lu.template triangularView<UnitLower>().transpose().solveInPlace(dst); } that could be factorized as: dst = m_lu.template triangularView<Upper>().transpose() .template conjugateIf<Conjugate>().solve(rhs); m_lu.template triangularView<UnitLower>().transpose() .template conjugateIf<Conjugate>().solveInPlace(dst); More complicated exemples include FullPivLU::_solve_impl_transposed, and some code in PR567: https://bitbucket.org/eigen/eigen/pull-requests/567/restructuring-of-all-densesolvers/diff We could keep it internal: dst = internal::conj_if<bool>(m_lu.template triangularView<Upper>().transpose()).solve(rhs); but (1) it's less readable than as a free function, and (2) if it's good for us, it's probably good for our users too.
Created attachment 916 [details] Add conjugateIf<cond>() members Patch ready. I also added it to triangularView and selfadjointView, and updated PartialPivLU to make use of it.
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1658.