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.promote_eltypeFunction
promote_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.restructureFunction
restructure(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.safevecFunction
safevec(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.