The Polynomial type from the Polynomials package has a symbol in its type signature that I don’t understand.
julia> typeof(Polynomial([1,2]))
Polynomial{Int64, :x}
julia> typeof(Polynomial([1,2], :s))
Polynomial{Int64, :s}
I am trying to use the Polynomial type inside my composite type, but it seems like I need to define the polynomial symbol ahead of time. Why? I wouldn’t think that changing the polynomial symbol would affect memory allocation for the compiler, so can I get away with leaving it abstract somehow? How and why would you define a type based on symbols instead of concrete types?
These error:
struct MyType
polys::Vector{Polynomial}
end
struct MyType{T<:Number}
polys::Vector{Polynomial{T, Symbol}}
end
This errors if the symbol changes.
struct MyType{T<:Number}
polys::Vector{Polynomial{T, :s}}
end
This works, but I think will be slow since it is an abstract type:
struct MyType
polys::Vector{<:Polynomial}
end
julia> isconcretetype(Vector{Polynomial{Int, :x}})
true
julia> isconcretetype(Vector{<:Polynomial})
false