@@ -71,18 +71,19 @@ Return the partial transpose of a density matrix ``\rho``, where `mask` is an ar
7171- `ρ_pt::QuantumObject`: The density matrix with the selected subsystems transposed.
7272"""
7373function partial_transpose (ρ:: QuantumObject{Operator} , mask:: Vector{Bool} )
74- if length (mask) != length (ρ. dimensions)
75- throw (ArgumentError (" The length of \` mask\` should be equal to the length of \` ρ.dims\` ." ))
76- end
77- return _partial_transpose (ρ, mask)
78- end
74+ any (s -> s isa EnrSpace, QO. dimensions. to) && throw (ArgumentError (" partial_transpose does not support EnrSpace" ))
75+
76+ (length (mask) != length (ρ. dimensions)) && throw (ArgumentError (" The length of \` mask\` should be equal to the length of \` ρ.dims\` ." ))
7977
80- # for dense matrices
81- function _partial_transpose (ρ:: QuantumObject{Operator} , mask:: Vector{Bool} )
8278 isa (ρ. dimensions, GeneralDimensions) &&
8379 (get_dimensions_to (ρ) != get_dimensions_from (ρ)) &&
8480 throw (ArgumentError (" Invalid partial transpose for dims = $(_get_dims_string (ρ. dimensions)) " ))
8581
82+ return _partial_transpose (ρ, mask)
83+ end
84+
85+ # for dense matrices
86+ function _partial_transpose (ρ:: QuantumObject{Operator} , mask:: Vector{Bool} )
8687 mask2 = [1 + Int (i) for i in mask]
8788 # mask2 has elements with values equal to 1 or 2
8889 # 1 - the subsystem don't need to be transposed
@@ -107,10 +108,6 @@ function _partial_transpose(
107108 ρ:: QuantumObject{Operator,DimsType,<:AbstractSparseArray} ,
108109 mask:: Vector{Bool} ,
109110) where {DimsType<: AbstractDimensions }
110- isa (ρ. dimensions, GeneralDimensions) &&
111- (get_dimensions_to (ρ) != get_dimensions_from (ρ)) &&
112- throw (ArgumentError (" Invalid partial transpose for dims = $(_get_dims_string (ρ. dimensions)) " ))
113-
114111 M, N = size (ρ)
115112 dimsTuple = Tuple (dimensions_to_dims (get_dimensions_to (ρ)))
116113 colptr = ρ. data. colptr
0 commit comments