Re: [eigen] AutoDiffScalar

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



Hi,

thanks for your help in improving the AD module. I'm currently looking at your changes and try to merge them with my local changes, but I have some remarks/questions:

* I think your "RealScalar prec => const RealScalar& prec" change is useless because, e.g., for a MatrixXd, or an AutoDiffScalar<VectorXd>, RealScalar==double. Basically, whatever the complexity of the coeffecient type, RealScalar type should always be equal to a primitive scalar type. Benoit, what do you think, shall I undo that change while doing the merge ? https://bitbucket.org/bjornpiltz/autodiff/changeset/d2bf8e746508/


* Why did you add ei_unused() ? What is its purpose ?

In CompressedStorage:

* The behavior of the reserve() function looks even more odd than before. Unless you have strong arguments, I will remove the optional reserveSizeFactor parameter and update resize/append accordingly.

* I don't understand the purpose of your changes in the ctor. E.g., it is fundamental that "CompressedStorage data(size);" is equivalent to "CompressedStorage data; data.resize(size);"

* Your change in realloacate kills performances if, e.g., Scalar==AutoDiffScalar<VectorXf> because here we really want shallow copies. I agree that using memcpy is unsafe if the Scalar object creates a child-object which itself reference the parent... but recall that here we are designing containers for numerical values, not general containers. So I think it is fine to use memcpy here. Also a memcpy is much faster than simple for loops, and it is very important to provide optimal performances here.

gael


2009/10/28 Björn Piltz <bjornpiltz@xxxxxxxxxxxxxx>
Ok, I've pushed my changes to https://bitbucket.org/bjornpiltz/autodiff. It would be great if you could take a look!
I'm getting performance like:

Computing first order:
        Fixed   Dynamic Sparse
Eigen   72 ms   427 ms  718 ms
Sacado  194 ms  430 ms

Computing second order:
        Fixed   Dynamic Sparse
Eigen   553 ms  7813 ms 13983 ms
Sacado  1002 ms 3617 ms


The first goal performance-wise should be to make the second order dynamic case as fast as Sacado.

If you remember I suggested doing something like:

template<typename T>
struct MyTraits
{
};
template<>
struct MyTraits<double>
{
  typedef double Real;
};
template<>
struct MyTraits<float>
{
  typedef float Real;
};
template<typename DerType>
struct MyTraits<AutoDiffScalar<DerType> >
{
  typedef MyTraits<AutoDiffScalar<DerType>::Real>::Real Real;
};

I think this should be put outside of the AutoDiff module, if you want Eigen to support matrices of matrices. I just don't know where exactly.

Björn



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