qukit
Version:
[](https://www.npmjs.com/package/qukit) [](https://crates.io/crates/qukit) [](https://opensource.org/lice
36 lines (35 loc) • 1.05 kB
JavaScript
import * as WasmLib from "../pkg/qukit";
export function phase(qbits, cControl, sameStep = false) {
if (Array.isArray(qbits)) {
const minLen = Math.min(qbits.length);
if (minLen > 0) {
phase(qbits[0], cControl, sameStep);
}
for (let i = 1; i < minLen; i++) {
phase(qbits[i], cControl, sameStep);
}
}
else {
if (!Array.isArray(qbits)) {
if (cControl !== null && cControl !== undefined) {
if (sameStep) {
WasmLib.phase_same_step_classically_controlled(qbits, cControl);
}
else {
WasmLib.phase_classically_controlled(qbits, cControl);
}
}
else {
if (sameStep) {
WasmLib.phase_same_step(qbits);
}
else {
WasmLib.phase(qbits);
}
}
}
else {
throw new Error("type mismatch");
}
}
}