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

Easier syntax for constructor #37

Open
plut opened this issue Jan 12, 2021 · 4 comments
Open

Easier syntax for constructor #37

plut opened this issue Jan 12, 2021 · 4 comments

Comments

@plut
Copy link

plut commented Jan 12, 2021

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}}.

@mateuszbaran
Copy link
Collaborator

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?

@DNF2
Copy link

DNF2 commented Mar 24, 2021

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).

@mateuszbaran
Copy link
Collaborator

IIRC there was some problem with using colon there but I may be wrong. I'll try that soon.

@mateuszbaran
Copy link
Collaborator

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.

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

3 participants