```rust use qvnt::prelude::*;
// create quantum register, called 'x', with 10 qubits let mut qreg = QReg::new(10); // or with initial state, where 3 qubits are already in state |1> let mut qreg = QReg::new(10).init_state(0b0011100000);
// get virtual register 'x', to interact with specified qubits let x = qreg.getvreg();
// create qft operation, acting on first 5 qubits in q_reg let op = op::qft(x[0] | x[1] | x[2] | x[3] | x[4]);
// apply operation q_reg.apply(&op);
// measure and write first 3 qubit, which leads to collapse of qreg wave function println!("{}", qreg.measure_mask(x[0] | x[1] | x[2])); ```
ALL operators have inverse versions, accessing by .dgr()
method:
```rust
use qvnt::prelude::*;
let usualop = op::s(0b1); // Inverse S operator let inverseop = op::s(0b1).dgr(); ```
Also, ALL these operators could be turned into controlled ones, using .c(...)
method:
```rust
use qvnt::prelude::*;
let usualop = op::x(0b001);
// NOT gate, controlled by 2 qubits, aka CCNOT gate, aka Toffoli gate
let controlledop = op::x(0b001).c(0b110).unwrap();
Controlled operation has to be unwrapped, since it could be None if its mask overlaps with the mask of operator.
For example, this code will *panic*:
rust,should_panic,panics
use qvnt::prelude::*;
let _ = op::x(0b001).c(0b001).unwrap();
```