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

◆ jjDBPRINT()

BOOLEAN jjDBPRINT ( leftv  res,
leftv  u 
)

Definition at line 316 of file ipprint.cc.

317{
318 BOOLEAN print=(printlevel>myynest);
319 if ((u->next!=NULL)&&(u->Typ()==INT_CMD))
320 {
321 print= (((int)((long)(u->Data()))) > 0);
322 u=u->next;
323 }
324 if (print)
325 {
326 // BOOLEAN r=FALSE;
327 leftv h=u;
328 leftv hh;
329 while (h!=NULL)
330 {
331 hh=h->next;
332 h->next=NULL;
333 if (jjPRINT(res, h)) return TRUE;
334 PrintS((char*)res->data);
335 omFree(res->data);
336 PrintLn();
337 h->next=hh;
338 h=hh;
339 }
340 }
341 return FALSE;
342}
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:1019
void * Data()
Definition: subexpr.cc:1162
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:250
STATIC_VAR Poly * h
Definition: janet.cc:971
@ INT_CMD
Definition: tok.h:96

◆ jjPRINT()

BOOLEAN jjPRINT ( leftv  res,
leftv  u 
)

Definition at line 250 of file ipprint.cc.

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

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