pub struct QPU {
pub u2_gates: U2Gates,
pub u4_gate: U4Gate,
/* private fields */
}Fields§
§u2_gates: U2Gates§u4_gate: U4GateImplementations§
Source§impl QPU
impl QPU
Sourcepub fn new(
coupling_graph: Option<Vec<(usize, usize)>>,
num_qubits: usize,
u2_gates: U2Gates,
u4_gate: U4Gate,
) -> Self
pub fn new( coupling_graph: Option<Vec<(usize, usize)>>, num_qubits: usize, u2_gates: U2Gates, u4_gate: U4Gate, ) -> Self
Examples found in repository?
examples/mcx.rs (lines 12-40)
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
fn main() -> Result<(), KetError> {
set_log_level(4);
let config = Configuration {
num_qubits: 12,
qpu: Some(QPU::new(
// 0--1--2--3
// | | | |
// 4--5--6--7
// | | | |
// 8--9--A--B
Some(vec![
(0, 4),
(0, 1),
(1, 2),
(1, 5),
(2, 3),
(2, 6),
(3, 7),
(4, 8),
(4, 5),
(5, 9),
(5, 6),
(6, 10),
(6, 7),
(7, 11),
(8, 9),
(9, 10),
(10, 11),
]),
12,
Default::default(),
Default::default(),
)),
..Default::default()
};
let mut process = Process::new(config);
let size = 6;
let qubits: Vec<_> = (0..size).map(|_| process.alloc().unwrap()).collect();
ctrl(&mut process, &qubits[1..], |process| {
process.gate(QuantumGate::PauliZ, qubits[0])
})?;
let _ = process.sample(&qubits, 1024)?;
process.transpile();
println!("Instructions:");
for line in process.instructions() {
println!("\t{:?}", line);
}
println!("ISA Instructions:");
if let Some(isa) = process.isa_instructions() {
for line in isa {
println!("\t{:?}", line);
}
}
Ok(())
}More examples
examples/grover.rs (lines 14-24)
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
fn main() -> Result<(), KetError> {
set_log_level(3);
let config = Configuration {
num_qubits: 12,
qpu: Some(QPU::new(
// 0--1--2--3
// | | | |
// 4--5--6--7
// | | | |
// 8--9--A--B
Some(ket::ex_arch::GRID12.to_vec()),
12,
U2Gates::RzSx,
U4Gate::CZ,
)),
..Default::default()
};
let mut process = Process::new(config);
let size = 8;
let qubits: Vec<_> = (0..size).map(|_| process.alloc().unwrap()).collect();
for qubit in &qubits {
process.gate(QuantumGate::Hadamard, *qubit)?;
}
let steps = ((FRAC_PI_4) * f64::sqrt((1 << size) as f64)) as i64;
for _ in 0..steps {
around(
&mut process,
|process| {
for qubit in &qubits {
process.gate(QuantumGate::PauliX, *qubit)?;
}
Ok(())
},
|process| {
ctrl(process, &qubits[1..], |process| {
process.gate(QuantumGate::PauliZ, qubits[0])
})
},
)?;
around(
&mut process,
|process| {
for qubit in &qubits {
process.gate(QuantumGate::Hadamard, *qubit)?;
}
for qubit in &qubits {
process.gate(QuantumGate::PauliX, *qubit)?;
}
Ok(())
},
|process| {
ctrl(process, &qubits[1..], |process| {
process.gate(QuantumGate::PauliZ, qubits[0])
})
},
)?;
}
let _ = process.sample(&qubits, 1024)?;
process.transpile();
println!("{:#?}", process.metadata());
Ok(())
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for QPU
impl RefUnwindSafe for QPU
impl Send for QPU
impl Sync for QPU
impl Unpin for QPU
impl UnwindSafe for QPU
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more