Am 24.04.2020 um 18:33 schrieb Riccardo (Jack) Lucchetti:
On Fri, 24 Apr 2020, Alecos Papadopoulos wrote:
> I thought we had a sign function in gretl but I cannot find it
> (returning 1 if positive -1 if negative, 0 if zero)
> ...
>
> but the sign seems pretty fundamental to be an expression or a
> user-defined function. Is it hidden somewhere? :)
That said, conditional assignment is your friend. The sign of x can be
easily wriiten as
s = x==0 ? 0 : (x>0 ? 1 : -1)
another example of the relativity of "easy" ;-)
but expressions like "z = sign(x) * y" translate into even
easier
constructs:
z = x > 0 ? y : -y
How is this relevant for the present question?
I agree that in most practical appliations you don't really want to
blindly write down the sign function that appears in the printed formula
because more efficient reformulations exist. But I still think Alecos
may have a point here. At least another candidate for the 'extra' package?
cheers
sven