Skip to content

Commit f0f51c3

Browse files
committed
new example to readme
1 parent de77c97 commit f0f51c3

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ the documentation, which contains the unreleased features.
2222

2323
## Example
2424

25+
### VectorOfArray
26+
2527
```julia
2628
using RecursiveArrayTools
2729
a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
@@ -30,11 +32,30 @@ vA = VectorOfArray(a)
3032
vB = VectorOfArray(b)
3133

3234
vA .* vB # Now all standard array stuff works!
35+
```
3336

37+
### ArrayPartition
38+
39+
```julia
3440
a = (rand(5), rand(5))
3541
b = (rand(5), rand(5))
3642
pA = ArrayPartition(a)
3743
pB = ArrayPartition(b)
3844

3945
pA .* pB # Now all standard array stuff works!
46+
47+
48+
x0 = rand(3,3)
49+
v0 = rand(3,3)
50+
a0 = rand(3,3)
51+
u0 = ArrayPartition(x0, v0, a0)
52+
u0.x[1] == x0 # true
53+
54+
u0 .+= 1
55+
u0.x[2] == v0 # still true
56+
57+
# do some calculations creating a new partitioned array
58+
unew = u0 * 10
59+
# easily access the individual components without having to rely on complicated indexing
60+
xnew, vnew, anew = unew.x
4061
```

src/array_partition.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,6 @@ end
383383
N = npartitions(dest, bc)
384384
# Check if this is a simple enough broadcast that we can optimize
385385
if bc.f isa Union{typeof(+), typeof(*), typeof(muladd)}
386-
# @show "hey", bc, N
387386
@inbounds for i in 1:N
388387
# Use materialize! which is more efficient than copyto! for simple broadcasts
389388
Base.Broadcast.materialize!(dest.x[i], unpack(bc, i))

0 commit comments

Comments
 (0)