Skip to content

Commit f49cab6

Browse files
committed
Merge branch 'main' into dev/entropy
2 parents 0ffbb5d + 7d58e46 commit f49cab6

File tree

6 files changed

+20
-4
lines changed

6 files changed

+20
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- Support for single `AbstractQuantumObject` in `sc_ops` for faster specific method in `ssesolve` and `smesolve`. ([#408])
1111
- Change save callbacks from `PresetTimeCallback` to `FunctionCallingCallback`. ([#410])
1212
- Align `eigenstates` and `eigenenergies` to QuTiP. ([#411])
13+
- Introduce `vector_to_operator` and `operator_to_vector`. ([#413])
1314

1415
## [v0.27.0]
1516
Release date: 2025-02-14
@@ -147,3 +148,4 @@ Release date: 2024-11-13
147148
[#408]: https://github.com/qutip/QuantumToolbox.jl/issues/408
148149
[#410]: https://github.com/qutip/QuantumToolbox.jl/issues/410
149150
[#411]: https://github.com/qutip/QuantumToolbox.jl/issues/411
151+
[#413]: https://github.com/qutip/QuantumToolbox.jl/issues/413

docs/src/resources/api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ unit
176176
tensor
177177
178178
qeye
179+
vector_to_operator
180+
operator_to_vector
179181
sqrtm
180182
logm
181183
expm

docs/src/users_guide/states_and_operators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ Therefore, a given density matrix ``\hat{\rho}`` can then be vectorized, denoted
314314
|\hat{\rho}\rangle\rangle = \textrm{vec}(\hat{\rho}).
315315
```
316316

317-
`QuantumToolbox` uses the column-stacking convention for the isomorphism between ``\mathcal{L}(\mathcal{H})`` and ``\mathcal{H}\otimes\mathcal{H}``. This isomorphism is implemented by the functions [`mat2vec`](@ref) and [`vec2mat`](@ref):
317+
`QuantumToolbox` uses the column-stacking convention for the isomorphism between ``\mathcal{L}(\mathcal{H})`` and ``\mathcal{H}\otimes\mathcal{H}``. This isomorphism is implemented by the functions [`mat2vec`](@ref) (or [`operator_to_vector`](@ref)) and [`vec2mat`](@ref) (or [`vector_to_operator`](@ref)):
318318

319319
```@example states_and_operators
320320
rho = Qobj([1 2; 3 4])

src/qobj/functions.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,23 @@ end
261261

262262
@doc raw"""
263263
vec2mat(A::QuantumObject)
264+
vector_to_operator(A::QuantumObject)
264265
265266
Convert a quantum object from vector ([`OperatorKetQuantumObject`](@ref)-type) to matrix ([`OperatorQuantumObject`](@ref)-type)
267+
268+
!!! note
269+
`vector_to_operator` is a synonym of `vec2mat`.
266270
"""
267271
vec2mat(A::QuantumObject{OperatorKetQuantumObject}) = QuantumObject(vec2mat(A.data), Operator, A.dimensions)
268272

269273
@doc raw"""
270274
mat2vec(A::QuantumObject)
275+
operator_to_vector(A::QuantumObject)
271276
272277
Convert a quantum object from matrix ([`OperatorQuantumObject`](@ref)-type) to vector ([`OperatorKetQuantumObject`](@ref)-type)
278+
279+
!!! note
280+
`operator_to_vector` is a synonym of `mat2vec`.
273281
"""
274282
mat2vec(A::QuantumObject{OperatorQuantumObject}) = QuantumObject(mat2vec(A.data), OperatorKet, A.dimensions)
275283

src/qobj/synonyms.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export Qobj, QobjEvo, shape, isherm
66
export trans, dag, matrix_element, unit
77
export tensor,
88
export qeye
9+
export vector_to_operator, operator_to_vector
910
export sqrtm, logm, expm, sinm, cosm
1011

1112
@doc raw"""
@@ -52,6 +53,9 @@ const ⊗ = kron
5253

5354
const qeye = eye
5455

56+
const vector_to_operator = vec2mat
57+
const operator_to_vector = mat2vec
58+
5559
@doc raw"""
5660
sqrtm(A::QuantumObject)
5761

test/core-test/quantum_objects.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@
125125
H = 0.3 * sigmax() + 0.7 * sigmaz()
126126
L = liouvillian(H)
127127
ρ = Qobj(rand(ComplexF64, 2, 2))
128-
ρ_ket = mat2vec(ρ)
128+
ρ_ket = operator_to_vector(ρ)
129129
ρ_bra = ρ_ket'
130-
@test ρ_bra == Qobj(mat2vec.data)', type = OperatorBra)
131-
@test ρ == vec2mat(ρ_ket)
130+
@test ρ_bra == Qobj(operator_to_vector.data)', type = OperatorBra)
131+
@test ρ == vector_to_operator(ρ_ket)
132132
@test isket(ρ_ket) == false
133133
@test isbra(ρ_ket) == false
134134
@test isoper(ρ_ket) == false

0 commit comments

Comments
 (0)