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
Defines the core PtrArray type so that some libraries can make use of it internally without the need for circular dependencies.
StrideArrays extends this type with many methods and functionality. It is
recommended you depend on and use StrideArrays instead.
Example initialization:
julia>using StrideArraysCore
julia> A =StrideArray(undef, 2, 5) # `Float64` is default eltype2×5 StrideArray{Tuple{Int64, Int64}, (true, true), Float64, 2, 1, 0, (1, 2), Tuple{StaticInt{8}, Int64}, Tuple{StaticInt{1}, StaticInt{1}}, Vector{Float64}}:1.5e-323-2.0092e-2374.94e-3211.0e-3221.6e-3221.6e-3224.94e-3221.235e-3211.5e-3232.0e-323
julia> B =StrideArray{Float32}(zero, 2, 5) # can specify initialization function; function must have 1-arg method accepting eltype as argument2×5 StrideArray{Tuple{Int64, Int64}, (true, true), Float32, 2, 1, 0, (1, 2), Tuple{StaticInt{4}, Int64}, Tuple{StaticInt{1}, StaticInt{1}}, Matrix{Float32}}:0.00.00.00.00.00.00.00.00.00.0
julia> C =StrideArray{Float32}(one, static(2), 5) # sizes may optionally be static2×5 StrideArray{Tuple{StaticInt{2}, Int64}, (true, true), Float32, 2, 1, 0, (1, 2), Tuple{StaticInt{4}, StaticInt{8}}, Tuple{StaticInt{1}, StaticInt{1}}, Vector{Float32}} with indices 1:1:2×Base.OneTo(5):1.01.01.01.01.01.01.01.01.01.0
julia> D =StrideArray{Float32}(one, static(2), static(5)) # all sizes being static will allow the compiler to elide the allocation if the array does not escape.2×5 StrideArraysCore.StaticStrideArray{Tuple{StaticInt{2}, StaticInt{5}}, (true, true), Float32, 2, 1, 0, (1, 2), Tuple{StaticInt{4}, StaticInt{8}}, Tuple{StaticInt{1}, StaticInt{1}}, 10} with indices 1:1:2×1:1:5:1.01.01.01.01.01.01.01.01.01.0
julia>using StrideArraysCore, BenchmarkTools
julia>@inlinefunctionalloctest()
D =StrideArray(one, static(2), static(5))
s =0.0for i ineachindex(D)
s += D[i]
end
s
end
alloctest (generic function with 1 method)
julia>@btimealloctest()
1.214 ns (0 allocations:0 bytes)
10.0
julia>@code_llvm debuginfo=:nonealloctest() # compiler compiled-away function
define double @julia_alloctest_1199() #0 {
L67.9:
ret double 1.000000e+01
}
About
The core AbstractStrideArray type, separated from StrideArrays.jl to avoid circular dependencies.