Re: [eigen] Forward declarations |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Forward declarations
- From: David Lonie <loniedavid@xxxxxxxxx>
- Date: Tue, 19 Jul 2011 11:27:09 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=wsQkxNUZhRsGg4XYcQpSLT4jkyW0N/RPvkYJ3xXl6k0=; b=uY5/UIoLogkdeYiaHCgXrZB4R9I0UCK8id3mUzLEv5utmQitWtbkUbxU6aK+6uRuQu ARW54ERkBbRXfKxmWpotDOQLHJJGyPCops/gNrwvhehnJW+VxXuVXHWUFYbVTDBb+4OO E7t8rO4I8sPvenYALR1vLQ2+kqyJDZLX5S4ZE=
When I try that, AutoAlign, RowMajor, ColMajor, and
EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION are all undefined. I could
swap out the integer values for the constants and have a fragile
solution, but AIUI EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION is
build-specific and cannot be known without including Eigen. Should I
assume that the class cannot be forward declared and start looking at
my other options, or is there a trick to get around this?
Thanks,
Dave
On Tue, Jul 19, 2011 at 11:17 AM, Gael Guennebaud
<gael.guennebaud@xxxxxxxxx> wrote:
> look at the file Eigen/src/Core/util/ForwardDeclarations.h, here is
> how it is declared:
>
> template<typename _Scalar, int _Rows, int _Cols,
> int _Options = AutoAlign |
> #if defined(__GNUC__) && __GNUC__==3 && __GNUC_MINOR__==4
> // workaround a bug in at least gcc 3.4.6
> // the innermost ?: ternary operator is misparsed. We write it slightly
> // differently and this makes gcc 3.4.6 happy, but it's ugly.
> // The error would only show up with EIGEN_DEFAULT_TO_ROW_MAJOR is defined
> // (when EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION is RowMajor)
> ( (_Rows==1 && _Cols!=1) ? RowMajor
> : !(_Cols==1 && _Rows!=1) ?
> EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION
> : ColMajor ),
> #else
> ( (_Rows==1 && _Cols!=1) ? RowMajor
> : (_Cols==1 && _Rows!=1) ? ColMajor
> : EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION ),
> #endif
> int _MaxRows = _Rows,
> int _MaxCols = _Cols
>> class Matrix;
>
> gael
>
> On Tue, Jul 19, 2011 at 5:08 PM, David Lonie <loniedavid@xxxxxxxxx> wrote:
>> Hi Gael,
>>
>> On Tue, Jul 19, 2011 at 3:21 AM, Gael Guennebaud
>> <gael.guennebaud@xxxxxxxxx> wrote:
>>> Hi,
>>>
>>> that's not so easy because I see that OpenQube headers typically
>>> contains functions returning Eigen::Vector3d objects by value or
>>> classes having Eigen's objects as members. That means the compiler has
>>> to know what is, e.g., a Eigen::Vector3d so I'm afraid simple forward
>>> declarations won't help.
>>
>> The OpenQube library is still fairly new, and I may be able to rewrite
>> the API to work around those issues -- at this point, I'm just trying
>> to gather information to figure out how to best handle this. My
>> options right now are (a) Forward declare Eigen classes (and rewrite
>> OpenQube API appropriately), (b) Remove Eigen from OpenQube's API
>> altogether, or (c) Make Eigen an optional dependency of VTK.
>>
>> (b) would lose some flexibility and be a decent bit of work, and (c)
>> may be difficult, while (a), if possible, would be the best solution
>> that I can see.
>>
>> Is it possible to forward declare the Eigen::Matrix class? This would
>> be useful for a few other projects I'm working on as well ;-)
>>
>>> Gael
>>>
>>> On Mon, Jul 18, 2011 at 4:09 PM, David Lonie <loniedavid@xxxxxxxxx> wrote:
>>>> Hi List,
>>>>
>>>> I'm currently integrating a library that uses Eigen vectors/matrices
>>>> in its API into VTK, and I have a quick question: Is it possible to
>>>> forward-declare Eigen::Matrix? The library (OpenQube
>>>> http://github.com/cryos/openqube) currently includes Eigen/Core in
>>>> it's headers, but I'd like to replace these includes with forward
>>>> declarations so that I wouldn't have to add Eigen as a dependency for
>>>> VTK.
>>>>
>>>> I've tried doing this myself, but it looks like the last three
>>>> template arguments are dependent on compiler options. Is there a trick
>>>> to forward declaring this class?
>>>>
>>>> Thanks,
>>>>
>>>> Dave
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
>
>