Skip to content

Defining a method for deleteat! #55

@vlepori

Description

@vlepori

It would be nice to have a convenience function to remove any column/slice from the last dimension of an ElasticArray. An implementation that currently only works for an ElasticMatrix could look like this.

function Base.deleteat!(A::ElasticArray{T,N}, at::Union{UnitRange{I}, I}) where {T,N,I <: Integer}
    idx = LinearIndices(A)[:, at]
    deleteat!(A.data, idx)
    return A
end

u = ElasticArray{Float64}([0.0 1.0 2.0; 0.0 1.0 2.0; 0.0 1.0 2.0])

#3×3 ElasticMatrix{Float64, Vector{Float64}}:
 #0.0  1.0  2.0
 #0.0  1.0  2.0
 #0.0  1.0  2.0

deleteat!(u, 2:3)

#3×1 ElasticMatrix{Float64, Vector{Float64}}:
#0.0
#0.0
#0.0

Do you think this would make sense? Is there an easy equivalent way to do the same already?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions