QUANTUM STATES quBaseState(int bits,int buflen=256); new base state with <bits> qubits and an initial buffer for <buflen> terms. quVar(); quVar(quVar& qs); quVar(quState& qs); state variable either empty or set to state <qs> quCombState(quState& head,quState& tail); concatenation of <head> and <tail> quSubString(int bits,int offs,quState& base); substate of <bits> bits from state <base>, beginning at bit <offs> quBit(int offs,quState& base); bit <offs> of state <base> quWord(int bits,int offs,quState& base); substate of <bits> bits from state <base>, beginning at bit <offs>. interpreted as word OPERATORS opMatrix(int n,term **m); matrix op. operating on <n> bits, <m> is a 2 dim. array of nonzero matrix elements (1st dim. is 2^n, all list terminated with term()) opU2(double theta,double delta=0,double sigma=0,double tau=0); U2 = | e^i(del+sig+tau) cos(th/2) e^-i(del+sig-tau) sin(th/2) | | -e^i(del-sig+tau) sin(th/2) e^i(del-sig-tau) cos(th/2) | opIdentity(int n); identity op. on <n> bits opSwap(int n,int m,int o1,int o2); swaps 2 not overlapping substrings of length <m>: |a_0, .. a_o1, .. a_o1+m-1, .. a_o2, .. a_o2+m-1, .. a_n-1> --> |a_0, .. a_o2, .. a_o2+m-1, .. a_o1, .. a_o1+m-1, .. a_n-1> opPermutation(int n,term *p); replaces an eigenvec. with an other eigenvec. with ampl. |i> --> p[i] opEXPN(int arg,int fct,word x,word num); modular exponentiation |a,0> --> |a,x^a mod num> opCk(int n,int k,int o,int *i); controlled-NOT: inverts bit <o> if all bits i[0] to i[k-1] are set opC0(int n,int o); |a_0, .. a_o, .. a_n-1> --> |a_0, .. NOT a_o, .. a_n-1> opNot(); NOT-Gate: |0> --> |1>, |1> --> |0> opC1(int n,int o,int i); |a_0,.. a_o,.. a_n-1> --> |a_0,.. (a_i XOR a_o),.. a_n-1> opXor(); XOR-Gate: |i,o> --> |i,i XOR o> opC2(int n,int o,int i1,int i2); |a_0, .. a_o, ..a_n-1> --> |a_0, .. (a_i1 AND a_i2) XOR a_o, .. a_n-1> opToffoli(); Toffoli-Gate: |o,i1,i2> --> |(i1 AND i2) XOR o,i1,i2> opCondPhase(int n,int k,int *i,double phi); cond. phase gate: multiplies bit <o> with e^( i phi) if all bits i[0] to i[k-1] are set opX(int n,int i1,int i2,int pow); |a_0, .. a_n-1> --> e^i(2 PI i1 i2 / 2^pow) |a_0, .. a_n-1> opComposition(const opOperator& in,const opOperator& out); opComposition(opOperator *in,opOperator *out); composition out * in: |psi> --> out in |psi> opEmbedded(int n,int offs,const opOperator& op); opEmbedded(int n,int offs,opOperator *op); |a_0..>|a_offs..>|..a_n-1> -> |a_0..> (op |a_offs..>) |..a_n-1> opVar(); opVar(const opVar& op); opVar(const opOperator& op); operator variable either empty or set to <op>