-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
specific getindex for single vs. slice #8
Conversation
Signed-off-by: Rachel Kurchin <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if we focus our attention on a single index, there is room for variation. For example, for lattices, the index might be of type CartesianIndex
; if we want to add some kind of grouping, we can have a composite index (i, ig)
, where ig
is the group index, while i
is an index inside the group.
So, may be we should not specify the type of single index:
Base.getindex(::AbstractSystem{AT}, I)::AT = error("Implement me").
There is another problem: we use AT<:AbstractParticle
as the type parameter for AbstractSystem
, which kind of favours array of structs implementation. May be we should instead use ET<:AbstractElement
as the type parameter for AbstractSystem
and define AbstractParticle
as
abstract type AbstractParticle{ET<:AbstractElement} end
Fair point. So what's the cleanest way to distinguish between the two return types, i.e. when a new |
Looks like the ranges are normally subtypes of
|
Should we also make |
I think saying that this version of |
Signed-off-by: Rachel Kurchin <[email protected]>
I wonder if not specifying the type of the |
Yeah, that was sort of what I was thinking as well... 🤔 |
It is true, that the linear index can be converted to other types of indices, but it may take time. For example, |
Linear indexing is addressed in #23, closing this for now and opening an issue to potentially support Cartesian indexing in the future. |
Thought it might make sense to explicitly include both of these options, per our discussion last Friday. I think we should also split out the sample implementations and rename the current
implementation_simple
toimplementation_simple_aos
or something like that and then add an analogous SoA version, which would need to explicitly dispatch these separately.Not sure this actually makes sense to merge as-is though, since currently I think it would also break the existing
implementation_simple
, and we may want to have things set up for that case to be able to "just work." If so, I think we'd just need to define the slice dispatch to be the standard Julia behavior.So yeah, this is more to start a conversation I suppose? But getting it to a non-draft state should be pretty simple once we decide what we want the behavior to be.