Re: [eigen] Overloading componentwise binary operators for vectors

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


I tried to replace to the overloading of assignment operator by a constructor.
But it does not solve the problem.
I get the following error messages in make.log.
It seems I use CwiseBinaryOp incorrectly.

Unfortunately, error messages does not help me very much except this one:

/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:232:25: note:   template argument deduction/substitution failed:
In file included from /home/cdoucet/logiciels/test_eigen/main.cpp:3:0:
/home/cdoucet/logiciels/test_eigen/Vector.hpp:28:24: note:   candidate expects 2 arguments, 1 provided
       : wrapped_(result)

However, I don't know how to handle it.

Cédric




----- Mail original -----
> De: "Cedric Doucet" <cedric.doucet@xxxxxxxx>
> À: eigen@xxxxxxxxxxxxxxxxxxx
> Envoyé: Lundi 5 Octobre 2015 18:31:25
> Objet: Re: [eigen] Overloading componentwise binary operators for vectors
> 
> 
> Hello Christoph,
> 
> thank you very much for your answer.
> 
> > As Gael already said, your Vector class also needs to have a constructor
> > which accepts a DenseBase<Derived> (or a Wrapped::Sum, if you prefer).
> 
> Ok, I will try this solution but I don't understand why it would solve the
> problem of my main example:
> 
> Vector sum(3);
> sum = lhs + rhs;
> 
> First, I construct a vector.
> Then, I assign the result of lhs+rhs in sum (operator=).
> I would expect the overloading of assignment operator to be called:
> 
> Vector & operator=(Sum const & result)
> {
>   wrapped_ = result;
>   return *this;
> }
> 
> Of course, the code is not optimal and I will implement Vector::Vector(Sum
> const &) anyway, in order to be able to write:
> 
> Vector sum = lhs + rhs;
> 
> But I would really appreciate to understand what is happening here.
> 
> > Btw, to me it is still not obvious what you actually want to achieve
> > here ...
> 
> I could try to explain but it's not obvious to guess what is not obvious to
> you from your sentence... ;)
> 
> 
> Cédric
> 
> ----- Mail original -----
> > De: "Christoph Hertzberg" <chtz@xxxxxxxxxxxxxxxxxxxxxxxx>
> > À: eigen@xxxxxxxxxxxxxxxxxxx
> > Envoyé: Lundi 5 Octobre 2015 16:39:21
> > Objet: Re: [eigen] Overloading componentwise binary operators for vectors
> > 
> > 
> > 
> > On 05.10.2015 16:00, Cedric Doucet wrote:
> > > Actually, it is very simple to get the best of both worlds if I
> > > understand
> > > how to overload operator + so that it returns Eigen::CwiseBinaryOp.
> > > I just have to add a level of indirection by replacing
> > > Eigen::CwiseBinaryOp
> > > by a typedef coming from a template:
> > >
> > > template<typename Wrapped>
> > > class Vector;
> > >
> > > template<typename Wrapped>
> > > typename Wrapped::Sum operator+(Vector const & lhs, Vector const & rhs);
> > >
> > >
> > > So, my question is very simple : what am I doing wrong in the code I sent
> > > to you?
> > 
> > 
> > As Gael already said, your Vector class also needs to have a constructor
> > which accepts a DenseBase<Derived> (or a Wrapped::Sum, if you prefer).
> > 
> > Btw, to me it is still not obvious what you actually want to achieve
> > here ...
> > 
> > 
> > Christoph
> > 
> > --
> >   Dipl. Inf., Dipl. Math. Christoph Hertzberg
> > 
> >   Universität Bremen
> >   FB 3 - Mathematik und Informatik
> >   AG Robotik
> >   Robert-Hooke-Straße 1
> >   28359 Bremen, Germany
> > 
> >   Zentrale: +49 421 178 45-6611
> > 
> >   Besuchsadresse der Nebengeschäftstelle:
> >   Robert-Hooke-Straße 5
> >   28359 Bremen, Germany
> > 
> >   Tel.:    +49 421 178 45-4021
> >   Empfang: +49 421 178 45-6600
> >   Fax:     +49 421 178 45-4150
> >   E-Mail:  chtz@xxxxxxxxxxxxxxxxxxxxxxxx
> > 
> >   Weitere Informationen: http://www.informatik.uni-bremen.de/robotik
> > 
> > 
> >
> 
> 
>
[100%] Building CXX object CMakeFiles/main.dir/main.cpp.o
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:296:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h: In instantiation of â??class Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<double>, Vector, Vector>â??:
/home/cdoucet/logiciels/test_eigen/Vector.hpp:28:24:   required from here
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:106:7: erreur: invalid use of incomplete type â??struct Eigen::internal::traits<Vector>â??
 class CwiseBinaryOp : internal::no_assignment_operator,
       ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:252:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:17:29: erreur: declaration of â??struct Eigen::internal::traits<Vector>â??
 template<typename T> struct traits;
                             ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:296:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:117:99: erreur: invalid use of incomplete type â??struct Eigen::internal::traits<Vector>â??
                                          typename internal::traits<Rhs>::StorageKind>::ret>::Base Base;
                                                                                                   ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:252:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:17:29: erreur: declaration of â??struct Eigen::internal::traits<Vector>â??
 template<typename T> struct traits;
                             ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:296:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h: In instantiation of â??struct Eigen::internal::traits<Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<double>, Vector, Vector> >â??:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:118:5:   required from â??class Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<double>, Vector, Vector>â??
/home/cdoucet/logiciels/test_eigen/Vector.hpp:28:24:   required from here
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:43:46: erreur: invalid use of incomplete type â??struct Eigen::internal::traits<Vector>â??
   typedef typename traits<Ancestor>::XprKind XprKind;
                                              ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:252:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:17:29: erreur: declaration of â??struct Eigen::internal::traits<Vector>â??
 template<typename T> struct traits;
                             ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:296:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:44:8: erreur: incomplete type â??Eigen::internal::traits<Vector>â?? used in nested name specifier
   enum {
        ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:44:8: erreur: incomplete type â??Eigen::internal::traits<Vector>â?? used in nested name specifier
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:44:8: erreur: incomplete type â??Eigen::internal::traits<Vector>â?? used in nested name specifier
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:44:8: erreur: incomplete type â??Eigen::internal::traits<Vector>â?? used in nested name specifier
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:58:28: erreur: no type named â??Scalarâ?? in â??class Vectorâ??
                    >::type Scalar;
                            ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:60:84: erreur: invalid use of incomplete type â??struct Eigen::internal::traits<Vector>â??
                                            typename traits<Rhs>::StorageKind>::ret StorageKind;
                                                                                    ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:252:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:17:29: erreur: declaration of â??struct Eigen::internal::traits<Vector>â??
 template<typename T> struct traits;
                             ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:296:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:62:77: erreur: invalid use of incomplete type â??struct Eigen::internal::traits<Vector>â??
                                          typename traits<Rhs>::Index>::type Index;
                                                                             ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:252:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:17:29: erreur: declaration of â??struct Eigen::internal::traits<Vector>â??
 template<typename T> struct traits;
                             ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:296:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:63:32: erreur: no type named â??Nestedâ?? in â??class Vectorâ??
   typedef typename Lhs::Nested LhsNested;
                                ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:64:32: erreur: no type named â??Nestedâ?? in â??class Vectorâ??
   typedef typename Rhs::Nested RhsNested;
                                ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:65:54: erreur: no type named â??Nestedâ?? in â??class Vectorâ??
   typedef typename remove_reference<LhsNested>::type _LhsNested;
                                                      ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:66:54: erreur: no type named â??Nestedâ?? in â??class Vectorâ??
   typedef typename remove_reference<RhsNested>::type _RhsNested;
                                                      ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:67:8: erreur: no type named â??Nestedâ?? in â??class Vectorâ??
   enum {
        ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:73:73: erreur: â??Flagsâ?? is not a member of â??Vectorâ??
     StorageOrdersAgree = (int(Lhs::Flags)&RowMajorBit)==(int(Rhs::Flags)&RowMajorBit),
                                                                         ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:73:42: erreur: â??Flagsâ?? is not a member of â??Vectorâ??
     StorageOrdersAgree = (int(Lhs::Flags)&RowMajorBit)==(int(Rhs::Flags)&RowMajorBit),
                                          ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h: In instantiation of â??class Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<double>, Vector, Vector>â??:
/home/cdoucet/logiciels/test_eigen/Vector.hpp:28:24:   required from here
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:120:50: erreur: invalid use of incomplete type â??struct Eigen::internal::traits<Vector>â??
     typedef typename internal::nested<Lhs>::type LhsNested;
                                                  ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:252:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:17:29: erreur: declaration of â??struct Eigen::internal::traits<Vector>â??
 template<typename T> struct traits;
                             ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:296:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:121:50: erreur: invalid use of incomplete type â??struct Eigen::internal::traits<Vector>â??
     typedef typename internal::nested<Rhs>::type RhsNested;
                                                  ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:252:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:17:29: erreur: declaration of â??struct Eigen::internal::traits<Vector>â??
 template<typename T> struct traits;
                             ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:296:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:122:66: erreur: invalid use of incomplete type â??struct Eigen::internal::traits<Vector>â??
     typedef typename internal::remove_reference<LhsNested>::type _LhsNested;
                                                                  ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:252:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:17:29: erreur: declaration of â??struct Eigen::internal::traits<Vector>â??
 template<typename T> struct traits;
                             ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:296:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:123:66: erreur: invalid use of incomplete type â??struct Eigen::internal::traits<Vector>â??
     typedef typename internal::remove_reference<RhsNested>::type _RhsNested;
                                                                  ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:252:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:17:29: erreur: declaration of â??struct Eigen::internal::traits<Vector>â??
 template<typename T> struct traits;
                             ^
In file included from /home/cdoucet/logiciels/test_eigen/main.cpp:3:0:
/home/cdoucet/logiciels/test_eigen/Vector.hpp: In constructor â??Vector::Vector(const Sum&)â??:
/home/cdoucet/logiciels/test_eigen/Vector.hpp:28:24: erreur: no matching function for call to â??Eigen::Matrix<double, -1, 1>::Matrix(const Sum&)â??
       : wrapped_(result)
                        ^
/home/cdoucet/logiciels/test_eigen/Vector.hpp:28:24: note: candidates are:
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:294:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:327:14: note: template<class OtherDerived> Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const Eigen::RotationBase<OtherDerived, ColsAtCompileTime>&)
     explicit Matrix(const RotationBase<OtherDerived,ColsAtCompileTime>& r);
              ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:327:14: note:   template argument deduction/substitution failed:
In file included from /home/cdoucet/logiciels/test_eigen/main.cpp:3:0:
/home/cdoucet/logiciels/test_eigen/Vector.hpp:28:24: note:   â??const Sum {aka const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<double>, Vector, Vector>}â?? is not derived from â??const Eigen::RotationBase<OtherDerived, 1>â??
       : wrapped_(result)
                        ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:294:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:303:25: note: template<class OtherDerived> Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const Eigen::EigenBase<OtherDerived>&)
     EIGEN_STRONG_INLINE Matrix(const EigenBase<OtherDerived> &other)
                         ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:303:25: note:   template argument deduction/substitution failed:
In file included from /home/cdoucet/logiciels/test_eigen/main.cpp:3:0:
/home/cdoucet/logiciels/test_eigen/Vector.hpp:28:24: note:   â??const Sum {aka const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<double>, Vector, Vector>}â?? is not derived from â??const Eigen::EigenBase<Derived>â??
       : wrapped_(result)
                        ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:294:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:292:25: note: template<class OtherDerived> Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const Eigen::ReturnByValue<OtherDerived>&)
     EIGEN_STRONG_INLINE Matrix(const ReturnByValue<OtherDerived>& other)
                         ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:292:25: note:   template argument deduction/substitution failed:
In file included from /home/cdoucet/logiciels/test_eigen/main.cpp:3:0:
/home/cdoucet/logiciels/test_eigen/Vector.hpp:28:24: note:   â??const Sum {aka const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<double>, Vector, Vector>}â?? is not derived from â??const Eigen::ReturnByValue<Derived>â??
       : wrapped_(result)
                        ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:294:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:284:25: note: Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&) [with _Scalar = double; int _Rows = -1; int _Cols = 1; int _Options = 0; int _MaxRows = -1; int _MaxCols = 1]
     EIGEN_STRONG_INLINE Matrix(const Matrix& other)
                         ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:284:25: note:   no known conversion for argument 1 from â??const Sum {aka const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<double>, Vector, Vector>}â?? to â??const Eigen::Matrix<double, -1, 1>&â??
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:272:25: note: template<class OtherDerived> Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const Eigen::MatrixBase<OtherDerived>&)
     EIGEN_STRONG_INLINE Matrix(const MatrixBase<OtherDerived>& other)
                         ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:272:25: note:   template argument deduction/substitution failed:
In file included from /home/cdoucet/logiciels/test_eigen/main.cpp:3:0:
/home/cdoucet/logiciels/test_eigen/Vector.hpp:28:24: note:   â??const Sum {aka const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<double>, Vector, Vector>}â?? is not derived from â??const Eigen::MatrixBase<Derived>â??
       : wrapped_(result)
                        ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:305:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Map.h:184:8: note: Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const Scalar*) [with _Scalar = double; int _Rows = -1; int _Cols = 1; int _Options = 0; int _MaxRows = -1; int _MaxCols = 1; Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Scalar = double]
 inline Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>
        ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Map.h:184:8: note:   no known conversion for argument 1 from â??const Sum {aka const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<double>, Vector, Vector>}â?? to â??const Scalar* {aka const double*}â??
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:294:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:258:25: note: Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const Scalar&, const Scalar&, const Scalar&, const Scalar&) [with _Scalar = double; int _Rows = -1; int _Cols = 1; int _Options = 0; int _MaxRows = -1; int _MaxCols = 1; Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Scalar = double]
     EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z, const Scalar& w)
                         ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:258:25: note:   candidate expects 4 arguments, 1 provided
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:249:25: note: Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const Scalar&, const Scalar&, const Scalar&) [with _Scalar = double; int _Rows = -1; int _Cols = 1; int _Options = 0; int _MaxRows = -1; int _MaxCols = 1; Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Scalar = double]
     EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z)
                         ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:249:25: note:   candidate expects 3 arguments, 1 provided
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:232:25: note: template<class T0, class T1> Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T0&, const T1&)
     EIGEN_STRONG_INLINE Matrix(const T0& x, const T1& y)
                         ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:232:25: note:   template argument deduction/substitution failed:
In file included from /home/cdoucet/logiciels/test_eigen/main.cpp:3:0:
/home/cdoucet/logiciels/test_eigen/Vector.hpp:28:24: note:   candidate expects 2 arguments, 1 provided
       : wrapped_(result)
                        ^
In file included from /home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/Core:294:0,
                 from /home/cdoucet/logiciels/test_eigen/Vector.hpp:2,
                 from /home/cdoucet/logiciels/test_eigen/main.cpp:3:
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:220:34: note: Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Index) [with _Scalar = double; int _Rows = -1; int _Cols = 1; int _Options = 0; int _MaxRows = -1; int _MaxCols = 1; Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Index = long int]
     EIGEN_STRONG_INLINE explicit Matrix(Index dim)
                                  ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:220:34: note:   no known conversion for argument 1 from â??const Sum {aka const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<double>, Vector, Vector>}â?? to â??Eigen::Matrix<double, -1, 1>::Index {aka long int}â??
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:210:5: note: Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(Eigen::internal::constructor_without_unaligned_array_assert) [with _Scalar = double; int _Rows = -1; int _Cols = 1; int _Options = 0; int _MaxRows = -1; int _MaxCols = 1]
     Matrix(internal::constructor_without_unaligned_array_assert)
     ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:210:5: note:   no known conversion for argument 1 from â??const Sum {aka const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<double>, Vector, Vector>}â?? to â??Eigen::internal::constructor_without_unaligned_array_assertâ??
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:203:25: note: Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix() [with _Scalar = double; int _Rows = -1; int _Cols = 1; int _Options = 0; int _MaxRows = -1; int _MaxCols = 1]
     EIGEN_STRONG_INLINE Matrix() : Base()
                         ^
/home/cdoucet/logiciels/test_eigen/eigen/install/include/eigen3/Eigen/src/Core/Matrix.h:203:25: note:   candidate expects 0 arguments, 1 provided
In file included from /home/cdoucet/logiciels/test_eigen/main.cpp:3:0:
/home/cdoucet/logiciels/test_eigen/Vector.hpp: In function â??Sum operator+(const Vector&, const Vector&)â??:
/home/cdoucet/logiciels/test_eigen/Vector.hpp:45:23: erreur: could not convert â??Eigen::MatrixBase<Derived>::operator+(const Eigen::MatrixBase<OtherDerived>&) const [with OtherDerived = Eigen::Matrix<double, -1, 1>; Derived = Eigen::Matrix<double, -1, 1>; typename Eigen::internal::traits<T>::Scalar = double]((*(const Eigen::MatrixBase<Eigen::Matrix<double, -1, 1> >*)(& rhs.Vector::wrapped_)))â?? from â??const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<double>, const Eigen::Matrix<double, -1, 1>, const Eigen::Matrix<double, -1, 1> >â?? to â??Sum {aka Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<double>, Vector, Vector>}â??
 { return lhs.wrapped_ + rhs.wrapped_; }
                       ^
/home/cdoucet/logiciels/test_eigen/Vector.hpp:45:39: attention : contrôle a atteint la fin non void de la fonction [-Wreturn-type]
 { return lhs.wrapped_ + rhs.wrapped_; }
                                       ^
make[2]: *** [CMakeFiles/main.dir/main.cpp.o] Erreur 1
make[1]: *** [CMakeFiles/main.dir/all] Erreur 2
make: *** [all] Erreur 2
#include <Eigen/Core>
#include <Eigen/Dense>

// forward declarations
class Vector;

typedef Eigen::Matrix<double,Eigen::Dynamic,1> WrappedType;
typedef Eigen::internal::scalar_sum_op<double> SumOperator;
typedef Eigen::CwiseBinaryOp<SumOperator,Vector,Vector> Sum;

Sum
operator+(Vector const & lhs, Vector const & rhs);

// Vector class definition
class Vector
{
    friend Vector 
    classical_sum(Vector const & lhs, Vector const & rhs);

    friend Sum
    operator+(Vector const & lhs, Vector const & rhs);


    public:
      
      Vector(Sum const & result)
      : wrapped_(result)
      {} 

      Vector(std::size_t const size)
      : wrapped_(size)
      {}

      double & 
      operator()(std::size_t const index)
      { return wrapped_(index); }

    private:
      WrappedType wrapped_;
};

Sum
operator+(Vector const & lhs, Vector const & rhs)
{ return lhs.wrapped_ + rhs.wrapped_; }


#include "Vector.hpp"

int main()
{
  Vector lhs(3);
  Vector rhs(3);

  lhs(0) = lhs(1) = lhs(2) = 1;
  rhs(0) = rhs(1) = rhs(2) = 2;

  Vector sum = lhs+rhs;
}
cmake_minimum_required (VERSION 2.6)

project (eigen_overloading CXX)

#==============
# INCLUDE FILES
#==============

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)

include(CheckCXXCompilerFlag)
include(ProcessorCount)

ProcessorCount(N)
if(NOT N EQUAL 0)
  set(CMAKE_BUILD_FLAGS -j${N})
endif()
#====================
# EXECUTABLE SETTINGS
#====================
add_executable(main main.cpp)

#=============
# USER OPTIONS
#=============


#=============================
# DOWNLOAD 3RD-PARTY LIBRARIES
#=============================


  include_directories(eigen/install/include/eigen3)

#==================
# COMPILER SETTINGS
#==================

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SIMOL_CXX_FLAGS} -Wall -Wextra")

CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
  message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} does not support -std=c++11 flag. Please use a different C++ compiler.")
endif()



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