shouldn't your last expression be:

if (any(tst)) big.vector.1[tst] <- big.vector.2[tst]


Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Wed, Mar 11, 2015 at 11:14 AM, William Dunlap <wdun...@tibco.com> wrote:

> > %/% which, BTW,
> > violated the sacred rule that for all a, and non-zero b:
> >
> > a = b * (a %/% b) + a %% b
> >
> > Namely, that Inf %/% n is not Inf, but NaN.
>
> But the other sacred rule is that a%%b is >=0 and <b.
>
> By the way, you will run into problems with %% long before Inf.  E.g.,
>   > (1 + 2^53) %% 2 # 1 if you had infinite precision
>   [1] 0
>   > (2 + 2^53) %% 2
>   [1] 0
>   Warning message:
>   probable complete loss of accuracy in modulus
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Wed, Mar 11, 2015 at 4:25 AM, ALBERTO VIEIRA FERREIRA MONTEIRO <
> albm...@centroin.com.br> wrote:
>
> > I've just found an annoyance with the behaviour of %/% which, BTW,
> > violated the sacred rule that for all a, and non-zero b:
> >
> > a = b * (a %/% b) + a %% b
> >
> > Namely, that Inf %/% n is not Inf, but NaN.
> >
> > Why is this so? It's an annoyance, because in expressions like:
> >
> > big.vector.1[a, b, c] <- big.vector.2[a, b, c] %/% n
> >
> > we must treat Inf and -Inf as exceptions, when a simple division does
> > not have these exceptions
> >
> > BTW, I treated this exception the way Grace Hopper would be proud of,
> > namely,
> > "it's easier to ask forgiveness than it is to get permission", but at
> > the cost of memory:
> >
> > big.vector.1 <- big.vector.2
> > big.vector.1[a, b, c] <- big.vector.2[a, b, c] %/% n
> > tst <- is.nan(big.vector.1)
> > if (any(tst)) big.vector.1[tst] <- big.vector.2
> >
> > Alberto Monteiro
> >
> > ______________________________________________
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to