Re: [eigen] something like cwise trinary operator? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] something like cwise trinary operator?
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Thu, 30 Sep 2010 11:14:58 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=cpULKOyPS7gwxHeeo7w430fq0WYGRCE3ONfCQTDz7rg=; b=uATCnfBPuZt5fe8MiRcELjcR6JCDSK9l/KFuZdS8twedzV7EmEt1T3Chk6faTBVjBu BnAeeYaNH7x9Ip44zvCmqNRS7dcHZnn721YHPfKFVcVyy8pGeMcFOgHjBQE/HHlDX57M uzCD7cIrLxVbPWa8XXpu8MgOmGnXPQiS9Ob4c=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=T4P6JrSoR3TX+Z2h8i/nFUZnZ8uBAyjr0z6aPZ2mHOVTgubJPI/VHv6FKkCL0RvcmI Pp46npKedchw2n3qvhXkxnGO3TL3YH9h1ge8tnDxL2+4/wM/2uYQOwfinTnP9JdKvl1+ 2AC5Xd44qrpcK+BoZ4IvW0HfXhvxZEK7cGQEg=
2010/9/30 David Roundy <roundyd@xxxxxxxxxxxxxxxxxxxxxxx>:
> 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?
We have this: see the select() method.
Benoit
>
> 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
>
>
>