Coder Social home page Coder Social logo

unofficialjuliamirror / diracnotation.jl-e655511c-e992-5001-b8e2-2048e6aa15e9 Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 80 KB

Last mirrored from https://github.com/goropikari/DiracNotation.jl.git on 2019-11-18T20:28:17.677-05:00 by @UnofficialJuliaMirrorBot via Travis job 481.9 , triggered by Travis cron job on branch "master"

License: Other

Julia 100.00%

diracnotation.jl-e655511c-e992-5001-b8e2-2048e6aa15e9's Introduction

DiracNotation

Build Status Build status Coverage Status codecov.io

By using this package, matrix representation is changed into Dirac notation. This package supports QuantumOptics.jl

mathjax

Installation

using Pkg
Pkg.add("DiracNotation")

Usage

Simple example

julia> using DiracNotation, LinearAlgebra, Random; Random.seed!(0);

julia> ket = normalize(rand(4)); bra = ket';

julia> dirac(ket) # if the dimension of state is a power of 2 ( 2^n ), it is interpreted as n-qubit system.
|ψ⟩ = 0.65825|00+0.727547|01+0.131519|10+0.141719|11⟩

julia> dirac(bra)
⟨ψ| = 0.6582500|+0.72754701|+0.13151910|+0.14171911|

julia> DiracNotation.set_properties(precision=3)

julia> op = rand(2,2);

julia> leftdims = [2];

julia> rightdims = [2];

julia> dirac(op, leftdims, rightdims)
ρ = 0.279|0⟩⟨0|+0.0423|0⟩⟨1|+0.203|1⟩⟨0|+0.0683|1⟩⟨1|

julia> DiracNotation.set_properties(numhead=10, displayall=false) # display numhead terms

julia> op = rand(6,4);

# if the system is not a qubits system, you have to specify the dimensions explicitly.
julia> dirac(op, [2,3], [2,2])
ρ = 0.362|00⟩⟨00|+0.167|00⟩⟨01|+0.469|00⟩⟨10|+0.0668|00⟩⟨11|+0.973|01⟩⟨00|+0.655|01⟩⟨01|+0.0624|01⟩⟨10|+0.157|01⟩⟨11|+0.586|02⟩⟨00|+0.576|02⟩⟨01| +...

Display a state with arbitrary state name.

julia> dirac(ket, "ϕ")
|ϕ⟩ = 0.658|00+0.728|01+0.132|10+0.142|11⟩

julia> dirac(op, [2,3], [2,2], "A")
A = 0.362|00⟩⟨00|+0.167|00⟩⟨01|+0.469|00⟩⟨10|+0.0668|00⟩⟨11|+0.973|01⟩⟨00|+0.655|01⟩⟨01|+0.0624|01⟩⟨10|+0.157|01⟩⟨11|+0.586|02⟩⟨00|+0.576|02⟩⟨01| +...

Restore to original style

julia> DiracNotation.reset_properties()

julia> dirac(ket, "ϕ")
|ϕ⟩ = 0.65825|00+0.727547|01+0.131519|10+0.141719|11⟩

julia> dirac(op, [2,3], [2,2], "A")
A = 0.361828|00⟩⟨00|+0.167036|00⟩⟨01|+0.469304|00⟩⟨10|+0.0668464|00⟩⟨11|+0.973216|01⟩⟨00|+0.655448|01⟩⟨01|+0.0623676|01⟩⟨10|+0.156637|01⟩⟨11|+0.585812|02⟩⟨00|+0.575887|02⟩⟨01|+0.353129|02⟩⟨10|+0.605297|02⟩⟨11|+0.539289|10⟩⟨00|+0.868279|10⟩⟨01|+0.767602|10⟩⟨10|+0.135745|10⟩⟨11|+0.260036|11⟩⟨00|+0.9678|11⟩⟨01|+0.043141|11⟩⟨10|+0.838118|11⟩⟨11|+0.910047|12⟩⟨00|+0.76769|12⟩⟨01|+0.267985|12⟩⟨10|+0.914712|12⟩⟨11|

Example on IJulia

On IJulia, Dirac notation is rendered as MathJax.

diracnotation.jl-e655511c-e992-5001-b8e2-2048e6aa15e9's People

Contributors

goropikari avatar

Watchers

James Cloos avatar

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.