-
Notifications
You must be signed in to change notification settings - Fork 0
/
phase-relative.js
44 lines (35 loc) · 939 Bytes
/
phase-relative.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const logger = require('../src/logger')()
circuit('a quarter turn (90 degree) relative phase change in super position with an S gate', 1)
.h(0)
.s(0)
.run()
.inspect()
circuit('a quarter turn (90 degree) relative phase change in super position with the U1 gate', 1)
.h(0)
.u1(0, [], { lambda: 'pi / 2' })
.run()
.inspect()
circuit('a quarter turn (90 degree) relative phase change in super position with an RZ gate', 1)
.h(0)
.rz(0, [], { phi: 'pi / 2' })
.run()
.inspect()
function circuit(name, size) {
let circuit = require('../src/circuit.js')({
name: name,
size: size,
logger: logger,
engine: 'optimized',
order: ['targets', 'controls']
})
return Object.assign(circuit, {
inspect: function() {
let phase = 0
this.each(function(each) {
phase = phase + Math.abs(each.phase)
})
logger.log(`In superposition the relative phase between states is ${phase} degrees.`)
logger.log()
}
})
}