HybridArrays.jl
HybridArrays.jl copied to clipboard
Easier syntax for constructor
Just like StaticArrays.jl has the nice SA[...] constructor, it should be possible to implement some easier-to-type HybridArray constructors. My suggestions would be a function HybridArray(n1,n2,...) which returns the type given by the arguments: either static if argument is an Integer, or dynamic otherwise (with another suggestion being to use either - or : as a shortcut for dynamic dimension). For example, HybridArray(2,:) would be a simpler alias for HybridArray{Tuple{2,StaticArrays.Dynamic()}}. (this is probably quite simple to code).
Another possibility which comes to mind would be to use cartesian product, so that, say, Vector*SVector{3} is computed as HybridArray{Tuple{StaticArrays.Dynamic(),3}}.
HybridArray(n1,n2,...) looks quite nice, my only issue is that is would be quite unusual re-use of a type constructor. Maybe hybrid_array(n1,n2,...)(wrapped_array) would be better?
This would be a welcome improvement. I suggest using : instead of -, since it already seems analogous to how : is used, for example in
reshape(A, 4, :)
I don't think - or ... have those connotations, or are commonly used like that.
As for the constructor syntax, is
HybridMatrix{2, :}(A)
possible? This is quite similar to StaticArrays: SMatrix{2, 5}(A).
IIRC there was some problem with using colon there but I may be wrong. I'll try that soon.
OK, now I see what the problem is: Size struct in StaticArrays.jl only accepts integers and Dynamic(), and thus I'd have to get rid of every single usage of that struct in HybridArrays.jl. That should be possible but quite a bit of work.