I am trying to create a type representing crystallographic space groups in arbitrary dimensions. The group operations are stored as static matrices of integers (plus eventually a static rational vector for non-symmorphic groups, but this part is not done yet). Here’s the code:
struct SpaceGroup{N, N2}
e2i::Dict{SMatrix{N,N,Int,N2},Int}
i2e::Vector{SMatrix{N,N,Int,N2}}
function SpaceGroup{N,N2}(g::Vector{SMatrix{N,N,Int,N2}}) where {N,N2}
sg=new(Dict{SMatrix{N,N,Int,N2},Int}(), Vector{SMatrix{N,N,Int,N2}}())
# More initialization here...
return sg
end
end
The inner constructor takes a vector of static matrices (group generators), with explicitely supplied type parameters. The question is: is it possible to infer these parameters from the type of the constructor argument, instead of passing them explicitely as in the snippet below?:
g=[@SMatrix [0 1 0 0; 0 0 1 0; 0 0 0 1; -1 0 0 0]]
sg=SpaceGroup{4,16}(g) # The type of g fixes the values of N and N2, does it?
Thanks.