Skip to content

Commit 75e647b

Browse files
Add READMEs for subpackages
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 66af122 commit 75e647b

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

  • lib
    • RecursiveArrayToolsArrayPartitionAnyAll
    • RecursiveArrayToolsShorthandConstructors
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# RecursiveArrayToolsArrayPartitionAnyAll.jl
2+
3+
Optimized `any` and `all` for
4+
[RecursiveArrayTools.jl](https://github.com/SciML/RecursiveArrayTools.jl)'s
5+
`ArrayPartition` type.
6+
7+
`ArrayPartition` stores data as a tuple of arrays. The default `AbstractArray`
8+
`any`/`all` iterates element-by-element through the partition, which incurs
9+
per-element partition lookup overhead. This subpackage provides methods that
10+
iterate partition-by-partition instead, giving ~1.5-1.8x speedup on full scans.
11+
12+
It is separated from the main package because `any(f::Function, ::ArrayPartition)`
13+
invalidates ~780 compiled specializations of `any(f::Function, ::AbstractArray)`.
14+
15+
## Installation
16+
17+
```julia
18+
using Pkg
19+
Pkg.add(url = "https://github.com/SciML/RecursiveArrayTools.jl",
20+
subdir = "lib/RecursiveArrayToolsArrayPartitionAnyAll")
21+
```
22+
23+
## Usage
24+
25+
```julia
26+
using RecursiveArrayTools
27+
using RecursiveArrayToolsArrayPartitionAnyAll
28+
29+
ap = ArrayPartition(rand(1000), rand(1000), rand(1000))
30+
31+
# These now use the optimized partition-by-partition iteration
32+
any(isnan, ap)
33+
all(x -> x > 0, ap)
34+
```
35+
36+
Without this package, `any`/`all` use the default `AbstractArray` implementation
37+
which is correct but ~1.5x slower due to per-element partition indexing overhead.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# RecursiveArrayToolsShorthandConstructors.jl
2+
3+
Shorthand constructor syntax for
4+
[RecursiveArrayTools.jl](https://github.com/SciML/RecursiveArrayTools.jl) types.
5+
6+
This subpackage provides `VA[...]` and `AP[...]` syntax for constructing
7+
`VectorOfArray` and `ArrayPartition` objects. It is separated from the main
8+
package because the `getindex(::Type, ...)` method definitions invalidate
9+
compiled specializations of `Base.getindex(::Type{T}, vals...)`, increasing
10+
load times for downstream packages that don't need the syntax.
11+
12+
## Installation
13+
14+
```julia
15+
using Pkg
16+
Pkg.add(url = "https://github.com/SciML/RecursiveArrayTools.jl",
17+
subdir = "lib/RecursiveArrayToolsShorthandConstructors")
18+
```
19+
20+
## Usage
21+
22+
```julia
23+
using RecursiveArrayTools
24+
using RecursiveArrayToolsShorthandConstructors
25+
26+
# VectorOfArray shorthand
27+
u = VA[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
28+
29+
# ArrayPartition shorthand
30+
x0, v0, a0 = rand(3, 3), rand(3, 3), rand(3, 3)
31+
u0 = AP[x0, v0, a0]
32+
33+
# Nesting works too
34+
nested = VA[
35+
fill(1, 2, 3),
36+
VA[3ones(3), zeros(3)],
37+
]
38+
```
39+
40+
Without this package, use the equivalent explicit constructors:
41+
42+
```julia
43+
u = VectorOfArray([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
44+
u0 = ArrayPartition(x0, v0, a0)
45+
```

0 commit comments

Comments
 (0)