[Rd] Error in FrF2 example on Mac OS
Ulrike Grömping
groemp at tfh-berlin.de
Tue Mar 24 15:41:31 CET 2009
Petr Savicky wrote:
>
> On Tue, Mar 24, 2009 at 02:45:57PM +0100, Uwe Ligges wrote:
>> >gives the custom error message "nruns must be a power of 2.", which is
>> >generated in the first check within function FrF2:
>> >
>> > if (!is.null(nruns)){
>> > k <- floor(log2(nruns))
>> > if (!2^k==nruns) stop("nruns must be a power of 2.")}
>>
>>
>> Probably a rounding issue on different platforms?
>> I guess the test should be something like:
>>
>> if (!is.null(nruns)){
>> if(!isTRUE(all.equal(log2(nruns) %% 1, 0)))
>> stop("nruns must be a power of 2.")
>> }
>
> Probably, k is needed also later. Assumig that 2^k works correctly,
> the following could be sufficient
>
> if (!is.null(nruns)){
> k <- round(log2(nruns))
> if (!2^k==nruns) stop("nruns must be a power of 2.")}
>
> In order to test the assumption, one can use
>
> x <- 2^(0:100 + 0) # use double exponent to be sure
> all(x == floor(x))
>
> Powers of two are represented exactly, since they have only one
> significant bit.
>
> Petr.
>
Yes, round instead of floor should also do the job, if rounding is the
issue. But then, with powers of 2 indeed being represented exactly (I would
expect even on Macs), maybe rounding is not the issue? I have no possibility
to check this, since I do not have access to a Mac with R installed. On my
windows machine,
all(log2(x)==floor(log2(x)))
with x as defined above yields TRUE.
Regards, Ulrike
--
View this message in context: http://www.nabble.com/Error-in-FrF2-example-on-Mac-OS-tp22675998p22681913.html
Sent from the R devel mailing list archive at Nabble.com.
More information about the R-devel
mailing list