Open lassepe opened 5 years ago
@jamgochiana By the way: Don't feel obligated to do all of this. These are just some hints as I really like the idea of this package. If it seriously bothers me when using this package, I'll just open a PR one day.
No, by all means, keep it coming this is great!
Regarding the use of Function
as a field type.
For the nonlinear models, what is the best way to define them such that the filtering algorithm are type stable?
Because right now calling model.f
or model.h
is not type stable since it depends on what model is.
Any suggestions? Are there other packages that use that kind of interface?
POMDPs uses function fields quite a lot (e.g. for FunctionPolicy
). Things should be type stable if you do:
struct Foo{F<:Function}
f::F
end
or am I getting your question wrong?
Fantastic, I forgot this worked for functions :)
If you want to maximize performance, having structs immutable is a good first step. However, to get even better performance, it should be avoided to have non-concrete fields. These things are sometimes quite subtle, e.g. this
https://github.com/sisl/GaussianFilters.jl/blob/bc24efe32d6c2c493d8458318150aef0ce40eca6/src/kf_classes.jl#L27
is a problem because
Symmetric
has two template parameters, e.g.:Therefore
Symmetric{a} where {a}
is not a concrete type and makes uses of the corresponding struct unnecessarily slow. A better thing to do here is to have a bounded type parameter, e.g.:Another instance of this problem is the use of
Function
as a field type, asFunction
is also an abstract type:https://github.com/sisl/GaussianFilters.jl/blob/bc24efe32d6c2c493d8458318150aef0ce40eca6/src/kf_classes.jl#L87