Operations on numerical type parameters

I’m sorry if this is a stupid question, but I could not find it in the docs (nor solve it myself). I have a type A parametrized with a number N. How can I make this work:

struct A{N}    
    x::Array{Float64, N-1}
    y::Array{Float64, N}

The problem is of course the N-1. Thanks in advance!

You can’t really make this work currently, but what you can do is something like this:

struct A{M,N}
    x::Array{Float64, M}
    y::Array{Float64, N}
    # inner constructor that checks that `M == N-1`
1 Like

You can do it with my forked version of ComputedFieldTypes, for which I have a pull-request updating 1.0

An example of it in action is Grassmann.jl I hope it gets registered soon

1 Like

This is a feature we could add eventually; see https://github.com/JuliaLang/julia/issues/18466.


Thanks all for the useful replies!