Skip to content

Commit c1fbedd

Browse files
committed
minor changes
1 parent c7383ea commit c1fbedd

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

src/qobj/dimensions.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ LinearAlgebra.transpose(dimensions::Dimensions) = dimensions
8686
LinearAlgebra.transpose(dimensions::GeneralDimensions) = GeneralDimensions(dimensions.from, dimensions.to) # switch `to` and `from`
8787
LinearAlgebra.adjoint(dimensions::AbstractDimensions) = transpose(dimensions)
8888

89+
# this is used to show `dims` for Qobj and QobjEvo
8990
_get_dims_string(dimensions::Dimensions) = string(dimensions_to_dims(dimensions))
9091
function _get_dims_string(dimensions::GeneralDimensions)
9192
dims = dimensions_to_dims(dimensions)

src/qobj/quantum_object_base.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -167,49 +167,49 @@ check_dimensions(Qobj_tuple::NTuple{N,AbstractQuantumObject}) where {N} =
167167
check_dimensions(getfield.(Qobj_tuple, :dimensions))
168168
check_dimensions(A::AbstractQuantumObject...) = check_dimensions(A)
169169

170-
function _check_QuantumObject(type::KetQuantumObject, dims::Dimensions, m::Int, n::Int)
170+
function _check_QuantumObject(type::KetQuantumObject, dimensions::Dimensions, m::Int, n::Int)
171171
(n != 1) && throw(DomainError((m, n), "The size of the array is not compatible with Ket"))
172-
(prod(dims) != m) && throw(DimensionMismatch("Ket with dims = $(dims) does not fit the array size = $((m, n))."))
172+
(prod(dimensions) != m) && throw(DimensionMismatch("Ket with dims = $(_get_dims_string(dimensions)) does not fit the array size = $((m, n))."))
173173
return nothing
174174
end
175175

176-
function _check_QuantumObject(type::BraQuantumObject, dims::Dimensions, m::Int, n::Int)
176+
function _check_QuantumObject(type::BraQuantumObject, dimensions::Dimensions, m::Int, n::Int)
177177
(m != 1) && throw(DomainError((m, n), "The size of the array is not compatible with Bra"))
178-
(prod(dims) != n) && throw(DimensionMismatch("Bra with dims = $(dims) does not fit the array size = $((m, n))."))
178+
(prod(dimensions) != n) && throw(DimensionMismatch("Bra with dims = $(_get_dims_string(dimensions)) does not fit the array size = $((m, n))."))
179179
return nothing
180180
end
181181

182-
function _check_QuantumObject(type::OperatorQuantumObject, dims::Dimensions, m::Int, n::Int)
183-
L = prod(dims)
184-
(L == m == n) || throw(DimensionMismatch("Operator with dims = $(dims) does not fit the array size = $((m, n))."))
182+
function _check_QuantumObject(type::OperatorQuantumObject, dimensions::Dimensions, m::Int, n::Int)
183+
L = prod(dimensions)
184+
(L == m == n) || throw(DimensionMismatch("Operator with dims = $(_get_dims_string(dimensions)) does not fit the array size = $((m, n))."))
185185
return nothing
186186
end
187187

188-
function _check_QuantumObject(type::OperatorQuantumObject, dims::GeneralDimensions, m::Int, n::Int)
188+
function _check_QuantumObject(type::OperatorQuantumObject, dimensions::GeneralDimensions, m::Int, n::Int)
189189
((m == 1) || (n == 1)) && throw(DomainError((m, n), "The size of the array is not compatible with Operator"))
190-
((prod(dims.to) != m) || (prod(dims.from) != n)) &&
191-
throw(DimensionMismatch("Operator with dims = $(dims) does not fit the array size = $((m, n))."))
190+
((prod(dimensions.to) != m) || (prod(dimensions.from) != n)) &&
191+
throw(DimensionMismatch("Operator with dims = $(_get_dims_string(dimensions)) does not fit the array size = $((m, n))."))
192192
return nothing
193193
end
194194

195-
function _check_QuantumObject(type::SuperOperatorQuantumObject, dims::Dimensions, m::Int, n::Int)
195+
function _check_QuantumObject(type::SuperOperatorQuantumObject, dimensions::Dimensions, m::Int, n::Int)
196196
(m != n) && throw(DomainError((m, n), "The size of the array is not compatible with SuperOperator"))
197-
(prod(dims) != sqrt(m)) &&
198-
throw(DimensionMismatch("SuperOperator with dims = $(dims) does not fit the array size = $((m, n))."))
197+
(prod(dimensions) != sqrt(m)) &&
198+
throw(DimensionMismatch("SuperOperator with dims = $(_get_dims_string(dimensions)) does not fit the array size = $((m, n))."))
199199
return nothing
200200
end
201201

202-
function _check_QuantumObject(type::OperatorKetQuantumObject, dims::Dimensions, m::Int, n::Int)
202+
function _check_QuantumObject(type::OperatorKetQuantumObject, dimensions::Dimensions, m::Int, n::Int)
203203
(n != 1) && throw(DomainError((m, n), "The size of the array is not compatible with OperatorKet"))
204-
(prod(dims) != sqrt(m)) &&
205-
throw(DimensionMismatch("OperatorKet with dims = $(dims) does not fit the array size = $((m, n))."))
204+
(prod(dimensions) != sqrt(m)) &&
205+
throw(DimensionMismatch("OperatorKet with dims = $(_get_dims_string(dimensions)) does not fit the array size = $((m, n))."))
206206
return nothing
207207
end
208208

209-
function _check_QuantumObject(type::OperatorBraQuantumObject, dims::Dimensions, m::Int, n::Int)
209+
function _check_QuantumObject(type::OperatorBraQuantumObject, dimensions::Dimensions, m::Int, n::Int)
210210
(m != 1) && throw(DomainError((m, n), "The size of the array is not compatible with OperatorBra"))
211-
(prod(dims) != sqrt(n)) &&
212-
throw(DimensionMismatch("OperatorBra with dims = $(dims) does not fit the array size = $((m, n))."))
211+
(prod(dimensions) != sqrt(n)) &&
212+
throw(DimensionMismatch("OperatorBra with dims = $(_get_dims_string(dimensions)) does not fit the array size = $((m, n))."))
213213
return nothing
214214
end
215215

src/qobj/quantum_object_evo.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,7 @@ function (A::QuantumObjectEvolution)(
508508
p,
509509
t,
510510
) where {DT1,DT2,QobjType<:Union{KetQuantumObject,OperatorKetQuantumObject}}
511-
check_dimensions(ψout, ψin)
512-
check_dimensions(ψout, A)
511+
check_dimensions(A, ψout, ψin)
513512

514513
if isoper(A) && isoperket(ψin)
515514
throw(ArgumentError("The input state must be a Ket if the QuantumObjectEvolution object is an Operator."))

0 commit comments

Comments
 (0)