You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a needed enhancement. The problem is that the simplification pass on the code cannot reduce zeros(..) + x to x without knowing the type of x (it simplifies if x is an Array, but not if x is a scalar); and the type of the variables are not always known at the simplification stage.
The change needed is not too complicated but it may make rdiff() significantly slower on more complex functions. I am trying to find a better solution involving larger changes in the code.
The following small example seems to produce very strange code, especially all the call to zeros() seem unnecessary?
julia> rdiff(ex,x=x)
quote
_tmp1 = xp - x
_tmp2 = x - goal
_tmp3 = _tmp1 .^ 2
_tmp4 = size(_tmp3)
_tmp5 = _tmp2 .^ 2
_tmp6 = sum(_tmp5)
_tmp7 = size(_tmp5)
_tmp8 = _tmp6 + c3
(((c1 * _tmp6 + c2 * log(_tmp8)) + sum(_tmp3)) + sum(u .^ 2),(zeros(size(x)) + -((zeros(size(_tmp1)) + (2_tmp1) .* (zeros(_tmp4) + ones(_tmp4))))) + (zeros(size(_tmp2)) + (2_tmp2) .* (zeros(_tmp7) + ones(_tmp7) .* (c2 / _tmp8 + c1))))
end
The text was updated successfully, but these errors were encountered: