1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/mirrors-quantum

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
MultiTargetCNOT.qs 2.5 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
Mariia Mykhailova Отправлено 20.07.2021 20:11 f57a5b1
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
namespace Microsoft.Quantum.Samples.UnitTesting {
open Microsoft.Quantum.Diagnostics;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Arrays;
///////////////////////////////////////////////////////////////////////////////////////////////
// Multi target Controlled Not gates
///////////////////////////////////////////////////////////////////////////////////////////////
// Multi target Controlled Not gate takes a control qubit
// with controls and target register |t₁,…,tₙ⟩. On computational basis states it acts as:
// |c₁⟩⊗|t₁,…,tₙ⟩ ↦ |c₁⟩⊗|t₁⊕c₁,…,tₙ⊕c₁⟩, i.e. the target qubits are flipped
// if and only if all control qubit is in state |1⟩.
///////////////////////////////////////////////////////////////////////////////////////////////
/// # Summary
/// A simple implementation of target Controlled Not gate using CNOT gates
operation ApplyMultiTargetNot(controls : Qubit[], target : Qubit[]) : Unit is Adj {
EqualityFactI(Length(controls), 1, "control register must have length 1");
ApplyToEachA(CNOT(Head(controls), _), target);
}
/// # Summary
/// Multi target multi controlled Not implementation using
/// ApplyMultiControlledCA
///
/// # See Also
/// - Microsoft.Quantum.Canon.ApplyMultiControlledCA
operation ApplyMultiTargetMultiNot(controls : Qubit[], targets : Qubit[]) : Unit is Adj {
body (...) {
let singlyControlledOp = ApplyToPartitionA(ApplyMultiTargetNot, 1, _);
ApplyMultiControlledCA(singlyControlledOp, CCNOTop(CCNOT), controls, targets);
}
controlled (extraControls, ...) {
ApplyMultiTargetMultiNot(extraControls + controls, targets);
}
}
}
// /////////////////////////////////////////////////////////////////////////////////////////////
// Implementations of Multi target Controlled Not gates not considered here
// /////////////////////////////////////////////////////////////////////////////////////////////
// ● Constant depth remote multi-target CNOT can be implemented
// in 2D nearest neighbor architecture using constant depth
// fanout/un-fanout circuit and ancillary qubits as described in
// [arXiv:1207.6655v2](https://arxiv.org/pdf/1207.6655v2.pdf)
// /////////////////////////////////////////////////////////////////////////////////////////////

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/mirrors-quantum.git
git@api.gitlife.ru:oschina-mirror/mirrors-quantum.git
oschina-mirror
mirrors-quantum
mirrors-quantum
main