éåã³ã³ãã¥ã¼ã¿ã§èªç±ã«åæç¶æ ãä½ãæ¹æ³
量子コンピュータの基礎:振幅の初期化 - yukobaのブログã®ç¶ãã
éåã³ã³ãã¥ã¼ã¿ã§ã¯ãåç¶æ ã®æ¯å¹ ã®çµ¶å¯¾å¤ã確çãªè¨³ã§ããã観測ããã¨ã©ããã決ã¾ãã®ã§ãã¤ã¾ãã確çãã¯ãã«ã§ããã©ããã£ã¦ç¢ºçãã¯ãã«ã®åæç¶æ ãä½ããã¯å¤§äºã§ããä¸ã®æ¥è¨ã¯ã(1/3, 1/3, 0, 1/3) ã¿ããã«ãå ¨ã¦åã確çã®ç©ããä½ããªãã£ãã®ã§ã(4/7, 2/7, 0, 1/7)ã®ããã«ãã°ãã°ãã®ç¢ºçã§ä½ããããã«èªåã§æ¹è¯ãã¾ãããã¤ã¾ããã®ä½ãæ¹ã§ããå½ç¶ã®ãã¨ãªããã確çã®åè¨ã¯1ã«ããå¿ è¦ãããã¾ããããã«å ãã¦ãçµã¿è¾¼ã¿é¢æ°ã®CPhase()ã使ãã¨ãèªç±ã«åè§ãè¨å®ã§ãã¾ãã
qcl -i initAmpGeneral.qcl ã§ãtestInitAmp() ã§å®è¡ã§ãã¾ããå®è¡ã«ã¯ãQCL - A Programming Language for Quantum Computersãå¿ è¦ã§ãã
: SPECTRUM x: <0,1> 0.57143 |0>, 0.28571 |1>, 0.14286 |3>
ãã®ãããªçµæãè¿ã£ã¦ãã¾ãã4/7 = 0.57143 ã§ãã
ã½ã¼ã¹ã³ã¼ã
å¤ãã£ãã®ã¯ãinitAmpStateGen() ã¨ãããå¼ã³åºãã¦ããé¨åã§ãã
// Initializing amplitude distribution (æ¯å¹ åå¸ã®åæå) // å ã®è«æã¯ç¢ºç 1 / #patterns ã«ããã§ããªãã£ãã®ããä»»æã®ç¢ºçã§åæåã§ããããã«ãããã® // è«æã®ä¸ä½ãããã¨ä¸ä½ãããã®é çªãä¸è¬ã®é åºã¨éã§ãããã¨ã«æ³¨æï¼ç¹ã«cã®ãããé ãåé¡ã // è«æã®3ã6è¡ç® qufunct initAmpFlip(qureg x, qureg c, int pattern, int prevPattern) { int j; // è«æã®5,6è¡ç®ã¯F^0ã§ãããCNotã¯F^1ãªã®ã§ããããå転ã Not(c[0]); // è«æã®3ã5è¡ç® for j = 0 to #x - 1 { if bit(pattern, j) xor bit(prevPattern, j) { CNot(x[j], c[0]); } } // è«æã®6è¡ç® CNot(c[1], c[0]); // å転ããc[0]ãå ã«æ»ã Not(c[0]); } // è«æã®7è¡ç® operator initAmpStateGen(qureg c, real p) { real p1; real p2; // p1^2 + p2^2 = 1 ããè¡åã¯ã¦ãã¿ãª p1 = sqrt(1 - p); p2 = sqrt(p); Matrix4x4( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, p1, -p2, 0, 0, p2, p1, c); } // c1 == i1 ã㤠c2 == i2 ã®æã«ãa ãå転ãããi1, i2 = {0, 1}ã#a, #c1, #c2 = 1ã qufunct fredkin(qureg a, qureg c1, boolean i1, qureg c2, boolean i2) { if not i1 { Not(c1); } if not i2 { Not(c2); } CNot(a, c1 & c2); if not i2 { Not(c2); } if not i1 { Not(c1); } } // è«æã®8ã10è¡ç® // x ã z ã¨çãããã°ãg[#x - 1] ã®ãã©ã°ãç«ã¦ã qufunct initAmpAnd(qureg x, quvoid g, int z) { int k; fredkin(g[0], x[0], bit(z, 0), x[1], bit(z, 1)); for k = 2 to #x - 1 { fredkin(g[k - 1], x[k], bit(z, k), g[k - 2], true); } } // æ¯å¹ åå¸ã®åæå operator initAmp(quvoid x, int vector patterns, real vector values) { int i; int prevPattern; real leftProb; qureg g[#x - 1]; qureg c[2]; prevPattern = 0; leftProb = 1; for i = 0 to #patterns - 1 { // è«æã®3ã6è¡ç® initAmpFlip(x, c, patterns[i], prevPattern); prevPattern = patterns[i]; // S^pãè«æã®7è¡ç®ã initAmpStateGen(c, values[i] / leftProb); leftProb = leftProb * (1 - values[i] / leftProb); // saveããã¿ã¼ã³ã«çãããã¤ã ãã® c[1]ãããªãã // è«æã®8ã10è¡ç®(AND) initAmpAnd(x, g, patterns[i]); // è«æã®11è¡ç® CNot(c[1], g[#x - 2]); // è«æã®12ã14è¡ç®(ANDéæ»ãï¼ !initAmpAnd(x, g, patterns[i]); } // è«æã®15è¡ç® Not(c[0]); } procedure testInitAmp() { const patternBitSize = 2; int vector patterns = vector(0, 1, 3); real vector values = vector(4.0/7.0, 2.0/7.0, 1.0/7.0); qureg x[patternBitSize]; initAmp(x, patterns, values); dump x; }