On 12 Jul 2005, at 14:51, Duncan Murdoch wrote:
> On 7/12/2005 9:29 AM, Robin Hankin wrote:
>
[bogus function snipped]
> I don't understand this.
>
> 1. I don't think you meant to use sqrt() there, did you??
>
> 2. What effect does the 0+0i have? x has already been determined
> to be
> complex.
>
> Duncan Murdoch
>
Er, guilty on all counts. I plead the hot weather.
I intended to modify and post the following function
for cube roots.
"sqrti" <-
function (x)
{
if (is.complex(x)) {
return(sqrt(x))
}
if (any(x < 0)) {
return(sqrt(x + 0i))
}
return(sqrt(x))
}
[which deals with square roots in a consistent way, handling positive
reals,
and negative reals, and complexes, in a nice way]
sorry about that
rksh
--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
tel 023-8059-7743
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html