Julia's Extended Array Conversions Interface
The following ArrayInterface functions extend Julia's Array interface for how arrays can be converted to different forms.
Conversion Functions
ArrayInterface.aos_to_soa
— Functionaos_to_soa(x)
Converts an array of structs formulation to a struct of array.
ArrayInterface.promote_eltype
— Functionpromote_eltype(::Type{<:AbstractArray{T,N}}, ::Type{T2})
Computes the type of the AbstractArray
that results from the element type changing to promote_type(T,T2)
.
Note that no generic fallback is given.
ArrayInterface.restructure
— Functionrestructure(x,y)
Restructures the object y
into a shape of x
, keeping its values intact. For simple objects like an Array
, this simply amounts to a reshape. However, for more complex objects such as an ArrayPartition
, not all of the structural information is adequately contained in the type for standard tools to work. In these cases, restructure
gives a way to convert for example an Array
into a matching ArrayPartition
.
ArrayInterface.safevec
— Functionsafevec(v)
It is a form of vec
which is safe for all values in vector spaces, i.e., if it is already a vector, like an AbstractVector or Number, it will return said AbstractVector or Number.