1

There are three overloads of .select() function in Eigen:

template<typename Derived >
template<typename ThenDerived , typename ElseDerived >
const Select< Derived, ThenDerived, ElseDerived > Eigen::DenseBase< Derived >::select   (
const DenseBase< ThenDerived > &    thenMatrix,
const DenseBase< ElseDerived > &    elseMatrix 
)       const;

template<typename Derived >
template<typename ThenDerived >
const Select< Derived, ThenDerived, typename ThenDerived::ConstantReturnType > Eigen::DenseBase< Derived >::select  (
const DenseBase< ThenDerived > &    thenMatrix,
const typename ThenDerived::Scalar &    elseScalar 
)       const;

template<typename Derived >
template<typename ElseDerived >
const Select< Derived, typename ElseDerived::ConstantReturnType, ElseDerived > Eigen::DenseBase< Derived >::select  (
const typename ElseDerived::Scalar &    thenScalar,
const DenseBase< ElseDerived > &    elseMatrix 
)       const;

Why isn't there an overload that accepts two Scalars?

This has been asked before at strange behavior of eigen::select(), but that question itself is not answered. The answers just say "if you want to .select() two scalars, you can write balabala", they didn't say why there is not an overload that selects two scalars.

  • 2
    only the authors can know. Maybe if you ask them they will say "Because there is already a way to do it" (and that is in the Q&A you link) – 463035818_is_not_an_ai Dec 16 '20 at 12:38
  • And how is your question not a duplicate? If you want this feature added, you need to file an issue/feature-request here: https://gitlab.com/libeigen/eigen/-/issues – chtz Dec 16 '20 at 12:46
  • 1
    Does this answer your question? [strange behavior of eigen::select()](https://stackoverflow.com/questions/21440511/strange-behavior-of-eigenselect) – chtz Dec 16 '20 at 12:47
  • @largest_prime_is_463035818 So I'm waiting for the authors to appear here... I guess they are most likely to say "Sorry we can't do that because of C++'s limitations..." – Shuai Zhang Dec 17 '20 at 07:29
  • @chtz That question hasn't had an answer yet. Nobody answers "why". – Shuai Zhang Dec 17 '20 at 07:31
  • The answer to "why" is: "Because it is not implemented". Not sure what kind of answer you expect here ... – chtz Dec 17 '20 at 10:19
  • @chtz I want to know "why it is not implemented" ... It seems very easy to implement, and it's natural to expect the existence of such an implementation. The fact that it is not implemented is counter intuitive and needs explanation. I guess the authors tried but found some limitation of C++ hindered such an implementation... – Shuai Zhang Dec 18 '20 at 10:26

0 Answers0