https://github.com/tpapp/multibroadcast.jl
Utilities for broadcasting functions with multiple values in Julia
https://github.com/tpapp/multibroadcast.jl
Last synced: 5 months ago
JSON representation
Utilities for broadcasting functions with multiple values in Julia
- Host: GitHub
- URL: https://github.com/tpapp/multibroadcast.jl
- Owner: tpapp
- License: other
- Created: 2017-09-17T08:47:53.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-12-20T09:16:57.000Z (over 5 years ago)
- Last Synced: 2026-01-20T20:05:03.413Z (5 months ago)
- Language: Julia
- Size: 9.77 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# MultiBroadcast
[](http://www.repostatus.org/#wip)
[](https://travis-ci.org/tpapp/MultiBroadcast.jl)
[](https://coveralls.io/github/tpapp/MultiBroadcast.jl?branch=master)
[](http://codecov.io/github/tpapp/MultiBroadcast.jl?branch=master)
## Introduction
This is an **experimental** Julia package that explores broadcasting functions
with multiple values (cf
[#23734](https://github.com/JuliaLang/julia/issues/23734)). The only
exported function is `multi_broadcast`, which is best explained with
an example:
```julia
f(x) = x+1, 2*x
a, b = multi_broadcast(f, 1:10)
a == collect(2:11)
b == collect(2:2:20)
```
There is a convenience syntax for this with the `@multi` macro:
```julia
@multi f.(1:10)
```
The package also extends `broadcast!`, so if you preallocate for the output, you can do
```julia
x = 1:10
a = similar(BitArray, x)
b = similar(Array{Int}, x)
f(x) = isodd(x), 3*x
a, b .= f.(a, b) # note: no new syntax required
```
## Implementation
I am relying on the existing implementation of `broadcast` as much as
possible, saving values in a thin wrapper type that contains a tuple
of arrays. Whether this is a viable approach remains to be seen.
I wrote this up so that I can experiment with the interface, and
because I find the functionality useful. If you have suggestions for
improvement, please open an issue or make a PR.