FieldDimArrays
Documentation for FieldDimArrays.
FieldDimArrays.ComponentFieldDimArrays.FieldDimArrayFieldDimArrays.FieldDimArrayStyleFieldDimArrays.RegroupFieldDimArrays.componentnamesFieldDimArrays.componentsFieldDimArrays.componenttypeFieldDimArrays.componentwiseFieldDimArrays.elementviewFieldDimArrays.fieldshapeFieldDimArrays.fieldviewFieldDimArrays.fromcomponentsFieldDimArrays.isfieldelementFieldDimArrays.ncomponentsFieldDimArrays.withcomponenttype
FieldDimArrays.Component — Type
Component{K}(f)Calls f and returns component K of its result.
FieldDimArrays.FieldDimArray — Type
FieldDimArray{T}(parent)
FieldDimArray{T, N}(parent)An AbstractArray{T, N} whose elements are read from and written to the dense array parent: the leading N dims of parent index the elements and its trailing dims index their components, in column-major order. Every component of T must have type eltype(parent); a UnionAll T is completed with that type (Point over a Float64 parent becomes Point{Float64}).
The trailing dims of parent are either fieldshape(T) (one dim of length ncomponents(T) for a struct, (2, 2) for a 2×2 static matrix) or a single dim of length ncomponents(T). FieldDimArray{T}(parent) uses fieldshape(T); giving N selects the layout from ndims(parent) - N.
parent(a) returns the dense storage, fieldview and getproperty return the slab of one component as a view.
Examples
julia> struct Point{T}
x::T
y::T
end
julia> a = FieldDimArray{Point}([1.0 3.0; 2.0 4.0]);
julia> a[2]
Point{Float64}(2.0, 4.0)
julia> a.y
2-element view(::Matrix{Float64}, :, 2) with eltype Float64:
3.0
4.0FieldDimArrays.FieldDimArrayStyle — Type
FieldDimArrayStyle{N}The broadcast style of an N-dim FieldDimArray. It wins over DefaultArrayStyle. An out-of-place broadcast whose result element type E satisfies isfieldelement(E) returns a FieldDimArray{E} over new storage allocated like the parent of the first FieldDimArray argument; other results are allocated with similar of that parent.
FieldDimArrays.Regroup — Type
Regroup{L}(f)Calls f with its positional arguments regrouped by L, a tuple holding, for each argument of f, either Val(T) for an element type T (the next ncomponents(T) arguments are the components of one T) or Val(nothing) (one argument).
FieldDimArrays.componentnames — Method
componentnames(::Type{T}) -> Tuple{Vararg{Symbol}}The names under which the components of T are accessible with getproperty on a FieldDimArray{T}. For a struct these are its field names.
FieldDimArrays.components — Method
components(x) -> NTupleThe components of x in order, the inverse of fromcomponents. For a struct these are its fields.
FieldDimArrays.componenttype — Method
componenttype(::Type{T}) -> TypeThe type shared by every component of an element of type T. For a struct this is the type of its fields, which must all be the same.
FieldDimArrays.componentwise — Method
componentwise(parent::AbstractArray) -> BoolWhether broadcasts involving FieldDimArrays over parents like parent run one broadcast per component over the component slabs instead of one pass over the elements. False by default; array types that cannot index elements one at a time (such as traced arrays) return true.
FieldDimArrays.elementview — Method
elementview(::Type{T}, parent::AbstractArray)
elementview(a::AbstractArray)The array whose elements are the logical elements of a container. elementview(T, parent) is FieldDimArray{T}(parent), or parent itself when eltype(parent) <: T. An array is its own element view. Containers that wrap dense storage add a method returning the array of their elements.
FieldDimArrays.fieldshape — Method
fieldshape(::Type{T}) -> NTuple{L, Int}The sizes of the trailing parent dims that hold the components of an element of type T by default, in column-major component order. Their product is ncomponents(T). For a struct this is (ncomponents(T),); for a static array it is its size.
FieldDimArrays.fieldview — Method
fieldview(a::FieldDimArray, k::Integer)
fieldview(a::FieldDimArray, i::Integer, j::Integer, ...)
fieldview(a::FieldDimArray, name::Symbol)The values of one component of every element of a, as a view of parent(a). The component is given by its position k in column-major order, by its indices into the trailing dims of parent(a), or by its name (see propertynames(a)); a.name is fieldview(a, :name).
FieldDimArrays.fromcomponents — Method
fromcomponents(::Type{T}, c::NTuple) -> TBuild an element of type T from its components in order. For a struct this calls T(c...).
FieldDimArrays.isfieldelement — Method
isfieldelement(::Type{T}) -> BoolWhether results of type T produced by broadcasting over a FieldDimArray are stored as a new FieldDimArray{T} over dense storage. True for concrete immutable structs whose fields all have one type, except Numbers, Tuples and NamedTuples, which are stored as plain arrays.
FieldDimArrays.ncomponents — Method
ncomponents(::Type{T}) -> IntThe number of components of an element of type T. For a struct this is its number of fields.
FieldDimArrays.withcomponenttype — Method
withcomponenttype(::Type{T}, ::Type{S}) -> TypeThe concrete element type of the same kind as T whose components have type S. T may be a UnionAll, as in withcomponenttype(Point, Float64) == Point{Float64}. For a struct this is W{S}, where W is the type T without its parameters, and it throws an ArgumentError when that type does not have components of type S.