Tensor Network Theory Library  Beta release 1.2.1 A library of routines for performing TNT-based operations
tntMpsCreateSTstaircase.c
1 /*
2 Authors: Sarah Al-Assam, Stephen Clark and Dieter Jaksch
3 $LastChangedDate$
4 (c) University of Oxford 2014
5 */
6
7 /* Include internal header */
8 #include "tntMpsInternal.h"
9
72 tntNetwork tntMpsCreatePropST2sc(unsigned L,
73  tntComplex dtc,
74  tntNodeArray *nnL,
75  tntNodeArray *nnR,
76  tntComplexArray *nnparam,
77  tntNodeArray *os,
78  tntComplexArray *osparam)
79 {
80  tntComplex h; /* Uniform scale factor for exponentials */
81  tntNodeArray Proparr; /* Array of propagators */
82  tntNetwork Prop; /* The propagator network to return */
83
84  /* Create the scale factor from the time step */
85  h.re = dtc.re/2.0;
86  h.im = dtc.im/2.0;
87
88  /* Generate an array of propagators required to build the network */
89  Proparr = tntMpsCreatePropArray(L,h,nnL,nnR,nnparam,os,osparam);
90
91  Prop = tntMpsPropArrayToST2sc(Proparr);
92
93  /* Free the array of propagators (copies of all nodes taken for the network so we can free it) */
94  tntNodeArrayFree(&Proparr);
95
96  /* Return the network */
97  return Prop;
98
99 }
100
115 tntNetwork tntMpsPropArrayToST2sc(tntNodeArray Proparr)
116 {
117
118  tntNetwork Prop; /* The propagator network to return */
119  tntNode Ptop; /* Last inserted node in the top or left-to-right staircase */
120  tntNode Pbot; /* Last inserted node in the bottom or right-to-left staircase */
121  unsigned j; /* site counter */
122
123  /* Create an empty network */
124  Prop = tntNetworkCreate();
125
126  /* Copy over first node */
127  Ptop = tntNodeCopy(Proparr.vals[0]);
128
129  /* Add a leg to the first node in the network for joining to start of network */
131
132  /* Place a copy of the first node at the start of the network
133  * This represents the top of the staircase
134  * Left bottom leg points to the end of the network */
135  tntNodeInsertAtStart(Ptop,"L","D",Prop);
136
137  /* Copy over first node again */
138  Pbot = tntNodeCopy(Proparr.vals[0]);
139
140  /* Add a leg to the first node in the network for joining to end of network */
142
143  /* Place a copy of the first node at the end of the network
144  * This represents the end of the staircase or zip back and forth
145  * The top left leg of this node connects to the bottom left leg of the topmost propagator that previously pointed to the end of the network */
146  tntNodeInsertAtEnd(Pbot, "U", "L", Prop);
147
148  /* Join the nodes on their right legs too */
149  tntNodeJoin(Ptop, "E", Pbot, "V");
150
151  /* Now move from left to right, inserting nodes below and right to the nodes forming the left to right staircase and above and right the nodes forming the right to left staircase */
152  for (j = 1; j < Proparr.sz; j++) {
153
154  /* Insert new top node to the right of and between the current top node and bottom node */
155  tntNodeInsert(tntNodeCopy(Proparr.vals[j]), "U", "D", Ptop, "E", Pbot, "V");
156
157  /* Reassign the current top node */
158  Ptop = tntNodeFindConn(Ptop, "E");
159
160  /* Insert new bottom node directly under the new current top node and above and to the right of the current bottom node */
161  tntNodeInsert(tntNodeCopy(Proparr.vals[j]), "U", "D", Ptop, "D", Pbot, "V");
162
163  /* Reassign the current bottom node */
164  Pbot = tntNodeFindConn(Pbot, "V");
165
166  /* Join the nodes on their right legs too */
167  tntNodeJoin(Ptop, "E", Pbot, "V");
168
169  }
170
171  /* Return the network */
172  return Prop;
173 }
tntNode tntNodeCopy(tntNode A)
Definition: tntNodeUtil.c:304
void tntNodeArrayFree(tntNodeArray *arr)
Definition: tntArray.c:668
void tntNodeJoin(tntNode A, tntLegLabel legA, tntNode B, tntLegLabel legB)
Definition: tntNodeConn.c:52
tntNetwork tntNetworkCreate(void)
Definition: tntNetwork.c:92
void tntNodeInsertAtEnd(tntNode I, tntLegLabel legIlast, tntLegLabel legInwend, tntNetwork nw)
Definition: tntNodeConn.c:252
void tntNodeInsert(tntNode I, tntLegLabel legIA, tntLegLabel legIB, tntNode A, tntLegLabel legA, tntNode B, tntLegLabel legB)
Definition: tntNodeConn.c:177
Definition: tnt.h:65