1
1
"""Module with the most commom superoperator transformations."""
2
2
3
3
import warnings
4
- from typing import Optional
4
+ from typing import List , Optional , Tuple , Union
5
5
6
6
import numpy as np
7
7
from scipy .optimize import minimize
@@ -303,6 +303,50 @@ def to_chi(
303
303
return channel
304
304
305
305
306
+ def to_stinespring (
307
+ channel ,
308
+ partition : Optional [Union [List [int ], Tuple [int , ...]]] = None ,
309
+ nqubits : Optional [int ] = None ,
310
+ initial_state_env = None ,
311
+ backend = None ,
312
+ ):
313
+ """Convert quantum ``channel`` :math:`U` to its Stinespring representation :math:`U_{0}`.
314
+
315
+ It uses the Kraus representation as an intermediate step.
316
+
317
+ Args:
318
+ channel (ndarray): quantum channel.
319
+ nqubits (int, optional): total number of qubits in the system that is
320
+ interacting with the environment. Must be equal or greater than
321
+ the number of qubits ``channel`` acts on. If ``None``,
322
+ defaults to the number of qubits in ``channel``.
323
+ Defauts to ``None``.
324
+ initial_state_env (ndarray, optional): statevector representing the
325
+ initial state of the enviroment. If ``None``, it assumes the
326
+ environment in its ground state. Defaults to ``None``.
327
+ backend (:class:`qibo.backends.abstract.Backend`, optional): backend
328
+ to be used in the execution. If ``None``, it uses
329
+ :class:`qibo.backends.GlobalBackend`. Defaults to ``None``.
330
+
331
+ Returns:
332
+ ndarray: Quantum channel in its Stinespring representation :math:`U_{0}`.
333
+ """
334
+ backend = _check_backend (backend )
335
+
336
+ if partition is None :
337
+ nqubits_channel = int (np .log2 (channel .shape [- 1 ]))
338
+ partition = tuple (range (nqubits_channel ))
339
+
340
+ channel = kraus_to_stinespring (
341
+ [(partition , channel )],
342
+ nqubits = nqubits ,
343
+ initial_state_env = initial_state_env ,
344
+ backend = backend ,
345
+ )
346
+
347
+ return channel
348
+
349
+
306
350
def choi_to_liouville (choi_super_op , order : str = "row" , backend = None ):
307
351
"""Converts Choi representation :math:`\\ Lambda` of quantum channel
308
352
to its Liouville representation :math:`\\ mathcal{E}`.
@@ -320,7 +364,6 @@ def choi_to_liouville(choi_super_op, order: str = "row", backend=None):
320
364
\\ Lambda_{\\ alpha\\ beta, \\ , \\ gamma\\ delta} \\ mapsto
321
365
\\ Lambda_{\\ delta\\ beta, \\ , \\ gamma\\ alpha} \\ equiv \\ mathcal{E}
322
366
323
-
324
367
Args:
325
368
choi_super_op: Choi representation of quantum channel.
326
369
order (str, optional): If ``"row"``, reshuffling is performed
@@ -640,7 +683,7 @@ def choi_to_stinespring(
640
683
if nqubits is None :
641
684
nqubits = int (np .log2 (kraus_ops [0 ].shape [0 ]))
642
685
643
- nqubits_list = [tuple (range (nqubits )) for _ in range ( len (kraus_ops ))]
686
+ nqubits_list = [tuple (range (nqubits ))] * len (kraus_ops )
644
687
645
688
kraus_ops = list (zip (nqubits_list , kraus_ops ))
646
689
0 commit comments