-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lack of API for checking left and right bases #26
Comments
As part of qojulia/QuantumOpticsBase.jl#115 and qojulia/QuantumOpticsBase.jl#177 I've been dealing a lot with the choices made around bases. Here's some thoughts based on issues I've run into with the current interface. First the current abstract type interface for the quantum primitives looks like: abstract type Basis end
function basis end
abstract type StateVector{B,T} end
abstract type AbstractKet{B,T} <: StateVector{B,T} end
abstract type AbstractBra{B,T} <: StateVector{B,T} end
abstract type AbstractOperator{BL,BR} end
abstract type AbstractSuperOperator{B1,B2} end It's a little strange to me to have only the abstract type So I think a potentially better abstract interface would probably look like this: abstract type Basis end
abstract type OperatorBasis{BL<:Basis,BR<:Basis} end
abstract type SuperOperatorBasis{BL<:OperatorBasis,BR<:OperatorBasis} end
function basis end
function basis_l end
function basis_r end
abstract type StateVector{B<:Basis,T} end
abstract type AbstractKet{B,T} <: StateVector{B,T} end
abstract type AbstractBra{B,T} <: StateVector{B,T} end
abstract type AbstractOperator{B<:OperatorBasis,T} end
abstract type AbstractSuperOperator{B<:SuperOperatorBasis, T} end Thus every quantum object must explicitly carry the appropriate number of bases. This fixes the current situation with AbstractSuperOperator where in QuantumOpticsBase I realize this would be a breaking change, but I'm willing to go through the work to implement it or anything else which improves the current situation, especially since it is very relevant for my ongoing work on the Choi and and Kraus superoperator representations. |
ping @Krastanov! I'm done with the code and tests in qojulia/QuantumOpticsBase.jl#177 and just have all the documentation tasks remaining. I would prefer to address this issue though before doing all the documentation as I think it would affect the documentation for those PRs. |
Apologies for the slow response. Your reminder in the other issue is what put this back on my radar. I think I feel favorably towards this. I am wondering whether we can make it less breaking.
|
Responding to each point you raise:
To summarize, here's a possible abstract interface with these suggestions: abstract type Basis end
abstract type StateVector{B<:Basis} end
abstract type AbstractKet{B} <: StateVector{B} end
abstract type AbstractBra{B} <: StateVector{B} end
abstract type AbstractOperator{Tuple{B<:Basis, B<:Basis}} end
abstract type AbstractSuperOperator{Tuple{Tuple{B<:Basis, B<:Basis}, Tuple{B<:Basis, B<:Basis}}} end
# non-breaking keeping same semantics of throwing error if basis_l != basis_r
function basis end
# returns B where B<:Basis for StateVector, AbstractKet, AbstractBra,
# returns Tuple{B,B} where B<:Basis for AbstractOperator
# returns Tuple{Tuple{B,B}, Tuple{B,B}} where B<:Basis for AbstractSuperOperator
function fullbasis end |
On the second point, it seems I don't know how to correctly define abstract subtypes of Then without tuples, the proposed abstract types look like abstract type Basis end
abstract type OperatorBasis{BL<:Basis,BR<:Basis} end
abstract type SuperOperatorBasis{BL<:OperatorBasis,BR<:OperatorBasis} end
abstract type StateVector{B<:Basis} end
abstract type AbstractKet{B} <: StateVector{B} end
abstract type AbstractBra{B} <: StateVector{B} end
abstract type AbstractOperator{B<:OperatorBasis} end
abstract type AbstractSuperOperator{B<:SuperOperatorBasis} end
# non-breaking keeping same semantics of throwing error if basis_l != basis_r
function basis end
# returns B where B<:Basis for StateVector, AbstractKet, AbstractBra,
# returns B where B<:OperatorBasis for AbstractOperator
# returns B where B<:SuperOperatorBasis for AbstractSuperOperator
function fullbasis end |
Just one more concern here (I think I agree with everything else). Concerning something like AbstractKet vs Ket and AbstractOperator vs DataOperator vs Operator. Currently we have
and currently we have
So if I am getting your suggestion right, you want to skip the equivalent of I am fine with that. I guess my first sentence was wrong, this is not a concern, just wanted to make sure we are on the same page. I am strongly in favor of this. It will also be a good excuse to release QuantumOpticsBase v1 (and to start keeping a CHANGELOG.md like in QuantumSymbolics). If you make these changes I will be championing them in front of the other maintainers (pinging @amilsted , @ChristophHotter , @david-pl ) @amilsted , @ChristophHotter , @david-pl -- the summary is in this current comment and in the previous comments -- all earlier comments are a bit outdated. This is also technically non-breaking -- changes to type parameters of unexported abstract types is not public API. |
Yes exactly that, I was mainly motivated by making the abstract type signatures for I'll definitely have issues #27 and #25 in mind as I work on this! |
Most of the user-facing basis-checking API (like using
basis
to get the basis in which an operator works) is convenient only for square matrices. If we have different left and right bases, one needs to use the.basis_r
and.basis_l
fields, which does not compose well with anything outside of the QuantumOptics package (e.g. QuantumSymbolics and QuantumClifford do not have such fields in their types).We need something like
basis_r
andbasis_l
functions.And we need to be careful what such functions do to superoperators.
The text was updated successfully, but these errors were encountered: