Oh my god, thank you, of course. I assume there is no way to define Some_Struct{n} in such a way that matrix is always a SMatrix{n,n,Float64,n*n}? I just need to add a second type parameter and propagate that up through any structures that include this one?
Depending on what you want to do, it might be possible to make the struct a bit more convenient for your purposes. For example, defining
using StaticArrays
struct SomeStruct{N, T<:SMatrix{N,N,Float64}}
matrix::T
end
allows you to do the following:
a = @SMatrix rand(3,3)
b = @SMatrix rand(4,4)
c = @SMatrix rand(4,3)
sa = SomeStruct(a) # Works fine
sb = SomeStruct(b) # Works fine
sc = SomeStruct(c) # Errors
This may or may not be easier to propagate up your structures depending on your use case.