Tensor Network Theory Library  Beta release 1.2.1
A library of routines for performing TNT-based operations
 All Data Structures Functions Variables Groups Pages
tntSave.c
1 /*
2 Authors: Sarah Al-Assam, Stephen Clark and Dieter Jaksch
3 Date: $LastChangedDate: 2015-05-14 13:43:34 +0100 (Thu, 14 May 2015) $
4 (c) University of Oxford 2014
5 */
6 
7 #include "../headers/tnt_int.h"
8 #include "../headers/dec_public.h"
9 #include "../headers/dec_io.h"
10 
17 #ifdef MAKINGPUBLICDOCS
18 void tntIntParamsSave(const char *fname,
19  int varA,
20  int varB,
21  int varC,
22  int varD,
23  int varE)
24 {}
31 void tntIntParamsNamedSave(const char *fname,
32  int varA,
33  const char *varnameA,
34  int varB,
35  const char *varnameB,
36  int varC,
37  const char *varnameC,
38  int varD,
39  const char *varnameD,
40  int varE,
41  const char *varnameE)
42 #else
43 void tntIntParamsSaveStatic(const char *fname,
44  int varA,
45  const char *varnameA,
46  int varB,
47  const char *varnameB,
48  int varC,
49  const char *varnameC,
50  int varD,
51  const char *varnameD,
52  int varE,
53  const char *varnameE)
54 #endif
55 {
56  int vars[TNT_MAX_NUMIO] = {varA,varB,varC,varD,varE};
57  const char *varnames[TNT_MAX_NUMIO] = {varnameA,varnameB,varnameC,varnameD,varnameE};
58  unsigned numint = _tnt_find_num_unique(varnames);
59  TNT_ERR_RET_DEFS
60 
61  ret = _tnt_save_intparams(fname, numint, varnames, vars);
62  TNT_PUB_N_ERR_CHK("tntIntParamsSave") /* NO_COVERAGE */
63 
64 }
65 
72 #ifdef MAKINGPUBLICDOCS
73 void tntDoubleParamsSave(const char *fname,
74  double varA,
75  double varB,
76  double varC,
77  double varD,
78  double varE)
79 {}
86 void tntDoubleParamsNamedSave(const char *fname,
87  double varA,
88  const char *varnameA,
89  double varB,
90  const char *varnameB,
91  double varC,
92  const char *varnameC,
93  double varD,
94  const char *varnameD,
95  double varE,
96  const char *varnameE)
98 #else
99 void tntDoubleParamsSaveStatic(const char *fname,
100  double varA,
101  const char *varnameA,
102  double varB,
103  const char *varnameB,
104  double varC,
105  const char *varnameC,
106  double varD,
107  const char *varnameD,
108  double varE,
109  const char *varnameE)
110 #endif
111 {
112  double vars[TNT_MAX_NUMIO] = {varA,varB,varC,varD,varE};
113  const char *varnames[TNT_MAX_NUMIO] = {varnameA,varnameB,varnameC,varnameD,varnameE};
114  unsigned numdbl = _tnt_find_num_unique(varnames);
115  TNT_ERR_RET_DEFS
116 
117  ret = _tnt_save_dblparams(fname, numdbl, varnames, vars);
118  TNT_PUB_N_ERR_CHK("tntDoubleParamsSave") /* NO_COVERAGE */
119 
120 }
121 
122 
129 #ifdef MAKINGPUBLICDOCS
130 void tntComplexParamsSave(const char *savepref,
131  tntComplex varA,
132  tntComplex varB,
133  tntComplex varC,
134  tntComplex varD,
135  tntComplex varE)
136 {}
143 void tntComplexParamsNamedSave(const char *fname,
144  tntComplex varA,
145  const char *varnameA,
146  tntComplex varB,
147  const char *varnameB,
148  tntComplex varC,
149  const char *varnameC,
150  tntComplex varD,
151  const char *varnameD,
152  tntComplex varE,
153  const char *varnameE)
154 #else
155 void tntComplexParamsSaveStatic(const char *fname,
156  tntComplex varA,
157  const char *varnameA,
158  tntComplex varB,
159  const char *varnameB,
160  tntComplex varC,
161  const char *varnameC,
162  tntComplex varD,
163  const char *varnameD,
164  tntComplex varE,
165  const char *varnameE)
166 #endif
167 {
168  tntComplex vars[TNT_MAX_NUMIO] = {varA,varB,varC,varD,varE};
169  const char *varnames[TNT_MAX_NUMIO] = {varnameA,varnameB,varnameC,varnameD,varnameE};
170  unsigned numcmp = _tnt_find_num_unique(varnames);
171  TNT_ERR_RET_DEFS
172 
173  ret = _tnt_save_cmpparams(fname, numcmp, varnames, vars);
174  TNT_PUB_N_ERR_CHK("tntComplexParamsSave") /* NO_COVERAGE */
175 }
176 
183 #ifdef MAKINGPUBLICDOCS
184 void tntStringsSave(const char *fname,
185  const char *varA,
186  const char *varB,
187  const char *varC,
188  const char *varD,
189  const char *varE)
190 #else
191 void tntStringsSaveStatic(const char *fname,
192  const char *varA,
193  const char *varnameA,
194  const char *varB,
195  const char *varnameB,
196  const char *varC,
197  const char *varnameC,
198  const char *varD,
199  const char *varnameD,
200  const char *varE,
201  const char *varnameE)
202 #endif
203 {
204  const char *vars[TNT_MAX_NUMIO] = {varA,varB,varC,varD,varE};
205  const char *varnames[TNT_MAX_NUMIO] = {varnameA,varnameB,varnameC,varnameD,varnameE};
206  unsigned numstrs = _tnt_find_num_unique(varnames);
207  TNT_ERR_RET_DEFS
208 
209  ret = _tnt_save_strs(fname, numstrs, varnames, vars);
210  TNT_PUB_N_ERR_CHK("tntStringsSave") /* NO_COVERAGE */
211 }
212 
213 
220 #ifdef MAKINGPUBLICDOCS
221 void tntIntArraysSave(const char *fname,
222  tntIntArray arrA,
223  tntIntArray arrB,
224  tntIntArray arrC,
225  tntIntArray arrD,
226  tntIntArray arrE)
227 #else
228 void tntIntArraysSaveStatic(const char *fname,
229  tntIntArray arrA,
230  const char *varnameA,
231  tntIntArray arrB,
232  const char *varnameB,
233  tntIntArray arrC,
234  const char *varnameC,
235  tntIntArray arrD,
236  const char *varnameD,
237  tntIntArray arrE,
238  const char *varnameE)
239 #endif
240 {
241  tntIntArray arrs[TNT_MAX_NUMIO] = {arrA,arrB,arrC,arrD,arrE};
242  const char *varnames[TNT_MAX_NUMIO] = {varnameA,varnameB,varnameC,varnameD,varnameE};
243  unsigned numint = _tnt_find_num_unique(varnames);
244  TNT_ERR_RET_DEFS
245 
246  ret = _tnt_save_intarrs(fname, numint, varnames, arrs);
247  TNT_PUB_N_ERR_CHK("tntIntArraysSave") /* NO_COVERAGE */
248 
249 }
250 
251 #ifdef MAKINGPUBLICDOCS
252 
258 void tntDoubleArraysSave(const char *fname,
259  tntDoubleArray arrA,
260  tntDoubleArray arrB,
261  tntDoubleArray arrC,
262  tntDoubleArray arrD,
263  tntDoubleArray arrE)
264 {}
271 void tntDoubleArraysNamedSave(const char *fname,
272  tntDoubleArray arrA,
273  const char *varnameA,
274  tntDoubleArray arrB,
275  const char *varnameB,
276  tntDoubleArray arrC,
277  const char *varnameC,
278  tntDoubleArray arrD,
279  const char *varnameD,
280  tntDoubleArray arrE,
281  const char *varnameE)
282 #else
283 void tntDoubleArraysSaveStatic(const char *fname,
284  tntDoubleArray arrA,
285  const char *varnameA,
286  tntDoubleArray arrB,
287  const char *varnameB,
288  tntDoubleArray arrC,
289  const char *varnameC,
290  tntDoubleArray arrD,
291  const char *varnameD,
292  tntDoubleArray arrE,
293  const char *varnameE)
294 #endif
295 {
296  tntDoubleArray arrs[TNT_MAX_NUMIO] = {arrA,arrB,arrC,arrD,arrE};
297  const char *varnames[TNT_MAX_NUMIO] = {varnameA,varnameB,varnameC,varnameD,varnameE};
298  unsigned numdbl = _tnt_find_num_unique(varnames);
299  TNT_ERR_RET_DEFS
300 
301  ret = _tnt_save_dblarrs(fname, numdbl, varnames, arrs);
302  TNT_PUB_N_ERR_CHK("tntDoubleArraysSave") /* NO_COVERAGE */
303 
304 }
305 
306 
307 #ifdef MAKINGPUBLICDOCS
308 
314 void tntComplexArraysSave(const char *fname,
315  tntComplexArray arrA,
316  tntComplexArray arrB,
317  tntComplexArray arrC,
318  tntComplexArray arrD,
319  tntComplexArray arrE)
320 {}
327 void tntComplexArraysNamedSave(const char *fname,
328  tntComplexArray arrA,
329  const char *varnameA,
330  tntComplexArray arrB,
331  const char *varnameB,
332  tntComplexArray arrC,
333  const char *varnameC,
334  tntComplexArray arrD,
335  const char *varnameD,
336  tntComplexArray arrE,
337  const char *varnameE)
338 #else
339 void tntComplexArraysSaveStatic(const char *fname,
340  tntComplexArray arrA,
341  const char *varnameA,
342  tntComplexArray arrB,
343  const char *varnameB,
344  tntComplexArray arrC,
345  const char *varnameC,
346  tntComplexArray arrD,
347  const char *varnameD,
348  tntComplexArray arrE,
349  const char *varnameE)
350 #endif
351 {
352  tntComplexArray arrs[TNT_MAX_NUMIO] = {arrA,arrB,arrC,arrD,arrE};
353  const char *varnames[TNT_MAX_NUMIO] = {varnameA,varnameB,varnameC,varnameD,varnameE};
354  unsigned numcmp = _tnt_find_num_unique(varnames);
355  TNT_ERR_RET_DEFS
356 
357  ret = _tnt_save_cmparrs(fname, numcmp, varnames, arrs);
358  TNT_PUB_N_ERR_CHK("tntComplexArraysSave") /* NO_COVERAGE */
359 }
360 
367 #ifdef MAKINGPUBLICDOCS
368 void tntNodesSave(const char *fname,
369  tntNode varA,
370  tntNode varB,
371  tntNode varC,
372  tntNode varD,
373  tntNode varE)
374 #else
375 void tntNodesSaveStatic(const char *fname,
376  tntNode varA,
377  const char *varnameA,
378  tntNode varB,
379  const char *varnameB,
380  tntNode varC,
381  const char *varnameC,
382  tntNode varD,
383  const char *varnameD,
384  tntNode varE,
385  const char *varnameE)
386 #endif
387 {
388  tntNode vars[TNT_MAX_NUMIO] = {varA,varB,varC,varD,varE};
389  const char *varnames[TNT_MAX_NUMIO] = {varnameA,varnameB,varnameC,varnameD,varnameE};
390  unsigned numnodes = _tnt_find_num_unique(varnames);
391  TNT_ERR_RET_DEFS
392 
393  ret = _tnt_save_nodes(fname, numnodes, varnames, vars);
394  TNT_PUB_N_ERR_CHK("tntNodesSave") /* NO_COVERAGE */
395 }
396 
403 #ifdef MAKINGPUBLICDOCS
404 void tntNodeArraysSave(const char *fname,
405  tntNodeArray arrA,
406  tntNodeArray arrB,
407  tntNodeArray arrC,
408  tntNodeArray arrD,
409  tntNodeArray arrE)
410 #else
411 void tntNodeArraysSaveStatic(const char *fname,
412  tntNodeArray arrA,
413  const char *varnameA,
414  tntNodeArray arrB,
415  const char *varnameB,
416  tntNodeArray arrC,
417  const char *varnameC,
418  tntNodeArray arrD,
419  const char *varnameD,
420  tntNodeArray arrE,
421  const char *varnameE)
422 #endif
423 {
424  tntNodeArray arrs[TNT_MAX_NUMIO] = {arrA,arrB,arrC,arrD,arrE};
425  const char *varnames[TNT_MAX_NUMIO] = {varnameA,varnameB,varnameC,varnameD,varnameE};
426  unsigned numarrs = _tnt_find_num_unique(varnames);
427  TNT_ERR_RET_DEFS
428 
429  ret = _tnt_save_nodearrs(fname, numarrs, varnames, arrs);
430  TNT_PUB_N_ERR_CHK("tntNodeArraysSave"); /* NO_COVERAGE */
431 }
432 
439 #ifdef MAKINGPUBLICDOCS
440 void tntExOpsSave(const char *fname,
441  tntExOp varA,
442  tntExOp varB,
443  tntExOp varC,
444  tntExOp varD,
445  tntExOp varE)
446 #else
447 void tntExOpsSaveStatic(const char *fname,
448  tntExOp varA,
449  const char *varnameA,
450  tntExOp varB,
451  const char *varnameB,
452  tntExOp varC,
453  const char *varnameC,
454  tntExOp varD,
455  const char *varnameD,
456  tntExOp varE,
457  const char *varnameE)
458 #endif
459 {
460  tntExOp vars[TNT_MAX_NUMIO] = {varA,varB,varC,varD,varE};
461  const char *varnames[TNT_MAX_NUMIO] = {varnameA,varnameB,varnameC,varnameD,varnameE};
462  unsigned numexs = _tnt_find_num_unique(varnames);
463  TNT_ERR_RET_DEFS
464 
465  ret = _tnt_save_exops(fname, numexs, varnames, vars);
466  TNT_PUB_N_ERR_CHK("tntExOpsSave"); /* NO_COVERAGE */
467 }
468 
469 #ifdef MAKINGPUBLICDOCS
470 
476 void tntNetworksSave(const char *fname,
477  tntNetwork varA,
478  tntNetwork varB,
479  tntNetwork varC,
480  tntNetwork varD,
481  tntNetwork varE)
482 {}
489 void tntNetworksNamedSave(const char *fname,
490  tntNetwork varA,
491  const char *varnameA,
492  tntNetwork varB,
493  const char *varnameB,
494  tntNetwork varC,
495  const char *varnameC,
496  tntNetwork varD,
497  const char *varnameD,
498  tntNetwork varE,
499  const char *varnameE)
500 #else
501 void tntNetworksSaveStatic(const char *fname,
502  tntNetwork varA,
503  const char *varnameA,
504  tntNetwork varB,
505  const char *varnameB,
506  tntNetwork varC,
507  const char *varnameC,
508  tntNetwork varD,
509  const char *varnameD,
510  tntNetwork varE,
511  const char *varnameE)
512 #endif
513 {
514  tntNetwork vars[TNT_MAX_NUMIO] = {varA,varB,varC,varD,varE};
515  const char *varnames[TNT_MAX_NUMIO] = {varnameA,varnameB,varnameC,varnameD,varnameE};
516  unsigned numnws = _tnt_find_num_unique(varnames);
517  TNT_ERR_RET_DEFS
518 
519  ret = _tnt_save_networks(fname, numnws, varnames, vars);
520  TNT_PUB_N_ERR_CHK("tntNetworksSave"); /* NO_COVERAGE */
521 }
void tntDoubleArraysSave(const char *fname, tntDoubleArray arrA, tntDoubleArray arrB, tntDoubleArray arrC, tntDoubleArray arrD, tntDoubleArray arrE)
Definition: tntSave.c:258
void tntIntParamsSave(const char *fname, int varA, int varB, int varC, int varD, int varE)
Definition: tntSave.c:18
void tntDoubleParamsSave(const char *fname, double varA, double varB, double varC, double varD, double varE)
Definition: tntSave.c:73
void tntNodeArraysSave(const char *fname, tntNodeArray arrA, tntNodeArray arrB, tntNodeArray arrC, tntNodeArray arrD, tntNodeArray arrE)
Definition: tntSave.c:404
void tntDoubleParamsNamedSave(const char *fname, double varA, const char *varnameA, double varB, const char *varnameB, double varC, const char *varnameC, double varD, const char *varnameD, double varE, const char *varnameE)
Definition: tntSave.c:86
void tntNetworksSave(const char *fname, tntNetwork varA, tntNetwork varB, tntNetwork varC, tntNetwork varD, tntNetwork varE)
Definition: tntSave.c:476
void tntComplexArraysSave(const char *fname, tntComplexArray arrA, tntComplexArray arrB, tntComplexArray arrC, tntComplexArray arrD, tntComplexArray arrE)
Definition: tntSave.c:314
void tntNodesSave(const char *fname, tntNode varA, tntNode varB, tntNode varC, tntNode varD, tntNode varE)
Definition: tntSave.c:368
Definition: tnt.h:65
void tntComplexParamsNamedSave(const char *fname, tntComplex varA, const char *varnameA, tntComplex varB, const char *varnameB, tntComplex varC, const char *varnameC, tntComplex varD, const char *varnameD, tntComplex varE, const char *varnameE)
Definition: tntSave.c:143
void tntComplexArraysNamedSave(const char *fname, tntComplexArray arrA, const char *varnameA, tntComplexArray arrB, const char *varnameB, tntComplexArray arrC, const char *varnameC, tntComplexArray arrD, const char *varnameD, tntComplexArray arrE, const char *varnameE)
Definition: tntSave.c:327
void tntStringsSave(const char *fname, const char *varA, const char *varB, const char *varC, const char *varD, const char *varE)
Definition: tntSave.c:184
void tntIntParamsNamedSave(const char *fname, int varA, const char *varnameA, int varB, const char *varnameB, int varC, const char *varnameC, int varD, const char *varnameD, int varE, const char *varnameE)
Definition: tntSave.c:31
void tntNetworksNamedSave(const char *fname, tntNetwork varA, const char *varnameA, tntNetwork varB, const char *varnameB, tntNetwork varC, const char *varnameC, tntNetwork varD, const char *varnameD, tntNetwork varE, const char *varnameE)
Definition: tntSave.c:489
void tntExOpsSave(const char *fname, tntExOp varA, tntExOp varB, tntExOp varC, tntExOp varD, tntExOp varE)
Definition: tntSave.c:440
void tntIntArraysSave(const char *fname, tntIntArray arrA, tntIntArray arrB, tntIntArray arrC, tntIntArray arrD, tntIntArray arrE)
Definition: tntSave.c:221
void tntDoubleArraysNamedSave(const char *fname, tntDoubleArray arrA, const char *varnameA, tntDoubleArray arrB, const char *varnameB, tntDoubleArray arrC, const char *varnameC, tntDoubleArray arrD, const char *varnameD, tntDoubleArray arrE, const char *varnameE)
Definition: tntSave.c:271
void tntComplexParamsSave(const char *savepref, tntComplex varA, tntComplex varB, tntComplex varC, tntComplex varD, tntComplex varE)
Definition: tntSave.c:130