QuantumInformation.jl—A Julia package for numerical computation in quantum information theory

Numerical investigations are an important research tool in quantum information theory. There already exists a wide range of computational tools for quantum information theory implemented in various programming languages. However, there is little effort in implementing this kind of tools in the Julia language. Julia is a modern programming language designed for numerical computation with excellent support for vector and matrix algebra, extended type system that allows for implementation of elegant application interfaces and support for parallel and distributed computing. QuantumInformation.jl is a new quantum information theory library implemented in Julia that provides functions for creating and analyzing quantum states, and for creating quantum operations in various representations. An additional feature of the library is a collection of functions for sampling random quantum states and operations such as unitary operations and generic quantum channels.


Introduction
Numerical investigations are prevalent in quantum information theory.Numerical experiments can be used to find counter examples for theorems, to test hypotheses or to gain insight about quantum objects and operations.
The variety of software that supports investigations in quantum information theory is very large.The purpose of QI.jl library is to provide functions to create quantum states, manipulate them with quantum channels, calculate functionals on these objects and sample them randomly from various distributions.QI.jl package is available on-line at https://github.com/ZKSI/QI.jl.It is published under GNU General Public License v3.0.

Related work
A comprehensive collection of software related to quantum mechanics, computation and information can be found at Quantiki [1]-an on-line resource for quantum information research community.There exist several notable libraries aimed at numerical and symbolic computation for quantum information theory.Two Mathemetica libraries-QI [2] and TRQS [3]-were an inspiration for creation of QI.jl.Additionally the QUANTUM [4] library was implemented in Mathematica.A library called FEYNMAN implemented in Maple described in a series of papers [5][6][7][8][9] provides a wide variety of functions.The above-mentioned libraries rely on non-free software and therefore their use can be very limited as use of this software requires acquiring expensive licenses and July 2, 2018 1/24 arXiv:1806.11464v1[quant-ph] 29 Jun 2018 its source code cannot be studied by researchers.Therefore any results obtained using this software rely on trust to the companies that produced it.Hence non-free software creates barriers for reproducibility of scientific results [10].
A widely celebrated and used framework QuTip [11] was written in Python.Python posses many scientific computation libraries.It is free software and is widely used for scientific computation.Nevertheless as a general purpose programming language has its limits.Implementations of multidimensional arrays and linear algebra routines are provided by NumPy [12] and SciPy [13] respectively.Unfortunately, due to low efficiency of Python, many of the underling functions are implemented in C or Fortran programming languages.Therefore study and development of these routines is difficult and requires familiarity with these low-level languages.
Julia [14], being a high-level just-in-time compiled language, is very efficient and therefore extremely useful for scientific computing.There are several libraries related to quantum mechanics and quantum information written in Julia.Those are: QuantumInfo.jl[15], Quantum.jl[16] and a collection of packages developed as a part of JuliaQuantum project [17].Unfortunately these development efforts stalled a couple of years ago.JuliaQuantum project is very ambitious but its scope seems to be too large to be implemented fully in a relatively short amount of time.The only package whose development was successful is QuantumOptics.jl-aJulia framework for simulating open quantum systems [18].Yet the applicability scope of this package is different than the one of QI.jl.

Design principles
Our goal while designing QI.jl library was to follow the principles presented in the book "Geometry of Quantum States" [19].We work with column vectors representing kets and row vectors representing bras.We fix our basis to the computational one.Density matrices and quantum channels are represented as two dimensional arrays in the same fixed basis.This approach allows us to obtain low level of complexity of our code, high flexibility and excellent computational efficiency.The design choices were highly motivated by the properties of the language in which the our library was implemented, namely Julia [20].
Julia is a novel scientific programming language mainly influenced by Python, Matlab and Lisp programming languages.The one of the main concepts widely used in Julia is multiple dispatch i.e. an ability to dispatch function calls to different methods depending on the types of all function arguments.The multiple dispatch mechanism together with a simple yet flexible type system allows to build clean and easy to use programming interfaces.Julia is just in time compiled to machine code using LLVM [21] therefore, despite being a high level programming language, it can reach computation efficiency similar to C or Fortran.Julia natively supports parallel and distributed computing techniques.Therefore it is easy to write programs for Monte-Carlo sampling in Julia.
In Julia arrays are first class objects [22] and linear algebra operations are integrated into the language standard library.The array system in Julia is designed in a way that minimizes the amount of memory copying operations during transformations of arrays.Julia supports various representations of vectors and matrices.For these reasons a design decision was made not to create library specific types but to rely on built-in standard library abstract array types.
Julia is a project that undergoes large changes during its development.The language has significantly changed since its conception.It is expected that until version 1.0 is reached the language syntax and semantics can change.Therefore for current information about the language the reader should consult the language documentation on-line [14].The QI.jl library is implemented in version 0.6 of Julia.A port to Julia version 0.7 will be done after its release, when packages such as Convex.jlwill also be ported to the new version.

Organization of the paper
In the section Linear algebra in Julia, we introduce a brief description of the usage of Julia in the area of linear algebra.Next, in the section States and channels, we introduce the notions of quantum states and quantum channels.Next, we discuss how we implement these concepts in Julia.Subsequently, the section Functionals focuses on functionals related with quantum information processing, i.e. trace norm, diamond norm, entropy, fidelity or the PPT criterion.Afterward, we show the usage of QI.jl to modeling and application of the quantum measurements.The section Random quantum objects introduces probabilistic measures on quatum states and channels and their implementation in Julia.Additionally, we introduce some common random matrix ensembles.Finally, in the section Conclusions and future work the final remarks are presented and we outline possible future work.

Linear algebra in Julia
A basic construction of vector in Julia creates a full one-index array containing elements of a number type as presented below.
A transposition of a column vector returns an object of type RowVector as shown below julia> xt = transpose(x) 1×2 RowVector{Complex{Float64},Array{Complex{Float64},1}}: 0.0+0.0im0.0+1.0im While a Hermitian conjugate of the same vector returns a RowVector parametrized by the type ConjArray: Values of variables xt and xc are views of the value of variable x.The column and row vectors behave like bra and kets, for example xc*x denotes the inner product of 'bra' xc and 'ket' x, while x*xc denotes its outer product resulting in a two-index array.
The linear algebra library in Julia provides standard operations on matrices and vectors that are designed to take into the account types of objects.

States and channels
In this and the following sections we will denote complex Euclidean spaces C d with X , Y, Z etc.When needed the dimension of a space X will be denoted dim(X ).The set of matrices transforming vectors from X to Y will be denoted L(X , Y).For simplicity we will write L(X ) ≡ L(X , X ).

States
The inner product of |φ , |ψ ∈ X is denoted by ψ|φ and the norm is defined as The form |ψ φ| ∈ L(X , Y) denotes outer product of |ψ ∈ Y and φ| ∈ X .

Channels
Physical transformations of quantum states into quantum states are called quantum channels i.e. linear Completely Positive Trace Preserving (CP-TP) transformations.Probabilistic transformations of quantum states are called quantum operations and mathematically they are defined as linear Completely Positive Trace Non-increasing (CP-TNI) maps.For the sake of simplicity we will refer to both CP-TP and CP-TNI maps as quantum channels when it will not cause confusion.
More formally this can be stated as follows [23].First, we introduce the notion of superoperator as a linear mapping acting on linear operators L(X ) and transforming them into operators acting on L(Y).The set of all such mapping will be denoted by T(X , Y) and T(X ) ≡ T(X , X ).In mathematical terms, a quantum channel is a superoperator ) and uniquely extended from linearity.
According to Kraus' theorem, any completely positive trace-preserving (CPTP) map Φ can always be written as where r is the rank of superoperator Φ.Another way to represent the quantum channel is based on Choi-Jamiołkowski isomorphism.Consider mapping The action of a superoperator in the Choi representation, also called dynamical matrix of Φ, is given by Φ The natural representation of a quantum channel T(X , Y) is a mapping for all ρ ∈ L(X ).
In QI.jl states and channels are always represented in the computational basis therefore channels are stored in the memory as either vectors of matrices in case of Kraus operators or matrices in other cases.In QI.jl quantum channels are represented by a set of types deriving from an abstract type AbstractQuantumOperation{T} where type parameter T should inherit from AbstractMatrix{<:Number}.Every type inheriting from AbstractQuantumOperation{T} should contain fields idim and odim representing the dimension of input and output space of the quantum channel.
Two special types of channels are implemented: UnitaryChannel and IdentityChannel that can transform ket vectors into ket vectors.

Constructors
Channel objects can be constructed from matrices that represents them.As shown in the following listing

julia> iscptp(Φ) true
There are no checks whether a matrix represents a valid CP-TP or CP-TNI map, because this kind of verification is costly and requires potentially expensive numerical computation.Function such as iscptp(), and iscptni() are provided to test properties of supposed quantum channel or quantum operation.
Due to the fact that Julia can construct objects using conversion (see below) one object inheriting from AbstractQuantumOperation{T} abstract type can be constructed from another object inheriting from the same abstract type.

Conversion
Conversions between all quantum channel types are implemented.The users are not limited by any single channel representation and can transform between representations they finds the most efficient or suitable for their purpose.

Application
Channels can act on pure and mixed states represented by vectors and matrices.Channels are callable and therefore mimic application of a function on a quantum state.

Fidelity and superfidelity
Fidelity is a measure of distance of quantum states.It is an example of a distance measure which is not a metric on the space of quantum states.The fidelity of two quantum states ρ, σ ∈ L(X ) is given by July 2, 2018 9/24 Superfidelity is an upper bound on the fidelity of two quantum states It is defined by julia> superfidelity(ρ, σ) 0.9330127018922193 + 0.0im

Diamond norm
In order to introduce the diamond norm, we first introduce the notion of the induced trace norm.Given Φ ∈ T(X , Y) we define its induced trace norm as Diamond norm and diamond distance are implemented using Convex.jlJulia package [24].

Distinguishability between two quantum states
One of the measure of distinguishability between two quantum states is the qauntum relative entropy, called also Kullback-Leibler divergence, defined as Another type of measure of distinguishability between two quantum state is quantum Jensen-Shannon divergence given by QJS(ρ, σ) The Bures distance defines an infinitesimal distance between quantum states, and it is defined as

Quantum entanglement
One of the entanglement measure is negativity defined as Positive partial transpose (the Peres-Horodecki criterion) is a necessary condition of separability of the joint state ρ AB .According PPT criterion, if ρ T B has non negative eigenvalues, then ρ AB is separable.

Measurements
Measurements are modeled in two ways: • as Positive Operator Valued Measure (POVM) based, • measurement with post-selection.
In both cases a measurement is treated as a special case of a quantum channel (operation).

Positive Operator Valued Measure measurement
A POVM measurement is defined as follows, let a mapping from a finite alphabet of measurement outcomes to the set of linear positive operators µ : Γ → P(X ) be given, if ξ∈Γ µ(ξ) = I X then µ is a POVM measurement.Set of positive semi-definite linear operators is defined as P(X ) = {X ∈ L(X ) : ψ| X |ψ ≥ 0 for all |ψ ∈ X }.POVM measurement models the situation where a quantum object is destroyed during the measurement process and quantum state after the measurement does not exists.

Measurement with post-selection
When a quantum system after being measured is not destroyed one can be interested in its state after the measurement.This state depends on the measurement outcome.In this case the measurement process is defined in the following way.

Random quantum objects
In this section we present the implementation of the sub-package RandomMatrices.The justification for including these functionalities in our package is twofold.First, the application of random matrix theory (RMT) in quantum information is a blooming field of research with a plethora of interesting results [25][26][27][28][29][30][31][32][33][34].Hence, it is useful to have readily available implementations of known algorithms of generating random matrices.Secondly, when performing numerical investigations, we often need "generic" inputs.Generating random matrices with a known distribution is one of the ways to obtain such generic inputs.

Circular ensembles
Circular ensembles are measures on the space of unitary matrices.There are three main circular ensembles.Each of this ensembles has an associated Dyson index β [37] • Circular orthogonal ensemble (COE), β = 1.
They can be characterized as follows.The CUE is simply the Haar measure on the unitary group.Now, if U is and element of CUE then U T U is an element of COE and U R U is an element CSE.Here As can be seen the sampling of Haar unitaries is at the core of sampling these ensembles.
Hence, we will focus on them in the remainder of this section.
There are several possible approaches to generating random unitary matrices according to that Haar measure.One way is to consider known parametrizations of unitary matrices, such as the Euler [38] or Jarlskog [39] ones.Sampling these parameters from appropriate distributions yields a Haar random unitary.The downside is the long computation time, especially for large matrices, as this involves a lot of

Conclusions and future work
Numerical investigations are important part of research in many fields of science, especially in quantum information.The Julia language is a modern programming language, which provides strong support for linear algebra and posses an extensive type system.One of the important feature of Julia is high performance approaching statically-compiled languages like C or Fortran.Those were the reasons why we created a QI.jl library in Julia.
Future work will consists of optimization of numerical code, extending the type system, developing further functionals, better integration with Convex.jlpackage.Additional work will also include parallelization of the code and support for writing quantum circuits in more intuitive manner.

Fig 1 .
Fig 1.Schematic depiction of the teleportation protocol.Squiggly line represents the maximally entangled state, and box Φ represents the noise operator.
By |ψ ∈ X we denote a normed column vector.Notice that any |ψ can be expressed as |ψ = By ψ| the row vector dual to |ψ is denoted.It means that |ψ = ψ| † , where the symbol † denotes the Hermitian conjugation.