New user self-registration is disabled due to spam. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Bug 1286 - Automatically adjust the prototype of functors for CwiseNullaryOp
Summary: Automatically adjust the prototype of functors for CwiseNullaryOp
Status: CONFIRMED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.3 (current stable)
Hardware: All All
: Normal Unknown
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 457 720
  Show dependency treegraph
 
Reported: 2016-08-31 12:46 UTC by Gael Guennebaud
Modified: 2016-08-31 13:14 UTC (History)
3 users (show)



Attachments
patch (19.07 KB, patch)
2016-08-31 12:46 UTC, Gael Guennebaud
no flags Details | Diff

Description Gael Guennebaud 2016-08-31 12:46:29 UTC
Created attachment 726 [details]
patch

Current functors passed to NullaryExpr must implement both operator()(i) and operator()(i,j) plus specialize internal::functor_has_linear_access<> for non trivial functors. This is rather painful and cumbersome to document (hence, this is currently not really documented!).

The proposed patch automatically detect whether the functor expose one or multiple of the following operators:

operator()()
operator()(i)
operator()(i,j)

and then a little helper augments the input functors with the missing operators.

With this change, no need to provide operator()(i,j) if nor i nor j are required (e.g.,  for random, and constant).

I'd like to push this change in 3.3 as it considerably help in documenting and using NullaryExpr.
Comment 1 Christoph Hertzberg 2016-08-31 13:14:50 UTC
I'm all for this!

Note You need to log in before you can comment on or make changes to this bug.