// quantum computing emulation: test state types and functions // #include #include #include #include #include "qce.h" using namespace qce; using namespace std; #define Real double //#define Complex Real #define Complex complex #define State state int main( int argc, char *argv[]) { Real x = 1.5, y = Conj(x); cout << x << " " << y << endl; Complex c = Complex(1.5,2.5), d = Conj(c); cout << c << " " << d << endl; printb( 128+5, 8); cout << endl; // state q(4); q.init(1); cout << "q:" << q; // State q(4); q.init(1); #if 1 State q(4); q.init(1); cout << "q:" << q; #if 1 q.qft(); cout << "fft:" << q; q.qft(1); cout << "ifft:" << q; #endif #endif // state> q(4); q.init(1); cout << "q:" << q; // state q(4); q.init(1); cout << "q:" << q; // state> q(4); q.init(1,1); cout << "q:" << q; // error // state q(4); q.init(1); cout << "q:" << q; // q.a[1] = complex(state<>::s2,state<>::s2); for( unsigned int i = 0; i < q.n; ++i) q.H(i); cout << "H(q):" << q; q.print( "E", PRINT_TANGLE); for( unsigned int i = 0; i < q.n; ++i) q.H(i); cout << "HH(q):" << q; cout.precision(30); cout << state<>::pi << endl; cout << state<>::s2 << endl; cout << state::onethird << endl; cout << state<>::onethird << endl; cout << state::onethird << endl; cout << "q.eps = " << q.eps << endl; cout << "FLT_EPSILON = " << FLT_EPSILON << endl; cout << "DBL_EPSILON = " << DBL_EPSILON << endl; cout << "LDBL_EPSILON = " << LDBL_EPSILON << endl; cout << sizeof(complex) << endl; cout << is_class::value << endl; return 0; }