A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/JuliaArrays/HybridArrays.jl below:

JuliaArrays/HybridArrays.jl: Arrays with both statically and dynamically sized axes in Julia

Arrays with both statically and dynamically sized axes in Julia. This is a convenient replacement for the commonly used Arrayss of SArrays 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 Arrayss of SArrays while mutation of single elements is possible, as well as other operations on the wrapped array.

Views are statically sized where possible for fast and convenient mutation of HybridArrays.

Example:

julia> using HybridArrays, StaticArrays

julia> A = HybridArray{Tuple{2,2,StaticArrays.Dynamic()}}(randn(2,2,100));

julia> A[1,1,10] = 12
12

julia> A[:,:,10]
2×2 SArray{Tuple{2,2},Float64,2,4} with indices SOneTo(2)×SOneTo(2):
 12.0       -1.39943
 -0.450564  -0.140096

julia> A[2,:,:]
2×100 HybridArray{Tuple{2,StaticArrays.Dynamic()},Float64,2,2,Array{Float64,2}} with indices SOneTo(2)×Base.OneTo(100):
 -0.262977  1.40715  -0.110194      -1.67315    2.30679   0.931161
 -0.432229  3.04082  -0.00971933     -0.905037  -0.446818  0.777833

julia> A[:,:,10] .*= 2
2×2 SizedArray{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):
 24.0       -2.79886
 -0.901128  -0.280193

julia> A[:,:,10] = SMatrix{2,2}(1:4)
2×2 SArray{Tuple{2,2},Int64,2,4} with indices SOneTo(2)×SOneTo(2):
 1  3
 2  4

HybridArrays.jl is implements (optionally loaded) ArrayInterface methods for compatibility with LoopVectorization.

Tips:

Code of this package is based on the code of the StaticArrays.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4