Re: How to express logarithm function by a pre-calculated table and a binary variable
- From: "e p chandler" <epc8@xxxxxxxx>
- Date: 15 Feb 2006 14:24:47 -0800
Mengxiao Wu wrote:
My objective function includes logarithm part. log(x+1). I want to use
a pre-calculated table and a binary variable y to replace it. That
means the table is z --> log(z+1). If (x=z) then (y=1), else (y=0). I
do not know how to use inequal equations to express "If (x=z) then
(y=1), else (y=0)."
Who can help me? Thanks a lot!!!!
Well if x and z are floating point (real) numbers then you *do not*
want to compare them using .EQ. (OR ==).
Let eps be a real constant set to some small tolerance.
if abs(z-x)<eps then
y=1
else
y=0
end if
You may wish to express this as an indicator function which returns 0
or 1.
* Yes there are other fancy ways to do this but they remind me of "C".
*
-- Elliot
.
- Follow-Ups:
- Re: How to express logarithm function by a pre-calculated table and a binary variable
- From: Michael Metcalf
- Re: How to express logarithm function by a pre-calculated table and a binary variable
- References:
- Prev by Date: Re: Python for Fortran programmers
- Next by Date: Re: How to express logarithm function by a pre-calculated table and a binary variable
- Previous by thread: How to express logarithm function by a pre-calculated table and a binary variable
- Next by thread: Re: How to express logarithm function by a pre-calculated table and a binary variable
- Index(es):