packages feed

newsynth 0.3.0.5 → 0.4.0.0

raw patch · 7 files changed

+32/−26 lines, 7 files

Files

ChangeLog view
@@ -1,5 +1,11 @@ ChangeLog +v0.4.0.0 2019/06/28+	(2019/06/27) PS1 - fixed a compiler warning.+	(2019/06/27) PS1 - use type class synonym to fix compiler warnings+	about simplifiable class constraints. This changed the type class+	assumptions of some API functions.+ v0.3.0.5 2019/02/23 	(2019/02/23) PS1 - updated package dependencies to work with Stack. 	(2019/02/22) PS1 - removed some unused LANGUAGE directives,
Quantum/Synthesis/Clifford.hs view
@@ -291,7 +291,7 @@ cinv 2 1 2 = (1,1,0,2) cinv 2 1 3 = (2,0,1,6) --- | 'tconj2' /a/ /b/ returns (/K/, /c/, /d/) such that+-- | 'tconj' /a/ /b/ returns (/K/, /c/, /d/) such that --  -- * /E/[sup /a/]/X/[sup /b/]/T/ = /K//T//X/[sup /b/]/S/[sup /c/]ω[sup /d/]. tconj :: Int -> Int -> (Axis, Int, Int)
Quantum/Synthesis/CliffordT.hs view
@@ -163,7 +163,7 @@                  (0,     omega)  -- | Convert a symbolic gate to the corresponding operator.-u2_of_gate :: (RootHalfRing a, ComplexRing a) => Gate -> U2 a+u2_of_gate :: (RootHalfRing a, ComplexRing a, OmegaRing a) => Gate -> U2 a u2_of_gate X = u2_X u2_of_gate Y = u2_Y u2_of_gate Z = u2_Z@@ -173,7 +173,7 @@ u2_of_gate E = u2_E u2_of_gate W = u2_W -instance (RootHalfRing a, ComplexRing a) => FromGates (U2 a) where+instance (RootHalfRing a, ComplexRing a, OmegaRing a) => FromGates (U2 a) where   from_gates = product' . map u2_of_gate where     product' = foldl' (*) 1 
Quantum/Synthesis/GridSynth.hs view
@@ -15,7 +15,7 @@ module Quantum.Synthesis.GridSynth where  import Quantum.Synthesis.Ring-import Quantum.Synthesis.Ring.FixedPrec+import Quantum.Synthesis.Ring.FixedPrec() import Quantum.Synthesis.Matrix import Quantum.Synthesis.CliffordT import Quantum.Synthesis.SymReal
Quantum/Synthesis/MultiQubitSynthesis.hs view
@@ -118,7 +118,7 @@     | otherwise = 0  -- | Convert a symbolic one- or two-level operator into a matrix.-matrix_of_twolevel :: (ComplexRing a, RootHalfRing a, Nat n) => TwoLevel -> Matrix n n a+matrix_of_twolevel :: (OmegaRing a, RootHalfRing a, Nat n) => TwoLevel -> Matrix n n a matrix_of_twolevel (TL_X i j) = twolevel_matrix (0,1) (1,0) i j matrix_of_twolevel (TL_H i j) = twolevel_matrix (s,s) (s,-s) i j   where s = roothalf@@ -128,7 +128,7 @@ -- | Convert a list of symbolic one- or two-level operators into a -- matrix. Note that the operators are to be applied right-to-left, -- exactly as in mathematical notation.-matrix_of_twolevels :: (ComplexRing a, RootHalfRing a, Nat n) => [TwoLevel] -> Matrix n n a+matrix_of_twolevels :: (OmegaRing a, RootHalfRing a, Nat n) => [TwoLevel] -> Matrix n n a matrix_of_twolevels gs = foldl' (*) 1 [ matrix_of_twolevel g | g <- gs ]  -- ----------------------------------------------------------------------
Quantum/Synthesis/Ring.hs view
@@ -6,6 +6,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE IncoherentInstances #-} {-# LANGUAGE BangPatterns #-}+{-# LANGUAGE ConstraintKinds #-}  -- | This module provides type classes for rings. It also provides -- several specific instances of rings, such as the ring ℤ₂ of@@ -31,8 +32,7 @@ -- don't make sense (or are inconvenient to define), we set 'abs' /x/ -- = /x/ and 'signum' /x/ = 1. -class (Num a) => Ring a-instance (Num a) => Ring a+type Ring a = (Num a)  -- ---------------------------------------------------------------------- -- * Rings with particular elements@@ -143,6 +143,9 @@ instance (Ring a, RealFloat a) => ComplexRing (Complex a) where   i = 0 :+ 1 +instance (RealFloat a, RootHalfRing a) => OmegaRing (Complex a) where+  omega = roothalf * (1 + i)+ -- ---------------------------------------------------------------------- -- ** Rings with ω @@ -152,8 +155,8 @@   -- | The square root of /i/.   omega :: a   -instance (ComplexRing a, RootHalfRing a) => OmegaRing a where-  omega = roothalf * (1 + i)+-- instance (Ring a, ComplexRing a, RootHalfRing a) => OmegaRing a where+--   omega = roothalf * (1 + i)  -- ---------------------------------------------------------------------- -- * Rings with particular automorphisms@@ -455,6 +458,9 @@ instance (Eq a, ComplexRing a) => ComplexRing (RootTwo a) where   i = RootTwo i 0 +instance (Eq a, ComplexRing a, HalfRing a) => OmegaRing (RootTwo a) where+  omega = roothalf * (1 + i)+ instance (Adjoint a) => Adjoint (RootTwo a) where     adj (RootTwo a b) = RootTwo (adj a) (adj b) @@ -566,6 +572,9 @@ instance (Ring a) => ComplexRing (Cplx a) where   i = Cplx 0 1 +instance (Ring a, RootHalfRing a) => OmegaRing (Cplx a) where        +  omega = roothalf * (1 + i)+ instance (HalfRing a) => HalfRing (Cplx a) where   half = Cplx half 0   fromDyadic x = Cplx (fromDyadic x) 0@@ -733,12 +742,7 @@       c = norm z       d = norm w --- This is an undecidable instance, but is not overlapping. Note: we--- do not declare OmegaRing (Omega a), because this usually follows--- from (ComplexRing a, RootHalfRing a). But there are some--- exceptions, such as OmegaRing (Omega Z2) and OmegaRing (Omega--- Integer).-instance OmegaRing (Omega Z2) where+instance (Ring a) => OmegaRing (Omega a) where   omega = Omega 0 0 1 0  -- ----------------------------------------------------------------------@@ -761,10 +765,6 @@ fromZOmega :: (OmegaRing a) => ZOmega -> a fromZOmega (Omega a b c d) = fromInteger a * omega^3 + fromInteger b * omega^2 + fromInteger c * omega + fromInteger d --- This is an undecidable instance, but is not overlapping.-instance OmegaRing ZOmega where-  omega = Omega 0 0 1 0- -- | Inverse of the embedding ℤ[√2] → ℤ[ω]. Note that ℤ[√2] = ℤ[ω] ∩ -- ℝ. This function takes an element of ℤ[ω] that is real, and -- converts it to an element of ℤ[√2]. It throws an error if the input@@ -783,8 +783,8 @@ type DOmega = Omega Dyadic  -- | The unique ring homomorphism from [bold D][ω] to any ring containing--- 1\/√2 and /i/. This exists because [bold D][ω] is the free such ring.-fromDOmega :: (RootHalfRing a, ComplexRing a) => DOmega -> a+-- ω and 1\/2. This exists because [bold D][ω] is the free such ring.+fromDOmega :: (OmegaRing a, HalfRing a) => DOmega -> a fromDOmega (Omega a b c d) = fromDyadic a * omega^3 + fromDyadic b * omega^2 + fromDyadic c * omega + fromDyadic d  -- This is an overlapping instance. It is nicer to show an element of@@ -805,9 +805,9 @@ type QOmega = Omega Rationals  -- | The unique ring homomorphism from ℚ[ω] to any ring containing the--- rational numbers, √2, and /i/. This exists because ℚ[ω] is the free+-- rational numbers and ω. This exists because ℚ[ω] is the free -- such ring.-fromQOmega :: (RootHalfRing a, ComplexRing a, Fractional a) => QOmega -> a+fromQOmega :: (OmegaRing a, Fractional a) => QOmega -> a fromQOmega (Omega a b c d) = fromRationals a * omega^3 + fromRationals b * omega^2 + fromRationals c * omega + fromRationals d  -- ----------------------------------------------------------------------
newsynth.cabal view
@@ -7,7 +7,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.3.0.5+version:             0.4.0.0  -- A short (one-line) description of the package. synopsis:            Exact and approximate synthesis of quantum circuits@@ -91,7 +91,7 @@   -- profiling enabled.   ghc-prof-options: -  ghc-options:  -fno-warn-simplifiable-class-constraints+  ghc-options:    executable gridsynth   -- .hs or .lhs file containing the Main module.