Skip to content
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

make this work for FixedSizeArrays and scalars [WIP] #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

SimonDanisch
Copy link
Member

I need this a lot of times and made some less generic types for my own usage in GLVisualize. (Allowing particles, colors, etc, to come in different memory layouts and still being able to calculate e.g. boundingboxes for them).
I'm not sure if this is in the broader interest, especially with scalars mixed in. This could easily go into FixedSizeArrays as well,
I plan to support even more complex constructs like, StructOfArrays(::Vec3f0, Vector{Vec2f0}, Vector{Float32}), or StructOfArrays(::Vec3f0, SomeFloatIterator, Vector{Float32}, Vector{Float32}).
WIP because this is the initial sketch to make it work and I'm not too sure about the direction yet ;)

@SimonDanisch
Copy link
Member Author

Would you prefer this to stay in FixedSizeArrays, or did you not have time to review yet?
I can definitely leave it somewhere else until it's a little more thought out!

Best,
Simon

@simonster
Copy link
Collaborator

I'm okay with a constructor that takes a type and some AbstractArrays and constructs a StructOfArrays. I'm not as big of a fan of integrating the scalar thing here, although with the aforementioned constructor you could pass a type like ScalarRepeat (but with a size and <: AbstractArray) and it ought to work.

As far as the FixedSizeArray thing goes, do you need the special case? Couldn't you nest two StructsOfArrays, e.g.:

immutable TupleStruct
       x::Tuple{Int,Int}
end

julia> StructOfArrays{TupleStruct,1,Tuple{StructOfArrays{Tuple{Int,Int},1,Tuple{Vector{Int},Vector{Int}}}}}((StructOfArrays{Tuple{Int,Int},1,Tuple{Vector{Int},Vector{Int}}}(([1:2;], [2:3;])),))
2-element StructsOfArrays.StructOfArrays{TupleStruct,1,Tuple{StructsOfArrays.StructOfArrays{Tuple{Int64,Int64},1,Tuple{Array{Int64,1},Array{Int64,1}}}}}:
 TupleStruct((1,2))
 TupleStruct((2,3))

Of course with the new constructor this would be less verbose.

@SimonDanisch
Copy link
Member Author

What I pushed now is not the smartest solution, but it enables my use cases...
It implements that you can use arbitrary structs and arbitrary abstract arrays, and it will work as long as the flattened element types match.
Setindex is not implemented yet, as I wanted to know your opinion first.
I want to be able to mix arrays which provide more than one field with arrays for only one field.
But maybe I could combine what you propose and improve my current solution with nesting StructsOfArrays...

Best,
Simon

@bjarthur
Copy link

is this PR relevant now that FixedSizeArrays has been deprecated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants