Re: [R] x*x*x*... vs x^n

From: Robin Hankin <r.hankin_at_noc.soton.ac.uk>
Date: Thu 30 Jun 2005 - 00:12:36 EST

On Jun 29, 2005, at 02:47 pm, Duncan Murdoch wrote:

> On 6/29/2005 9:31 AM, Robin Hankin wrote:
>
>> Hi Duncan
>>
>>
>> library(gsl)
>> system.time(ignore <- pow_int(a,8))
>> [1] 1.07 1.11 3.08 0.00 0.00
>>
>> <why the slow execution time?>
>>
>
> Shouldn't you ask the gsl maintainer that? :-)
>

well I did ask myself, but in this case the gsl maintainer told me to ask the gsl co-author, who
is no doubt much better informed in these matters ;-)

>>
>> (Of course, I'm not suggesting that other programming tasks be
>> suspended! All I'm pointing
>> out is that there may exist a user to whom fast integer powers are
>> very very important)
>>
>
> Then that user should submit the patch, not you. But whoever does it
> should include an argument to convince an R core member that the
> change
> is worth looking at, and do it well enough that the patch is accepted.

> Changes to the way R does arithmetic affect everyone, so they had
> better
> be done right, and checking them takes time.
>

yes, that's a fair point.
But including a native R command pow.int(), say, wouldn't affect anyone, would it?
One could even use the (tested) GSL code, as it is GPL'ed.

This would just be a new function that users could use at their discretion, and no
existing code would break.

I assume that such a function would not suffer whatever performance disadvantage
that the GSL package approach had, so it may well be quite a significant improvement
over the method used by R_pow_di() in arithmetic.c especially for large n.

best wishes

rksh

> Duncan Murdoch
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-
> guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jun 30 00:17:40 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:06 EST