RE: [eigen] no matching function for call to 'abs(const float&)'

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


Hi Adrien,

Thanks for the answer.

>It looks like your cmath is not providing an abs function for float.
>You can try to define this function (in the std namespace) prior to including Eigen.

That doesn't make sense, as std::abs also is defined for floats on <cmath>: http://en.cppreference.com/w/cpp/numeric/math/fabs.

A side note: I don't know what are the exact computations you want to achieve, but there are very few cases in numerical computations where it is necessary to 
>explicitly compute the inverse of a matrix.
>Especially for solving a system Ax=b (and you are most likely solving such a system one way or an other), one never compute the inverse of A because it is expensive 
>to produce.
>Instead in Eigen, you can do A.partialPivLu().solve(b);  (or A.colPivHouseholderQR.solve(b); if you are willing to trade speed for robustness).

I'll keep that in mind but for now I want to keep it as is.

Don't know, but should we use std::fabs() instead?

Best,

---
Nuno Marques
Tenente Aluno de Transmissões (Eng)

+351 912 090 991
Azambuja | Portugal

As the creation appears, the path is driven in the conscious feeling of madness and happiness, which returns, in multiple ways, to what we achieve in greatness...

Follow me in:
   

This message and any files herewith attached may contain confidential or privileged information and is intended solely for the use of the entity to which it is addressed. If you receive this message in error, please notify the sender immediately and delete this message and any files attached without copying them in any way.



Date: Thu, 27 Aug 2015 13:45:12 +0900
Subject: Re: [eigen] no matching function for call to 'abs(const float&)'
From: adrien.escande@xxxxxxxxx
To: eigen@xxxxxxxxxxxxxxxxxxx

It looks like your cmath is not providing an abs function for float.
You can try to define this function (in the std namespace) prior to including Eigen.

A side note: I don't know what are the exact computations you want to achieve, but there are very few cases in numerical computations where it is necessary to explicitly compute the inverse of a matrix.
Especially for solving a system Ax=b (and you are most likely solving such a system one way or an other), one never compute the inverse of A because it is expensive to produce.
Instead in Eigen, you can do A.partialPivLu().solve(b);  (or A.colPivHouseholderQR.solve(b); if you are willing to trade speed for robustness).

Best,
Adrien Escande

On Thu, Aug 27, 2015 at 12:51 AM, Nuno Marques <n.marques21@xxxxxxxxxxx> wrote:
Anyone? Christoph?

Thanks! Best,

---
Nuno Marques
Tenente Aluno de Transmissões (Eng)

Azambuja | Portugal

As the creation appears, the path is driven in the conscious feeling of madness and happiness, which returns, in multiple ways, to what we achieve in greatness...

Follow me in:
   

This message and any files herewith attached may contain confidential or privileged information and is intended solely for the use of the entity to which it is addressed. If you receive this message in error, please notify the sender immediately and delete this message and any files attached without copying them in any way.



From: n.marques21@xxxxxxxxxxx
To: eigen@xxxxxxxxxxxxxxxxxxx
Subject: [eigen] no matching function for call to 'abs(const float&)'
Date: Mon, 24 Aug 2015 23:29:59 +0100


Hello,

I'm getting the bellow error for the following code:   Matrix<float, 6, 6> S_I = ((C * _P * C.transpose()) + R).inverse();

../Eigen/src/Core/functors/UnaryFunctors..h: In instantiation of 'const result_type Eigen::internal::scalar_abs_op<Scalar>::operator()(const Scalar&) const [with Scalar = float; Eigen::internal::scalar_abs_op<Scalar>::result_type = float]':
../Eigen/src/Core/CoreEvaluators.h:396:47:   required from 'Eigen::internal::unary_evaluator<Eigen::CwiseUnaryOp<UnaryOp, ArgType>, Eigen::internal::IndexBased>::CoeffReturnType Eigen::internal::unary_evaluator<Eigen::CwiseUnaryOp<UnaryOp, ArgType>, Eigen::internal::IndexBased>::coeff(Eigen::Index, Eigen::Index) const [with UnaryOp = Eigen::internal::scalar_score_coeff_op<float>; ArgType = const Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<float, -1, -1, 1, -1, -1>, 0, Eigen::Stride<0, 0> >, -1, -1, false>, -1, 1, false>, -1, 1, false>; typename Eigen::CwiseUnaryOp<UnaryOp, ArgType>::Scalar = float; Eigen::internal::unary_evaluator<Eigen::CwiseUnaryOp<UnaryOp, ArgType>, Eigen::internal::IndexBased>::CoeffReturnType = float; Eigen::Index = int]'
../Eigen/src/Core/Visitor.h:79:38:   required from 'Eigen::internal::visitor_evaluator<XprType>::CoeffReturnType Eigen::internal::visitor_evaluator<XprType>::coeff(Eigen::Index, Eigen::Index) const [with XprType = Eigen::CwiseUnaryOp<Eigen::internal::scalar_score_coeff_op<float>, const Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<float, -1, -1, 1, -1, -1>, 0, Eigen::Stride<0, 0> >, -1, -1, false>, -1, 1, false>, -1, 1, false> >; Eigen::internal::visitor_evaluator<XprType>::CoeffReturnType = float; Eigen::Index = int]'
../Eigen/src/Core/Visitor.h:49:5:   required from 'static void Eigen::internal::visitor_impl<Visitor, Derived, -1>::run(const Derived&, Visitor&) [with Visitor = Eigen::internal::max_coeff_visitor<Eigen::CwiseUnaryOp<Eigen::internal::scalar_score_coeff_op<float>, const Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<float, -1, -1, 1, -1, -1>, 0, Eigen::Stride<0, 0> >, -1, -1, false>, -1, 1, false>, -1, 1, false> > >; Derived = Eigen::internal::visitor_evaluator<Eigen::CwiseUnaryOp<Eigen::internal::scalar_score_coeff_op<float>, const Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<float, -1, -1, 1, -1, -1>, 0, Eigen::Stride<0, 0> >, -1, -1, false>, -1, 1, false>, -1, 1, false> > >]'
../Eigen/src/Core/Visitor.h:119:29:   required from 'void Eigen::DenseBase<Derived>::visit(Visitor&) const [with Visitor = Eigen::internal::max_coeff_visitor<Eigen::CwiseUnaryOp<Eigen::internal::scalar_score_coeff_op<float>, const Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<float, -1, -1, 1, -1, -1>, 0, Eigen::Stride<0, 0> >, -1, -1, false>, -1, 1, false>, -1, 1, false> > >; Derived = Eigen::CwiseUnaryOp<Eigen::internal::scalar_score_coeff_op<float>, const Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<float, -1, -1, 1, -1, -1>, 0, Eigen::Stride<0, 0> >, -1, -1, false>, -1, 1, false>, -1, 1, false> >]'
../Eigen/src/Core/Visitor.h:267:3:   required from 'typename Eigen::internal::traits<T>::Scalar Eigen::DenseBase<Derived>::maxCoeff(IndexType*) const [with IndexType = int; Derived = Eigen::CwiseUnaryOp<Eigen::internal::scalar_score_coeff_op<float>, const Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<float, -1, -1, 1, -1, -1>, 0, Eigen::Stride<0, 0> >, -1, -1, false>, -1, 1, false>, -1, 1, false> >; typename Eigen::internal::traits<T>::Scalar = float]'
../Eigen/src/LU/PartialPivLU.h:298:86:   [ skipping 7 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
../Eigen/src/LU/InverseImpl.h:306:76:   required from 'static void Eigen::internal::Assignment<DstXprType, Eigen::Inverse<XprType>, Eigen::internal::assign_op<Scalar>, Eigen::internal::Dense2Dense, Scalar>::run(DstXprType&, const SrcXprType&, const Eigen::internal::assign_op<Scalar>&) [with DstXprType = Eigen::Matrix<float, 6, 6, 0, 6, 6>; XprType = Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<float>, const Eigen::Product<Eigen::Product<Eigen::Matrix<float, 6, 6, 0, 6, 6>, Eigen::Matrix<float, 6, 6, 0, 6, 6>, 0>, Eigen::Transpose<Eigen::Matrix<float, 6, 6, 0, 6, 6> >, 0>, const Eigen::Matrix<float, 6, 6, 0, 6, 6> >; Scalar = float; Eigen::internal::Assignment<DstXprType, Eigen::Inverse<XprType>, Eigen::internal::assign_op<Scalar>, Eigen::internal::Dense2Dense, Scalar>::SrcXprType = Eigen::Inverse<Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<float>, const Eigen::Product<Eigen::Product<Eigen::Matrix<float, 6, 6, 0, 6, 6>, Eigen::Matrix<float, 6, 6, 0, 6, 6>, 0>, Eigen::Transpose<Eigen::Matrix<float, 6, 6, 0, 6, 6> >, 0>, const Eigen::Matrix<float, 6, 6, 0, 6, 6> > >]'
../Eigen/src/Core/AssignEvaluator.h:765:70:   required from 'void Eigen::internal::call_assignment_no_alias(Dst&, const Src&, const Func&) [with Dst = Eigen::Matrix<float, 6, 6, 0, 6, 6>; Src = "" const Eigen::Product<Eigen::Product<Eigen::Matrix<float, 6, 6, 0, 6, 6>, Eigen::Matrix<float, 6, 6, 0, 6, 6>, 0>, Eigen::Transpose<Eigen::Matrix<float, 6, 6, 0, 6, 6> >, 0>, const Eigen::Matrix<float, 6, 6, 0, 6, 6> > >; Func = Eigen::internal::assign_op<float>]'
../Eigen/src/Core/PlainObjectBase.h:695:105:   required from 'Derived& Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived>&) [with OtherDerived = Eigen::Inverse<Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<float>, const Eigen::Product<Eigen::Product<Eigen::Matrix<float, 6, 6, 0, 6, 6>, Eigen::Matrix<float, 6, 6, 0, 6, 6>, 0>, Eigen::Transpose<Eigen::Matrix<float, 6, 6, 0, 6, 6> >, 0>, const Eigen::Matrix<float, 6, 6, 0, 6, 6> > >; Derived = Eigen::Matrix<float, 6, 6, 0, 6, 6>]'
../Eigen/src/Core/PlainObjectBase.h:518:25:   required from 'Eigen::PlainObjectBase<Derived>::PlainObjectBase(const Eigen::DenseBase<OtherDerived>&) [with OtherDerived = Eigen::Inverse<Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<float>, const Eigen::Product<Eigen::Product<Eigen::Matrix<float, 6, 6, 0, 6, 6>, Eigen::Matrix<float, 6, 6, 0, 6, 6>, 0>, Eigen::Transpose<Eigen::Matrix<float, 6, 6, 0, 6, 6> >, 0>, const Eigen::Matrix<float, 6, 6, 0, 6, 6> > >; Derived = Eigen::Matrix<float, 6, 6, 0, 6, 6>]'
../Eigen/src/Core/Matrix.h:380:29:   required from 'Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const Eigen::EigenBase<OtherDerived>&) [with OtherDerived = Eigen::Inverse<Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<float>, const Eigen::Product<Eigen::Product<Eigen::Matrix<float, 6, 6, 0, 6, 6>, Eigen::Matrix<float, 6, 6, 0, 6, 6>, 0>, Eigen::Transpose<Eigen::Matrix<float, 6, 6, 0, 6, 6> >, 0>, const Eigen::Matrix<float, 6, 6, 0, 6, 6> > >; _Scalar = float; int _Rows = 6; int _Cols = 6; int _Options = 0; int _MaxRows = 6; int _MaxCols = 6]'
...:   required from here
../Eigen/src/Core/functors/UnaryFunctors.h:44:124: error: no matching function for call to 'abs(const float&)'
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { using std::abs; return abs(a); }
                                                                                                                            ^
compilation terminated due to -Wfatal-errors.

Is this a bug related to Eigen? In the abs() macro?

Thanks in advance! Best,

---
Nuno Marques
Tenente Aluno de Transmissões (Eng)

Azambuja | Portugal

As the creation appears, the path is driven in the conscious feeling of madness and happiness, which returns, in multiple ways, to what we achieve in greatness...

Follow me in:
   

This message and any files herewith attached may contain confidential or privileged information and is intended solely for the use of the entity to which it is addressed. If you receive this message in error, please notify the sender immediately and delete this message and any files attached without copying them in any way.



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