Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# News

## v0.4.0 - 2025-04-22

This version implements the RFC in #40 without deprecating anything. Future versions will first add deprecation warnings before removing any existing interfaces.

- Eliminate all type parameters from `StateVector`, `AbstractKet`, `AbstractBra`, `AbstractOperator`, and `AbstractSuperOperator`.
- Implement new basis checking interface consisting of `multiplicable`, `addible`, `check_multiplicable`, `check_addible`, and `@compatiblebases`.
- Add `basis_l` and `basis_r` to get left and right bases of operators.
- Implement `getindex` for `CompositeBasis` and `SumBasis`.
- Add method interface to existing subtypes of `Bases`: `spinnumber`, `cutoff`, `offset`.
- Add `KetBraBasis`, `ChoiRefSysBasis`, `ChoiOutSysBasis`, and `_PauliBasis`. Note that eventually `_PauliBasis` will be renamed to `PauliBasis`.
- Change internal fields and constructors for subtypes of `Basis`.

## v0.3.10 - 2025-04-21

- Deprecate `PauliBasis` as it is identical to `SpinBasis(1//2)^N` but without the compatibility with `CompositeBasis`.
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.10"
version = "0.4.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
2 changes: 1 addition & 1 deletion src/QuantumInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ function wigner end
include("bases.jl")
include("abstract_types.jl")

include("linalg.jl")
include("tensor.jl")
include("embed_permute.jl")
include("expect_variance.jl")
include("identityoperator.jl")
include("superoperators.jl")

include("julia_base.jl")
include("julia_linalg.jl")
Expand Down
70 changes: 40 additions & 30 deletions src/abstract_types.jl
Original file line number Diff line number Diff line change
@@ -1,47 +1,57 @@
"""
Abstract base class for `Bra` and `Ket` states.
Abstract type for all state vectors.

The state vector class stores the coefficients of an abstract state
in respect to a certain basis. These coefficients are stored in the
`data` field and the basis is defined in the `basis`
field.
This type represents any abstract pure quantum state as given by an element of a
Hilbert space with respect to a certain basis. To be compatible with methods
defined in `QuantumInterface`, all subtypes must implement the `basis` method
which should return a subtype of the abstract [`Basis`](@ref) type.

See also [`AbstractKet`](@ref) and [`AbstractBra`](@ref).
"""
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 base class for all operators.
Abstract type for `Ket` states.

All deriving operator classes have to define the fields
`basis_l` and `basis_r` defining the left and right side bases.
This subtype of [`StateVector`](@ref) is meant to represent `Ket` states which
are related to their dual `Bra` by the conjugate transpose.

For fast time evolution also at least the function
`mul!(result::Ket,op::AbstractOperator,x::Ket,alpha,beta)` should be
implemented. Many other generic multiplication functions can be defined in
terms of this function and are provided automatically.
See also [`AbstractBra`](@ref).
"""
abstract type AbstractOperator{BL,BR} end
abstract type AbstractKet <: StateVector end

"""
Abstract type for `Bra` states.

This subtype of [`StateVector`](@ref) is meant to represent `Bra` states which
are related to their dual `Ket` by the conjugate transpose.

See also [`AbstractBra`](@ref).
"""
Base class for all super operator classes.
abstract type AbstractBra <: StateVector end

Super operators are bijective mappings from operators given in one specific
basis to operators, possibly given in respect to another, different basis.
To embed super operators in an algebraic framework they are defined with a
left hand basis `basis_l` and a right hand basis `basis_r` where each of
them again consists of a left and right hand basis.
```math
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 for all operators and super operators.

This type represents any abstract mixed quantum state given by a density
operator (or superoperator) mapping between two Hilbert spaces. All subtypes
must implement the [`basis_l`](@ref) and [`basis_r`](@ref) methods which return
subtypes of [`Basis`](@ref) representing the left and right bases that the
operator maps between. A subtype is considered compatible with multiplication by
a subtype of [`AbstractBra`](@ref) defined in same left basis as the operator
and a subtype of [`AbstractKet`](@ref) defined in the same right basis as the
operator.

For fast time evolution also at least the function
`mul!(result::Ket,op::AbstractOperator,x::Ket,alpha,beta)` should be
implemented. Many other generic multiplication functions can be defined in terms
of this function and are provided automatically.
"""
abstract type AbstractOperator end

function summary(stream::IO, x::AbstractOperator)
print(stream, "$(typeof(x).name.name)(dim=$(length(x.basis_l))x$(length(x.basis_r)))\n")
if samebases(x)
print(stream, "$(typeof(x).name.name)(dim=$(dimension(x.basis_l))x$(dimension(x.basis_r)))\n")
if multiplicable(x,x)

Check warning on line 54 in src/abstract_types.jl

View check run for this annotation

Codecov / codecov/patch

src/abstract_types.jl#L53-L54

Added lines #L53 - L54 were not covered by tests
print(stream, " basis: ")
show(stream, basis(x))
else
Expand Down
Loading
Loading