-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add "tket2.qsystem.random" extension (#779)
Closes: #748 Apart from the signatures in the reporting issue, I had to include an additional function to discard the linear context. ```rust /// fn delete_rng_context(RNGContext) -> () DeleteContext, ``` Appreciate other ideas to discard the context.
- Loading branch information
Showing
6 changed files
with
638 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
354 changes: 354 additions & 0 deletions
354
tket2-exts/src/tket2_exts/data/tket2/qsystem/random.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,354 @@ | ||
{ | ||
"version": "0.1.0", | ||
"name": "tket2.qsystem.random", | ||
"runtime_reqs": [ | ||
"prelude" | ||
], | ||
"types": { | ||
"context": { | ||
"extension": "tket2.qsystem.random", | ||
"name": "context", | ||
"params": [ | ||
{ | ||
"tp": "Type", | ||
"b": "A" | ||
} | ||
], | ||
"description": "The linear RNG context type", | ||
"bound": { | ||
"b": "Explicit", | ||
"bound": "A" | ||
} | ||
} | ||
}, | ||
"values": {}, | ||
"operations": { | ||
"DeleteRNGContext": { | ||
"extension": "tket2.qsystem.random", | ||
"name": "DeleteRNGContext", | ||
"description": "Discard the given RNG context.", | ||
"signature": { | ||
"params": [], | ||
"body": { | ||
"input": [ | ||
{ | ||
"t": "Opaque", | ||
"extension": "tket2.qsystem.random", | ||
"id": "context", | ||
"args": [ | ||
{ | ||
"tya": "Type", | ||
"ty": { | ||
"t": "Opaque", | ||
"extension": "arithmetic.int.types", | ||
"id": "int", | ||
"args": [ | ||
{ | ||
"tya": "BoundedNat", | ||
"n": 6 | ||
} | ||
], | ||
"bound": "C" | ||
} | ||
} | ||
], | ||
"bound": "A" | ||
} | ||
], | ||
"output": [], | ||
"runtime_reqs": [] | ||
} | ||
}, | ||
"binary": false | ||
}, | ||
"NewRNGContext": { | ||
"extension": "tket2.qsystem.random", | ||
"name": "NewRNGContext", | ||
"description": "Seed the RNG and return a new RNG context. Required before using other RNG ops, can be called only once.", | ||
"signature": { | ||
"params": [], | ||
"body": { | ||
"input": [ | ||
{ | ||
"t": "Opaque", | ||
"extension": "arithmetic.int.types", | ||
"id": "int", | ||
"args": [ | ||
{ | ||
"tya": "BoundedNat", | ||
"n": 6 | ||
} | ||
], | ||
"bound": "C" | ||
} | ||
], | ||
"output": [ | ||
{ | ||
"t": "Sum", | ||
"s": "General", | ||
"rows": [ | ||
[], | ||
[ | ||
{ | ||
"t": "Opaque", | ||
"extension": "tket2.qsystem.random", | ||
"id": "context", | ||
"args": [ | ||
{ | ||
"tya": "Type", | ||
"ty": { | ||
"t": "Opaque", | ||
"extension": "arithmetic.int.types", | ||
"id": "int", | ||
"args": [ | ||
{ | ||
"tya": "BoundedNat", | ||
"n": 6 | ||
} | ||
], | ||
"bound": "C" | ||
} | ||
} | ||
], | ||
"bound": "A" | ||
} | ||
] | ||
] | ||
} | ||
], | ||
"runtime_reqs": [] | ||
} | ||
}, | ||
"binary": false | ||
}, | ||
"RandomFloat": { | ||
"extension": "tket2.qsystem.random", | ||
"name": "RandomFloat", | ||
"description": "Generate a random floating point value in the range [0,1).", | ||
"signature": { | ||
"params": [], | ||
"body": { | ||
"input": [ | ||
{ | ||
"t": "Opaque", | ||
"extension": "tket2.qsystem.random", | ||
"id": "context", | ||
"args": [ | ||
{ | ||
"tya": "Type", | ||
"ty": { | ||
"t": "Opaque", | ||
"extension": "arithmetic.int.types", | ||
"id": "int", | ||
"args": [ | ||
{ | ||
"tya": "BoundedNat", | ||
"n": 6 | ||
} | ||
], | ||
"bound": "C" | ||
} | ||
} | ||
], | ||
"bound": "A" | ||
} | ||
], | ||
"output": [ | ||
{ | ||
"t": "Opaque", | ||
"extension": "tket2.qsystem.random", | ||
"id": "context", | ||
"args": [ | ||
{ | ||
"tya": "Type", | ||
"ty": { | ||
"t": "Opaque", | ||
"extension": "arithmetic.int.types", | ||
"id": "int", | ||
"args": [ | ||
{ | ||
"tya": "BoundedNat", | ||
"n": 6 | ||
} | ||
], | ||
"bound": "C" | ||
} | ||
} | ||
], | ||
"bound": "A" | ||
}, | ||
{ | ||
"t": "Opaque", | ||
"extension": "arithmetic.float.types", | ||
"id": "float64", | ||
"args": [], | ||
"bound": "C" | ||
} | ||
], | ||
"runtime_reqs": [] | ||
} | ||
}, | ||
"binary": false | ||
}, | ||
"RandomInt": { | ||
"extension": "tket2.qsystem.random", | ||
"name": "RandomInt", | ||
"description": "Generate a random 32-bit unsigned integer.", | ||
"signature": { | ||
"params": [], | ||
"body": { | ||
"input": [ | ||
{ | ||
"t": "Opaque", | ||
"extension": "tket2.qsystem.random", | ||
"id": "context", | ||
"args": [ | ||
{ | ||
"tya": "Type", | ||
"ty": { | ||
"t": "Opaque", | ||
"extension": "arithmetic.int.types", | ||
"id": "int", | ||
"args": [ | ||
{ | ||
"tya": "BoundedNat", | ||
"n": 6 | ||
} | ||
], | ||
"bound": "C" | ||
} | ||
} | ||
], | ||
"bound": "A" | ||
} | ||
], | ||
"output": [ | ||
{ | ||
"t": "Opaque", | ||
"extension": "tket2.qsystem.random", | ||
"id": "context", | ||
"args": [ | ||
{ | ||
"tya": "Type", | ||
"ty": { | ||
"t": "Opaque", | ||
"extension": "arithmetic.int.types", | ||
"id": "int", | ||
"args": [ | ||
{ | ||
"tya": "BoundedNat", | ||
"n": 6 | ||
} | ||
], | ||
"bound": "C" | ||
} | ||
} | ||
], | ||
"bound": "A" | ||
}, | ||
{ | ||
"t": "Opaque", | ||
"extension": "arithmetic.int.types", | ||
"id": "int", | ||
"args": [ | ||
{ | ||
"tya": "BoundedNat", | ||
"n": 5 | ||
} | ||
], | ||
"bound": "C" | ||
} | ||
], | ||
"runtime_reqs": [] | ||
} | ||
}, | ||
"binary": false | ||
}, | ||
"RandomIntBounded": { | ||
"extension": "tket2.qsystem.random", | ||
"name": "RandomIntBounded", | ||
"description": "Generate a random 32-bit unsigned integer less than `bound`.", | ||
"signature": { | ||
"params": [], | ||
"body": { | ||
"input": [ | ||
{ | ||
"t": "Opaque", | ||
"extension": "tket2.qsystem.random", | ||
"id": "context", | ||
"args": [ | ||
{ | ||
"tya": "Type", | ||
"ty": { | ||
"t": "Opaque", | ||
"extension": "arithmetic.int.types", | ||
"id": "int", | ||
"args": [ | ||
{ | ||
"tya": "BoundedNat", | ||
"n": 6 | ||
} | ||
], | ||
"bound": "C" | ||
} | ||
} | ||
], | ||
"bound": "A" | ||
}, | ||
{ | ||
"t": "Opaque", | ||
"extension": "arithmetic.int.types", | ||
"id": "int", | ||
"args": [ | ||
{ | ||
"tya": "BoundedNat", | ||
"n": 5 | ||
} | ||
], | ||
"bound": "C" | ||
} | ||
], | ||
"output": [ | ||
{ | ||
"t": "Opaque", | ||
"extension": "tket2.qsystem.random", | ||
"id": "context", | ||
"args": [ | ||
{ | ||
"tya": "Type", | ||
"ty": { | ||
"t": "Opaque", | ||
"extension": "arithmetic.int.types", | ||
"id": "int", | ||
"args": [ | ||
{ | ||
"tya": "BoundedNat", | ||
"n": 6 | ||
} | ||
], | ||
"bound": "C" | ||
} | ||
} | ||
], | ||
"bound": "A" | ||
}, | ||
{ | ||
"t": "Opaque", | ||
"extension": "arithmetic.int.types", | ||
"id": "int", | ||
"args": [ | ||
{ | ||
"tya": "BoundedNat", | ||
"n": 5 | ||
} | ||
], | ||
"bound": "C" | ||
} | ||
], | ||
"runtime_reqs": [] | ||
} | ||
}, | ||
"binary": false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
//! This module defines the Hugr extensions used by tket2-hseries. | ||
pub mod futures; | ||
pub mod qsystem; | ||
pub mod random; | ||
pub mod result; | ||
pub mod utils; | ||
pub mod wasm; |
Oops, something went wrong.