Re: [eigen] AutoDiff: complex doesn't compile

[ Thread Index | Date Index | More Archives ]

The template argument of AutoDiffScalar is supposed to hold the partial derivatives (which are always real). If you want complex AutoDiffs, all you can do is:

  typedef Eigen::AutoDiffScalar<Eigen::Vector2d> TpRFloat;
  typedef std::complex<TpRFloat> TpCFloat;

This does not take into account if functions are actually complex derivable, unfortunately.


On 2016-09-11 16:56, Peter wrote:
Dear All,

in my Quest in using Eigen for own types, I realized, that
Eigen::AutoDiff should posses the same difficulties.

Sadly, I can't get even a simple case working.

#include <complex>

#include <Eigen/Dense>
#include <unsupported/Eigen/AutoDiff>

typedef Eigen::AutoDiffScalar<Eigen::Vector2cd> TpFloat;
typedef Eigen::AutoDiffScalar<Eigen::Vector2d> TpRFloat;

int main( const int argc, const char *argv[] )
    TpRFloat x(3.0) ;   // o.k.
    TpFloat  z;   // not o.k.

    return 0;

Eigen::AutoDiffScalar doesn't compile for complex types. Since the type
definitions are within nested traits,
    I couldn't spot a solution immediately.

As note, the doc may clarify, that "the vector type used to
store/represent the derivatives",
means first-order derivatives, or gradients. I was first confused by
assuming it would represent a Taylor

Best regards,


$ g++   -std=c++11 -DNDEBUG -O2  TestAutoDiff.C  -I $HOME/Eigen/eigen -o
DiffPC 2>&1 | tee Err.txt | more
In file included from
                 from TestAutoDiff.C:5:
In instantiation of 'struct
Eigen::internal::auto_diff_special_op<Eigen::Matrix<std::complex<double>, 2,
1>, true>':
required from 'class
Eigen::AutoDiffScalar<Eigen::Matrix<std::complex<double>, 2, 1> >'
TestAutoDiff.C:18:10:   required from here
error: no type named 'Type' in 'class

lex<double>, double> >, Eigen::Matrix<std::complex<double>, 2, 1> >'
   operator*(const Real& other) const
error: no type named 'DerType' in 'class

, std::complex<double> > >, Eigen::Matrix<std::complex<double>, 2, 1> >'
   operator*(const Real& other, const AutoDiffScalar<_DerType>& a)
In instantiation of 'class
Eigen::AutoDiffScalar<Eigen::Matrix<std::complex<double>, 2, 1> >':
TestAutoDiff.C:18:10:   required from here
error: no members matching
'Eigen::AutoDiffScalar<Eigen::Matrix<std::complex<double>, 2, 1> >::Base
{aka Eigen::internal::auto_dif
f_special_op<Eigen::Matrix<std::complex<double>, 2, 1>,
true>}::operator*' in
'Eigen::AutoDiffScalar<Eigen::Matrix<std::complex<double>, 2, 1> >::Base
{aka struct Eigen::internal::auto_diff_special_op<Eigen::M
atrix<std::complex<double>, 2, 1>, true>}'
     using Base::operator*;

 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äftsstelle:
 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:

Mail converted by MHonArc 2.6.19+