extern qufunct Fanout(quconst a,quvoid b); extern qufunct Swap(qureg a,qureg b); extern operator Matrix2x2( complex u00,complex u01, complex u10,complex u11, qureg q); extern operator Matrix4x4( complex u00,complex u01,complex u02,complex u03, complex u10,complex u11,complex u12,complex u13, complex u20,complex u21,complex u22,complex u23, complex u30,complex u31,complex u32,complex u33, qureg q); extern operator Matrix8x8( complex u00,complex u01,complex u02,complex u03, complex u04,complex u05,complex u06,complex u07, complex u10,complex u11,complex u12,complex u13, complex u14,complex u15,complex u16,complex u17, complex u20,complex u21,complex u22,complex u23, complex u24,complex u25,complex u26,complex u27, complex u30,complex u31,complex u32,complex u33, complex u34,complex u35,complex u36,complex u37, complex u40,complex u41,complex u42,complex u43, complex u44,complex u45,complex u46,complex u47, complex u50,complex u51,complex u52,complex u53, complex u54,complex u55,complex u56,complex u57, complex u60,complex u61,complex u62,complex u63, complex u64,complex u65,complex u66,complex u67, complex u70,complex u71,complex u72,complex u73, complex u74,complex u75,complex u76,complex u77, qureg q); extern qufunct Perm2(int p0 ,int p1 ,qureg q); extern qufunct Perm4(int p0 ,int p1 ,int p2 ,int p3 ,qureg q); extern qufunct Perm8( int p0 ,int p1 ,int p2 ,int p3 ,int p4 ,int p5 ,int p6 ,int p7 , qureg q); extern qufunct Perm16( int p0 ,int p1 ,int p2 ,int p3 ,int p4 ,int p5 ,int p6 ,int p7 , int p8 ,int p9 ,int p10,int p11,int p12,int p13,int p14,int p15, qureg q); extern qufunct Perm32( int p0 ,int p1 ,int p2 ,int p3 ,int p4 ,int p5 ,int p6 ,int p7 , int p8 ,int p9 ,int p10,int p11,int p12,int p13,int p14,int p15, int p16,int p17,int p18,int p19,int p20,int p21,int p22,int p23, int p24,int p25,int p26,int p27,int p28,int p29,int p30,int p31, qureg q); extern qufunct Perm64( int p0 ,int p1 ,int p2 ,int p3 ,int p4 ,int p5 ,int p6 ,int p7 , int p8 ,int p9 ,int p10,int p11,int p12,int p13,int p14,int p15, int p16,int p17,int p18,int p19,int p20,int p21,int p22,int p23, int p24,int p25,int p26,int p27,int p28,int p29,int p30,int p31, int p32,int p33,int p34,int p35,int p36,int p37,int p38,int p39, int p40,int p41,int p42,int p43,int p44,int p45,int p46,int p47, int p48,int p49,int p50,int p51,int p52,int p53,int p54,int p55, int p56,int p57,int p58,int p59,int p60,int p61,int p62,int p63, qureg q); extern qufunct Not(qureg q); extern qufunct CNot(qureg q,quconst c); extern operator CPhase(real phi,qureg q); extern operator Rot(real theta,qureg q); extern operator Mix(qureg q); extern qufunct ModExp(int n,int x,quconst a,quvoid b); boolean bit(int n,int b) { return n/2^b mod 2 == 1; } qufunct set(int n,qureg q) { int i; for i=0 to #q-1 { if bit(n,i) { Not(q[i]); } } } const pi=3.141592653589793238462643383279502884197;