quantumutils / quantum-utils-mathematica Goto Github PK
View Code? Open in Web Editor NEWQuantumUtils for Mathematica is a software library for quantum information scientists.
License: Other
QuantumUtils for Mathematica is a software library for quantum information scientists.
License: Other
For some completely positive channels, it seems that CompletelyPositiveQ
fails to correctly return True
. In particular, for a qubit amplitude damping channel, CompletelyPositiveQ
returns False
if the strength is left as a symbol, even if enough $Assumptions
are provided such that FullSimplify
and Reduce
give that all eigenvalues are nonnegative.
In[1]:= Needs["QuantumChannel`"]
In[2]:= $Assumptions = And[
$Assumptions,
1 >= p >= 0
];
In[3]:= AmplitudeDampingChannel[p_] = FullSimplify@Super@Kraus[{( {
{1, 0},
{0, Sqrt[1 - p]}
} ), ( {
{0, Sqrt[p]},
{0, 0}
} )}]
Out[3]= "Super"[{{1, 0, 0, p}, {0, Sqrt[1 - p], 0, 0}, {0, 0, Sqrt[
1 - p], 0}, {0, 0, 0, 1 - p}}, "<params>"]
In[4]:= AmplitudeDampingChannel[0] // CompletelyPositiveQ
Out[4]= True
In[5]:= AmplitudeDampingChannel[1] // CompletelyPositiveQ
Out[5]= True
In[6]:= choieigs =
Choi[AmplitudeDampingChannel[p]] // FullSimplify // First //
Eigenvalues
Out[6]= {0, 0, 2 - p, p}
In[7]:= Simplify[Reduce[choieigs >= 0]]
Out[7]= True
In[8]:= CompletelyPositiveQ[AmplitudeDampingChannel[p],
Simplify -> FullSimplify]
Out[8]= False
In[9]:= CompletelyPositiveQ[AmplitudeDampingChannel[1]]
Out[9]= True
It appears that the problem goes back to the builtin function PositiveSemidefiniteMatrixQ
:
In[10]:= PositiveSemidefiniteMatrixQ[
First@Choi@AmplitudeDampingChannel[p]]
Out[10]= False
In[11]:= AllQ[# >= 0 &,
Eigenvalues[First@Choi@AmplitudeDampingChannel[p]]]
Out[11]= 2 - p >= 0 && p >= 0
In[12]:= Simplify[%]
Out[12]= True
Somehow tie the git version tag and/or commit SHA to a variable stored in $FrontEnd or something.
Since some unit tests (eg. Quantum Channels) are as many lines of code as the actual package, it might be a good idea to move the unit testing frame work and unit tests to a separate package which isn't loaded by default. The package could then be loaded by a specific function to run the unit tests, and then be cleared.
Eg. Something like:
RunUnitTests[]:=Block[{results},
Needs["UnitTests`"];
results= (function from UnitTests that returns the test results);
Remove["UnitTests`*"];
results
]
I find myself using this snippet of code a bunch in my notebooks
RotatingFrameOperator[BaseHamiltonian_, ReferenceHamiltonian_, ScaledTime_] :=
MatrixExp[I * ReferenceHamiltonian * ScaledTime] . BaseHamiltonian .
MatrixExp[-I * ReferenceHamiltonian * ScaledTime] - ReferenceHamiltonian
However, when I want to move it, I resort to copypasta. Is something like this already in quantum utils? If so, where?
Some things should eventually have parallelization options:
The concurrence function is giving incorrect values for symbolic matrices, but still is correct numerically.
There seems to be a subtle issue with how Basis interacts with multipartite systems that affects how Chi
/Choi
and Super
represent two-qubit operators. In particular, Basis โ "Pauli"
and Basis โ Basis["Pauli", 2]
lead different re-orderings of the Pauli basis when used as options to Choi
and Super
:
In[1]:= Needs["QuantumChannel`"];
In[2]:=Needs["Tensor`"];
In[3]:= First@Super[Unitary@TP@XX,Basis->"Pauli"]-First@Super[Unitary@TP@XX,Basis->Basis["Pauli",2]]
Out[3]= {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,-2,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,-2,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,-2,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,-2,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}
In[4]:= First@Chi[Unitary@TP@XX,Basis->"Pauli"]-First@Chi[Unitary@TP@XX,Basis->Basis["Pauli",2]]
Out[4]= {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,-4,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}
Digging into the issue, it seems as though it originates with BasisMatrixCol
, but I'm not sure how to fix it:
In[5]:= Tensor`Private`BasisMatrixCol[Basis["Pauli"],2]-Tensor`Private`BasisMatrixCol[Basis["Pauli",2]]
Out[5]= {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,I/2,1/2,0,-(I/2),0,0,1/2,1/2,0,0,I/2,0,1/2,-(I/2),0},{-(1/2),0,0,1/2,0,1/2,1/2,0,0,1/2,-(1/2),0,1/2,0,0,1/2},{0,-(I/2),-(1/2),0,I/2,0,0,-(1/2),-(1/2),0,0,-(I/2),0,-(1/2),I/2,0},{1/2,0,0,-(1/2),0,-(1/2),-(1/2),0,0,-(1/2),1/2,0,-(1/2),0,0,-(1/2)},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{1/2,0,0,1/2,0,1/2,-(1/2),0,0,-(1/2),-(1/2),0,1/2,0,0,-(1/2)},{0,1/2,I/2,0,1/2,0,0,-(I/2),-(I/2),0,0,-(1/2),0,I/2,-(1/2),0},{-(1/2),0,0,-(1/2),0,-(1/2),1/2,0,0,1/2,1/2,0,-(1/2),0,0,1/2},{0,-(1/2),-(I/2),0,-(1/2),0,0,I/2,I/2,0,0,1/2,0,-(I/2),1/2,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}
Using CGate
with an empty list for the controls argument returns Null
, as in the following example:
In[2]:= CGate[{2, 2}, TP@X, 1, {}] // FullForm
Out[2]//FullForm= Null
I think that this should either return an uncontrolled gate acting on the target register, or should produce a message and an unevaluated result.
Hello,
I use Mathematica 11.3.0 on my iMac with macOS 10.12.6.
After installation following instructions, I check if the installed packages are running correctly by running the commands;
Needs["QUTesting`"];
RunAllTests[]
After running the commands, I found the following errors.
Could you help me fix these errors?
Thanks,
Ki.
Hello,
i installed correctly the package on Ubuntu 20.04 with Mathematica 12.1. But when i try to run the test it returns:
Needs["QUTesting`"];
AssignUsage::nousg: No usage message in UsageData[] for symbol TestResults found; using a blank message instead.
AssignUsage::nousg: No usage message in UsageData[] for symbol RunAllTests found; using a blank message instead.
RunAllTests[]
Needs::string: String expected at position 2 in Needs[PredicatesTests`,FileNameJoin[{QUDevTools`Private`TestingPath,PredicatesTests.m}]].
Needs::string: String expected at position 2 in Needs[TensorTests`,FileNameJoin[{QUDevTools`Private`TestingPath,TensorTests.m}]].
Needs::string: String expected at position 2 in Needs[QuantumSystemsTests`,FileNameJoin[{QUDevTools`Private`TestingPath,QuantumSystemsTests.m}]].
General::stop: Further output of Needs::string will be suppressed during this calculation.
0 of 7 unit tests passed.
A few people have complained, including me, about some freezing issues that have come up in Mathematica 11. I have posted the problem here: http://mathematica.stackexchange.com/questions/141482/mathematica-freezes-often-when-using-third-party-library
Would it be worthwhile to write something to decompose a matrix into planar rotations? This would allow you to express a matrix
X \in SU(n)
as a product of a diagonal matrix and a set of unitary rotation matrices.
As it stands, the installer sort of pollutes the Applications folder. It would be possible to modify the init.m file with a line that adds the src folder to the path everytime Mathematica starts. I am aware of no other way to acheive this that does not require the user to manually run a command at the beginnig of a session. This method has the down side of having to automatically modify a file that some users may modify themselves.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.