Closed gummif closed 9 years ago
This came up on julia-users once, and the "julian" way seems to be to use a symbol. See e.g. here. I would even write :periodic, rather than :per.
Types for these choices are definitely useful internally, so you can dispatch on them, but I see you have them already.
Btw - thanks for this work!
We use types in DSP.jl, since it helps with dispatching. You could add symbols or strings as "syntactic sugar", but in the end you'll want to call the methods with specific types anyways.
Right, thanks. These functions are just "syntactic sugar" for the equivalent, but maybe more complex
OrthoFilter{PerBoundary}("db2")
I think the suggestion to use
wavelet("db2"; transform=:filter, boundary=:periodic)
is good.
For Julia to be able to infer the type of wavelet you're constructing, you would need one of the following approaches:
wavelet
function where the type of the returned wavelet depends only on the types of positional arguments. (Julia cannot presently infer return types based on keyword arguments.) Your type-based approach above looks like it would work if you made transform
and boundary
optional positional arguments.I'm not sure exactly what performance hit you'll get if the wavelet type is not inferred. If methods on all wavelet types have the same return types and there are not too many, you'll get a slowdown in method dispatch but not much else. If methods that have different return types for different wavelets, or if there are too many methods of the same function, you may get a multiple order of magnitude slowdown if you try to e.g. loop over the result of dwt
in the same function that calls it.
Thanks for these comments. See #16 .
For construction of wavelet transform types, the currect API is
Any thoughts whether using symbols
or types
might be better, or more elegant?