Skip to content
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support for single `AbstractQuantumObject` in `sc_ops` for faster specific method in `ssesolve` and `smesolve`. ([#408])
- Change save callbacks from `PresetTimeCallback` to `FunctionCallingCallback`. ([#410])
- Align `eigenstates` and `eigenenergies` to QuTiP. ([#411])
- Introduce `vector_to_operator` and `operator_to_vector`. ([#413])

## [v0.27.0]
Release date: 2025-02-14
Expand Down Expand Up @@ -147,3 +148,4 @@ Release date: 2024-11-13
[#408]: https://github.com/qutip/QuantumToolbox.jl/issues/408
[#410]: https://github.com/qutip/QuantumToolbox.jl/issues/410
[#411]: https://github.com/qutip/QuantumToolbox.jl/issues/411
[#413]: https://github.com/qutip/QuantumToolbox.jl/issues/413
2 changes: 2 additions & 0 deletions docs/src/resources/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ unit
tensor
qeye
vector_to_operator
operator_to_vector
sqrtm
logm
expm
Expand Down
2 changes: 1 addition & 1 deletion docs/src/users_guide/states_and_operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ Therefore, a given density matrix ``\hat{\rho}`` can then be vectorized, denoted
|\hat{\rho}\rangle\rangle = \textrm{vec}(\hat{\rho}).
```

`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):
`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)):

```@example states_and_operators
rho = Qobj([1 2; 3 4])
Expand Down
8 changes: 8 additions & 0 deletions src/qobj/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,23 @@ end

@doc raw"""
vec2mat(A::QuantumObject)
vector_to_operator(A::QuantumObject)

Convert a quantum object from vector ([`OperatorKetQuantumObject`](@ref)-type) to matrix ([`OperatorQuantumObject`](@ref)-type)

!!! note
`vector_to_operator` is a synonym of `vec2mat`.
"""
vec2mat(A::QuantumObject{OperatorKetQuantumObject}) = QuantumObject(vec2mat(A.data), Operator, A.dimensions)

@doc raw"""
mat2vec(A::QuantumObject)
operator_to_vector(A::QuantumObject)

Convert a quantum object from matrix ([`OperatorQuantumObject`](@ref)-type) to vector ([`OperatorKetQuantumObject`](@ref)-type)

!!! note
`operator_to_vector` is a synonym of `mat2vec`.
"""
mat2vec(A::QuantumObject{OperatorQuantumObject}) = QuantumObject(mat2vec(A.data), OperatorKet, A.dimensions)

Expand Down
4 changes: 4 additions & 0 deletions src/qobj/synonyms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export Qobj, QobjEvo, shape, isherm
export trans, dag, matrix_element, unit
export tensor, ⊗
export qeye
export vector_to_operator, operator_to_vector
export sqrtm, logm, expm, sinm, cosm

@doc raw"""
Expand Down Expand Up @@ -52,6 +53,9 @@ const ⊗ = kron

const qeye = eye

const vector_to_operator = vec2mat
const operator_to_vector = mat2vec

@doc raw"""
sqrtm(A::QuantumObject)

Expand Down
6 changes: 3 additions & 3 deletions test/core-test/quantum_objects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@
H = 0.3 * sigmax() + 0.7 * sigmaz()
L = liouvillian(H)
ρ = Qobj(rand(ComplexF64, 2, 2))
ρ_ket = mat2vec(ρ)
ρ_ket = operator_to_vector(ρ)
ρ_bra = ρ_ket'
@test ρ_bra == Qobj(mat2vec(ρ.data)', type = OperatorBra)
@test ρ == vec2mat(ρ_ket)
@test ρ_bra == Qobj(operator_to_vector(ρ.data)', type = OperatorBra)
@test ρ == vector_to_operator(ρ_ket)
@test isket(ρ_ket) == false
@test isbra(ρ_ket) == false
@test isoper(ρ_ket) == false
Expand Down