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

53 lines (52 loc) 2.15 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.cRotationSwap = void 0; const WasmLib = __importStar(require("../pkg/qukit")); function cRotationSwap(theta, cQbits, qbits0, qbits1, sameStep = false) { if (Array.isArray(cQbits) && Array.isArray(qbits0) && Array.isArray(qbits1)) { const minLen = Math.min(cQbits.length, qbits0.length, qbits1.length); if (minLen > 0) { cRotationSwap(theta, cQbits[0], qbits0[0], qbits1[0], sameStep); } for (let i = 1; i < minLen; i++) { cRotationSwap(theta, cQbits[i], qbits0[i], qbits1[i], sameStep); } } else { if (!Array.isArray(cQbits) && !Array.isArray(qbits0) && !Array.isArray(qbits1)) { if (sameStep) { WasmLib.controlled_rotation_swap_same_step(theta, cQbits, qbits0, qbits1); } else { WasmLib.controlled_rotation_swap(theta, cQbits, qbits0, qbits1); } } else { throw new Error("type mismatch"); } } } exports.cRotationSwap = cRotationSwap;