[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Q]: ID analog to FORTRAN "sign" function
- Subject: Re: [Q]: ID analog to FORTRAN "sign" function
- From: Alex Schuster <alex(at)pet.mpin-koeln.mpg.de>
- Date: Mon, 09 Oct 2000 14:56:07 +0200
- Newsgroups: comp.lang.idl-pvwave
- Organization: Regional Computing Center, University of Cologne
- References: <39DEB5DD.3B262CEB@maxwell.apphy.fukui-u.ac.jp>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:21648
Rostyslav Pavlichenko wrote:
> Does the IDl have something close to Fortran SIGN (DSIGN... so on...)
> functions
>
> IN FORTRAN:
> Elemental Intrinsic Function (Generic):
> Returns the absolute value of the first argument times the sign of the
> second argument.
>
> Syntax:
> =======
> result = SIGN (a, b)
> a (Input) Must be of type integer or real.
>
> b Must have the same type and kind parameters as a.
>
> Results:
> =========
> The result type is the same as a.
> The value of the result is
> | a | if b >= zero
> and -| a | if b < zero.
No, but you can easily write it:
function sign, a, b
if ( b ge 0 ) then $
return, abs( a ) $
else $
return, -abs( a )
end
It works for both integer and float data types
Alex
--
Alex Schuster Wonko@weird.cologne.de PGP Key available
alex@pet.mpin-koeln.mpg.de