My Project  UNKNOWN_GIT_VERSION
Typedefs | Functions
ipprint.h File Reference
#include "kernel/structs.h"

Go to the source code of this file.

Typedefs

typedef sleftvleftv
 

Functions

BOOLEAN jjPRINT (leftv res, leftv u)
 
BOOLEAN jjPRINT_FORMAT (leftv res, leftv u, leftv v)
 
BOOLEAN jjDBPRINT (leftv res, leftv u)
 
void ipPrint_MA0 (matrix m, const char *name)
 

Typedef Documentation

◆ leftv

typedef sleftv* leftv

Definition at line 11 of file ipprint.h.

Function Documentation

◆ ipPrint_MA0()

void ipPrint_MA0 ( matrix  m,
const char *  name 
)

Definition at line 58 of file ipprint.cc.

59 {
60  if ((MATCOLS(m)>0)&&(MATROWS(m)>0))
61  {
62  char **s=(char **)omAlloc(MATCOLS(m)*MATROWS(m)*sizeof(char*));
63  char *ss;
64  int *l=(int *)omAlloc0(MATCOLS(m)*sizeof(int));
65  int i,j,k;
66  int vl=si_max(colmax/MATCOLS(m),8);
67 
68  /* make enough space for the "largest" name*/
69  ss=(char *)omAlloc(14+strlen(name));
70  sprintf(ss,"%s[%d,%d]",name,MATCOLS(m),MATROWS(m));
71  vl=si_max(vl,(int)strlen(ss));
72  omFree(ss);
73 
74  /* convert all polys to string */
75  i=MATCOLS(m)*MATROWS(m)-1;
76  ss=pString(m->m[i]);
77  if ((int)strlen(ss)>colmax) { s[i]=NULL; omFree(ss); }
78  else s[i]=ss;
79  for(i--;i>=0;i--)
80  {
81  StringSetS("");
82  pString0(m->m[i]);
83  StringAppendS(",");
84  ss=StringEndS();
85  if ((int)strlen(ss)>colmax) s[i]=NULL;
86  else s[i]=ss;
87  }
88  /* look up the width of all columns, put it in l[col_nr] */
89  /* insert names for very long entries */
90  for(i=MATROWS(m)-1;i>=0;i--)
91  {
92  for(j=MATCOLS(m)-1;j>=0;j--)
93  {
94  if (s[i*MATCOLS(m)+j]==NULL)
95  {
96  ss=(char *)omAlloc(14+strlen(name));
97  s[i*MATCOLS(m)+j]=ss;
98  ss[0]='\0';
99  sprintf(ss,"%s[%d,%d]",name,i+1,j+1);
100  if ((i!=MATROWS(m)-1) || (j!=MATCOLS(m)-1))
101  {
102  strcat(ss,",");
103  vl=si_max(vl,(int)strlen(ss));
104  }
105  }
106  k=strlen(s[i*MATCOLS(m)+j]);
107  if (k>l[j]) l[j]=k;
108  }
109  }
110  /* does it fit on a line ? */
111  int maxlen=0;
112  for(j=MATCOLS(m)-1;j>=0;j--)
113  {
114  maxlen+=l[j];
115  }
116  if (maxlen>colmax)
117  {
118  /* NO, it does not fit, so retry: */
119  /* look up the width of all columns, clear very long entriess */
120  /* put length in l[col_nr] */
121  /* insert names for cleared entries */
122  for(j=MATCOLS(m)-1;j>=0;j--)
123  {
124  for(i=MATROWS(m)-1;i>=0;i--)
125  {
126  k=strlen(s[i*MATCOLS(m)+j]);
127  if (/*strlen(s[i*MATCOLS(m)+j])*/ k > vl)
128  {
129  omFree((ADDRESS)s[i*MATCOLS(m)+j]);
130  ss=(char *)omAlloc(14+strlen(name));
131  s[i*MATCOLS(m)+j]=ss;
132  ss[0]='\0';
133  sprintf(ss,"%s[%d,%d]",name,i+1,j+1);
134  if ((i!=MATROWS(m)-1) || (j!=MATCOLS(m)-1))
135  {
136  strcat(ss,",");
137  }
138  l[j]=strlen(s[i*MATCOLS(m)+j]);
139  if (l[j]>vl)
140  {
141 //#ifdef TEST
142 // PrintS("pagewidth too small in print(matrix)\n");
143 //#endif
144  vl=l[j]; /* make large names fit*/
145  }
146  i=MATROWS(m);
147  }
148  else
149  {
150  if (k>l[j]) l[j]=k;
151  }
152  }
153  }
154  }
155  /*output of the matrix*/
156  for(i=0;i<MATROWS(m);i++)
157  {
158  k=l[0];
159  Print("%-*.*s",l[0],l[0],s[i*MATCOLS(m)]);
160  omFree(s[i*MATCOLS(m)]);
161  for(j=1;j<MATCOLS(m);j++)
162  {
163  if (k+l[j]>colmax)
164  {
165  PrintS("\n ");
166  k=2;
167  }
168  k+=l[j];
169  Print("%-*.*s",l[j],l[j],s[i*MATCOLS(m)+j]);
170  omFree(s[i*MATCOLS(m)+j]);
171  }
172  PrintLn();
173  }
174  /* clean up */
175  omFreeSize((ADDRESS)s,MATCOLS(m)*MATROWS(m)*sizeof(char*));
176  omFreeSize((ADDRESS)l,MATCOLS(m)*sizeof(int));
177  }
178  else Print("%d x %d zero matrix\n",MATROWS(m),MATCOLS(m));
179 }

◆ jjDBPRINT()

BOOLEAN jjDBPRINT ( leftv  res,
leftv  u 
)

Definition at line 317 of file ipprint.cc.

318 {
319  BOOLEAN print=(printlevel>myynest);
320  if ((u->next!=NULL)&&(u->Typ()==INT_CMD))
321  {
322  print= (((int)((long)(u->Data()))) > 0);
323  u=u->next;
324  }
325  if (print)
326  {
327  // BOOLEAN r=FALSE;
328  leftv h=u;
329  leftv hh;
330  while (h!=NULL)
331  {
332  hh=h->next;
333  h->next=NULL;
334  if (jjPRINT(res, h)) return TRUE;
335  PrintS((char*)res->data);
336  omFree(res->data);
337  PrintLn();
338  h->next=hh;
339  h=hh;
340  }
341  }
342  return FALSE;
343 }

◆ jjPRINT()

BOOLEAN jjPRINT ( leftv  res,
leftv  u 
)

Definition at line 251 of file ipprint.cc.

252 {
253  SPrintStart();
254  BOOLEAN bo=FALSE;
255  void *d=u->Data();
256  switch(u->Typ())
257  {
258  case INTVEC_CMD:
259  bo=ipPrint_INTVEC((intvec*)d);
260  break;
261 
262  case INTMAT_CMD:
263  bo=ipPrint_INTMAT((intvec*)d);
264  break;
265 
266  case MATRIX_CMD:
267  bo=ipPrint_MA(u);
268  break;
269 
270  case IDEAL_CMD:
271  {
272  char* s = u->String(NULL, FALSE, 2);
273  PrintS(s);
274  PrintLn();
275  omFree(s);
276  break;
277  }
278 
279  case MODUL_CMD:
280  {
282  ipPrint_MA0(m, u->Name());
283  id_Delete((ideal *) &m,currRing);
284  break;
285  }
286 
287  case VECTOR_CMD:
288  bo=ipPrint_V((poly)d);
289  break;
290 
291  case RING_CMD:
292  bo=ipPrint_RING((ring)d);
293  break;
294 
295  case CRING_CMD:
296  bo=ipPrint_CRING((coeffs)d);
297  break;
298 
299  default:
300  u->Print();
301  break;
302  }
303  char *s=SPrintEnd();
304  if (u->next==NULL)
305  {
306  int l=strlen(s);
307  if (s[l-1]=='\n') s[l-1]='\0';
308  }
309  res->data=(void*)s;
310  return bo;
311 }

◆ jjPRINT_FORMAT()

BOOLEAN jjPRINT_FORMAT ( leftv  res,
leftv  u,
leftv  v 
)

Definition at line 390 of file ipprint.cc.

391 {
392 /* ==================== betti ======================================== */
393  if ((u->Typ()==INTMAT_CMD)&&(strcmp((char *)v->Data(),"betti")==0))
394  {
395  SPrintStart();
396  ipPrintBetti(u);
397  char *s = SPrintEnd();
398  s[strlen(s)]='\0';
399  res->data=s;
400  }
401  else
402 /* ======================== end betti ================================= */
403  {
404  char* ns = omStrDup((char*) v->Data());
405  int dim = 1;
406  if (strlen(ns) == 3 && ns[1] == '2')
407  {
408  dim = 2;
409  ns[1] = ns[2];
410  ns[2] = '\0';
411  }
412  if (strcmp(ns,"%l") == 0)
413  {
414  res->data = (char*) u->String(NULL, TRUE, dim);
415  if (dim == 2)
416  {
417  char* ns = (char*) omAlloc(strlen((char*) res->data) + 2);
418  strcpy(ns, (char*) res->data);
419  omFree(res->data);
420  strcat(ns, "\n");
421  res->data = ns;
422  }
423  }
424  else if (strcmp(ns,"%t") == 0)
425  {
426  SPrintStart();
427  type_cmd(u);
428  res->data = SPrintEnd();
429  if (dim != 2)
430  ((char*)res->data)[strlen((char*)res->data) -1] = '\0';
431  }
432  else if (strcmp(ns,"%;") == 0)
433  {
434  SPrintStart();
435  u->Print();
436  if (dim == 2) PrintLn();
437  res->data = SPrintEnd();
438  }
439  else if (strcmp(ns,"%p") == 0)
440  {
442  }
443  else if (strcmp(ns,"%b") == 0 && (u->Typ()==INTMAT_CMD))
444  {
445  SPrintStart();
446  ipPrintBetti(u);
447  if (dim == 2) PrintLn();
448  res->data = SPrintEnd();
449  }
450  else
451  {
452  res->data = u->String(NULL, FALSE, dim);
453  if (dim == 2)
454  {
455  char* ns = (char*) omAlloc(strlen((char*) res->data) + 2);
456  strcpy(ns, (char*) res->data);
457  omFree(res->data);
458  strcat(ns, "\n");
459  res->data = ns;
460  }
461  }
462  omFree(ns);
463  }
464  return FALSE;
465 }
dim
int dim(ideal I, ring r)
Definition: tropicalStrategy.cc:23
FALSE
#define FALSE
Definition: auxiliary.h:94
sleftv::Data
void * Data()
Definition: subexpr.cc:1182
ipPrint_V
static BOOLEAN ipPrint_V(poly u)
Definition: ipprint.cc:225
ip_smatrix
Definition: matpol.h:14
StringAppendS
void StringAppendS(const char *st)
Definition: reporter.cc:107
j
int j
Definition: facHensel.cc:105
omFree
#define omFree(addr)
Definition: omAllocDecl.h:261
k
int k
Definition: cfEzgcd.cc:92
CRING_CMD
@ CRING_CMD
Definition: tok.h:56
ipPrint_CRING
static BOOLEAN ipPrint_CRING(coeffs r)
Definition: ipprint.cc:211
sleftv::Print
void Print(leftv store=NULL, int spaces=0)
Called by type_cmd (e.g. "r;") or as default in jPRINT.
Definition: subexpr.cc:69
iiExprArith1
BOOLEAN iiExprArith1(leftv res, leftv a, int op)
Definition: iparith.cc:8448
ADDRESS
void * ADDRESS
Definition: auxiliary.h:133
MODUL_CMD
@ MODUL_CMD
Definition: grammar.cc:287
pString0
void pString0(poly p)
Definition: polys.h:301
ipPrint_MA
static BOOLEAN ipPrint_MA(leftv u)
Definition: ipprint.cc:184
SPrintEnd
char * SPrintEnd()
Definition: reporter.cc:273
type_cmd
void type_cmd(leftv v)
Definition: ipshell.cc:251
omStrDup
#define omStrDup(s)
Definition: omAllocDecl.h:263
ipPrint_INTVEC
static BOOLEAN ipPrint_INTVEC(intvec *v)
Definition: ipprint.cc:31
PRINT_CMD
@ PRINT_CMD
Definition: tok.h:155
StringEndS
char * StringEndS()
Definition: reporter.cc:151
sleftv
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
pString
char * pString(poly p)
Definition: polys.h:300
RING_CMD
@ RING_CMD
Definition: grammar.cc:281
MATRIX_CMD
@ MATRIX_CMD
Definition: grammar.cc:286
currRing
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
TRUE
#define TRUE
Definition: auxiliary.h:98
i
int i
Definition: cfEzgcd.cc:125
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition: simpleideals.cc:114
res
CanonicalForm res
Definition: facAbsFact.cc:64
INT_CMD
@ INT_CMD
Definition: tok.h:96
PrintS
void PrintS(const char *s)
Definition: reporter.cc:284
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:85
id_Module2Matrix
matrix id_Module2Matrix(ideal mod, const ring R)
Definition: simpleideals.cc:1201
IDEAL_CMD
@ IDEAL_CMD
Definition: grammar.cc:284
h
static Poly * h
Definition: janet.cc:972
ipPrintBetti
static void ipPrintBetti(leftv u)
Definition: ipprint.cc:345
coeffs
intvec
Definition: intvec.h:17
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:210
jjPRINT
BOOLEAN jjPRINT(leftv res, leftv u)
Definition: ipprint.cc:251
VECTOR_CMD
@ VECTOR_CMD
Definition: grammar.cc:292
myynest
int myynest
Definition: febase.cc:41
INTVEC_CMD
@ INTVEC_CMD
Definition: tok.h:101
INTMAT_CMD
@ INTMAT_CMD
Definition: grammar.cc:279
ipPrint_RING
static BOOLEAN ipPrint_RING(ring r)
Definition: ipprint.cc:194
sleftv::String
char * String(void *d=NULL, BOOLEAN typed=FALSE, int dim=1)
Called for conversion to string (used by string(..), write(..),..)
Definition: subexpr.cc:789
StringSetS
void StringSetS(const char *st)
Definition: reporter.cc:128
si_max
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
ipPrint_MA0
void ipPrint_MA0(matrix m, const char *name)
Definition: ipprint.cc:58
Print
#define Print
Definition: emacs.cc:80
name
char name(const Variable &v)
Definition: factory.h:180
sleftv::Typ
int Typ()
Definition: subexpr.cc:1039
m
int m
Definition: cfEzgcd.cc:121
MATCOLS
#define MATCOLS(i)
Definition: matpol.h:29
NULL
#define NULL
Definition: omList.c:10
colmax
int colmax
Definition: reporter.h:17
l
int l
Definition: cfEzgcd.cc:93
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
sleftv::Name
const char * Name()
Definition: subexpr.h:120
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
id_Copy
ideal id_Copy(ideal h1, const ring r)
copy an ideal
Definition: simpleideals.cc:404
printlevel
int printlevel
Definition: febase.cc:36
PrintLn
void PrintLn()
Definition: reporter.cc:310
SPrintStart
void SPrintStart()
Definition: reporter.cc:246
MATROWS
#define MATROWS(i)
Definition: matpol.h:28
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:211
sleftv::next
leftv next
Definition: subexpr.h:86
ipPrint_INTMAT
static BOOLEAN ipPrint_INTMAT(intvec *v)
Definition: ipprint.cc:41