Re: [eigen] User defined reductions |

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

On 02.03.2012 15:41, Douglas Bates wrote:

In the documentation for Eigen 3.1, Tutorial page 7 on Reductions
makes a brief mention of user defined reductions and suggests looking
at the DenseBase::redux() function.
My immediate goal is to determine the column-wise medians of an array.
It would be convenient if I could write it as
A.colwise().median()
but I suspect that won't be possible because the median cannot be
calculated sequentially and it appears that redux implies, well, a
reduction in the sense of MapReduce. (Evaluating the median requires
at least a partial sort of the vector.)

Yes, I would say so to.

I can write the calculation in a loop over the columns - I just wanted
to confirm that there was not a more compact way of expressing this.

`I guess a loop calling std::nth_element for every column is still quite
``compact. Or better yet, implement a median() function for Eigen
``expressions and provide a patch. Maybe with a destructive (i.e.
``partially sorting the expression) and a non-destructive (working on a
``copy) version.
`
Christoph
--
----------------------------------------------
Dipl.-Inf. Christoph Hertzberg
Cartesium 0.051
Universität Bremen
Enrique-Schmidt-Straße 5
28359 Bremen
Tel: (+49) 421-218-64252
----------------------------------------------