Hello,
I’m developing QuantumToolbox.jl for simulating quantum systems in Julia. Everything is based on the QuantumObject constructor, which is currently defined as follows
struct QuantumObject{MT<:AbstractArray,ObjType<:QuantumObjectType} <: AbstractQuantumObject
    data::MT
    type::ObjType
    dims::Vector{Int}
end
Where data is either a matrix or a vector, type tells you what kind of quantum object we are dealing with (Operator, Ket state, ecc…), and dims tells you the space dimension of each subsystem (e.g., [2,2] if I have two qubits).
I was wondering if using dims as a NamedTuple{N,Int} instead of a Vector would be better. This object would include less then 20 subsystems at most (so a maximum length of 20).
Indeed, yesterday I noticed that I have some type instabilities in the ptrace function. Basically, it is related to the reshape(data, dims), which reshapes data depending on dims. This causes type instabilities because the reshaped array is unknown (Array{ComplexF64, N} where N).
Now, I was trying to change dims to NTuple{N,Int}. My first basic question is if this would lead to recompilation of the codes any time the QuantumObject changes its dimensions. Is my case suitable to use NTuple instead of Vector? The functions using dims perform very basic operations like vcat, +, -, repeat and a few others.
During this change I’m facing several test error for both code quality and implementation, which I’m fixing one by one. So that’s why I’m asking if it worth it to make such a significant change.
Thanks.