Re: [eigen] Re: problem with local nested typedefs |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Re: problem with local nested typedefs
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Thu, 28 Oct 2010 11:45:46 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=OaF5ri3l5kMFmPEnvDwanAeM5+y+UJBF0jN2dBOVJCw=; b=b+C08nw096Z4jTtCkcTEByPROjRG9s3wJ8Z1ZoLAZa0FlT6TjWHR7pxtLQ3acztg0P F9PN/kVEfltwWY2GWMytVo+cqM8HixSwk6Z5SLSuE5OcVYAc8dintP/sgqshACN8oZfV 5v2WA8YJpyVtTjxLoLD8yScPUHo7dfJolkJsE=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=MDes/jBF036CUSSFfa7FMnpjowmN3kpPnv7mJZUyi7MLm3oOOif0ShFe72CMXXclmk LU8aciI/o5+f4+g3WnhXfP1BxkXLC595Vv/JUi1wI6ml3lzEudKIMXAUXR/UeuLrkeWr paohMPQx91v6QYReCIa2EFF77tKju6YUjQaDQ=
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
>