forked from Strilanc/Quirk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Strilanc#373 from Strilanc/dev
Dev
- Loading branch information
Showing
23 changed files
with
328 additions
and
169 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
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
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {Gate} from "src/circuit/Gate.js" | ||
import {ketArgs, ketShaderPermute} from "src/circuit/KetShaderUtil.js" | ||
import {WglArg} from "src/webgl/WglArg.js" | ||
|
||
let IncrementGates = {}; | ||
|
||
const offsetShader = ketShaderPermute( | ||
'uniform float amount;', | ||
'return mod(out_id - amount + span, span);'); | ||
|
||
IncrementGates.IncrementFamily = Gate.buildFamily(1, 16, (span, builder) => builder. | ||
setSerializedId("inc" + span). | ||
setSymbol("+1"). | ||
setTitle("Increment Gate"). | ||
setBlurb("Adds 1 to the little-endian number represented by a block of qubits."). | ||
setActualEffectToShaderProvider(ctx => offsetShader.withArgs( | ||
...ketArgs(ctx, span), | ||
WglArg.float("amount", +1))). | ||
setKnownEffectToPermutation(t => (t + 1) & ((1 << span) - 1))); | ||
|
||
IncrementGates.DecrementFamily = Gate.buildFamily(1, 16, (span, builder) => builder. | ||
setSerializedId("dec" + span). | ||
setSymbol("−1"). | ||
setTitle("Decrement Gate"). | ||
setBlurb("Subtracts 1 from the little-endian number represented by a block of qubits."). | ||
setActualEffectToShaderProvider(ctx => offsetShader.withArgs( | ||
...ketArgs(ctx, span), | ||
WglArg.float("amount", -1))). | ||
setKnownEffectToPermutation(t => (t - 1) & ((1 << span) - 1))); | ||
|
||
IncrementGates.all = [ | ||
...IncrementGates.IncrementFamily.all, | ||
...IncrementGates.DecrementFamily.all, | ||
]; | ||
|
||
export {IncrementGates, offsetShader} |
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
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
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
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
Oops, something went wrong.