JuliaArrays / JuliaArrays/StructArrays.jl

Allow different type for LazyRow index

Open
#151 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
402
Forks
49
PR merge metrics
No merged PRs in 30d

Description

Having the possibility to have a different type for the LazyRow index other than I

struct LazyRow{T, N, C, Ic, Ii}
    columns::StructArray{T, N, C, Ic} # a `Columns` object
    index::Ii
end

allows me to define a StructArray of points and a StructArray of triangles, with indexes being of type StaticVectors (a triangle always contains 3 points):

struct Point{T}
    position::SVector{3,T}
    force::SVector{3,T}
end

struct Triangle{Tp}
    points::Tp
end

points = StructArray([Point{Float64}(rand(3), zeros(3)) for _ in 1:10])

tris = StructArray([Triangle(LazyRow(points, @SVector [rand(1:10), rand(1:10), rand(1:10)])) for _ in 1:5])

I can now update the point forces in the triangles this way, which is really helpful in my case:

for t in tris
    pos = t.points.position
    f1 = sum.(pos)
    f2 = tan.(f1)
    f3 = sin.(f1)
    f = Vec3(f1, f2, f3)
    t.points.force += f
end

Does that make sense? Would that make some thing break somewhere?

Thanks

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the LazyRow definition and tracing how its index type is used in construction, indexing, and mutation. Check whether the proposed StaticVector index works without changing existing LazyRow behavior; done means distinct index types are supported and the point/triangle example works without regressions.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.