Last active
September 18, 2018 15:46
-
-
Save mschauer/83762b81b2eaed9f1e587c4241e94658 to your computer and use it in GitHub Desktop.
Minimal broadcast example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct MyType | |
| x | |
| end | |
| Base.broadcastable(x::MyType) = x | |
| Broadcast.BroadcastStyle(::Type{<:MyType}) = Broadcast.Style{MyType}() | |
| x = rand(5) | |
| Base.size(x::MyType) = size(x.x) | |
| Base.copyto!(x::MyType, y) = copyto!(x.x, y) | |
| Base.getindex(x::MyType, i::CartesianIndex) = x.x[i] | |
| MyType(x) .= x | |
| MyType(x) .= 1 .* MyType(x) | |
| x .= 1 .* MyType(x) | |
| MyType(x) .= 1 .* MyType(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment