@@ -39,7 +39,7 @@ julia> round(negativity(ρ, 2), digits=2)
3939```
4040"""
4141function negativity (ρ:: QuantumObject , subsys:: Int ; logarithmic:: Bool = false )
42- mask = fill (false , length (ρ. _dims ))
42+ mask = fill (false , length (ρ. dimensions ))
4343 try
4444 mask[subsys] = true
4545 catch
@@ -69,16 +69,16 @@ Return the partial transpose of a density matrix ``\rho``, where `mask` is an ar
6969- `ρ_pt::QuantumObject`: The density matrix with the selected subsystems transposed.
7070"""
7171function partial_transpose (ρ:: QuantumObject{DT,OperatorQuantumObject} , mask:: Vector{Bool} ) where {DT}
72- if length (mask) != length (ρ. _dims )
72+ if length (mask) != length (ρ. dimensions )
7373 throw (ArgumentError (" The length of \` mask\` should be equal to the length of \` ρ.dims\` ." ))
7474 end
7575 return _partial_transpose (ρ, mask)
7676end
7777
7878# for dense matrices
7979function _partial_transpose (ρ:: QuantumObject{DT,OperatorQuantumObject} , mask:: Vector{Bool} ) where {DT<: AbstractArray }
80- isa (ρ. _dims, CompoundDimensions ) &&
81- (ρ . _to != ρ . _from ) &&
80+ isa (ρ. dimensions, GeneralDimensions ) &&
81+ (get_dimensions_to (ρ) != get_dimensions_from (ρ) ) &&
8282 throw (ArgumentError (" Invalid partial transpose for dims = $(ρ. dims) " ))
8383
8484 mask2 = [1 + Int (i) for i in mask]
@@ -87,27 +87,27 @@ function _partial_transpose(ρ::QuantumObject{DT,OperatorQuantumObject}, mask::V
8787 # 2 - the subsystem need be transposed
8888
8989 nsys = length (mask2)
90- dimslist = dims_to_list (ρ . _to )
90+ dims = dimensions_to_dims ( get_dimensions_to (ρ) )
9191 pt_dims = reshape (Vector (1 : (2 * nsys)), (nsys, 2 ))
9292 pt_idx = [
93- [pt_dims[n, mask2[n]] for n in 1 : nsys] # origin value in mask2
94- [pt_dims[n, 3 - mask2[n]] for n in 1 : nsys] # opposite value in mask2 (1 -> 2, and 2 -> 1)
93+ [pt_dims[n, mask2[n]] for n in 1 : nsys] # origin value in mask2
94+ [pt_dims[n, 3 - mask2[n]] for n in 1 : nsys] # opposite value in mask2 (1 -> 2, and 2 -> 1)
9595 ]
9696 return QuantumObject (
97- reshape (permutedims (reshape (ρ. data, (dimslist ... , dimslist ... )), pt_idx), size (ρ)),
97+ reshape (permutedims (reshape (ρ. data, (dims ... , dims ... )), pt_idx), size (ρ)),
9898 Operator,
99- Dimensions (ρ. _dims . to),
99+ Dimensions (ρ. dimensions . to),
100100 )
101101end
102102
103103# for sparse matrices
104104function _partial_transpose (ρ:: QuantumObject{<:AbstractSparseArray,OperatorQuantumObject} , mask:: Vector{Bool} )
105- isa (ρ. _dims, CompoundDimensions ) &&
106- (ρ . _to != ρ . _from ) &&
105+ isa (ρ. dimensions, GeneralDimensions ) &&
106+ (get_dimensions_to (ρ) != get_dimensions_from (ρ) ) &&
107107 throw (ArgumentError (" Invalid partial transpose for dims = $(ρ. dims) " ))
108108
109109 M, N = size (ρ)
110- dimsTuple = Tuple (dims_to_list (ρ . _to ))
110+ dimsTuple = Tuple (dimensions_to_dims ( get_dimensions_to (ρ) ))
111111 colptr = ρ. data. colptr
112112 rowval = ρ. data. rowval
113113 nzval = ρ. data. nzval
@@ -139,5 +139,5 @@ function _partial_transpose(ρ::QuantumObject{<:AbstractSparseArray,OperatorQuan
139139 end
140140 end
141141
142- return QuantumObject (sparse (I_pt, J_pt, V_pt, M, N), Operator, ρ. _dims )
142+ return QuantumObject (sparse (I_pt, J_pt, V_pt, M, N), Operator, ρ. dimensions )
143143end
0 commit comments