Skip to content

Allow vector-like init for ArrayPartitions/VectorOfArrays #544

Description

@rokke-git

Is your feature request related to a problem? Please describe.

the function names ArrayPartition() and VectorOfArray() are quite long, and take up the majority of the space of small functions. For example,

f(y,p,t) = ArrayParition(f1(y),
                         f2(y),
                         f3(y))
ODEProblem(f, ArrayPartition(A, B, C), (0, 1)) |> solve

Describe the solution you’d like

It would be nice if we could use the vector-like initialization like with StaticArrays:

f(y,p,t) = AP[f1(y),
              f2(y),
              f3(y)]
ODEProblem(f, AP[A, B, C], (0, 1)) |> solve

Additional context

This is pretty easily implemented in a few lines:

struct AP end
struct VA end
Base.getindex(::Type{AP}, xs...) = ArrayPartition(xs...)
Base.getindex(::Type{VA}, xs...) = VectorOfArray(collect(xs))
export AP, VA

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions