Re: [eigen] How can I improve this function
• To: eigen@xxxxxxxxxxxxxxxxxxx
• Subject: Re: [eigen] How can I improve this function
• From: Hung Dang <hungptit@xxxxxxxxx>
• Date: Sat, 22 Sep 2012 23:23:41 -0400

```Hi Gael,

Thanks a lot for your help.

Hung

On 09/22/2012 05:17 PM, Gael Guennebaud wrote:
```
```  you could try:

x = (x.array()>0).select(xval, (y.array()>0).select(yval, x) );

but that won't be faster.

gael

On Sat, Sep 22, 2012 at 1:54 AM, Hung Dang <hungptit@xxxxxxxxx> wrote:
```
```Hi all,

I have below function and I would like to improve it using Eigen's way. Any
suggestion?

Thanks a lot
Hung

template<typename T>
void combine(Eigen::Matrix<T, Eigen::Dynamic, 1> & x, const T xval,
const Eigen::Matrix<T, Eigen::Dynamic, 1> & y, const T yval) {
const size_t len = x.rows();
for (size_t idx = 0; idx < len; idx ++) {
if (x(idx,0) > 0) {
x(idx,0) = xval;
} else {
if (y(idx,0) > 0) x(idx,0) = yval;
}
}
}

```
```
```
```

```

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