Skip to content

Creating a new array with a different element type? #217

Closed
@ChrisRackauckas

Description

@ChrisRackauckas

Usually similar returns the same type, but for SArray it does not. Is there no solution for getting "the same array" with a new element type?

if typeof(A) <: StaticArray
  B = similar_type(A,T)
else
  B = similar(A,T)
end

That's the only solution I could come up with, and it requires separate codepaths every time an SArray is encounters and makes it tough to write generic codes. I am hoping there's a method I missed.

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