Skip to content

Commit

Permalink
shove
Browse files Browse the repository at this point in the history
  • Loading branch information
simplygreatwork committed Jun 28, 2020
1 parent fb40a3e commit bc53dc4
Show file tree
Hide file tree
Showing 23 changed files with 819 additions and 74 deletions.
4 changes: 1 addition & 3 deletions examples/algorithm-bitstring-query-quantum.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ function Circuit(name, size) {
order: ['targets', 'controls']
})

Object.assign(circuit, {
return Object.assign(circuit, {

evaluate: function(main) {
return main.measure()
}
})

return circuit
}

function Oracle(options) {
Expand Down
4 changes: 1 addition & 3 deletions examples/algorithm-constant-or-balanced-quantum.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function Circuit(name, size) {
order: ['targets', 'controls']
})

Object.assign(circuit, {
return Object.assign(circuit, {

kind: function() {

Expand All @@ -43,8 +43,6 @@ function Circuit(name, size) {
return bits.toNumber() === 0 ? 'constant' : 'balanced'
}
})

return circuit
}

function Oracle(options) {
Expand Down
4 changes: 1 addition & 3 deletions examples/algorithm-exclusive-or-pairs-quantum.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,13 @@ function Host() {

function Circuit(name, size) {

let circuit = require('../src/circuit.js')({
return require('../src/circuit.js')({
name: name,
size: size,
logger: logger,
engine: 'optimized',
order: ['targets', 'controls']
})

return circuit
}

function Oracle(options) {
Expand Down
4 changes: 1 addition & 3 deletions examples/amplify-two-states.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function circuit(name, size, options) {
order: ['targets', 'controls']
})

Object.assign(circuit, {
return Object.assign(circuit, {

flip: function(bits) {

Expand Down Expand Up @@ -72,8 +72,6 @@ function circuit(name, size, options) {
.h(0).h(1).h(2).h(3)
}
})

return circuit
}

function main(index) {
Expand Down
4 changes: 1 addition & 3 deletions examples/amplify-wave.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function circuit(name, size, options) {
order: ['targets', 'controls']
})

Object.assign(circuit, {
return Object.assign(circuit, {

repeat: function(value, fn) {

Expand Down Expand Up @@ -73,8 +73,6 @@ function circuit(name, size, options) {
.h(0).h(1).h(2).h(3)
}
})

return circuit
}

function main(index) {
Expand Down
4 changes: 1 addition & 3 deletions examples/amplify.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function circuit(name, size, options) {
order: ['targets', 'controls']
})

Object.assign(circuit, {
return Object.assign(circuit, {

repeat: function(value, fn) {

Expand Down Expand Up @@ -78,8 +78,6 @@ function circuit(name, size, options) {
.h(0).h(1).h(2).h(3)
}
})

return circuit
}

function main(index) {
Expand Down
4 changes: 1 addition & 3 deletions examples/frequency-approximate.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function Circuit(name, size, options) {
order: ['targets', 'controls']
})

Object.assign(circuit, {
return Object.assign(circuit, {

period: function(period) {

Expand Down Expand Up @@ -143,6 +143,4 @@ function Circuit(name, size, options) {
.swap(2, 3)
}
})

return circuit
}
4 changes: 1 addition & 3 deletions examples/frequency.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function Circuit(name, size, options) {
order: ['targets', 'controls']
})

Object.assign(circuit, {
return Object.assign(circuit, {

period: function(period) {

Expand Down Expand Up @@ -80,6 +80,4 @@ function Circuit(name, size, options) {
.swap(1, 2)
}
})

return circuit
}
2 changes: 1 addition & 1 deletion examples/measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ const logger = require('../src/logger')()

// illustrate through measuring why it is necessary to run a circuit perhaps hundreds of times
// to get a glimpse of the real certainty of an answer
// measuring only gives reveals the state vector combination - not probabilities
// measuring only gives reveals the state vector combination - not probabilities
4 changes: 1 addition & 3 deletions examples/not-conditionally-toffoli-constructed.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function circuit(name, size, options) {
order: ['targets', 'controls']
})

Object.assign(circuit, {
return Object.assign(circuit, {

toffoli: function(target, controls) {

Expand All @@ -38,6 +38,4 @@ function circuit(name, size, options) {
.cx(controls[1], controls[0])
}
})

return circuit
}
4 changes: 1 addition & 3 deletions examples/phase-rotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function circuit(name, size) {
order: ['targets', 'controls']
})

Object.assign(circuit, {
return Object.assign(circuit, {

repeat: function(value, fn) {

Expand All @@ -46,6 +46,4 @@ function circuit(name, size) {
return this
}
})

return circuit
}
4 changes: 1 addition & 3 deletions examples/phase-spread-rz.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function Circuit(name, size) {
order: ['targets', 'controls']
})

Object.assign(circuit, {
return Object.assign(circuit, {

spread: function(fn) {

Expand All @@ -38,6 +38,4 @@ function Circuit(name, size) {
return this
}
})

return circuit
}
4 changes: 1 addition & 3 deletions examples/phase-spread-s.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function Circuit(name, size) {
order: ['targets', 'controls']
})

Object.assign(circuit, {
return Object.assign(circuit, {

spread: function(fn) {

Expand All @@ -37,6 +37,4 @@ function Circuit(name, size) {
return this
}
})

return circuit
}
4 changes: 1 addition & 3 deletions examples/phase-spread-t.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function Circuit(name, size) {
order: ['targets', 'controls']
})

Object.assign(circuit, {
return Object.assign(circuit, {

spread: function(fn) {

Expand All @@ -38,6 +38,4 @@ function Circuit(name, size) {
return this
}
})

return circuit
}
4 changes: 1 addition & 3 deletions examples/phase-spread-z.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function Circuit(name, size) {
order: ['targets', 'controls']
})

Object.assign(circuit, {
return Object.assign(circuit, {

spread: function(fn) {

Expand All @@ -38,6 +38,4 @@ function Circuit(name, size) {
return this
}
})

return circuit
}
4 changes: 1 addition & 3 deletions examples/quantum-fourier-transform-inverse.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function Circuit(name, size, options) {
order: ['targets', 'controls']
})

Object.assign(circuit, {
return Object.assign(circuit, {

frequency: function(frequency) {

Expand Down Expand Up @@ -90,8 +90,6 @@ function Circuit(name, size, options) {
return this
}
})

return circuit
}

function repeat(number, fn) {
Expand Down
4 changes: 1 addition & 3 deletions examples/quantum-fourier-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Circuit(name, size, options) {
order: ['targets', 'controls']
})

Object.assign(circuit, {
return Object.assign(circuit, {

period: function(period) {

Expand Down Expand Up @@ -168,8 +168,6 @@ function Circuit(name, size, options) {
return this
}
})

return circuit
}

function repeat(number, fn) {
Expand Down
9 changes: 3 additions & 6 deletions examples/superdense.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ encode(3)

function encode(value) {

let circuit = Circuit('superdense: ' + value, 2)
let circuit = Circuit(`superdense value: ${value}`, 2)
let alice = circuit.alice()
let bob = circuit.bob()
circuit.entangle(alice, bob)
Expand All @@ -34,19 +34,18 @@ function Circuit(name, size, options) {
order: ['targets', 'controls']
})

Object.assign(circuit, {
return Object.assign(circuit, {

alice: function() {

let alice = this.unit(0)
Object.assign(alice, {
return Object.assign(alice, {
encode: function(value) {
let array = Bits.fromNumber(value, 2).toArray()
if (array.pop()) alice.z()
if (array.pop()) alice.x()
}
})
return alice
},

bob: function() {
Expand All @@ -71,6 +70,4 @@ function Circuit(name, size, options) {
return this
}
})

return circuit
}
4 changes: 1 addition & 3 deletions examples/teleportation.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function circuit(name, size, options) {
order: ['targets', 'controls']
})

Object.assign(circuit, {
return Object.assign(circuit, {

state: function(state, target) {
return this['state_' + state].apply(this, [target])
Expand Down Expand Up @@ -63,6 +63,4 @@ function circuit(name, size, options) {
return this.h(from).h(0)
}
})

return circuit
}
12 changes: 6 additions & 6 deletions output/amplify-two-states.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
-----------------------------------------------------------------------------------

Running circuit "amplify-two-states-input"
Running circuit "the input for amplifying two states"


Finished "amplify-two-states-input"
Finished "the input for amplifying two states"

| > 6.2500% 0.25000000+0.00000000i ( 0.00)
| x> 6.2500% 0.25000000+0.00000000i ( 0.00)
Expand All @@ -24,10 +24,10 @@ Running circuit "amplify-two-states-input"

-----------------------------------------------------------------------------------

Running circuit "amplify-two-states-one-time"
Running circuit "amplify two states one time"


Finished "amplify-two-states-one-time"
Finished "amplify two states one time"

| > 1.5625% -0.12500000+0.00000000i (180.00)
| x> 1.5625% -0.12500000+0.00000000i (180.00)
Expand All @@ -48,10 +48,10 @@ Running circuit "amplify-two-states-one-time"

-----------------------------------------------------------------------------------

Running circuit "amplify-two-states-two-times"
Running circuit "amplify two states two times"


Finished "amplify-two-states-two-times"
Finished "amplify two states two times"

| > 0.3906% -0.06250000+0.00000000i (180.00)
| x> 0.3906% -0.06250000+0.00000000i (180.00)
Expand Down
4 changes: 2 additions & 2 deletions output/phase-rz.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-----------------------------------------------------------------------------------

Running circuit "phase-rz"
Running circuit "phase: rz"

Initial state

Expand Down Expand Up @@ -43,7 +43,7 @@ Running circuit "phase-rz"

|x> 100.0000% 1.00000000+0.00000000i ( 0.00) <<< 100.0000% 0.70710678-0.70710678i (-45.00)

Finished "phase-rz"
Finished "phase: rz"

|x> 100.0000% 1.00000000+0.00000000i ( 0.00)

Loading

0 comments on commit bc53dc4

Please sign in to comment.