Re: [eigen] Re: problem with local nested typedefs

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


you have to use the C++ template keyword here:

ref.template triangularView<StrictlyUpper>();

because the type of ref depends on the template parameters of your
function. This is similar to the use of typename for types.

the rest is correct.

gael


On Thu, Oct 28, 2010 at 11:20 AM, Patrick Sauer <pat05.mlst@xxxxxxxxx> wrote:
> Hi,
>
> I am trying to access the triangularView method of an Eigen3 matrix using
> the following code:
>
> template< class Derived >
> void get_view_local_td( MatrixBase<Derived>& in )
> {
>     typedef typename MatrixBase<Derived>::Scalar        Float;
>     typedef Matrix<Float, Dynamic, Dynamic>         MatrixType;
>
>     MatrixType& ref = static_cast<MatrixType&>( in );
>     ref.triangularView<StrictlyUpper>();
> }
>
> This results in the error:
>
> In function ‘void get_view_local_td(Eigen::MatrixBase<Derived>&)’:
> /home/psauer/software/sources/cpp/sandbox/eigen/eigen_sandbox.cxx:95: error:
> expected primary-expression before ‘)’ token
> /home/psauer/software/sources/cpp/sandbox/eigen/eigen_sandbox.cxx: In
> function ‘void get_view_local_td(Eigen::MatrixBase<Derived>&) [with Derived
> = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001, 0,
> -0x00000000000000001, -0x00000000000000001>]’:
> /home/psauer/software/sources/cpp/sandbox/eigen/eigen_sandbox.cxx:115:
> instantiated from here
> /home/psauer/software/sources/cpp/sandbox/eigen/eigen_sandbox.cxx:95: error:
> no match for ‘operator<’ in ‘ref->Eigen::MatrixBase::triangularView [with
> unsigned int Mode = Mode, Derived = Eigen::Matrix<double,
> -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001,
> -0x00000000000000001>] < (Eigen::._96)10u’
>
> The problem appears to be the use of the nested typedef in MatrixType. If I
> replace the implicit Float type with e.g. double, the code compiles and
> runs.
> Am I missing something, or is the use of nested typedefs illegal inside C++
> functions?
>
> Thanks.
>
> Kind regards,
>
> Patrick
>



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