we are defining a polynomial function in the first lab like this:
function polynomial(as, x)
powers = map(enumerate(a)) do (i, a)
x^(i-1) * a
end
accumulator = sum(powers)
return accumulator
end
this should really be a mapreduce. the example above is allocating much more than it has to (which becomes only really important when x is a matrix, but still)
mapreduce(+, enumerate(as), init=zero(x)) do (i,a)
x^(i-1) * a
end
we are defining a
polynomial
function in the first lab like this:this should really be a
mapreduce
. the example above is allocating much more than it has to (which becomes only really important whenx
is a matrix, but still)