From bf5f4541bcee6df519d02fd57de872f26ff00a24 Mon Sep 17 00:00:00 2001 From: Akira Kyle Date: Mon, 25 Nov 2024 14:46:19 -0700 Subject: [PATCH] Elimite type parameters from abstract types and add fullbasis function --- CHANGELOG.md | 6 ++++++ Project.toml | 2 +- src/QuantumInterface.jl | 15 +++++++++++++-- src/abstract_types.jl | 10 +++++----- src/julia_linalg.jl | 4 ++-- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c30de4..52ab459 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/Project.toml b/Project.toml index d8b70c0..9f743ed 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/QuantumInterface.jl b/src/QuantumInterface.jl index 1f306fa..58213df 100644 --- a/src/QuantumInterface.jl +++ b/src/QuantumInterface.jl @@ -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 ## diff --git a/src/abstract_types.jl b/src/abstract_types.jl index 0650290..70a2ce6 100644 --- a/src/abstract_types.jl +++ b/src/abstract_types.jl @@ -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. @@ -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. @@ -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 diff --git a/src/julia_linalg.jl b/src/julia_linalg.jl index cdcceea..3087d0a 100644 --- a/src/julia_linalg.jl +++ b/src/julia_linalg.jl @@ -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) @@ -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)