Skip to content

Commit cb67978

Browse files
Merge pull request #463 from cwittens/patch-1
Added a new example to the README
2 parents cba9af5 + 9206527 commit cb67978

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
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+
# or do:
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
```

0 commit comments

Comments
 (0)