Re: [eigen] Problem compiling dense matrix mult with complex<custom-real-scalar>

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


This works. Attaching patch as per your instructions.

Thanks!
Manoj



On Wednesday 26 May 2010 11:59:24 am Benoit Jacob wrote:
> Go to the line of code pointed to by your error: ProductBase.h:107
>
> it is:
>
>     inline void evalTo(Dest& dst) const { dst.setZero();
> scaleAndAddTo(dst,1); }
>
> and it complains it can't find a method accepting a int arg here.
> Instead it wants a Scalar arg. So can you try this:
>
>     inline void evalTo(Dest& dst) const { dst.setZero();
> scaleAndAddTo(dst, Scalar(1)); }
>
> and if that fixes your problem, send me the patch and i'll push it for
> you. (see link in previous mail)
>
> Benoit
>
> 2010/5/26 Manoj Rajagopalan <rmanoj@xxxxxxxxx>:
> > Hi eigen developers,
> >
> >   I am able to extend eigen for use with a real-scalar class named
> > dd_real. But I get compilation errors when using std::complex<dd_real>
> > value-type for dense-matrix multiplication (no problems with addition).
> > The error seems to be due to no declaration/definition of
> > ProductBase<>::scaleAndAddTo() for matrices of complex<dd_real>.
> >
> >   I tested the + and * operators for complex<dd_real> scalars and they
> > work. Is there something I am missing? I have implemented
> > NumTraits<dd_real> and I believe NumTraits<complex<dd_real> > is
> > auto-inferred.
> >
> > The gcc 4.2.4 error log is appended.
> >
> > Thanks,
> > Manoj
> >
> >
> >
> > g++ -I/usr/local/include/eigen3 -I/home/rmanoj/Software/src
> > -ftemplate-depth-100 qd-gemv.cpp -o qd-gemv -lqd
> >
> > /usr/local/include/eigen3/Eigen/src/Core/ProductBase.h: In member
> > function ‘void Eigen::ProductBase<Derived, Lhs, Rhs>::evalTo(Dest&) const
> > [with Dest = Eigen::Matrix<std::complex<dd_real>, 33331, 33331, 0, 33331,
> > 33331>, Derived =
> > Eigen::GeneralProduct<Eigen::Matrix<std::complex<dd_real>, 33331, 33331,
> > 0, 33331, 33331>, Eigen::Matrix<std::complex<dd_real>, 33331, 33331, 0,
> > 33331, 33331>, 5>, Lhs = Eigen::Matrix<std::complex<dd_real>, 33331,
> > 33331, 0, 33331, 33331>, Rhs = Eigen::Matrix<std::complex<dd_real>,
> > 33331, 33331, 0, 33331, 33331>]’:
> >
> > /usr/local/include/eigen3/Eigen/src/Core/ProductBase.h:244:  
> > instantiated from ‘Derived& Eigen::MatrixBase<Derived>::lazyAssign(const
> > Eigen::ProductBase<ProductDerived, Lhs, Rhs>&) [with ProductDerived =
> > Eigen::GeneralProduct<Eigen::Matrix<std::complex<dd_real>, 33331, 33331,
> > 0, 33331, 33331>, Eigen::Matrix<std::complex<dd_real>, 33331, 33331, 0,
> > 33331, 33331>, 5>, Lhs = Eigen::Matrix<std::complex<dd_real>, 33331,
> > 33331, 0, 33331, 33331>, Rhs = Eigen::Matrix<std::complex<dd_real>,
> > 33331, 33331, 0, 33331, 33331>, Derived =
> > Eigen::Matrix<std::complex<dd_real>, 33331, 33331, 0, 33331, 33331>]’
> >
> > /usr/local/include/eigen3/Eigen/src/Core/DenseStorageBase.h:306:  
> > instantiated from ‘Derived&
> > Eigen::DenseStorageBase<Derived>::lazyAssign(const
> > Eigen::DenseBase<OtherDerived>&) [with OtherDerived =
> > Eigen::GeneralProduct<Eigen::Matrix<std::complex<dd_real>, 33331, 33331,
> > 0, 33331, 33331>, Eigen::Matrix<std::complex<dd_real>, 33331, 33331, 0,
> > 33331, 33331>, 5>, Derived = Eigen::Matrix<std::complex<dd_real>, 33331,
> > 33331, 0, 33331, 33331>]’
> >
> > /usr/local/include/eigen3/Eigen/src/Core/Assign.h:492:   instantiated
> > from ‘static Derived& Eigen::ei_assign_selector<Derived, OtherDerived,
> > false, false>::run(Derived&, const OtherDerived&) [with Derived =
> > Eigen::Matrix<std::complex<dd_real>, 33331, 33331, 0, 33331, 33331>,
> > OtherDerived = Eigen::GeneralProduct<Eigen::Matrix<std::complex<dd_real>,
> > 33331, 33331, 0, 33331, 33331>, Eigen::Matrix<std::complex<dd_real>,
> > 33331, 33331, 0, 33331, 33331>, 5>]’
> >
> > /usr/local/include/eigen3/Eigen/src/Core/DenseStorageBase.h:473:  
> > instantiated from ‘Derived&
> > Eigen::DenseStorageBase<Derived>::_set_noalias(const
> > Eigen::DenseBase<OtherDerived>&) [with OtherDerived =
> > Eigen::GeneralProduct<Eigen::Matrix<std::complex<dd_real>, 33331, 33331,
> > 0, 33331, 33331>, Eigen::Matrix<std::complex<dd_real>, 33331, 33331, 0,
> > 33331, 33331>, 5>, Derived = Eigen::Matrix<std::complex<dd_real>, 33331,
> > 33331, 0, 33331, 33331>]’
> >
> > /usr/local/include/eigen3/Eigen/src/Core/Matrix.h:284:   instantiated
> > from ‘Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows,
> > _MaxCols>::Matrix(const Eigen::MatrixBase<OtherDerived>&) [with
> > OtherDerived = Eigen::GeneralProduct<Eigen::Matrix<std::complex<dd_real>,
> > 33331, 33331, 0, 33331, 33331>, Eigen::Matrix<std::complex<dd_real>,
> > 33331, 33331, 0, 33331, 33331>, 5>, _Scalar = std::complex<dd_real>, int
> > _Rows = 33331, int _Cols = 33331, int _Options = 0, int _MaxRows = 33331,
> > int _MaxCols = 33331]’
> >
> > /usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:453:   instantiated
> > from ‘const typename Eigen::ei_eval<T, typename
> > Eigen::ei_traits<T>::StorageKind>::type Eigen::DenseBase<Derived>::eval()
> > const [with Derived =
> > Eigen::GeneralProduct<Eigen::Matrix<std::complex<dd_real>, 33331, 33331,
> > 0, 33331, 33331>, Eigen::Matrix<std::complex<dd_real>, 33331, 33331, 0,
> > 33331, 33331>, 5>]’
> >
> > /usr/local/include/eigen3/Eigen/src/Core/DenseStorageBase.h:457:  
> > instantiated from ‘void
> > Eigen::DenseStorageBase<Derived>::_set_selector(const OtherDerived&,
> > const Eigen::ei_meta_true&) [with OtherDerived =
> > Eigen::GeneralProduct<Eigen::Matrix<std::complex<dd_real>, 33331, 33331,
> > 0, 33331, 33331>, Eigen::Matrix<std::complex<dd_real>, 33331, 33331, 0,
> > 33331, 33331>, 5>, Derived = Eigen::Matrix<std::complex<dd_real>, 33331,
> > 33331, 0, 33331, 33331>]’
> >
> > /usr/local/include/eigen3/Eigen/src/Core/DenseStorageBase.h:452:  
> > instantiated from ‘Derived& Eigen::DenseStorageBase<Derived>::_set(const
> > Eigen::DenseBase<OtherDerived>&) [with OtherDerived =
> > Eigen::GeneralProduct<Eigen::Matrix<std::complex<dd_real>, 33331, 33331,
> > 0, 33331, 33331>, Eigen::Matrix<std::complex<dd_real>, 33331, 33331, 0,
> > 33331, 33331>, 5>, Derived = Eigen::Matrix<std::complex<dd_real>, 33331,
> > 33331, 0, 33331, 33331>]’
> >
> > /usr/local/include/eigen3/Eigen/src/Core/Matrix.h:180:   instantiated
> > from ‘Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
> > Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows,
> > _MaxCols>::operator=(const Eigen::MatrixBase<OtherDerived>&) [with
> > OtherDerived = Eigen::GeneralProduct<Eigen::Matrix<std::complex<dd_real>,
> > 33331, 33331, 0, 33331, 33331>, Eigen::Matrix<std::complex<dd_real>,
> > 33331, 33331, 0, 33331, 33331>, 5>, _Scalar = std::complex<dd_real>, int
> > _Rows = 33331, int _Cols = 33331, int _Options = 0, int _MaxRows = 33331,
> > int _MaxCols = 33331]’
> >
> > qd-gemv.cpp:96:   instantiated from here   (this line is 'C=A*B;' where
> > all are 5x5 matrices of complex<dd_real>)
> >
> > /usr/local/include/eigen3/Eigen/src/Core/ProductBase.h:107: error: no
> > matching function for call to
> > ‘Eigen::ProductBase<Eigen::GeneralProduct<Eigen::Matrix<std::complex<dd_r
> >eal>, 33331, 33331, 0, 33331, 33331>, Eigen::Matrix<std::complex<dd_real>,
> > 33331, 33331, 0, 33331, 33331>, 5>, Eigen::Matrix<std::complex<dd_real>,
> > 33331, 33331, 0, 33331, 33331>, Eigen::Matrix<std::complex<dd_real>,
> > 33331, 33331, 0, 33331, 33331>
> >
> >>::scaleAndAddTo(Eigen::Matrix<std::complex<dd_real>, 33331, 33331, 0,
> >>:: 33331, 33331>&, int) const’
> >
> > make: *** [qd-gemv] Error 1

# HG changeset patch
# User Manoj Rajagopalan <rmanoj@xxxxxxxxx>
# Date 1274893255 14400
# Node ID a8a4240da04ce80ba532e711f17ae4dc0044959d
# Parent  cb295b7e8bdb9b12cb8914ea32b0f6fbc5f702be
Fix to ProductBase::evalTo() in order to get matrix multiplication working for std::complex<custom real-scalar> value-types

diff -r cb295b7e8bdb -r a8a4240da04c Eigen/src/Core/ProductBase.h
--- a/Eigen/src/Core/ProductBase.h	Wed May 26 02:33:28 2010 +0200
+++ b/Eigen/src/Core/ProductBase.h	Wed May 26 13:00:55 2010 -0400
@@ -104,7 +104,7 @@ class ProductBase : public MatrixBase<De
     inline int cols() const { return m_rhs.cols(); }
 
     template<typename Dest>
-    inline void evalTo(Dest& dst) const { dst.setZero(); scaleAndAddTo(dst,1); }
+    inline void evalTo(Dest& dst) const { dst.setZero(); scaleAndAddTo(dst,Scalar(1)); }
 
     template<typename Dest>
     inline void addTo(Dest& dst) const { scaleAndAddTo(dst,1); }


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