Skip to content

Instantly share code, notes, and snippets.

@shogochiai
Last active August 29, 2015 14:05
Show Gist options
  • Save shogochiai/bbde04f179da4a9e678e to your computer and use it in GitHub Desktop.
Save shogochiai/bbde04f179da4a9e678e to your computer and use it in GitHub Desktop.
QCLという言語が量子コンピューター上に実装された処理系らしく面白そうだったので引用させていただいた

離散フーリエ変換をqubit操作を用いて計算している?

量子回路にユニタリ行列など出てきている。

// qcl-0.6.4/lib/dft.qcl

set library 1;

// pseudo classic operator to swap bit order

cond qufunct flip(qureg q) { 
  int i;                // declare loop counter
  for i=0 to #q/2-1 {   // swap 2 symmetric bits
    Swap(q[i],q[#q-i-1]);
  }
}  

// discrete Fourier transform (Coppersmith)

operator dft(qureg q) { // main operator
  const n=#q;           // set n to length of input
  int i; int j;         // declare loop counters
  for i=1 to n {
    for j=1 to i-1 {    // apply conditional phase gates
      V(pi/2^(i-j),q[n-i] & q[n-j]);
//      if q[n-i] and q[n-j] { Phase(pi/2^(i-j)); }
    }
    H(q[n-i]);          // qubit rotation
  }    
  flip(q);              // swap bit order of the output
}

set library 0;

Bernhard Ömer教授のホームページでダウンロード可能

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment