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

2005-06-29 Thread Robin Hankin
Hi I have been wondering if there one can speed up calculating small powers of numbers such as x^8 using multiplication. In addition, one can be a bit clever and calculate x^8 using only 3 multiplies. look at this: f1 - function(x){x*x*x*x*x*x*x*x} f2 - function(x){x^8} f3 -

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

2005-06-29 Thread Ken Knoblauch
Something like this is exploited very nicely in the mtx.exp for matrix powers in the Malmig package, actually. Hi I have been wondering if there one can speed up calculating small powers of numbers such as x^8 using multiplication. In addition, one can be a bit

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

2005-06-29 Thread Tuszynski, Jaroslaw W.
- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robin Hankin Sent: Wednesday, June 29, 2005 7:32 AM To: r-help Subject: [R] x*x*x*... vs x^n Hi I have been wondering if there one can speed up calculating small powers of numbers such as x^8 using multiplication. In addition, one can

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

2005-06-29 Thread Duncan Murdoch
On 6/29/2005 7:32 AM, Robin Hankin wrote: Hi I have been wondering if there one can speed up calculating small powers of numbers such as x^8 using multiplication. In addition, one can be a bit clever and calculate x^8 using only 3 multiplies. look at this: f1 -

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

2005-06-29 Thread Robin Hankin
Hi Duncan On Jun 29, 2005, at 02:04 pm, Duncan Murdoch wrote: On 6/29/2005 7:32 AM, Robin Hankin wrote: Hi I have been wondering if there one can speed up calculating small powers of numbers such as x^8 using multiplication. In addition, one can be a bit clever and calculate x^8 using

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

2005-06-29 Thread Prof Brian Ripley
On Wed, 29 Jun 2005, Duncan Murdoch wrote: On 6/29/2005 7:32 AM, Robin Hankin wrote: I have been wondering if there one can speed up calculating small powers of numbers such as x^8 using multiplication. In addition, one can be a bit clever and calculate x^8 using only 3 multiplies. look

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

2005-06-29 Thread Duncan Murdoch
On 6/29/2005 9:31 AM, Robin Hankin wrote: Hi Duncan On Jun 29, 2005, at 02:04 pm, Duncan Murdoch wrote: On 6/29/2005 7:32 AM, Robin Hankin wrote: Hi I have been wondering if there one can speed up calculating small powers of numbers such as x^8 using multiplication. In addition,

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

2005-06-29 Thread Robin Hankin
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,

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

2005-06-29 Thread Ravi Varadhan
PROTECTED] [mailto:r-help- [EMAIL PROTECTED] On Behalf Of Tuszynski, Jaroslaw W. Sent: Wednesday, June 29, 2005 8:25 AM To: 'Robin Hankin'; r-help Subject: Re: [R] x*x*x*... vs x^n I tried your code and got different results: system.time(ignore - f1(a)) [1] 0.83 0.09 1.08 NA NA

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

2005-06-29 Thread davidr
: [EMAIL PROTECTED] [mailto:r-help- [EMAIL PROTECTED] On Behalf Of Robin Hankin Sent: Wednesday, June 29, 2005 9:13 AM To: Duncan Murdoch Cc: r-help; Robin Hankin Subject: Re: [R] x*x*x*... vs x^n On Jun 29, 2005, at 02:47 pm, Duncan Murdoch wrote: On 6/29/2005 9:31 AM, Robin Hankin wrote

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

2005-06-29 Thread davidr
-Original Message- From: [EMAIL PROTECTED] [mailto:r-help- [EMAIL PROTECTED] On Behalf Of Robin Hankin Sent: Wednesday, June 29, 2005 9:13 AM To: Duncan Murdoch Cc: r-help; Robin Hankin Subject: Re: [R] x*x*x*... vs x^n On Jun 29, 2005, at 02:47 pm, Duncan Murdoch wrote

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

2005-06-29 Thread davidr
] [mailto:r-help- [EMAIL PROTECTED] On Behalf Of David Reiner [EMAIL PROTECTED] Sent: Wednesday, June 29, 2005 10:24 AM To: r-help Subject: Re: [R] x*x*x*... vs x^n Looking at the code for gsl_pow_int, I see they do use that method. David L. Reiner -Original Message- From