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

Use StaticArray for children #86

Open
MilesCranmer opened this issue Jun 27, 2024 · 0 comments
Open

Use StaticArray for children #86

MilesCranmer opened this issue Jun 27, 2024 · 0 comments

Comments

@MilesCranmer
Copy link
Member

I think the generalization to more than 2 children would be best attempted with StaticArrays.MArray. So you could have a field

struct Node{T,N}
    degree::UInt8
    ...
    _children::MVector{Node{T,N},N}
end

The beauty of this is you could still have undefined values (https://discourse.julialang.org/t/how-to-initialize-an-empty-staticarray/69942/11?u=milescranmer) and the max number of children would still be a compile time constant.

And calling children(node) could return a Vector according to the degree of the node. (Though we would still want to have special methods for each degree).

Similarly, for OperatorEnum, it could be a tuple of tuples up to the maximum arity.

@gca30 interested to hear your thoughts

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

No branches or pull requests

1 participant