#include <iostream>
#include "Net.h"
#include "Exception.h"
using namespace std;
typedef complex<double> cdouble;
int main(void)
{
cdouble I = cdouble(0,1);
char labels[] = {'H', 'T'};
cdouble gates[][4] =
{
{ I/SQRT2, I/SQRT2, I/SQRT2, -1.0*I/SQRT2 },
{ cdouble(cos(PI/8),-sin(PI/8)) ,0, 0, cdouble(cos(PI/8),sin(PI/8)) }
};
Net enet(0.18);
cout << "... generating net ..." << endl;
enet.generate(labels,gates,2,14);
cout << enet << endl;
srand(time(0));
double a[4];
double norm = 0;
for (int i=0;i<4;i++) {a[i] = (float)rand()/RAND_MAX; norm += a[i]*a[i]; }
norm = sqrtf(norm);
for (int i=0;i<4;i++) { a[i] /= norm; }
Matrix<cdouble> A(2,2);
su2::cart4_to_mat(a,A);
cout << "A = " << A << endl;
try {
cout << "calling Solovay-Kitaev() to depth 5" << endl;
Net::knot ska = enet.solovay_kitaev(A,5);
cout << "got a sequence of length " << ska.l << endl;
cout << "A ~ " << ska.M << endl;
cout << "accuracy " << su2::proj_trace_dist(A,ska.M) << endl;
}
catch (Exception& E) { cout << "*** ERROR: " << E.msg << endl; }
}