1 //---------------------------------------------------------------------------
3 //---------------------------------------------------------------------------
5 //---------------------------------------------------------------------------
9 QC_not::QC_not(const int _Target) : QCalcUnit() {
12 //---------------------------------------------------------------------------
16 void QC_not::calc(int target, double BitsR[], double BitsI[], int NumberOfBits) {
17 unsigned int states = (1 << (NumberOfBits - 1));
18 for (unsigned int i = 0; i < states; i++) {
19 unsigned int ix0 = QCalcUnit::insert1(i, target);
20 unsigned int ix1 = QCalcUnit::insert0(i, target);
21 swap(BitsR[ix0], BitsR[ix1]);
22 swap(BitsI[ix0], BitsI[ix1]);
25 //---------------------------------------------------------------------------
27 QC_not::Calc(QBits *qBits) {
28 double *R = qBits->GetBitsR();//Real Part
29 double *I = qBits->GetBitsI();//Imaginary Part
30 int N = qBits->GetNumberOfQBits();
32 QC_not::calc(Target, R, I, N);
34 //---------------------------------------------------------------------------
37 QC_not::calcmpi(int t1, double R[], double I[], int N) {
42 unsigned int ix0, ix1;
44 for (int i = 0; i < (1 << (N - 1)); i++) {
45 // Obtain indices of state:
46 ix0 = QCalcUnit::insert0(i, t1);
47 ix1 = QCalcUnit::insert1(i, t1);
49 bool bstore = setup(R, I, ix0, ix1, r0, i0, r1, i1);
55 store(R, I, ix0, ix1, r0, i0, r1, i1);
60 //---------------------------------------------------------------------------