UNPKG

qukit

Version:

[![Npm](https://badgen.net/npm/v/qukit)](https://www.npmjs.com/package/qukit) [![Crates](https://badgen.net/crates/v/qukit)](https://crates.io/crates/qukit) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/lice

36 lines (35 loc) 1.09 kB
import * as WasmLib from "../pkg/qukit"; export function phaseRoot(qbits, cControl, sameStep = false) { if (Array.isArray(qbits)) { const minLen = Math.min(qbits.length); if (minLen > 0) { phaseRoot(qbits[0], cControl, sameStep); } for (let i = 1; i < minLen; i++) { phaseRoot(qbits[i], cControl, sameStep); } } else { if (!Array.isArray(qbits)) { if (cControl !== null && cControl !== undefined) { if (sameStep) { WasmLib.phase_root_same_step_classically_controlled(qbits, cControl); } else { WasmLib.phase_root_classically_controlled(qbits, cControl); } } else { if (sameStep) { WasmLib.phase_root_same_step(qbits); } else { WasmLib.phase_root(qbits); } } } else { throw new Error("type mismatch"); } } }