JuliaAttic / QuBase.jl

A foundational library for quantum mechanics in Julia
Other
43 stars 6 forks source link

Add some shortcuts and type defines for Quantum Computing? #48

Open Roger-luo opened 8 years ago

Roger-luo commented 8 years ago

Will it be better to add some short cuts for quantum computing in QuBase.jl or just make it a single package? Cause I currently use them as a single dependency in QuComputStates.jl. But most of the types uses super-types in QuBase.jl

If it is, I would happy to create a PR to merge them into QuBase.jl. :-)

acroy commented 8 years ago

As I said, I think it is good to start with a package and if it turns out to be of general interest we can include it to QuBase.

In this case I am a bit puzzled, because I don't see the difference between ComputState and QuArray. Also note that stlzState is not a proper subtype of AbstractQuVector.

Roger-luo commented 8 years ago

yes, there is no big difference between ComputState and QuArray, besides the basis. I store the number of bits in the type definition as N

type ComputState{A<:AbstractVector,B<:AbstractFiniteBasis,T,N} <: AbstractQuVector{B,T}
    coeffs::A
    bases::B
end

Therefore, we are able not to store basis, when user do not need to specify the basis, which could save some memory

function rawbases{A,B,T,N}(states::ComputState{A,B,T,N})
      return comput_basis(N)
end

But I did not find a good way to implement another rawbases since its inputs stay the same. I wonder if you have any idea? I found QuBase.jl still store bases even user inputs a single vector. But memory costs could be one of the main concern when simulating large states in my case.

For stlzState, it's a representation for stabilizer states implemented by Aanronson in his chp.c, and I have not found a way converting normal quantum states to stabilizer states yet which may need us to classify the states. Therefore, I did not define any further overloads required by QuBase.jl.

Aanronson use this type originally in his implementation, as this is also a kind of subtype for quantum states, I include it in this package since it names QuComputStates...

acroy commented 8 years ago

So you want to have a basis that consists of a product of N qubits? Right now the memory footprint of FiniteBasis would be 8 N bytes. If you want to reduce this further you should really define a new basis type instead of a new array type. If I manage to find the time I can try to post an example.

For stlzState, it's a representation for stabilizer states

This might be true, but it is not a subtype of QuArray because it is lacking the necessary interface functions ... Depending on how you want to use it, it might be easier to not make it a subtype of QuArray, but provide methods for converting between the two (I guess any stlzState can be represented by a ComputState but not necessarily vice versa)? It's just a thought.