diff --git a/Hyperbolic_Codes_Q_ary.zip b/Hyperbolic_Codes_Q_ary.zip new file mode 100644 index 0000000..ac659e9 Binary files /dev/null and b/Hyperbolic_Codes_Q_ary.zip differ diff --git a/README.md b/README.md index 704ccdd..eec2f15 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,8 @@ Collection of quantum LDPC codes Hyperbolic Codes Planar: a collection of planar hyperbolic codes ordered by Schläfli symbol {f,d} of the corresponding infinite graph. These are CSS codes whose Z and X generators are edge-site incidence matrices of a pair of mutually dual locally planar vertex transitive graphs, finite quotients of the regular hyperbolic tiling. +Hyperbolic Codes Q_ary: q-ary version of the hyperbolic codes, where the incidence matrix elements are 0, 1 and -1, such that the incidence matrix of a graph Gx is orthogonal to that of the dual graph Gz over Z, instead of only Z/2Z. + +qudit_hyperbolic_1.cpp: To create q-ary incidence matrices based on the binary ones. +Input: Put the incidence matrices in the same directory, write the filenames of the same {p,q} tilings and the dual tilings in "latticelist" and "duallatticelist". "d" is the vertex degree of the graph, and "dd" is the degree of the dual graph. The graphs must be regular. +Output: The q-ary incidence matrices, filename is "q_" followed by the original filename. If the graph are non-orientable, e.g. on a Klein bottle, it returns -1 with an error. diff --git a/qudit_hyperbolic_1.cpp b/qudit_hyperbolic_1.cpp new file mode 100644 index 0000000..fd11030 --- /dev/null +++ b/qudit_hyperbolic_1.cpp @@ -0,0 +1,396 @@ +//By Yi Jiang, April 2021 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + int d=7;//degree + int dd=5;//degree of dual graph + string latticelist[]={"5_7_1260.mtx","5_7_6090.mtx"}; + string duallatticelist[]={"7_5_1260.mtx","7_5_6090.mtx"}; + +int** sb;//bonds list for spins +int** bs;//spins list for bonds +//vector > bc;//coefficient +int ns,nb,nc=0; + +bool read_incidence(string readname){ + if(readname.length()){ + ifstream mtxin(readname.c_str()); + if(!mtxin.good()){ + cout<<"error opening file"<>ns>>nb>>nc; + sb=new int*[ns]; + bs=new int*[nb]; + for(int i=0;i>s>>b>>c; + for(int i=0;i=0) + continue; + sb[s-1][i]=b; + break; + } + for(int i=0;i<2;++i){ + if(bs[b-1][i]>=0) + continue; + bs[b-1][i]=s; + break; + } + } + mtxin.close(); + } + return true; + } + else{ + cout<<"error in function \"read_incidence\""<>nf>>nb>>nc; + fb=new int*[nf]; + bf=new int*[nb]; + for(int i=0;i>s>>b>>c; + for(int i=0;i=0) + continue; + fb[s-1][i]=b; + break; + } + for(int i=0;i<2;++i){ + if(bf[b-1][i]>=0) + continue; + bf[b-1][i]=s; + break; + } + } + mtxin.close(); + } + return true; + } + /* + d=4; + lattsize="square_"+to_string(l); + sb2=new int*[l*l]; + bs2=new int*[l*l*2]; + for(int i=0;i > ef_curr;//current layer of edge-face + vector > ef_next;//next layer of edge-face + //vector faces_next;//next layer of faces + + ef_next.push_back(make_pair(1,bf[0][0])); + ef_curr.push_back(ef_next[0]); + + int layercount=0; + while(ef_next.size()){ + layercount++; + if(layercount>=100){ + cout<<"too many layers"< ef=ef_next[i]; + //current face is ef.second, work on all the other edges, create current layer. + vector edges; + for(int j=0;j e1; + if(abs(bf[ef.first-1][0])==ef.second){ + if(bf[ef.first-1][0]<0){ + e1=make_pair(abs(bs[ef.first-1][1]),abs(bs[ef.first-1][0])); + } + else if(bf[ef.first-1][1]<0){ + e1=make_pair(abs(bs[ef.first-1][0]),abs(bs[ef.first-1][1])); + } + else{ + cout<<"something wrong in part 000"; + return -1; + } + } + else if(abs(bf[ef.first-1][1])==ef.second){ + if(bf[ef.first-1][1]<0){ + e1=make_pair(abs(bs[ef.first-1][1]),abs(bs[ef.first-1][0])); + } + else if(bf[ef.first-1][0]<0){ + e1=make_pair(abs(bs[ef.first-1][0]),abs(bs[ef.first-1][1])); + } + else{ + cout<<"something wrong in part 001"; + return -1; + } + } + else{ + cout<<"something wrong in part 002"; + return -1; + } + for(int j=0;j0){ + bf[edges[j]-1][1]*=-1; + ef_curr.push_back(make_pair(edges[j],ef.second)); + } + } + else{ + if(bf[edges[j]-1][1]<0){ + cout<<"graph not orientable"<0){ + bf[edges[j]-1][0]*=-1; + ef_curr.push_back(make_pair(edges[j],ef.second)); + } + } + } + else{//wrong order + e1.first=e1.second; + e1.second=abs(bs[edges[j]-1][0]); + if(abs(bf[edges[j]-1][0])==ef.second){ + if(bf[edges[j]-1][1]<0){ + cout<<"graph not orientable"<0){ + bf[edges[j]-1][0]*=-1; + ef_curr.push_back(make_pair(edges[j],ef.second)); + } + } + else{ + if(bf[edges[j]-1][0]<0){ + cout<<"graph not orientable"<0){ + bf[edges[j]-1][1]*=-1; + ef_curr.push_back(make_pair(edges[j],ef.second)); + } + } + } + edges.erase(edges.begin()+j); + break; + } + } + /* + if(flag==0){ + cout<<"edge not found?"<dd){ + cout<<"stuck in loop"<0) + outfile<<1<0) + outfile<<1<0) + outfile<<1<0) + outfile<<1<