Giter Club home page Giter Club logo

muladdmacro.jl's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

muladdmacro.jl's Issues

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Multiply-add with minus signs doesn't get converted to muladd

I expected this to work, but it didn't. There is generally no problem with having minus signs inside muladd, because FMA instructions allow for that, so expressions like b-a*x should be converted to muladd(-a, x, b).

julia> macroexpand(:(MuladdMacro.@muladd b - a * x))
:(b - a * x)

julia> macroexpand(:(MuladdMacro.@muladd b + a * x))
:((muladd)(a, x, b))

Not broadcasting?

┌ Warning: `a::Number + b::AbstractArray` is deprecated, use `a .+b` instead.
│   caller = muladd at math.jl:1014 [inlined]

is showing up in some tests. That's caused by

julia> muladd(1, 1, ones(1))
┌ Warning: `a::Number + b::AbstractArray` is deprecated, use `a .+ b` instead.
│   caller = muladd(::Int64, ::Int64, ::Array{Float64,1}) at math.jl:1014
└ @ Base.Math ./math.jl:1014

@devmotion does the newest version not catch broadcasting as muladd.(...)? This is showing up in OrdinaryDiffEq.jl and StochasticDiffEq.jl tests.

Order of evaluation is changed by `@muladd`

@muladd should not change the order in which operands are multiplied and added, since any reordering might introduce numerical instabilities. So the examples of the README should rather give

julia> macroexpand(:(@muladd k3 = f(t + c3*dt, @. uprev+dt*(a031*k1+a032*k2))))
:(k3 = f((muladd)(c3, dt, t), (muladd).(dt, (muladd).(a032, k2, *.(a031, k1)), uprev)))

julia> macroexpand(:(@muladd integrator.EEst = integrator.opts.internalnorm((update - dt*(bhat1*k1 + bhat4*k4 + bhat5*k5 + bhat6*k6 + bhat7*k7 + bhat10*k10))./ @. (integrator.opts.abstol+max(abs(uprev),abs(u))*integrator.opts.reltol))))
:(integrator.EEst = integrator.opts.internalnorm((update - dt * (muladd)(bhat10, k10, (muladd)(bhat7, k7, (muladd)(bhat6, k6, (muladd)(bhat5, k5, (muladd)(bhat4, k4, bhat1 * k1)))))) ./ (muladd).(max.(abs.(uprev), abs.(u)), integrator.opts.reltol, integrator.opts.abstol)))

This occured first in SciML/OrdinaryDiffEq.jl#93 (comment)

I would suggest changing @muladd in such a way that at least the order of evaluation of the summation-multiplication complexes is left unchanged (i.e. the implementation should be reversed) and summands with n factors are split in two groups of the first n-1 factors and the last factor (i.e. contrary to the current implementation; this should leave the evaluation order unchanged also inside of each summand). However, I'm not sure whether it would be best to evaluate the sum of all not-multiplication summands first (as currently done) or last.

use `if` instead of MacroTools

MacroTools' pattern matching is very slow, mostly due to using exceptions to signal no-match. This causes JuliaLang/julia#28221. Ideally MacroTools can be fixed too, but in the meantime it seems easier to switch this package to use simple tests like isexpr(ex, :call) && ex.args[1] == :+ instead of MacroTools. Of course that can be abstracted into iscall(ex, :+), etc. --- feel free to go nuts with that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.