{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaArrays/LazyArrays.jl/issues/8","repository_url":"https://api.github.com/repos/JuliaArrays/LazyArrays.jl","labels_url":"https://api.github.com/repos/JuliaArrays/LazyArrays.jl/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/JuliaArrays/LazyArrays.jl/issues/8/comments","events_url":"https://api.github.com/repos/JuliaArrays/LazyArrays.jl/issues/8/events","html_url":"https://github.com/JuliaArrays/LazyArrays.jl/issues/8","id":384014801,"node_id":"MDU6SXNzdWUzODQwMTQ4MDE=","number":8,"title":"Lazy addition?","user":{"login":"tkf","id":29282,"node_id":"MDQ6VXNlcjI5Mjgy","avatar_url":"https://avatars3.githubusercontent.com/u/29282?v=4","gravatar_id":"","url":"https://api.github.com/users/tkf","html_url":"https://github.com/tkf","followers_url":"https://api.github.com/users/tkf/followers","following_url":"https://api.github.com/users/tkf/following{/other_user}","gists_url":"https://api.github.com/users/tkf/gists{/gist_id}","starred_url":"https://api.github.com/users/tkf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkf/subscriptions","organizations_url":"https://api.github.com/users/tkf/orgs","repos_url":"https://api.github.com/users/tkf/repos","events_url":"https://api.github.com/users/tkf/events{/privacy}","received_events_url":"https://api.github.com/users/tkf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2018-11-24T19:19:18Z","updated_at":"2018-11-24T23:01:33Z","closed_at":null,"author_association":"NONE","body":"Are you planning to implement lazy addition `Add(A, B)` similar to `Mul(A, B)`?  By that I mean a lazy object such that `mul!(y, Add(A, B), x, α, β)` lowers into\r\n\r\n```julia\r\nlmul!(β, y)\r\nmul!(y, A, x, α, 1)\r\nmul!(y, B, x, α, 1)\r\n```\r\n\r\nIf you are OK with it, I think I can write up a PR.\r\n\r\n(In fact, I've written something like this a while ago https://github.com/tkf/MatrixCombinators.jl but I thought I'd better contribute to this package since it's _much_ more feature complete.)\r\n"},"comment":{"url":"https://api.github.com/repos/JuliaArrays/LazyArrays.jl/issues/comments/441402217","html_url":"https://github.com/JuliaArrays/LazyArrays.jl/issues/8#issuecomment-441402217","issue_url":"https://api.github.com/repos/JuliaArrays/LazyArrays.jl/issues/8","id":441402217,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MTQwMjIxNw==","user":{"login":"tkf","id":29282,"node_id":"MDQ6VXNlcjI5Mjgy","avatar_url":"https://avatars3.githubusercontent.com/u/29282?v=4","gravatar_id":"","url":"https://api.github.com/users/tkf","html_url":"https://github.com/tkf","followers_url":"https://api.github.com/users/tkf/followers","following_url":"https://api.github.com/users/tkf/following{/other_user}","gists_url":"https://api.github.com/users/tkf/gists{/gist_id}","starred_url":"https://api.github.com/users/tkf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkf/subscriptions","organizations_url":"https://api.github.com/users/tkf/orgs","repos_url":"https://api.github.com/users/tkf/repos","events_url":"https://api.github.com/users/tkf/events{/privacy}","received_events_url":"https://api.github.com/users/tkf/received_events","type":"User","site_admin":false},"created_at":"2018-11-24T23:01:33Z","updated_at":"2018-11-24T23:01:33Z","author_association":"NONE","body":"What I mean by compositionality is something like the following.  Suppose that I wrote some code before knowing LazyArrays.jl:\r\n\r\n```julia\r\nfunction f(du, u, A, t)\r\n    du .= .- u .+ tanh.(mul!(du, A, u))\r\nend\r\n\r\nA = sprand(100, 100, 0.1)\r\node = ODEProblem(f, u0, tspan, A)\r\n```\r\n\r\n_If_ LazyArrays.jl exposes `mul!`-compatible interface, I can just use the lazy array instead of `Matrix` and get a performance boost right away _without_ touching my code:\r\n\r\n```julia\r\nB = -0.1 * Eye(100)\r\nM = Add(A, B)  # This is a highly structured matrix so I don't want to materialize it.\r\node = ODEProblem(f, u0, tspan, M)\r\n```\r\n\r\nOf course, since it's my code, I can rewrite my function `f` to use LazyArrays.jl.  But now imagine that function `f` is some more complicated function deep in the library I'm using.  Then there is no way I can use LazyArrays.jl API unless I fork this library.\r\n\r\n> `@lazymul MyArrayType` will cause `mul!` to use the lazy arrays version.\r\n\r\nGreat.  So why not just do\r\n\r\n```julia\r\nconst Add = BroadcastArray{<:Any, <:Any, <:Broadcasted{<:Any, <:Any, typeof(+)}}\r\n@lazymul Add{<:Any, 2}\r\n```\r\n\r\n?\r\n"}}
{"actor":{"display_login":"tkf"}}