Skip to content

Commit 6f6a32c

Browse files
committed
Implement basis interface proposed in #40
1 parent 7683d2d commit 6f6a32c

File tree

11 files changed

+565
-242
lines changed

11 files changed

+565
-242
lines changed

src/QuantumInterface.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ function wigner end
8888
include("bases.jl")
8989
include("abstract_types.jl")
9090

91-
include("linalg.jl")
9291
include("tensor.jl")
9392
include("embed_permute.jl")
9493
include("expect_variance.jl")

src/abstract_types.jl

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,57 @@
11
"""
2-
Abstract base class for `Bra` and `Ket` states.
2+
Abstract type for all state vectors.
33
4-
The state vector class stores the coefficients of an abstract state
5-
in respect to a certain basis. These coefficients are stored in the
6-
`data` field and the basis is defined in the `basis`
7-
field.
4+
This type represents any abstract pure quantum state as given by an element of a
5+
Hilbert space with respect to a certain basis. To be compatible with methods
6+
defined in `QuantumInterface`, all subtypes must implement the `basis` method
7+
which should return a subtype of the abstract [`Basis`](@ref) type.
8+
9+
See also [`AbstractKet`](@ref) and [`AbstractBra`](@ref).
810
"""
9-
abstract type StateVector{B,T} end
10-
abstract type AbstractKet{B,T} <: StateVector{B,T} end
11-
abstract type AbstractBra{B,T} <: StateVector{B,T} end
11+
abstract type StateVector end
1212

1313
"""
14-
Abstract base class for all operators.
14+
Abstract type for `Ket` states.
1515
16-
All deriving operator classes have to define the fields
17-
`basis_l` and `basis_r` defining the left and right side bases.
16+
This subtype of [`StateVector`](@ref) is meant to represent `Ket` states which
17+
are related to their dual `Bra` by the conjugate transpose.
1818
19-
For fast time evolution also at least the function
20-
`mul!(result::Ket,op::AbstractOperator,x::Ket,alpha,beta)` should be
21-
implemented. Many other generic multiplication functions can be defined in
22-
terms of this function and are provided automatically.
19+
See also [`AbstractBra`](@ref).
2320
"""
24-
abstract type AbstractOperator{BL,BR} end
21+
abstract type AbstractKet <: StateVector end
22+
23+
"""
24+
Abstract type for `Bra` states.
25+
26+
This subtype of [`StateVector`](@ref) is meant to represent `Bra` states which
27+
are related to their dual `Ket` by the conjugate transpose.
2528
29+
See also [`AbstractBra`](@ref).
2630
"""
27-
Base class for all super operator classes.
31+
abstract type AbstractBra <: StateVector end
2832

29-
Super operators are bijective mappings from operators given in one specific
30-
basis to operators, possibly given in respect to another, different basis.
31-
To embed super operators in an algebraic framework they are defined with a
32-
left hand basis `basis_l` and a right hand basis `basis_r` where each of
33-
them again consists of a left and right hand basis.
34-
```math
35-
A_{bl_1,bl_2} = S_{(bl_1,bl_2) ↔ (br_1,br_2)} B_{br_1,br_2}
36-
\\\\
37-
A_{br_1,br_2} = B_{bl_1,bl_2} S_{(bl_1,bl_2) ↔ (br_1,br_2)}
38-
```
3933
"""
40-
abstract type AbstractSuperOperator{B1,B2} end
34+
Abstract type for all operators and super operators.
35+
36+
This type represents any abstract mixed quantum state given by a density
37+
operator (or superoperator) mapping between two Hilbert spaces. All subtypes
38+
must implement the [`basis_l`](@ref) and [`basis_r`](@ref) methods which return
39+
subtypes of [`Basis`](@ref) representing the left and right bases that the
40+
operator maps between. A subtype is considered compatible with multiplication by
41+
a subtype of [`AbstractBra`](@ref) defined in same left basis as the operator
42+
and a subtype of [`AbstractKet`](@ref) defined in the same right basis as the
43+
operator.
44+
45+
For fast time evolution also at least the function
46+
`mul!(result::Ket,op::AbstractOperator,x::Ket,alpha,beta)` should be
47+
implemented. Many other generic multiplication functions can be defined in terms
48+
of this function and are provided automatically.
49+
"""
50+
abstract type AbstractOperator end
4151

4252
function summary(stream::IO, x::AbstractOperator)
4353
print(stream, "$(typeof(x).name.name)(dim=$(length(x.basis_l))x$(length(x.basis_r)))\n")
44-
if samebases(x)
54+
if multiplicable(x,x)
4555
print(stream, " basis: ")
4656
show(stream, basis(x))
4757
else

0 commit comments

Comments
 (0)