This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen

Bug 1658

Summary: Add DenseBase::conjugateIf<bool>()
Product: Eigen Reporter: Gael Guennebaud <gael.guennebaud>
Component: Core - generalAssignee: Nobody <eigen.nobody>
Status: DECISIONNEEDED ---    
Severity: Feature Request CC: chtz, gael.guennebaud, jacob.benoit.1
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Add conjugateIf<cond>() members none

Description Gael Guennebaud 2019-01-13 20:59:16 UTC
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.
Comment 1 Gael Guennebaud 2019-01-15 09:58:26 UTC
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.
Comment 2 Nobody 2019-12-04 18:21:52 UTC
-- 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.