[eigen] something like cwise trinary operator?

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


Hi all,

I'm wondering if there is a way to generate something like the ((a <
b) ? c : d) expression that will efficiently operate component-wise on
an array?

My particular issue is that I am computing (with eigen2)
x.cwise()*(x.cwise().log()), which is a NaN for elements of x that
have a value of zero, but the actual limiting value is well-defined
and zero.  Right now, I'm doing this with an explicit for loop, but
it'd be considerably nicer if I could do this with an expression.

Any ideas?

For the curious (or those of you who might recognize this function),
it is the same as the Shannon entropy, but in my context it's to
compute the free energy of an ideal gas at fixed temperature (which is
-TS where S is the entropy).  To get the actual free energy, we'd have
to add in the energy term, which would be 3/2kT for a monatomic ideal
gas.
-- 
David Roundy



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