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
tntPrint.c
1 /*
2 Authors: Sarah Al-Assam, Stephen Clark and Dieter Jaksch
3 Date: February 2013
4 (c) University of Oxford 2012
5 */
6 
12 /*-------------------------------------------*/
13 
14 #include "../headers/tnt_int.h"
15 #include "../headers/dec_public.h"
16 
22 #ifdef MAKINGPUBLICDOCS
23 void tntIntArrayPrint(tntIntArray arr)
24 #else
25 void tntNamedIntArrayPrint(const char *varname, tntIntArray *arr)
26 #endif
27 {
28 
29  TNT_ERR_RET_DEFS
30 
31  _tnt_printf("%s[%d,%d] = ", varname, arr->numrows, arr->numcols);
32  _tnt_la_iprint(arr->numrows,arr->numcols,arr->vals,TNT_PLAIN_STYLE);
33 
34 }
35 
41 #ifdef MAKINGPUBLICDOCS
42 void tntDoubleArrayPrint(tntDoubleArray arr)
43 #else
44 void tntNamedDoubleArrayPrint(const char *varname, tntDoubleArray *arr)
45 #endif
46 {
47  TNT_ERR_RET_DEFS
48 
49  _tnt_printf("%s[%d,%d] = ", varname, arr->numrows, arr->numcols);
50  _tnt_la_dprint(arr->numrows,arr->numcols,arr->vals,TNT_PLAIN_STYLE);
51 
52 }
53 
59 #ifdef MAKINGPUBLICDOCS
60 void tntComplexArrayPrint(tntComplexArray arr)
61 #else
62 void tntNamedComplexArrayPrint(const char *varname, tntComplexArray *arr)
63 #endif
64 {
65  TNT_ERR_RET_DEFS
66 
67  _tnt_printf("%s[%d,%d] = ", varname, arr->numrows, arr->numcols);
68  _tnt_la_zprint(arr->numrows,arr->numcols,arr->vals,TNT_PLAIN_STYLE);
69 }
70 
77 int tntPrintf(const char * format, ...)
78 {
79  va_list ap;
80  extern int _tnt_quiet_mode;
81 
82  if (1 != _tnt_quiet_mode) {
83  va_start(ap, format);
84  return vprintf(format, ap);
85  }
86 
87  return 0;
88 }
89 
90 /*
91  * Prints a formatted error message to stderr. The error msg can be several lines long, where a line break is signified by the character `|'.
92  * Once the error is printed execution is terminated with error code given by the argument.
93  */
94 
95 /* START_NOCOV */
96 void tntNamedErrorPrint(const char *funcname, const char *msg, ...)
97 {
98 
99  extern struct tnt_error_info tnt_err;
100  char new_msg[TNT_STRLEN];
101  va_list ap;
102 
103  va_start(ap, msg);
104 
105  vsprintf(new_msg,msg,ap);
106  sprintf(tnt_err.errinfostr,"%s",new_msg);
107  sprintf(tnt_err.pubfuncname,"%s",funcname);
108 
109  _tnt_print_error();
110 
111 }
112 
113 /*
114  * Prints a formatted warning to stdout. The warning msg can be several lines long, where a line break is signified by the character `|'.
115  * Once the warning is printed execution continues as normal */
116 void tntWarningPrint(const char *msg, ...)
117 {
118  va_list ap;
119  char new_msg[TNT_STRLEN];
120 
121  va_start(ap, msg);
122 
123  vsprintf(new_msg,msg,ap);
124 
125  _tnt_print_warning(new_msg);
126 
127 }
128 /* END_NOCOV */
void tntIntArrayPrint(tntIntArray arr)
Definition: tntPrint.c:23
void tntComplexArrayPrint(tntComplexArray arr)
Definition: tntPrint.c:60
void tntDoubleArrayPrint(tntDoubleArray arr)
Definition: tntPrint.c:42
int tntPrintf(const char *format,...)
Definition: tntPrint.c:77