Giter Site home page Giter Site logo

quantum-utils-mathematica's People

Contributors

cgranade avatar chriseclectic avatar ihincks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quantum-utils-mathematica's Issues

False negatives from CompletelyPositiveQ

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

Feature: version number

Somehow tie the git version tag and/or commit SHA to a variable stored in $FrontEnd or something.

Unit Testing Framework

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
]

Interaction Frame Operator

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?

Parallelism

Some things should eventually have parallelization options:

  • GRAPE
    • Over Distributions
    • Over initial guesses
    • Over the time sliced unitary list
  • QSim
    • Over Distribitions (should be easy)
    • Over time slices (would not fit well with current implementation)

Basis ordering for Choi/Chi on multiple qubits

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]: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,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,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}}

CGate returns Null for empty controls.

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.

Problem with RunAllTests[]

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.
screen shot 2018-08-14 at 2 34 39 pm

Could you help me fix these errors?

Thanks,
Ki.

Error after installation

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.

Planar Rotation Decompositions

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.

Rewrite installer

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.