Tensor Network Theory Library  Beta release 1.0
A library of routines for performing TNT-based operations
Deprecated

Functions

tntNodeArray tntMpsCreatePropagator (unsigned L, tntComplex dtc, tntNodeArray *nnL, tntNodeArray *nnR, tntComplexArray *nnparam, tntNodeArray *os, tntComplexArray *osparam)
 
void tntMpsProcessInitOptions (int argc, char **argv, tntNetwork *mps, tntNetwork *mpo, tntNodeArray *Uarr, tntMpsExOp *ExOp)
 
double tntMpsExpecSing (tntNetwork mps, unsigned num_op, tntNode op[], unsigned sitenum[], int orth_centre, double norm)
 
void tntMpsFlip (tntNetwork mpsA, tntNetwork mpsB)
 
double tntMpsOverlap (tntNetwork mpsA, tntNetwork mpsB)
 
double tntMpsMpoExpec (tntNetwork mps, tntNetwork mpo)
 
double tntMpsMpoProdExpec (tntNetwork mps, unsigned num_op, tntNode op[], unsigned sitenum[])
 
double tntMpsNorm (tntNetwork mps, int orth_centre)
 
double tntMpsTebdSweepInhom (tntNetwork wf, int direction, int chi, tntNodeArray U)
 
double tntMpsTebdSweepUni (tntNetwork wf, int direction, int chi, tntNode UL, tntNode UM, tntNode UR)
 
double tntMpsTebdSweepVar (tntNetwork wf, int direction, int chi, tntNode U, tntDoubleArray params)
 

Detailed Description

These functions are marked for removal. Do not use them if writing new code. They will still work in your exisiting codes but will generate warnings.

See the warnings or the documentation for the functions for information on how to move to new non-deprecated functions.

Function Documentation

tntNodeArray tntMpsCreatePropagator ( unsigned  L,
tntComplex  dtc,
tntNodeArray nnL,
tntNodeArray nnR,
tntComplexArray nnparam,
tntNodeArray os,
tntComplexArray osparam 
)
Deprecated:
Functions to create propagators are being renamed to better describe what they do. The function has been replaced with tntMpsCreatePropArray(), which expects matrices for the arguments instead of arrays. This function creates an array of propagators, however in future consider using tntMpsCreatePropST2sc(), which creates a network of propagators arranged in a staircase. Note in function tntMpsCreatePropST2sc() the argument for the timestep represents a full time-step for a backwards a forwards sweep i.e. each two site gate is created using a scale factor which is half of this. This network is then suitable for passing directly to the function for a TEBD time step (now renamed tntMpsPropST2scProduct())
38 {
39 
40  char warning_msg[TNT_STRLEN]; /* Buffer to contain warning message */
41 
42  if (!tntMpsCreatePropagator_warning) {
43  strcpy(warning_msg,"Function tntMpsCreatePropagator() is deprecated and has been replaced with tntMpsCreatePropArray() instead|");
44  strcat(warning_msg,"Consider using tntMpsCreatePropST2sc() which creates a network of propagators arranged in a staircase|");
45  strcat(warning_msg,"In function tntMpsCreatePropST2sc() the argument dtc represents a full time-step for RTL+LTR sweep|");
46  strcat(warning_msg,"i.e. each two site gate is created using a scale factor which is half of this|");
47  strcat(warning_msg,"This warning will not be printed for any subsequent calls to tntMpsCreatePropagator()");
48  tntWarningPrint(warning_msg);
49  tntMpsCreatePropagator_warning = 1;
50  }
51 
52  if ((NULL != nnL)&&(nnL->sz != 0)) {
53  nnparam->numrows = nnL->sz;
54  nnparam->numcols = nnparam->sz/nnL->sz;
55  }
56 
57  if ((NULL != os)&&(os->sz != 0)) {
58  osparam->numrows = os->sz;
59  osparam->numcols = osparam->sz/os->sz;
60  }
61 
62  return tntMpsCreatePropArray(L,dtc,nnL,nnR,nnparam,os,osparam);
63 }
tntNodeArray tntMpsCreatePropArray(unsigned L, tntComplex h, tntNodeArray *nnl, tntNodeArray *nnr, tntComplexArray *nnparam, tntNodeArray *os, tntComplexArray *osparam)
Definition: tntMpsCreatePropagator.c:77
unsigned sz
The number of elements in the array.
Definition: tnt.h:170
unsigned numrows
The number of rows in the matrix.
Definition: tnt.h:171
#define TNT_STRLEN
Definition: tnt.h:59
unsigned numcols
The number of columns in the matrix.
Definition: tnt.h:172
unsigned sz
The number of elements in the array.
Definition: tnt.h:180
double tntMpsExpecSing ( tntNetwork  mps,
unsigned  num_op,
tntNode  op[],
unsigned  sitenum[],
int  orth_centre,
double  norm 
)
Deprecated:
This function is deprecated - use function tntMpsPmpoMpsProduct(). This function expects tntNodeArray and tntIntArray arguments instead. In addition tntMpsPmpoMpsProduct() does not divide by the norm of the MPS. Therefore If the norm of your mps is not 1.0, then divide your result by the result of tntMpsSelfProduct(). The new function also returns a tntComplex rather than double type - use tntComplexToReal() to convert type.
144 {
145 
146  char warning_msg[TNT_STRLEN]; /* Buffer to contain warning message */
147  tntNodeArray opArray; /* Node array to hold operators */
148  tntIntArray sitenumArray; /* Integer array to hold site numbers */
149  double expec; /* un-normalised expecation value */
150 
151  opArray.sz = sitenumArray.sz = num_op;
152 
153  opArray.vals = op;
154  sitenumArray.vals = (int *) sitenum;
155 
156  if (!tntMpsExpecSing_warning) {
157  strcpy(warning_msg,"Function tntMpsExpecSing() is deprecated - use tntMpsPmpoMpsProduct() instead|");
158  strcat(warning_msg,"This function expects tntNodeArray and tntIntArray arguments instead|");
159  strcat(warning_msg,"It does not divide by the MPS norm so you may also need to divide by the result of tntMpsMpsProduct()|");
160  strcat(warning_msg,"It returns a tntComplex rather than double type - use tntComplexToReal() to convert type|");
161  strcat(warning_msg,"This warning will not be printed for any subsequent calls to tntMpsExpecSing()");
162  tntWarningPrint(warning_msg);
163 
164  tntMpsExpecSing_warning = 1;
165  }
166 
167 
168  /* Find the product of the MPS-PMPO-MPS contraction */
169  expec = tntComplexToReal(tntMpsPmpoMpsProduct(mps,&opArray,&sitenumArray,orth_centre));
170 
171  return expec/norm;
172 
173 }
Simple 1D array for integer values.
Definition: tnt.h:148
double tntComplexToReal(tntComplex var)
Definition: tntMisc_funcs.c:1022
int * vals
Pointer to the first element in the integer array.
Definition: tnt.h:149
Simple 1D array for tntNodes.
Definition: tnt.h:178
tntNode * vals
Pointer to the first element in the tntNode array.
Definition: tnt.h:179
#define TNT_STRLEN
Definition: tnt.h:59
tntComplex tntMpsPmpoMpsProduct(tntNetwork mps, tntNodeArray *op, tntIntArray *sitenum, int orth_centre)
Definition: tntMpsPmpoMps.c:56
unsigned sz
The number of elements in the array.
Definition: tnt.h:150
unsigned sz
The number of elements in the array.
Definition: tnt.h:180
void tntMpsFlip ( tntNetwork  mpsA,
tntNetwork  mpsB 
)
Deprecated:
This function is deprecated - it has been renamed to follow a naming convention which better descibes its operation. Use function tntMpsMpsConnect() instead.
183 {
184 
185  char warning_msg[TNT_STRLEN]; /* Buffer to contain warning message */
186 
187  if (!tntMpsFlip_warning) {
188  strcpy(warning_msg,"Function tntMpsFlip() is deprecated - use tntMpsMpsConnect() instead|");
189  strcat(warning_msg,"This warning will not be printed for any subsequent calls to tntMpsFlip()");
190  tntWarningPrint(warning_msg);
191  tntMpsFlip_warning = 1;
192  }
193 
194 
195  /* Connect the networks */
196  tntMpsMpsConnect(mpsA,mpsB);
197 
198  return;
199 }
void tntMpsMpsConnect(tntNetwork mpsA, tntNetwork mpsB)
Definition: tntMpsMps.c:38
#define TNT_STRLEN
Definition: tnt.h:59
double tntMpsMpoExpec ( tntNetwork  mps,
tntNetwork  mpo 
)
Deprecated:
This function is deprecated - it has been renamed to follow a naming convention which better descibes its operation. Use function tntMpsMpoMpsProduct() instead. The new function returns a tntComplex rather than double type - use tntComplexToReal() to convert type.
232 {
233 
234  char warning_msg[TNT_STRLEN]; /* Buffer to contain warning message */
235 
236  if (!tntMpsMpoExpec_warning) {
237  strcpy(warning_msg,"Function tntMpsMpoExpec() is deprecated|It has been renamed to follow a naming convention which better descibes its operation|");
238  strcat(warning_msg,"Use function tntMpsMpoMpsProduct() instead|");
239  strcat(warning_msg,"It returns a tntComplex rather than double type - use tntComplexToReal() to convert type|");
240  strcat(warning_msg,"This warning will not be printed for any subsequent calls to tntMpsMpoExpec()");
241  tntWarningPrint(warning_msg);
242 
243  tntMpsMpoExpec_warning = 1;
244  }
245 
246  return tntComplexToReal(tntMpsMpoMpsProduct(mps,mpo));
247 }
double tntComplexToReal(tntComplex var)
Definition: tntMisc_funcs.c:1022
tntComplex tntMpsMpoMpsProduct(tntNetwork mps, tntNetwork mpo)
Definition: tntMpsMpoMps.c:195
#define TNT_STRLEN
Definition: tnt.h:59
double tntMpsMpoProdExpec ( tntNetwork  mps,
unsigned  num_op,
tntNode  op[],
unsigned  sitenum[] 
)
Deprecated:
This function is deprecated - use function tntMpsPmpoMpsProduct() instead. This function has the same behaviour but expects tntNodeArray and tntIntArray arguments instead. In addition it expects the orthogonality centre as an argument, so pass zero as the last argument. The new function returns a tntComplex rather than double type - use tntComplexToReal() to convert type.
257 {
258 
259  char warning_msg[TNT_STRLEN]; /* Buffer to contain warning message */
260  tntNodeArray opArray; /* Node array to hold operators */
261  tntIntArray sitenumArray; /* Integer array to hold site numbers */
262 
263  opArray.sz = sitenumArray.sz = num_op;
264 
265  opArray.vals = op;
266  sitenumArray.vals = (int *) sitenum;
267 
268  if (!tntMpsMpoProdExpec_warning) {
269  strcpy(warning_msg,"Function tntMpsMpoProdExpec() is deprecated - use tntMpsPmpoMpsProduct instead|");
270  strcat(warning_msg,"This function expects tntNodeArray and tntIntArray arguments instead|");
271  strcat(warning_msg,"It returns a tntComplex rather than double type - use tntComplexToReal() to convert type|");
272  strcat(warning_msg,"This warning will not be printed for any subsequent calls to tntMpsMpoProdExpec()");
273  tntWarningPrint(warning_msg);
274 
275  tntMpsMpoProdExpec_warning = 1;
276  }
277  return tntComplexToReal(tntMpsPmpoMpsProduct(mps,&opArray,&sitenumArray,0));
278 }
Simple 1D array for integer values.
Definition: tnt.h:148
double tntComplexToReal(tntComplex var)
Definition: tntMisc_funcs.c:1022
int * vals
Pointer to the first element in the integer array.
Definition: tnt.h:149
Simple 1D array for tntNodes.
Definition: tnt.h:178
tntNode * vals
Pointer to the first element in the tntNode array.
Definition: tnt.h:179
#define TNT_STRLEN
Definition: tnt.h:59
tntComplex tntMpsPmpoMpsProduct(tntNetwork mps, tntNodeArray *op, tntIntArray *sitenum, int orth_centre)
Definition: tntMpsPmpoMps.c:56
unsigned sz
The number of elements in the array.
Definition: tnt.h:150
unsigned sz
The number of elements in the array.
Definition: tnt.h:180
double tntMpsNorm ( tntNetwork  mps,
int  orth_centre 
)
Deprecated:
This function is deprecated - it has been renamed to follow a naming convention which better descibes its operation. Use function tntMpsSelfProduct() instead. Note this function (as the original function) returns the 2-norm squared rather than the norm itself.
287 {
288 
289  char warning_msg[TNT_STRLEN]; /* Buffer to contain warning message */
290 
291  if (!tntMpsNorm_warning) {
292 
293  strcpy(warning_msg,"Function tntMpsNorm() is deprecated - use tntMpsSelfProduct() instead|");
294  strcat(warning_msg,"This warning will not be printed for any subsequent calls to tntMpsNorm()");
295  tntWarningPrint(warning_msg);
296 
297  tntMpsNorm_warning = 1;
298  }
299 
300  /* Find the norm squared */
301  return tntMpsSelfProduct(mps,orth_centre);
302 
303 }
double tntMpsSelfProduct(tntNetwork mps, int orth_centre)
Definition: tntMpsMps.c:355
#define TNT_STRLEN
Definition: tnt.h:59
double tntMpsOverlap ( tntNetwork  mpsA,
tntNetwork  mpsB 
)
Deprecated:
This function is deprecated - it has been renamed to follow a naming convention which better descibes its operation. Use function tntMpsMpsProduct() instead. The new function returns a tntComplex rather than double type - use tntComplexToReal() to convert type.
208 {
209 
210  char warning_msg[TNT_STRLEN]; /* Buffer to contain warning message */
211 
212  if (!tntMpsOverlap_warning) {
213  strcpy(warning_msg,"Function tntMpsOverlap() is deprecated|It has been renamed to follow a naming convention which better descibes its operation|");
214  strcat(warning_msg,"Use function tntMpsMpsProduct() instead|");
215  strcat(warning_msg,"It returns a tntComplex rather than double type - use tntComplexToReal() to convert type|");
216  strcat(warning_msg,"This warning will not be printed for any subsequent calls to tntMpsOverlap()");
217  tntWarningPrint(warning_msg);
218 
219  tntMpsOverlap_warning = 1;
220  }
221 
222  return tntComplexToReal(tntMpsMpsProduct(mpsA,mpsB));
223 }
double tntComplexToReal(tntComplex var)
Definition: tntMisc_funcs.c:1022
tntComplex tntMpsMpsProduct(tntNetwork mpsA, tntNetwork mpsB)
Definition: tntMpsMps.c:301
#define TNT_STRLEN
Definition: tnt.h:59
void tntMpsProcessInitOptions ( int  argc,
char **  argv,
tntNetwork mps,
tntNetwork mpo,
tntNodeArray Uarr,
tntMpsExOp ExOp 
)
Deprecated:
Functions to create propagators are being renamed to better describe what they do. The function has been replaced with tntMpsCreatePropArray(), which expects matrices for the arguments instead of arrays. This function creates an array of propagators, however in future consider using tntMpsCreatePropST2sc(), which creates a network of propagators arranged in a staircase. Note in function tntMpsCreatePropST2sc() the argument for the timestep represents a full time-step for a backwards a forwards sweep i.e. each two site gate is created using a scale factor which is half of this. This network is then suitable for passing directly to the function for a TEBD time step (now renamed tntMpsPropST2scProduct())
76 {
77 
78  char warning_msg[TNT_STRLEN]; /* Buffer to contain warning message */
79 
80  if (!tntMpsProcessInitOptions_warning) {
81  strcpy(warning_msg,"Function tntMpsProcessInitOptions() is deprecated and has been replaced with tntMpsProcessSysOptions() instead|");
82  strcat(warning_msg,"This function returns the propagator as a network instead of an array|");
83  strcat(warning_msg,"This network is then suitable for passing to the new function for evolution with a propagator tntMpsPropSt2scProduct()|");
84  strcat(warning_msg,"This warning will not be printed for any subsequent calls to tntMpsProcessInitOptions()");
85  tntWarningPrint(warning_msg);
86  tntMpsProcessInitOptions_warning = 1;
87  }
88 
89 
90  /* Call functon to process options */
91  if (NULL == Uarr) {
92  /* No additional action required if Uarr is NULL */
93  tntMpsProcessSysOptions(argc,argv,mps,mpo,NULL,ExOp);
94  } else {
95  /* Otherwise need to change the propagator network to an array */
96  tntNetwork prop; /* Propagator network */
97  unsigned numprop=1; /* number of propagators */
98  tntNode P; /* Current propagator node */
99 
100  /* Get the system options including the propagator network */
101  tntMpsProcessSysOptions(argc,argv,mps,mpo,&prop,ExOp);
102 
103  /* Need to get length of system, but cannot assume that any of the arguments are not NULL apart from prop */
104  /* Instead use property that it is only on the rightmost node that the two downwards facing legs connect to the same propagator */
105  P = tntNodeFindFirst(prop);
107  /* Move to next node */
109  /* increment number of nodes encountered */
110  numprop++;
111  }
112 
113  /* Assign an array of the correct size */
114  *Uarr = tntNodeArrayAlloc(numprop);
115 
116  /* Move through network again copying nodes to the array */
117  P = tntNodeFindFirst(prop);
118  /* turn the network to a node group to remove singleton legs */
119  tntNetworkToNodeGroup(&prop);
120  Uarr->vals[0] = tntNodeCopy(P,0);
121  for (numprop = 1; numprop < Uarr->sz; numprop++) {
122  /* Move to next node */
124  /* Copy it to array */
125  Uarr->vals[numprop] = tntNodeCopy(P,0);
126  }
127 
128  /* all required nodes now coped from this group so it is no longer required */
129  tntNodeGroupFree(&P);
130  }
131 
132  return;
133 }
void tntNetworkToNodeGroup(tntNetwork *tnwp)
Definition: tntNetwork_funcs.c:209
tntNode tntNodeFindConn(tntNode tn, unsigned legA)
Definition: tntNode_funcs.c:438
struct tnode * tntNode
Definition: tnt.h:118
#define TNT_MPS_TDR
Definition: tntMps.h:91
tntNodeArray tntNodeArrayAlloc(unsigned num_elems)
Definition: tntArray_funcs.c:110
void tntNodeGroupFree(tntNode *tn)
Definition: tntNode_funcs.c:1053
struct tnetwork * tntNetwork
Definition: tnt.h:123
tntNode * vals
Pointer to the first element in the tntNode array.
Definition: tnt.h:179
#define TNT_STRLEN
Definition: tnt.h:59
tntNode tntNodeCopy(tntNode tn, int conj)
Definition: tntNode_funcs.c:486
tntNode tntNodeFindFirst(tntNetwork tnw)
Definition: tntNode_funcs.c:664
void tntMpsProcessSysOptions(int argc, char **argv, tntNetwork *mps, tntNetwork *mpo, tntNetwork *prop, tntMpsExOp *ExOp)
Definition: tntMpsProcessInitOptions.c:251
#define TNT_MPS_TDL
Definition: tntMps.h:86
unsigned sz
The number of elements in the array.
Definition: tnt.h:180
double tntMpsTebdSweepInhom ( tntNetwork  wf,
int  direction,
int  chi,
tntNodeArray  U 
)
Deprecated:
This function is deprecated - use tntMpsCreatePropST2sc() to create a propogator network then apply it using tntMpsPropSt2scProduct(). See the documentation for these functions for more details.
311  {
312 
313  char warning_msg[TNT_STRLEN]; /* Buffer to contain warning message */
314 
315  if (!tntMpsTebdSweepInhom_warning) {
316 
317  strcpy(warning_msg,"Function tntMpsTebdSweepInhom() is deprecated|");
318  strcat(warning_msg,"Use tntMpsCreatePropST2sc() to create a propogator network then apply it using tntMpsPropSt2scProduct()|");
319  strcat(warning_msg,"Parameter direction is being ignored:| a sweep in both directions is being carried out if direction = TNT_MPS_R and none otherwise|");
320  strcat(warning_msg,"This warning will not be printed for any subsequent calls to tntMpsTebdSweepInhom()");
321  tntWarningPrint(warning_msg);
322 
323  tntMpsTebdSweepInhom_warning = 1;
324  }
325 
326 
327  if (TNT_MPS_R == direction) {
328 
329  double err; /* truncation error */
330 
331  /* Create the propagator network */
333 
334  /* Apply the sweep of propagators and return the truncation error */
335  err = tntMpsPropST2scProduct(wf, Prop, chi);
336 
337  /* free the propagator network */
338  tntNetworkFree(&Prop);
339 
340  return err;
341 
342  } else {
343  return 0.0;
344  }
345 
346 }
void tntNetworkFree(tntNetwork *tnwp)
Definition: tntNetwork_funcs.c:84
struct tnetwork * tntNetwork
Definition: tnt.h:123
tntNetwork tntMpsPropArrayToST2sc(tntNodeArray Proparr)
Definition: tntMpsCreateSTstaircase.c:85
double tntMpsPropST2scProduct(tntNetwork mps, tntNetwork Prop, int chi)
Definition: tntMpsST2sc.c:217
#define TNT_STRLEN
Definition: tnt.h:59
#define TNT_MPS_R
Definition: tntMps.h:61
double tntMpsTebdSweepUni ( tntNetwork  wf,
int  direction,
int  chi,
tntNode  UL,
tntNode  UM,
tntNode  UR 
)
Deprecated:
This function is deprecated - use tntMpsCreatePropST2sc() to create a propogator network then apply it using tntMpsPropSt2scProduct(). See the documentation for these functions for more details.
355 {
356 
357  char warning_msg[TNT_STRLEN]; /* Buffer to contain warning message */
358 
359  if (!tntMpsTebdSweepUni_warning) {
360 
361  strcpy(warning_msg,"Function tntMpsTebdSweepUni() is deprecated|");
362  strcat(warning_msg,"Use tntMpsCreatePropST2sc() to create a propogator network then apply it using tntMpsPropSt2scProduct()|");
363  strcat(warning_msg,"Parameter direction is being ignored:| a sweep in both directions is being carried out if direction == TNT_MPS_R and none otherwise|");
364  strcat(warning_msg,"This warning will not be printed for any subsequent calls to tntMpsTebdSweepInhom()");
365  tntWarningPrint(warning_msg);
366 
367  tntMpsTebdSweepUni_warning = 1;
368  }
369 
370  if (TNT_MPS_R == direction) {
371 
372  double err; /* truncation error */
373  tntNodeArray Proparr; /* array of propagators */
374  tntNetwork Prop; /* the propagator network */
375  unsigned L; /* Length of MPS */
376  unsigned j; /* site counter */
377 
378  /* Create the array of nodes */
379  L = tntMpsLength(wf); /* length of the MPS */
380  Proparr = tntNodeArrayAlloc(L-1); /* L-1 two site gates needed */
381 
382  /* Populate the array with copies of the nodes */
383  Proparr.vals[0] = tntNodeCopy(UL,0);
384  Proparr.vals[L-2] = tntNodeCopy(UR,0);
385 
386  for (j = 1; j < L-2; j++) {
387  Proparr.vals[j] = tntNodeCopy(UM,0);
388  }
389 
390  /* Create the propagator network */
391  Prop = tntMpsPropArrayToST2sc(Proparr);
392 
393  /* Apply the sweep of propagators and return the truncation error */
394  err = tntMpsPropST2scProduct(wf, Prop, chi);
395 
396  /* free the propagator network */
397  tntNetworkFree(&Prop);
398 
399  /* free the array of nodes */
400  tntNodeArrayFree(&Proparr);
401 
402  return err;
403 
404  } else {
405  return 0.0;
406  }
407 
408 }
unsigned tntMpsLength(tntNetwork mps)
Definition: tntMpsUtil.c:208
void tntNetworkFree(tntNetwork *tnwp)
Definition: tntNetwork_funcs.c:84
tntNodeArray tntNodeArrayAlloc(unsigned num_elems)
Definition: tntArray_funcs.c:110
Simple 1D array for tntNodes.
Definition: tnt.h:178
struct tnetwork * tntNetwork
Definition: tnt.h:123
void tntNodeArrayFree(tntNodeArray *arr)
Definition: tntArray_funcs.c:210
tntNetwork tntMpsPropArrayToST2sc(tntNodeArray Proparr)
Definition: tntMpsCreateSTstaircase.c:85
double tntMpsPropST2scProduct(tntNetwork mps, tntNetwork Prop, int chi)
Definition: tntMpsST2sc.c:217
tntNode * vals
Pointer to the first element in the tntNode array.
Definition: tnt.h:179
#define TNT_STRLEN
Definition: tnt.h:59
tntNode tntNodeCopy(tntNode tn, int conj)
Definition: tntNode_funcs.c:486
#define TNT_MPS_R
Definition: tntMps.h:61
double tntMpsTebdSweepVar ( tntNetwork  wf,
int  direction,
int  chi,
tntNode  U,
tntDoubleArray  params 
)
Deprecated:
This function is deprecated - use tntMpsCreatePropST2sc() to create a propogator network then apply it using tntMpsPropSt2scProduct(). See the documentation for these functions for more details.
417 {
418 
419  char warning_msg[TNT_STRLEN]; /* Buffer to contain warning message */
420 
421  if (!tntMpsTebdSweepVar_warning) {
422 
423  strcpy(warning_msg,"Function tntMpsTebdSweepVar() is deprecated|");
424  strcat(warning_msg,"Use tntMpsCreatePropST2sc() to create a propogator network then apply it using tntMpsPropSt2scProduct()|");
425  strcat(warning_msg,"Parameter direction is being ignored:| a sweep in both directions is being carried out if direction == TNT_MPS_R and none otherwise|");
426  strcat(warning_msg,"This warning will not be printed for any subsequent calls to tntMpsTebdSweepVar()");
427  tntWarningPrint(warning_msg);
428 
429  tntMpsTebdSweepVar_warning = 1;
430  }
431 
432  if (TNT_MPS_R == direction) {
433 
434  double err; /* truncation error */
435  tntNodeArray Proparr; /* array of propagators */
436  tntNetwork Prop; /* the propagator network */
437  unsigned L; /* Length of MPS */
438  unsigned i, j; /* term counter, site counter */
439  unsigned numterms; /* number of terms in node */
440 
441  /* Check if U is a functional node and get the number of parameters */
442  numterms = tntNodeIsFunctional(U);
443  if (0 == numterms) {
444  /* Insert error handling here */
445  fprintf(stderr,"Error in tntMpsTebdSweepVar(): The two-site gate must be a functional node!"); /* NO_COVERAGE */
446  exit(1); /* NO_COVERAGE */
447  } /* NO_COVERAGE */
448 
449  /* Create the array of nodes */
450  L = tntMpsLength(wf); /* length of the MPS */
451  Proparr = tntNodeArrayAlloc(L-1); /* L-1 two site gates needed */
452 
453  /* Fill array setting relevant parameters for each site */
454  for (j = 0; j < L-1; j++) {
455 
456  /* Create a copy of the unitary */
457  Proparr.vals[j] = tntNodeCopy(U,0);
458 
459  /* Apply the relevant parameters */
460  for (i = 0; i < numterms; i++) {
461  tntNodeSetRealParam(Proparr.vals[j], params.vals[i + j*numterms], i);
462  }
463  }
464 
465  /* Create the propagator network */
466  Prop = tntMpsPropArrayToST2sc(Proparr);
467 
468  /* Apply the sweep of propagators and return the truncation error */
469  err = tntMpsPropST2scProduct(wf, Prop, chi);
470 
471  /* free the propagator network */
472  tntNetworkFree(&Prop);
473 
474  /* free the array of nodes */
475  tntNodeArrayFree(&Proparr);
476 
477  return err;
478 
479  } else {
480  return 0.0;
481  }
482 
483 }
void tntNodeSetRealParam(tntNode tn, double pval, unsigned pnum)
Definition: tntNode_funcs.c:985
unsigned tntMpsLength(tntNetwork mps)
Definition: tntMpsUtil.c:208
unsigned tntNodeIsFunctional(tntNode tn)
Definition: tntNode_funcs.c:1243
void tntNetworkFree(tntNetwork *tnwp)
Definition: tntNetwork_funcs.c:84
tntNodeArray tntNodeArrayAlloc(unsigned num_elems)
Definition: tntArray_funcs.c:110
double * vals
Pointer to the first element in the double array.
Definition: tnt.h:159
Simple 1D array for tntNodes.
Definition: tnt.h:178
struct tnetwork * tntNetwork
Definition: tnt.h:123
void tntNodeArrayFree(tntNodeArray *arr)
Definition: tntArray_funcs.c:210
tntNetwork tntMpsPropArrayToST2sc(tntNodeArray Proparr)
Definition: tntMpsCreateSTstaircase.c:85
double tntMpsPropST2scProduct(tntNetwork mps, tntNetwork Prop, int chi)
Definition: tntMpsST2sc.c:217
tntNode * vals
Pointer to the first element in the tntNode array.
Definition: tnt.h:179
#define TNT_STRLEN
Definition: tnt.h:59
tntNode tntNodeCopy(tntNode tn, int conj)
Definition: tntNode_funcs.c:486
#define TNT_MPS_R
Definition: tntMps.h:61