Skip to content
Open
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
1,174 changes: 690 additions & 484 deletions doc/api-doc/QuantumChannel.nb

Large diffs are not rendered by default.

728 changes: 574 additions & 154 deletions doc/api-doc/Visualization.nb

Large diffs are not rendered by default.

63 changes: 48 additions & 15 deletions src/QuantumChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
(*Usage Declarations*)


(* ::Subsection::Closed:: *)
(* ::Subsection:: *)
(*Quantum Channels*)


Unprotect[QuantumChannel,ChannelRep,InputDim,OutputDim,Basis];
Unprotect[QuantumChannel,ChannelRep,InputDim,OutputDim,Basis, ExtendUnitary];
Unprotect[Choi,Super,Chi,Kraus,Stinespring,Unitary,SysEnv];


Expand All @@ -61,6 +61,7 @@
AssignUsage[InputDim,$QuantumChannelUsages];
AssignUsage[OutputDim,$QuantumChannelUsages];
AssignUsage[Basis,$QuantumChannelUsages];
AssignUsage[ExtendUnitary, $QuantumChannelUsages];
AssignUsage[ChannelRep,$QuantumChannelUsages];
AssignUsage[ChannelParameters,$QuantumChannelUsages];

Expand Down Expand Up @@ -145,7 +146,7 @@
Begin["`Private`"];


(* ::Subsection::Closed:: *)
(* ::Subsection:: *)
(*Predicates*)


Expand Down Expand Up @@ -251,15 +252,18 @@
]]


(* ::Subsection::Closed:: *)
(* ::Subsection:: *)
(*Options and Formatting*)


(* ::Subsubsection::Closed:: *)
(* ::Subsubsection:: *)
(*Options*)


Options[QuantumChannel]={InputDim->Automatic,OutputDim->Automatic,Basis->Automatic};
Options[QuantumChannel] = {
InputDim->Automatic,OutputDim->Automatic,Basis->Automatic,
ExtendUnitary -> False
};


ChannelParameters[chan_QuantumChannel]:=Last@chan
Expand All @@ -276,7 +280,7 @@
Format[chan_QuantumChannel]:=ToString[ChannelRep[chan]][First[chan],"<params>"]


(* ::Subsection::Closed:: *)
(* ::Subsection:: *)
(*Constructing Channels*)


Expand Down Expand Up @@ -411,15 +415,20 @@
]]


(* ::Subsection::Closed:: *)
(* ::Subsection:: *)
(*Transforming Representations*)


(* ::Subsubsection::Closed:: *)
(* ::Subsubsection:: *)
(*Calling methods*)


Options[TransformChannel]={ChannelRep->Automatic,InputDim->Automatic,OutputDim->Automatic,"InputBasis"->Automatic,"OutputBasis"->Automatic};
Options[TransformChannel]={
ChannelRep->Automatic,InputDim->Automatic,OutputDim->Automatic,
"InputBasis"->Automatic,
"OutputBasis"->Automatic,
ExtendUnitary -> False
};


TransformChannel[chan_QuantumChannel,opts:OptionsPattern[TransformChannel]]:=
Expand All @@ -445,7 +454,9 @@
InputDim->inDim,
OutputDim->outDim,
"InputBasis"->inBasis,
"OutputBasis"->outBasis],
"OutputBasis"->outBasis,
ExtendUnitary -> OptionValue[ExtendUnitary]
],
{
ChannelRep->outRep,
InputDim->inDim,
Expand Down Expand Up @@ -473,7 +484,7 @@
TransformChannel[chan,ChannelRep->Stinespring,"OutputBasis"->OptionValue[Basis]]

SysEnv[chan_QuantumChannel,opts:OptionsPattern[QuantumChannel]]:=
TransformChannel[chan,ChannelRep->SysEnv,"OutputBasis"->OptionValue[Basis]]
TransformChannel[chan,ChannelRep->SysEnv,"OutputBasis"->OptionValue[Basis], ExtendUnitary->OptionValue[ExtendUnitary]]

(*Unitary[chan_QuantumChannel,opts:OptionsPattern[QuantumChannel]]:=
TransformChannel[chan,ChannelRep->ChannelRep[chan],"OutputBasis"->OptionValue[Basis]]*)
Expand All @@ -485,7 +496,7 @@
]


(* ::Subsubsection::Closed:: *)
(* ::Subsubsection:: *)
(*From Stinespring*)


Expand All @@ -502,7 +513,29 @@


TransformChannel[Stinespring->SysEnv,op_,opts:OptionsPattern[TransformChannel]]:=
ReducedUnitary[op,OptionValue[OutputDim]]
Module[{RU = ReducedUnitary[op,OptionValue[OutputDim]]},

If[OptionValue[ExtendUnitary],

Module[{U, V, v0},
If[Length @ Dimensions[RU[[1]]] == 3,
{{U, V}, v0} = RU;
{CompleteUnitary /@ {U, V}, v0},

{U, v0} = RU;
{CompleteUnitary[U], v0}
]
],

RU
]
]


CompleteUnitary[U_] := Module[{Uu, Uw, Uv},
{Uu, Uw, Uv} = SingularValueDecomposition[U];
Uu . Uv\[ConjugateTranspose]
];


ReducedUnitary[stine_,outDim_]:=
Expand Down Expand Up @@ -571,7 +604,7 @@
TransformChannel[Stinespring->Unitary,op_,opts:OptionsPattern[TransformChannel]]:=op


(* ::Subsubsection::Closed:: *)
(* ::Subsubsection:: *)
(*From SysEnv*)


Expand Down
72 changes: 66 additions & 6 deletions src/Visualization.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
(*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AREDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLEFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ORSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVERCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USEOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*)


(* ::Subsection::Closed:: *)
(*Preample*)
(* ::Subsection:: *)
(*Preamble*)


BeginPackage["Visualization`",{"QUDoc`"}];
Expand All @@ -36,6 +36,7 @@
Needs["QUDevTools`"];
Needs["Predicates`"];
Needs["Tensor`"];
Needs["QuantumChannel`"];


$VisualizationUsages = LoadUsages[FileNameJoin[{$QUDocumentationPath, "api-doc", "Visualization.nb"}]];
Expand All @@ -45,16 +46,17 @@
(*Usage Declaration*)


(* ::Subsection::Closed:: *)
(* ::Subsection:: *)
(*Matrices*)


Unprotect[ComplexMatrixPlot,BlockForm,MatrixListForm];
Unprotect[ComplexMatrixPlot,BlockForm,MatrixListForm, HintonPlot];


AssignUsage[ComplexMatrixPlot,$VisualizationUsages];
AssignUsage[BlockForm,$VisualizationUsages];
AssignUsage[MatrixListForm,$VisualizationUsages];
AssignUsage[{Gap, HintonPlot, ChannelHintonPlot}, $VisualizationUsages];


(* ::Subsection::Closed:: *)
Expand Down Expand Up @@ -108,7 +110,7 @@
Begin["`Private`"];


(* ::Subsection::Closed:: *)
(* ::Subsection:: *)
(*Matrices*)


Expand Down Expand Up @@ -147,6 +149,64 @@
MatrixListForm[mats_]:=Row[Riffle[MatrixForm/@mats,","]]


Options[HintonPlot] = {
AxesLabel -> None,
Gap -> 0.05
};


HintonPlot[dat_,OptionsPattern[]] := With[{data=Reverse[dat\[Transpose],{2}]},With[{n=Dimensions[data][[1]],m=Dimensions[data][[2]],normdata=(1-OptionValue[Gap])data/Max[Abs[data]],graydata=Map[GrayLevel,(Sign[data]+1)/2,{2}]},
Module[{plot},
plot = Graphics[
{GrayLevel[1/2],Rectangle[{1/4,1/4},{n+3/4,m+3/4}]}~Join~
Table[
{
graydata[[i,j]],
Tooltip[Rectangle[
{i-normdata[[i,j]]/2,j-normdata[[i,j]]/2},
{i+normdata[[i,j]]/2,j+normdata[[i,j]]/2}
], data[[i,j]]]
},
{i,n}, {j,m}
]
];

If[OptionValue[AxesLabel]=!=None,
plot[[1]]=Join[
plot[[1]],
Table[
Text[OptionValue[AxesLabel][[1,i]],{i,m+3/4},{0,-2}],
{i,n}
],
Table[
Text[Reverse[OptionValue[AxesLabel][[2]]][[j]],{0,j},{1,0}],
{j,m}
]
];
];
plot
]
]];


(* Not exposed by intention. *)
PauliLabels[nq_] := Table[
StringJoin@@(Reverse[IntegerDigits[i,4,nq]]/.{
0->"I",1->"X",2->"Y",3->"Z"
}),
{i,0,4^nq-1}
];


ChannelHintonPlot[chan_]:=With[{
mtx=First@Super[chan,Basis->"Pauli"],
nqIn=Log2 @ InputDim@ chan,
nqOut=Log2 @ OutputDim @ chan
},
HintonPlot[mtx,AxesLabel->PauliLabels/@{nqOut,nqIn}]
]


(* ::Subsection::Closed:: *)
(*Bloch Plots*)

Expand Down Expand Up @@ -459,7 +519,7 @@


Protect[ComplexMatrixPlot,BlockForm,MatrixListForm];
Protect[BlochPlot,BlochPlot2D,ListBlochPlot2D,BlochPlotColors,BlochPlotEndPoints,BlochPlotJoined,BlochPlotLabels];
Protect[BlochPlot,BlochPlot2D,ListBlochPlot2D,BlochPlotColors,BlochPlotEndPoints,BlochPlotJoined,BlochPlotLabels,HintonPlot];
Protect[EigensystemForm];
Protect[FourierListPlot];

Expand Down
Binary file added src/pylink/__init__.pyc
Binary file not shown.
Loading