Re: [eigen] DenseBase::NullaryExpr - Functor requirements |

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

*To*: eigen <eigen@xxxxxxxxxxxxxxxxxxx>*Subject*: Re: [eigen] DenseBase::NullaryExpr - Functor requirements*From*: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>*Date*: Fri, 11 Mar 2016 12:11:06 +0100*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=SGlwYBSn8rc4HIPYwcQYU1Iri4VIjn1zTTYRGD7Ov0Q=; b=mr93Wfg1Fr0U7dxqlS/I8ACAiYdpLAggdHyUASuZ5P6Juw3OxJSqxfPNGSA0K0x189 gVVzkfWKW6n8wKrjkdY3HdMKprZ0TBfbbWH4VS5qfLUpKsmRsvESflmQ2KSyOVIDDYsu 8NoAlUoePq5PWGCUmD9q346smES0jfmy4cGA3oDdLrAiCAagElwnxstd+2vX1/bZD+jA BGu8MmymatOPuqj9yZdN+DY4KQ7fhyPAh1wBXqXVUGi077/NZ/v4N7JrsPaWB07PiQ2S 7yZgtKQjoldLbYFrRdzTyZrLgQyLl5t+50yiw/DdJCbqTN6RDPJB3ZYszYQQ3wZUA+xH Tacw==

Hi Dan,

Indeed, for vectors, it calls operator()(Index), as in the following example:

For really 2D matrices, operator()(Index) should not be called, otherwise we would need to know the storage order within the functor itself.

And yes, you can also add a packet(Index{,Index}) method to enable vectorization.

You are very welcome to propose a patch to improve the documentation regarding these aspects. A common adage says that documentation is better written by users.

cheers,

gael

On Thu, Mar 10, 2016 at 11:41 PM, Dan Čermák <dan.cermak@xxxxxxxxxxxxxxxxxxx> wrote:

Hi guys,

I am slightly confused by the required functions for the Functors to create a

CwiseNullaryOp using DenseBase::NullaryExpr.

I thought it would be enough to write a struct which provides a operator()

(int,int) which returns the element i,j of the _expression_. However when doing

that, I get frequent compilation errors which end with the following:

/usr/include/eigen3/Eigen/src/Core/CwiseNullaryOp.h:82:29: error: no match for

call to '(...)'

return m_functor(index)

(... <- is an ugly template _expression_ which is my functor)

So after some experimentation, I guessed that this operator()(int) should

return also the matrix elements but compressed into a 1D array. But I am not

sure at all about that. Although I seem to get the correct result when doing

that.

Could you maybe point me to the documentation where this is specified (sorry

couldn't find it)? Also is the single index operator dependent on the storage

order of DenseBase?

And out of curiosity, when searching the file Eigen/src/Core/CwiseNullaryOp..h

(the compile error from above occurred there), I found a function call

PacketScalar. What's that about? Is this for vectorization?

Thanks in advance!

Dan

**Follow-Ups**:**Re: [eigen] DenseBase::NullaryExpr - Functor requirements***From:*Dan Čermák

**References**:**[eigen] DenseBase::NullaryExpr - Functor requirements***From:*Dan Čermák

**Messages sorted by:**[ date | thread ]- Prev by Date:
**[eigen] best way to map matlab mex complex data to tensor** - Next by Date:
**[eigen] Circulant matrix and FFT** - Previous by thread:
**[eigen] DenseBase::NullaryExpr - Functor requirements** - Next by thread:
**Re: [eigen] DenseBase::NullaryExpr - Functor requirements**

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