Re: [eigen] TriangularViewType& operator/=(const typename internal::traits<MatrixType>::Scalar& other)

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]



On Tue, Sep 6, 2016 at 3:53 PM, Peter <list@xxxxxxxxxxxxxxxxx> wrote:
template <class T> struct ScalarBinaryOpTraits< T, typename NumTraits<T>::Real > { typedef T ReturnType; };
template <class T> struct ScalarBinaryOpTraits< typename NumTraits<T>::Real, T > { typedef T ReturnType; };

nope, that does not work for real, for instance the following lines will fail because typename NumTraits<T>::Real==T and you will have the same specialization twice.

  Eigen::MatrixXd A;
  Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> ei(A);

But the following seems to do the job:

template <typename T, typename BinaryOp>
struct ScalarBinaryOpTraits< T, typename NumTraits<typename internal::enable_if<!internal::is_same<T,typename NumTraits<T>::Real>::value,T>::type>::Real, BinaryOp>
{
  typedef T ReturnType;
};
template <typename T, typename BinaryOp>
struct ScalarBinaryOpTraits< typename NumTraits<typename internal::enable_if<!internal::is_same<T,typename NumTraits<T>::Real>::value,T>::type>::Real, T, BinaryOp>
{
  typedef T ReturnType;
};


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/