From groemp at tfh-berlin.de  Tue Mar 24 15:41:31 2009
From: groemp at tfh-berlin.de (=?UTF-8?Q?Ulrike_Gr=C3=B6mping?=)
Date: Tue, 24 Mar 2009 07:41:31 -0700 (PDT)
Subject: [Rd] Error in FrF2 example on Mac OS
In-Reply-To: <20090324141728.GC4963@cs.cas.cz>
References: <22675998.post@talk.nabble.com>
	<49C8E415.3060702@statistik.tu-dortmund.de>
	<20090324141728.GC4963@cs.cas.cz>
Message-ID: <22681913.post@talk.nabble.com>



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.



[Rd] Error in FrF2 example on Mac OS
=?UTF-8?Q?Ulrike_Gr=C3=B6mping?=