This forum has been archived. All content is frozen. Please use KDE Discuss instead.

redefine cwisemin as a function taking two args

Tags: eigen eigen eigen
(comma "," separated)
zhenhuang
Registered Member
Posts
1
Karma
0
Hi, I'm in the process of converting some old vector operation code to use Eigen/ArrayXf. I have a lot of code like this:
Code: Select all
    a = x + y + min(x, y)

where x, y and a can either be a double or vector. When they are vector represented as ArrayXf, I could change the formula to
Code: Select all
   a = x + y + x.cwisemin(y)

but that would break the original code that works also for regular double. I tried to define

Code: Select all
inline ArrayXf min(const ArrayXf &x, const ArrayXf &y)
{
    return x.cwisemin(y)
}

that would make the original code work without any changes, but this approach seems introducing temporary objects and slow down quite a bit. As the last resort and a temporary solution I was using marco, like this
Code: Select all
 #define  min(x, y) x.cwisemin(y)

It works for ArrayXf without code changes, but not for double. Any idea of how to get around it?


Bookmarks



Who is online

Registered users: bcooksley, Bing [Bot], claydoh, Google [Bot], paulgureghian, Yahoo [Bot]