On 2010-05-06 22:46:42 -0400, Michel Fortin <michel.for...@michelf.com> said:

That said, I'd expect the compiler to call sin(y) only once, so it'd be more like that:

        auto sinY = sin(y);
        for(int i = 0; i < x.length; i++) {
                x[i] = sinY[i];
        }

And I'd expect that because in the expression "x[] = sin(y)[]" none of sin's argument are part of an array operation. Calling a function repeatedly should only happen when one of its arguments can change between iterations (and possibly only pure functions should be allowed to be called repeatedly through array ops).

--
Michel Fortin
michel.for...@michelf.com
http://michelf.com/

Reply via email to