Are scalars precomputed when multiplied with or added to vectors?

Olaf Till olaf.till at uni-jena.de
Wed Mar 12 09:17:40 CDT 2008


If x and y are vectors and all other variables are scalars, e.g. in

octave:1> y = sqrt (x.^2 * a^2 + sqrt ((a + b)^2 + c * d)) + c + d;

will all scalar subexpressions

(i.e.: a^2, sqrt ((a + b)^2 + c * d), c + d)

be computed by Octave only once for the operations on all components
of x, or is it worth explicitly precomputing them?

Olaf


More information about the Help-octave mailing list