My Project  UNKNOWN_GIT_VERSION
Functions
ipprint.cc File Reference
#include "kernel/mod2.h"
#include "omalloc/omalloc.h"
#include "misc/intvec.h"
#include "polys/matpol.h"
#include "kernel/polys.h"
#include "kernel/ideals.h"
#include "tok.h"
#include "ipid.h"
#include "subexpr.h"
#include "ipshell.h"
#include "ipprint.h"
#include "attrib.h"

Go to the source code of this file.

Functions

static BOOLEAN ipPrint_INTVEC (intvec *v)
 
static BOOLEAN ipPrint_INTMAT (intvec *v)
 
void ipPrint_MA0 (matrix m, const char *name)
 
static BOOLEAN ipPrint_MA (leftv u)
 
static BOOLEAN ipPrint_RING (ring r)
 
static BOOLEAN ipPrint_CRING (coeffs r)
 
static BOOLEAN ipPrint_V (poly u)
 
BOOLEAN jjPRINT (leftv res, leftv u)
 
BOOLEAN jjDBPRINT (leftv res, leftv u)
 
static void ipPrintBetti (leftv u)
 
BOOLEAN jjPRINT_FORMAT (leftv res, leftv u, leftv v)
 

Function Documentation

◆ ipPrint_CRING()

static BOOLEAN ipPrint_CRING ( coeffs  r)
static

Definition at line 211 of file ipprint.cc.

212 {
213  if (nCoeff_is_Ring(r))
214  {
215  if (nCoeff_is_Domain(r)) PrintS("domain: ");
216  else PrintS("ring (with zero-divisors): ");
217  }
218  else PrintS("field: ");
219  PrintS(nCoeffName(r));
220  return FALSE;
221 }

◆ ipPrint_INTMAT()

static BOOLEAN ipPrint_INTMAT ( intvec v)
static

Definition at line 41 of file ipprint.cc.

42 {
43  int i,j;
44  for(i=0;i<v->rows();i++)
45  {
46  for(j=0;j<v->cols();j++)
47  {
48  Print(" %5d",IMATELEM(*v,i+1,j+1));
49  }
50  PrintLn();
51  }
52  return FALSE;
53 }

◆ ipPrint_INTVEC()

static BOOLEAN ipPrint_INTVEC ( intvec v)
static

Definition at line 31 of file ipprint.cc.

32 {
33  v->show();
34  PrintLn();
35  return FALSE;
36 }

◆ ipPrint_MA()

static BOOLEAN ipPrint_MA ( leftv  u)
static

Definition at line 184 of file ipprint.cc.

185 {
186  matrix m=(matrix)u->Data();
187  ipPrint_MA0(m,u->Name());
188  return FALSE;
189 }

◆ 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 }

◆ ipPrint_RING()

static BOOLEAN ipPrint_RING ( ring  r)
static

Definition at line 194 of file ipprint.cc.

195 {
196  PrintS("polynomial ring, over a ");
197  if (rField_is_Ring(r))
198  {
199  if (rField_is_Domain(r)) PrintS("domain");
200  else PrintS("ring (with zero-divisors)");
201  }
202  else PrintS("field");
203  if (r->OrdSgn==1) PrintS(", global");
204  else if (r->MixedOrder==1) PrintS(", mixed");
205  else PrintS(", local");
206  PrintS(" ordering\n");
207  rWrite(r, TRUE);
208  return FALSE;
209 }

◆ ipPrint_V()

static BOOLEAN ipPrint_V ( poly  u)
static

Definition at line 225 of file ipprint.cc.

226 {
227  polyset m=NULL;
228  int l,j;
229  /*convert into an array of the components*/
230  p_Vec2Polys(u, &m, &l, currRing);
231  /*output*/
232  PrintS("[");
233  j=0;
234  loop
235  {
236  PrintS(pString(m[j]));
237  j++;
238  if (j<l) PrintS(",");
239  else
240  {
241  PrintS("]\n");
242  break;
243  }
244  }
245  /* clean up */
246  for(j=l-1;j>=0;j--) pDelete(&m[j]);
247  omFreeSize((ADDRESS)m,l*sizeof(poly));
248  return FALSE;
249 }

◆ ipPrintBetti()

static void ipPrintBetti ( leftv  u)
static

Definition at line 345 of file ipprint.cc.

346 {
347  int i,j;
348  int row_shift=(int)((long)(atGet(u,"rowShift",INT_CMD)));
349  intvec * betti=(intvec *)u->Data();
350  // head line --------------------------------------------------------
351  PrintS(" "); // 6 spaces for no. and :
352  for(j=0;j<betti->cols();j++) Print(" %5d",j); // 6 spaces pro column
353  PrintS("\n------"); // 6 spaces for no. and :
354  for(j=0;j<betti->cols();j++) PrintS("------"); // 6 spaces pro column
355  PrintLn();
356  // the table --------------------------------------------------------
357  for(i=0;i<betti->rows();i++)
358  {
359  Print("%5d:",i+row_shift);
360  for(j=1;j<=betti->cols();j++)
361  {
362  int m=IMATELEM(*betti,i+1,j);
363  if (m==0)
364  PrintS(" -");
365  else
366  Print(" %5d",m);
367  }
368  PrintLn();
369  }
370  // sum --------------------------------------------------------------
371  PrintS("------"); // 6 spaces for no. and :
372  for(j=0;j<betti->cols();j++) PrintS("------"); // 6 spaces pro column
373  PrintS("\ntotal:");
374  for(j=0;j<betti->cols();j++)
375  {
376  int s=0;
377  for(i=0;i<betti->rows();i++)
378  {
379  s+=IMATELEM(*betti,i+1,j+1);
380  }
381  Print(" %5d",s); // 6 spaces pro column
382  }
383  PrintLn();
384 }

◆ 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
matrix
ip_smatrix * matrix
Definition: matpol.h:31
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:15
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
rField_is_Domain
static BOOLEAN rField_is_Domain(const ring r)
Definition: ring.h:478
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
polyset
poly * polyset
Definition: polys.h:254
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
pDelete
#define pDelete(p_ptr)
Definition: polys.h:181
PRINT_CMD
@ PRINT_CMD
Definition: tok.h:155
StringEndS
char * StringEndS()
Definition: reporter.cc:151
loop
#define loop
Definition: structs.h:78
sleftv
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
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
rField_is_Ring
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:475
id_Module2Matrix
matrix id_Module2Matrix(ideal mod, const ring R)
Definition: simpleideals.cc:1201
nCoeff_is_Ring
static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
Definition: coeffs.h:752
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
The main handler for Singular numbers which are suitable for Singular polynomials.
intvec
Definition: intvec.h:21
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
IMATELEM
#define IMATELEM(M, I, J)
Definition: intvec.h:83
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
rWrite
void rWrite(ring r, BOOLEAN details)
Definition: ring.cc:227
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
intvec::cols
int cols() const
Definition: intvec.h:93
atGet
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition: attrib.cc:131
p_Vec2Polys
void p_Vec2Polys(poly v, poly **p, int *len, const ring r)
Definition: p_polys.cc:3573
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:27
NULL
#define NULL
Definition: omList.c:10
nCoeffName
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition: coeffs.h:985
colmax
int colmax
Definition: reporter.h:17
l
int l
Definition: cfEzgcd.cc:93
intvec::rows
int rows() const
Definition: intvec.h:94
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:26
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:211
sleftv::next
leftv next
Definition: subexpr.h:86
nCoeff_is_Domain
static FORCE_INLINE BOOLEAN nCoeff_is_Domain(const coeffs r)
returns TRUE, if r is a field or r has no zero divisors (i.e is a domain)
Definition: coeffs.h:761
ipPrint_INTMAT
static BOOLEAN ipPrint_INTMAT(intvec *v)
Definition: ipprint.cc:41