Skip to content

Commit

Permalink
Elimite type parameters from abstract types and add fullbasis function
Browse files Browse the repository at this point in the history
  • Loading branch information
akirakyle committed Dec 5, 2024
1 parent f17ee1e commit bf5f454
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# News

## v0.4.0 - 2024-11-26

- Add `OperatorBasis` and `SuperOperatorBasis` abstract types along with corresponding `fullbasis` function to obtain these from instances of subtypes of `AbstractOperator` and `AbstractSuperOperator`.
- Change type parameters for `StateVector`, `AbstractKet` `AbstractBra` `AbstractOperator` `AbstractSuperOperator` to elimitate all type parameters.


## v0.3.6 - 2024-09-08

- Add `coherentstate`, `thermalstate`, `displace`, `squeeze`, `wigner`, previously from QuantumOptics.
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "QuantumInterface"
uuid = "5717a53b-5d69-4fa3-b976-0bf2f97ca1e5"
authors = ["QuantumInterface.jl contributors"]
version = "0.3.6"
version = "0.4.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
15 changes: 13 additions & 2 deletions src/QuantumInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,22 @@ module QuantumInterface
Return the basis of an object.
If it's ambiguous, e.g. if an operator has a different left and right basis,
an [`IncompatibleBases`](@ref) error is thrown.
If it's ambiguous, e.g. if an operator or superoperator has a different
left and right basis, an [`IncompatibleBases`](@ref) error is thrown.
"""
function basis end

"""
fullbasis(a)
Return the full basis of an object.
Returns subtype of `Basis` when a is a subtype of `StateVector`.
Returns a subtype of `OperatorBasis` a is a subtype of `AbstractOperator`.
Returns a subtype of `SuperOperatorBasis` when a is a subtype of `AbstractSuperOperator`.
"""
function fullbasis end

##
# Standard methods
##
Expand Down
10 changes: 5 additions & 5 deletions src/abstract_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ in respect to a certain basis. These coefficients are stored in the
`data` field and the basis is defined in the `basis`
field.
"""
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 StateVector end
abstract type AbstractKet <: StateVector end
abstract type AbstractBra <: StateVector end

"""
Abstract base class for all operators.
Expand All @@ -36,7 +36,7 @@ For fast time evolution also at least the function
implemented. Many other generic multiplication functions can be defined in
terms of this function and are provided automatically.
"""
abstract type AbstractOperator{BL,BR} end
abstract type AbstractOperator end

"""
Base class for all super operator classes.
Expand All @@ -52,4 +52,4 @@ A_{bl_1,bl_2} = S_{(bl_1,bl_2) ↔ (br_1,br_2)} B_{br_1,br_2}
A_{br_1,br_2} = B_{bl_1,bl_2} S_{(bl_1,bl_2) ↔ (br_1,br_2)}
```
"""
abstract type AbstractSuperOperator{B1,B2} end
abstract type AbstractSuperOperator end
4 changes: 2 additions & 2 deletions src/julia_linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ tr(x::AbstractOperator) = arithmetic_unary_error("Trace", x)
Norm of the given bra or ket state.
"""
norm(x::StateVector) = norm(x.data)
norm(x::StateVector) = norm(x.data) # FIXME issue #12

"""
normalize(x::StateVector)
Expand All @@ -33,7 +33,7 @@ normalize(x::StateVector) = x/norm(x)
In-place normalization of the given bra or ket so that `norm(x)` is one.
"""
normalize!(x::StateVector) = (normalize!(x.data); x)
normalize!(x::StateVector) = (normalize!(x.data); x) # FIXME issue #12

"""
normalize(op)
Expand Down

0 comments on commit bf5f454

Please sign in to comment.