You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-10Lines changed: 15 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,10 @@
6
6
7
7
Arrays with both statically and dynamically sized axes in Julia. This is a convenient replacement for the commonly used `Arrays`s of `SArray`s which are fast but not easy to mutate. `HybridArray` makes this easier: any `AbstractArray` can be wrapped in a structure that specifies which axes are statically sized. Based on this information code for `getindex`, `setindex!` and broadcasting is (or should soon be, not all cases have been optimized yet) as efficient as for `Arrays`s of `SArray`s while mutation of single elements is possible, as well as other operations on the wrapped array.
8
8
9
-
There are also statically sized views for fast and convenient mutation of `HybridArray`s.
9
+
Views are statically sized where possible for fast and convenient mutation of `HybridArray`s.
10
10
11
11
Example:
12
+
12
13
```julia
13
14
julia>using HybridArrays, StaticArrays
14
15
@@ -19,26 +20,30 @@ julia> A[1,1,10] = 12
19
20
20
21
julia> A[:,:,10]
21
22
2×2 SArray{Tuple{2,2},Float64,2,4} with indices SOneTo(2)×SOneTo(2):
22
-
12.0-0.264816
23
-
0.615372-1.00042
23
+
12.0-1.39943
24
+
-0.450564-0.140096
24
25
25
26
julia> A[2,:,:]
26
27
2×100 HybridArray{Tuple{2,StaticArrays.Dynamic()},Float64,2,2,Array{Float64,2}} with indices SOneTo(2)×Base.OneTo(100):
2×2HybridArrays.SSubArray{Tuple{2,2},Float64,2,HybridArray{Tuple{2,2,StaticArrays.Dynamic()},Float64,3,3,Array{Float64,3}},Tuple{Base.Slice{SOneTo{2}},Base.Slice{SOneTo{2}},Int64},false} with indices SOneTo(2)×SOneTo(2):
32
-
24.0-0.529633
33
-
1.23074-2.00083
32
+
2×2SizedArray{Tuple{2,2},Float64,2,2,SubArray{Float64,2,HybridArray{Tuple{2,2,StaticArrays.Dynamic()},Float64,3,3,Array{Float64,3}},Tuple{Base.Slice{SOneTo{2}},Base.Slice{SOneTo{2}},Int64},true}} with indices SOneTo(2)×SOneTo(2):
33
+
24.0-2.79886
34
+
-0.901128-0.280193
34
35
35
36
julia> A[:,:,10] =SMatrix{2,2}(1:4)
36
37
2×2 SArray{Tuple{2,2},Int64,2,4} with indices SOneTo(2)×SOneTo(2):
37
38
13
38
39
24
39
40
```
40
41
42
+
`HybridArrays.jl` is implements (optionally loaded) [`ArrayInterface`](https://github.com/SciML/ArrayInterface.jl/) methods for compatibility with [`LoopVectorization`](https://github.com/chriselrod/LoopVectorization.jl).
43
+
41
44
Tips:
42
-
- If possible, statically known dimensions should come first. This way the most common access pattern where indices of dynamic dimensions are specified will be faster.
43
45
44
-
Code of this package is based on the code of the [`StaticArrays`](https://github.com/JuliaArrays/StaticArrays.jl) package and the `SubArray` type from Julia base.
46
+
- If possible, statically known dimensions should come first. This way the most common access pattern where indices of dynamic dimensions are specified will be faster.
47
+
- Since version 0.4 of `HybridArrays`, Julia 1.5 or newer is required for best performance (most importantly the memory layout changes). It still works correctly on earlier versions of Julia but versions from the 0.3.x line may be faster in some cases on Julia <=1.4.
48
+
49
+
Code of this package is based on the code of the [`StaticArrays`](https://github.com/JuliaArrays/StaticArrays.jl).
0 commit comments