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;
}
}
}