Helpers

Note

Julia 1.7 provides findmin, argmin, findmax, argmax for generators.

BaseUtilities.decompose_vectypeFunction
N, T = decompose_vectype(v)

Get eltype and length from v::AbstractVector. The intended use is decomposing parameters of SVector{N,T} (at no cost).

source
BaseUtilities.filledFunction
x = SVector(...)
y = filled(typeof(x), [y1, y2, ...], fill=yend)
y = filled(x, [y1, y2, ...], fill=yend)

Construct an SVector{T, N} as given by typeof(x) with components (y1, y2, ..., yend, ..., yend), i.e., set the first components and "fills" to match length N.

source
BaseUtilities.struct_to_dictMethod
d = struct_to_dict(s)

Convert struct type (or named tuple) to Dict.

One use case is testing implementations of Base.copy for a new struct: There is a generic equal comparison for Dict, and we can easily check that no fields where missed.

source