My Project
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 57 of file ipprint.cc.

58{
59 if ((MATCOLS(m)>0)&&(MATROWS(m)>0))
60 {
61 char **s=(char **)omAlloc(MATCOLS(m)*MATROWS(m)*sizeof(char*));
62 char *ss;
63 int *l=(int *)omAlloc0(MATCOLS(m)*sizeof(int));
64 int i,j,k;
65 int vl=si_max(colmax/MATCOLS(m),8);
66
67 /* make enough space for the "largest" name*/
68 size_t len=14+strlen(name);
69 ss=(char *)omAlloc(len);
70 snprintf(ss,len,"%s[%d,%d]",name,MATCOLS(m),MATROWS(m));
71 vl=si_max(vl,(int)strlen(ss));
72 omFreeBinAddr(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; omFree(ss); }
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(len);
97 s[i*MATCOLS(m)+j]=ss;
98 ss[0]='\0';
99 snprintf(ss,len,"%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 size_t len=14+strlen(name);
123 for(j=MATCOLS(m)-1;j>=0;j--)
124 {
125 for(i=MATROWS(m)-1;i>=0;i--)
126 {
127 k=strlen(s[i*MATCOLS(m)+j]);
128 if (/*strlen(s[i*MATCOLS(m)+j])*/ k > vl)
129 {
130 omFree((ADDRESS)s[i*MATCOLS(m)+j]);
131 ss=(char *)omAlloc(len);
132 s[i*MATCOLS(m)+j]=ss;
133 ss[0]='\0';
134 snprintf(ss,len,"%s[%d,%d]",name,i+1,j+1);
135 if ((i!=MATROWS(m)-1) || (j!=MATCOLS(m)-1))
136 {
137 strcat(ss,",");
138 }
139 l[j]=strlen(s[i*MATCOLS(m)+j]);
140 if (l[j]>vl)
141 {
142//#ifdef TEST
143// PrintS("pagewidth too small in print(matrix)\n");
144//#endif
145 vl=l[j]; /* make large names fit*/
146 }
147 i=MATROWS(m);
148 }
149 else
150 {
151 if (k>l[j]) l[j]=k;
152 }
153 }
154 }
155 }
156 /*output of the matrix*/
157 for(i=0;i<MATROWS(m);i++)
158 {
159 k=l[0];
160 Print("%-*.*s",l[0],l[0],s[i*MATCOLS(m)]);
161 omFree(s[i*MATCOLS(m)]);
162 for(j=1;j<MATCOLS(m);j++)
163 {
164 if (k+l[j]>colmax)
165 {
166 PrintS("\n ");
167 k=2;
168 }
169 k+=l[j];
170 Print("%-*.*s",l[j],l[j],s[i*MATCOLS(m)+j]);
171 omFree(s[i*MATCOLS(m)+j]);
172 }
173 PrintLn();
174 }
175 /* clean up */
176 omFreeSize((ADDRESS)s,MATCOLS(m)*MATROWS(m)*sizeof(char*));
177 omFreeSize((ADDRESS)l,MATCOLS(m)*sizeof(int));
178 }
179 else Print("%d x %d zero matrix\n",MATROWS(m),MATCOLS(m));
180}
static int si_max(const int a, const int b)
Definition: auxiliary.h:124
void * ADDRESS
Definition: auxiliary.h:119
int l
Definition: cfEzgcd.cc:100
int m
Definition: cfEzgcd.cc:128
int i
Definition: cfEzgcd.cc:132
int k
Definition: cfEzgcd.cc:99
#define Print
Definition: emacs.cc:80
const CanonicalForm int s
Definition: facAbsFact.cc:51
int j
Definition: facHensel.cc:110
char name(const Variable &v)
Definition: factory.h:189
#define MATROWS(i)
Definition: matpol.h:26
#define MATCOLS(i)
Definition: matpol.h:27
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omFree(addr)
Definition: omAllocDecl.h:261
#define omAlloc0(size)
Definition: omAllocDecl.h:211
#define omFreeBinAddr(addr)
Definition: omAllocDecl.h:258
#define NULL
Definition: omList.c:12
void pString0(poly p)
Definition: polys.h:307
char * pString(poly p)
Definition: polys.h:306
void StringSetS(const char *st)
Definition: reporter.cc:128
void StringAppendS(const char *st)
Definition: reporter.cc:107
void PrintS(const char *s)
Definition: reporter.cc:284
char * StringEndS()
Definition: reporter.cc:151
void PrintLn()
Definition: reporter.cc:310
EXTERN_VAR int colmax
Definition: reporter.h:17

◆ jjDBPRINT()

BOOLEAN jjDBPRINT ( leftv  res,
leftv  u 
)

Definition at line 318 of file ipprint.cc.

319{
320 BOOLEAN print=(printlevel>myynest);
321 if ((u->next!=NULL)&&(u->Typ()==INT_CMD))
322 {
323 print= (((int)((long)(u->Data()))) > 0);
324 u=u->next;
325 }
326 if (print)
327 {
328 // BOOLEAN r=FALSE;
329 leftv h=u;
330 leftv hh;
331 while (h!=NULL)
332 {
333 hh=h->next;
334 h->next=NULL;
335 if (jjPRINT(res, h)) return TRUE;
336 PrintS((char*)res->data);
337 omFree(res->data);
338 PrintLn();
339 h->next=hh;
340 h=hh;
341 }
342 }
343 return FALSE;
344}
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
int Typ()
Definition: subexpr.cc:1030
void * Data()
Definition: subexpr.cc:1173
leftv next
Definition: subexpr.h:86
CanonicalForm res
Definition: facAbsFact.cc:60
VAR int printlevel
Definition: febase.cc:36
VAR int myynest
Definition: febase.cc:41
BOOLEAN jjPRINT(leftv res, leftv u)
Definition: ipprint.cc:252
STATIC_VAR Poly * h
Definition: janet.cc:971
@ INT_CMD
Definition: tok.h:96

◆ jjPRINT()

BOOLEAN jjPRINT ( leftv  res,
leftv  u 
)

Definition at line 252 of file ipprint.cc.

253{
254 SPrintStart();
255 BOOLEAN bo=FALSE;
256 void *d=u->Data();
257 switch(u->Typ())
258 {
259 case INTVEC_CMD:
260 bo=ipPrint_INTVEC((intvec*)d);
261 break;
262
263 case INTMAT_CMD:
264 bo=ipPrint_INTMAT((intvec*)d);
265 break;
266
267 case MATRIX_CMD:
268 bo=ipPrint_MA(u);
269 break;
270
271 case IDEAL_CMD:
272 {
273 char* s = u->String(NULL, FALSE, 2);
274 PrintS(s);
275 PrintLn();
276 omFree(s);
277 break;
278 }
279
280 case MODUL_CMD:
281 {
283 ipPrint_MA0(m, u->Name());
284 id_Delete((ideal *) &m,currRing);
285 break;
286 }
287
288 case VECTOR_CMD:
289 bo=ipPrint_V((poly)d);
290 break;
291
292 case RING_CMD:
293 bo=ipPrint_RING((ring)d);
294 break;
295
296 case CRING_CMD:
297 bo=ipPrint_CRING((coeffs)d);
298 break;
299
300 default:
301 u->Print();
302 break;
303 }
304 char *s=SPrintEnd();
305 if (u->next==NULL)
306 {
307 int l=strlen(s);
308 if (s[l-1]=='\n') s[l-1]='\0';
309 }
310 res->data=(void*)s;
311 return bo;
312}
Definition: intvec.h:23
char * String(void *d=NULL, BOOLEAN typed=FALSE, int dim=1)
Called for conversion to string (used by string(..), write(..),..)
Definition: subexpr.cc:761
const char * Name()
Definition: subexpr.h:120
void Print(leftv store=NULL, int spaces=0)
Called by type_cmd (e.g. "r;") or as default in jPRINT.
Definition: subexpr.cc:63
@ IDEAL_CMD
Definition: grammar.cc:284
@ MATRIX_CMD
Definition: grammar.cc:286
@ INTMAT_CMD
Definition: grammar.cc:279
@ MODUL_CMD
Definition: grammar.cc:287
@ VECTOR_CMD
Definition: grammar.cc:292
@ RING_CMD
Definition: grammar.cc:281
ideal id_Copy(ideal h1, const ring r)
copy an ideal
static BOOLEAN ipPrint_RING(ring r)
Definition: ipprint.cc:195
void ipPrint_MA0(matrix m, const char *name)
Definition: ipprint.cc:57
static BOOLEAN ipPrint_V(poly u)
Definition: ipprint.cc:226
static BOOLEAN ipPrint_MA(leftv u)
Definition: ipprint.cc:185
static BOOLEAN ipPrint_INTVEC(intvec *v)
Definition: ipprint.cc:30
static BOOLEAN ipPrint_INTMAT(intvec *v)
Definition: ipprint.cc:40
static BOOLEAN ipPrint_CRING(coeffs r)
Definition: ipprint.cc:212
The main handler for Singular numbers which are suitable for Singular polynomials.
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
void SPrintStart()
Definition: reporter.cc:246
char * SPrintEnd()
Definition: reporter.cc:273
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
matrix id_Module2Matrix(ideal mod, const ring R)
@ CRING_CMD
Definition: tok.h:56
@ INTVEC_CMD
Definition: tok.h:101

◆ jjPRINT_FORMAT()

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

Definition at line 391 of file ipprint.cc.

392{
393/* ==================== betti ======================================== */
394 if ((u->Typ()==INTMAT_CMD)&&(strcmp((char *)v->Data(),"betti")==0))
395 {
396 SPrintStart();
397 ipPrintBetti(u);
398 char *s = SPrintEnd();
399 s[strlen(s)]='\0';
400 res->data=s;
401 }
402 else
403/* ======================== end betti ================================= */
404 {
405 char* ns = omStrDup((char*) v->Data());
406 int dim = 1;
407 if (strlen(ns) == 3 && ns[1] == '2')
408 {
409 dim = 2;
410 ns[1] = ns[2];
411 ns[2] = '\0';
412 }
413 if (strcmp(ns,"%l") == 0)
414 {
415 res->data = (char*) u->String(NULL, TRUE, dim);
416 if (dim == 2)
417 {
418 char* ns = (char*) omAlloc(strlen((char*) res->data) + 2);
419 strcpy(ns, (char*) res->data);
420 omFree(res->data);
421 strcat(ns, "\n");
422 res->data = ns;
423 }
424 }
425 else if (strcmp(ns,"%t") == 0)
426 {
427 SPrintStart();
428 type_cmd(u);
429 res->data = SPrintEnd();
430 if (dim != 2)
431 ((char*)res->data)[strlen((char*)res->data) -1] = '\0';
432 }
433 else if (strcmp(ns,"%;") == 0)
434 {
435 SPrintStart();
436 u->Print();
437 if (dim == 2) PrintLn();
438 res->data = SPrintEnd();
439 }
440 else if (strcmp(ns,"%p") == 0)
441 {
443 }
444 else if (strcmp(ns,"%b") == 0 && (u->Typ()==INTMAT_CMD))
445 {
446 SPrintStart();
447 ipPrintBetti(u);
448 if (dim == 2) PrintLn();
449 res->data = SPrintEnd();
450 }
451 else
452 {
453 res->data = u->String(NULL, FALSE, dim);
454 if (dim == 2)
455 {
456 char* ns = (char*) omAlloc(strlen((char*) res->data) + 2);
457 strcpy(ns, (char*) res->data);
458 omFree(res->data);
459 strcat(ns, "\n");
460 res->data = ns;
461 }
462 }
463 omFree(ns);
464 }
465 return FALSE;
466}
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
BOOLEAN iiExprArith1(leftv res, leftv a, int op)
Definition: iparith.cc:9137
static void ipPrintBetti(leftv u)
Definition: ipprint.cc:346
void type_cmd(leftv v)
Definition: ipshell.cc:254
#define omStrDup(s)
Definition: omAllocDecl.h:263
@ PRINT_CMD
Definition: tok.h:155
int dim(ideal I, ring r)