Skip to content

Commit 9d7aee8

Browse files
Minor chnages
1 parent bc1adb0 commit 9d7aee8

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased](https://github.com/qutip/QuantumToolbox.jl/tree/main)
99

10-
- Support different length for to and from on GeneralDimensions. ([#448])
10+
- Support different length for `to` and `from` on GeneralDimensions. ([#448])
1111

1212
## [v0.30.0]
1313
Release date: 2025-04-12

src/entropy.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ Here, ``S`` is the [Von Neumann entropy](https://en.wikipedia.org/wiki/Von_Neuma
149149
- `kwargs` are the keyword arguments for calculating Von Neumann entropy. See also [`entropy_vn`](@ref).
150150
"""
151151
function entropy_mutual(
152-
ρAB::QuantumObject{ObjType,<:AbstractDimensions{N,M}},
152+
ρAB::QuantumObject{ObjType,<:AbstractDimensions{N,N}},
153153
selA::Union{Int,AbstractVector{Int},Tuple},
154154
selB::Union{Int,AbstractVector{Int},Tuple};
155155
kwargs...,
156-
) where {ObjType<:Union{KetQuantumObject,OperatorQuantumObject},N,M}
156+
) where {ObjType<:Union{KetQuantumObject,OperatorQuantumObject},N}
157157
# check if selA and selB matches the dimensions of ρAB
158158
sel_A_B = (selA..., selB...)
159159
(length(sel_A_B) != N) && throw(

src/qobj/dimensions.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This file defines the Dimensions structures, which can describe composite Hilber
44

55
export AbstractDimensions, Dimensions, GeneralDimensions
66

7-
abstract type AbstractDimensions{N,M} end
7+
abstract type AbstractDimensions{M,N} end
88

99
@doc raw"""
1010
struct Dimensions{N,T<:Tuple} <: AbstractDimensions{N, N}
@@ -42,14 +42,14 @@ Dimensions(dims::Any) = throw(
4242
4343
A structure that describes the left-hand side (`to`) and right-hand side (`from`) Hilbert [`Space`](@ref) of an [`Operator`](@ref).
4444
"""
45-
struct GeneralDimensions{N,M,T1<:Tuple,T2<:Tuple} <: AbstractDimensions{N,M}
45+
struct GeneralDimensions{M,N,T1<:Tuple,T2<:Tuple} <: AbstractDimensions{M,N}
4646
# note that the number `N` should be the same for both `to` and `from`
4747
to::T1 # space acting on the left
4848
from::T2 # space acting on the right
4949

5050
# make sure the elements in the tuple are all AbstractSpace
51-
GeneralDimensions(to::NTuple{N,T1}, from::NTuple{M,T2}) where {N,M,T1<:AbstractSpace,T2<:AbstractSpace} =
52-
new{N,M,typeof(to),typeof(from)}(to, from)
51+
GeneralDimensions(to::NTuple{M,T1}, from::NTuple{N,T2}) where {M,N,T1<:AbstractSpace,T2<:AbstractSpace} =
52+
new{M,N,typeof(to),typeof(from)}(to, from)
5353
end
5454
function GeneralDimensions(dims::Union{AbstractVector{T},NTuple{N,T}}) where {T<:Union{AbstractVector,NTuple},N}
5555
(length(dims) != 2) && throw(ArgumentError("Invalid dims = $dims"))
@@ -59,9 +59,8 @@ function GeneralDimensions(dims::Union{AbstractVector{T},NTuple{N,T}}) where {T<
5959

6060
L1 = length(dims[1])
6161
L2 = length(dims[2])
62-
((L1 > 0) && (L2 > 0)) || throw(
63-
DomainError((L1, L2), "The length of the arguments `dims[1]` and `dims[2]` must have at least one element."),
64-
)
62+
(L1 > 0) || throw(DomainError(L1, "The length of `dims[1]` must be larger or equal to 1."))
63+
(L2 > 0) || throw(DomainError(L2, "The length of `dims[2]` must be larger or equal to 1."))
6564

6665
return GeneralDimensions(Tuple(Space.(dims[1])), Tuple(Space.(dims[2])))
6766
end

src/qobj/quantum_object_base.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,13 @@ get_dimensions_to(
274274

275275
# this returns `from` in GeneralDimensions representation
276276
get_dimensions_from(A::AbstractQuantumObject{KetQuantumObject,<:Dimensions{N}}) where {N} = space_one_list(N)
277-
get_dimensions_from(A::AbstractQuantumObject{BraQuantumObject,<:Dimensions{N}}) where {N} = A.dimensions.to
278-
get_dimensions_from(A::AbstractQuantumObject{OperatorQuantumObject,<:Dimensions{N}}) where {N} = A.dimensions.to
279-
get_dimensions_from(A::AbstractQuantumObject{OperatorQuantumObject,<:GeneralDimensions{N,M}}) where {N,M} =
277+
get_dimensions_from(A::AbstractQuantumObject{BraQuantumObject,<:Dimensions}) = A.dimensions.to
278+
get_dimensions_from(A::AbstractQuantumObject{OperatorQuantumObject,<:Dimensions}) = A.dimensions.to
279+
get_dimensions_from(A::AbstractQuantumObject{OperatorQuantumObject,<:GeneralDimensions}) =
280280
A.dimensions.from
281281
get_dimensions_from(
282-
A::AbstractQuantumObject{ObjType,<:Dimensions{N}},
283-
) where {ObjType<:Union{SuperOperatorQuantumObject,OperatorBraQuantumObject,OperatorKetQuantumObject},N} =
282+
A::AbstractQuantumObject{ObjType,<:Dimensions},
283+
) where {ObjType<:Union{SuperOperatorQuantumObject,OperatorBraQuantumObject,OperatorKetQuantumObject}} =
284284
A.dimensions.to
285285

286286
# functions for getting Float or Complex element type

0 commit comments

Comments
 (0)