Loading...
Searching...
No Matches
ipprint.cc File Reference
`#include "kernel/mod2.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()

BOOLEAN ipPrint_CRING | ( | coeffs | r | ) |

static

Definition at line 212 of file ipprint.cc.

{
if (nCoeff_is_Ring(r))
{
if (nCoeff_is_Domain(r)) PrintS("domain: ");
else PrintS("ring (with zero-divisors): ");
}
else PrintS("field: ");
PrintS(nCoeffName(r));
return FALSE;
}
FALSE
#define FALSE
Definition auxiliary.h:97
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:736
nCoeff_is_Ring
static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
Definition coeffs.h:732
nCoeffName
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition coeffs.h:962
PrintS
void PrintS(const char *s)
Definition reporter.cc:288

## ipPrint_INTMAT()

BOOLEAN ipPrint_INTMAT | ( | intvec * | v | ) |

static

Definition at line 40 of file ipprint.cc.

{
int i,j;
for(i=0;i<v->rows();i++)
{
for(j=0;j<v->cols();j++)
{
Print(" %5d",IMATELEM(*v,i+1,j+1));
}
PrintLn();
}
return FALSE;
}
i
int i
Definition cfEzgcd.cc:132
Print
#define Print
Definition emacs.cc:80
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
j
int j
Definition facHensel.cc:110
IMATELEM
#define IMATELEM(M, I, J)
Definition intvec.h:86
PrintLn
void PrintLn()
Definition reporter.cc:314

## ipPrint_INTVEC()

BOOLEAN ipPrint_INTVEC | ( | intvec * | v | ) |

static

Definition at line 30 of file ipprint.cc.

{
v->show();
PrintLn();
return FALSE;
}

## ipPrint_MA()

BOOLEAN ipPrint_MA | ( | leftv | u | ) |

static

Definition at line 185 of file ipprint.cc.

{
matrix m=(matrix)u->Data();
ipPrint_MA0(m,u->Name());
return FALSE;
}
m
int m
Definition cfEzgcd.cc:128
sleftv::Data
void * Data()
Definition subexpr.cc:1192
sleftv::Name
const char * Name()
Definition subexpr.h:120
ipPrint_MA0
void ipPrint_MA0(matrix m, const char *name)
Definition ipprint.cc:57
matrix
ip_smatrix * matrix
Definition matpol.h:43

## ipPrint_MA0()

void ipPrint_MA0 | ( | matrix | m,
|  | const char * | name )

Definition at line 57 of file ipprint.cc.

{
if ((MATCOLS(m)>0)&&(MATROWS(m)>0))
{
char **s=(char **)omAlloc(MATCOLS(m)*MATROWS(m)*sizeof(char*));
char *ss;
int *l=(int *)omAlloc0(MATCOLS(m)*sizeof(int));
int i,j,k;
int vl=si_max(colmax/MATCOLS(m),8);
/* make enough space for the "largest" name*/
size_t len=14+strlen(name);
ss=(char *)omAlloc(len);
snprintf(ss,len,"%s[%d,%d]",name,MATCOLS(m),MATROWS(m));
vl=si_max(vl,(int)strlen(ss));
omFreeBinAddr(ss);
/* convert all polys to string */
i=MATCOLS(m)*MATROWS(m)-1;
ss=pString(m->m[i]);
if ((int)strlen(ss)>colmax) { s[i]=NULL; omFree(ss); }
else s[i]=ss;
for(i--;i>=0;i--)
{
StringSetS("");
pString0(m->m[i]);
StringAppendS(",");
ss=StringEndS();
if ((int)strlen(ss)>colmax) { s[i]=NULL; omFree(ss); }
else s[i]=ss;
}
/* look up the width of all columns, put it in l[col_nr] */
/* insert names for very long entries */
for(i=MATROWS(m)-1;i>=0;i--)
{
for(j=MATCOLS(m)-1;j>=0;j--)
{
if (s[i*MATCOLS(m)+j]==NULL)
{
ss=(char *)omAlloc(len);
s[i*MATCOLS(m)+j]=ss;
ss[0]='\0';
snprintf(ss,len,"%s[%d,%d]",name,i+1,j+1);
if ((i!=MATROWS(m)-1) || (j!=MATCOLS(m)-1))
{
strcat(ss,",");
vl=si_max(vl,(int)strlen(ss));
}
}
k=strlen(s[i*MATCOLS(m)+j]);
if (k>l[j]) l[j]=k;
}
}
/* does it fit on a line ? */
int maxlen=0;
for(j=MATCOLS(m)-1;j>=0;j--)
{
maxlen+=l[j];
}
if (maxlen>colmax)
{
/* NO, it does not fit, so retry: */
/* look up the width of all columns, clear very long entriess */
/* put length in l[col_nr] */
/* insert names for cleared entries */
size_t len=14+strlen(name);
for(j=MATCOLS(m)-1;j>=0;j--)
{
for(i=MATROWS(m)-1;i>=0;i--)
{
k=strlen(s[i*MATCOLS(m)+j]);
if (/*strlen(s[i*MATCOLS(m)+j])*/ k > vl)
{
omFree((ADDRESS)s[i*MATCOLS(m)+j]);
ss=(char *)omAlloc(len);
s[i*MATCOLS(m)+j]=ss;
ss[0]='\0';
snprintf(ss,len,"%s[%d,%d]",name,i+1,j+1);
if ((i!=MATROWS(m)-1) || (j!=MATCOLS(m)-1))
{
strcat(ss,",");
}
l[j]=strlen(s[i*MATCOLS(m)+j]);
if (l[j]>vl)
{
//#ifdef TEST
// PrintS("pagewidth too small in print(matrix)\n");
//#endif
vl=l[j]; /* make large names fit*/
}
i=MATROWS(m);
}
else
{
if (k>l[j]) l[j]=k;
}
}
}
}
/*output of the matrix*/
for(i=0;i<MATROWS(m);i++)
{
k=l[0];
Print("%-*.*s",l[0],l[0],s[i*MATCOLS(m)]);
omFree(s[i*MATCOLS(m)]);
for(j=1;j<MATCOLS(m);j++)
{
if (k+l[j]>colmax)
{
PrintS("\n ");
k=2;
}
k+=l[j];
Print("%-*.*s",l[j],l[j],s[i*MATCOLS(m)+j]);
omFree(s[i*MATCOLS(m)+j]);
}
PrintLn();
}
/* clean up */
omFreeSize((ADDRESS)s,MATCOLS(m)*MATROWS(m)*sizeof(char*));
omFreeSize((ADDRESS)l,MATCOLS(m)*sizeof(int));
}
else Print("%d x %d zero matrix\n",MATROWS(m),MATCOLS(m));
}
si_max
static int si_max(const int a, const int b)
Definition auxiliary.h:125
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
l
int l
Definition cfEzgcd.cc:100
k
int k
Definition cfEzgcd.cc:99
s
const CanonicalForm int s
Definition facAbsFact.cc:51
name
char name(const Variable &v)
Definition factory.h:189
MATROWS
#define MATROWS(i)
Definition matpol.h:26
MATCOLS
#define MATCOLS(i)
Definition matpol.h:27
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
omFreeBinAddr
#define omFreeBinAddr(addr)
Definition omAllocDecl.h:258
NULL
#define NULL
Definition omList.c:12
pString0
void pString0(poly p)
Definition polys.h:308
pString
char * pString(poly p)
Definition polys.h:307
StringSetS
void StringSetS(const char *st)
Definition reporter.cc:128
StringAppendS
void StringAppendS(const char *st)
Definition reporter.cc:107
StringEndS
char * StringEndS()
Definition reporter.cc:151
colmax
EXTERN_VAR int colmax
Definition reporter.h:17

## ipPrint_RING()

BOOLEAN ipPrint_RING | ( | ring | r | ) |

static

Definition at line 195 of file ipprint.cc.

{
PrintS("polynomial ring, over a ");
if (rField_is_Ring(r))
{
if (rField_is_Domain(r)) PrintS("domain");
else PrintS("ring (with zero-divisors)");
}
else PrintS("field");
if (r->OrdSgn==1) PrintS(", global");
else if (r->MixedOrder==1) PrintS(", mixed");
else PrintS(", local");
PrintS(" ordering\n");
rWrite(r, TRUE);
return FALSE;
}
TRUE
#define TRUE
Definition auxiliary.h:101
rWrite
void rWrite(ring r, BOOLEAN details)
Definition ring.cc:227
rField_is_Domain
static BOOLEAN rField_is_Domain(const ring r)
Definition ring.h:493
rField_is_Ring
#define rField_is_Ring(R)
Definition ring.h:491

## ipPrint_V()

BOOLEAN ipPrint_V | ( | poly | u | ) |

static

Definition at line 226 of file ipprint.cc.

{
polyset m=NULL;
int l,j;
/*convert into an array of the components*/
p_Vec2Polys(u, &m, &l, currRing);
/*output*/
PrintS("[");
j=0;
loop
{
PrintS(pString(m[j]));
j++;
if (j<l) PrintS(",");
else
{
PrintS("]\n");
break;
}
}
/* clean up */
for(j=l-1;j>=0;j--) pDelete(&m[j]);
omFreeSize((ADDRESS)m,l*sizeof(poly));
return FALSE;
}
p_Vec2Polys
void p_Vec2Polys(poly v, poly **p, int *len, const ring r)
Definition p_polys.cc:3750
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
pDelete
#define pDelete(p_ptr)
Definition polys.h:187
polyset
poly * polyset
Definition polys.h:260
loop
#define loop
Definition structs.h:71

## ipPrintBetti()

void ipPrintBetti | ( | leftv | u | ) |

static

Definition at line 346 of file ipprint.cc.

{
int i,j;
int row_shift=(int)((long)(atGet(u,"rowShift",INT_CMD)));
intvec * betti=(intvec *)u->Data();
// head line --------------------------------------------------------
PrintS(" "); // 6 spaces for no. and :
for(j=0;j<betti->cols();j++) Print(" %5d",j); // 6 spaces pro column
PrintS("\n------"); // 6 spaces for no. and :
for(j=0;j<betti->cols();j++) PrintS("------"); // 6 spaces pro column
PrintLn();
// the table --------------------------------------------------------
for(i=0;i<betti->rows();i++)
{
Print("%5d:",i+row_shift);
for(j=1;j<=betti->cols();j++)
{
int m=IMATELEM(*betti,i+1,j);
if (m==0)
PrintS(" -");
else
Print(" %5d",m);
}
PrintLn();
}
// sum --------------------------------------------------------------
PrintS("------"); // 6 spaces for no. and :
for(j=0;j<betti->cols();j++) PrintS("------"); // 6 spaces pro column
PrintS("\ntotal:");
for(j=0;j<betti->cols();j++)
{
int s=0;
for(i=0;i<betti->rows();i++)
{
s+=IMATELEM(*betti,i+1,j+1);
}
Print(" %5d",s); // 6 spaces pro column
}
PrintLn();
}
atGet
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition attrib.cc:132
intvec
Definition intvec.h:24
intvec::cols
int cols() const
Definition intvec.h:96
intvec::rows
int rows() const
Definition intvec.h:97
INT_CMD
@ INT_CMD
Definition tok.h:96

## jjDBPRINT()

BOOLEAN jjDBPRINT | ( | leftv | res,
|  | leftv | u )

Definition at line 318 of file ipprint.cc.

{
BOOLEAN print=(printlevel>myynest);
if ((u->next!=NULL)&&(u->Typ()==INT_CMD))
{
print= (((int)((long)(u->Data()))) > 0);
u=u->next;
}
if (print)
{
// BOOLEAN r=FALSE;
leftv h=u;
leftv hh;
while (h!=NULL)
{
hh=h->next;
h->next=NULL;
if (jjPRINT(res, h)) return TRUE;
PrintS((char*)res->data);
omFree(res->data);
PrintLn();
h->next=hh;
h=hh;
}
}
return FALSE;
}
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
sleftv::Typ
int Typ()
Definition subexpr.cc:1048
sleftv::next
leftv next
Definition subexpr.h:86
res
CanonicalForm res
Definition facAbsFact.cc:60
printlevel
VAR int printlevel
Definition febase.cc:36
myynest
VAR int myynest
Definition febase.cc:41
jjPRINT
BOOLEAN jjPRINT(leftv res, leftv u)
Definition ipprint.cc:252
h
STATIC_VAR Poly * h
Definition janet.cc:971
leftv
sleftv * leftv
Definition structs.h:53

## jjPRINT()

BOOLEAN jjPRINT | ( | leftv | res,
|  | leftv | u )

Definition at line 252 of file ipprint.cc.

{
SPrintStart();
BOOLEAN bo=FALSE;
void *d=u->Data();
switch(u->Typ())
{
case INTVEC_CMD:
bo=ipPrint_INTVEC((intvec*)d);
break;
case INTMAT_CMD:
bo=ipPrint_INTMAT((intvec*)d);
break;
case MATRIX_CMD:
bo=ipPrint_MA(u);
break;
case IDEAL_CMD:
{
char* s = u->String(NULL, FALSE, 2);
PrintS(s);
PrintLn();
omFree(s);
break;
}
case MODUL_CMD:
{
matrix m = id_Module2Matrix(id_Copy((ideal)d,currRing),currRing);
ipPrint_MA0(m, u->Name());
id_Delete((ideal *) &m,currRing);
break;
}
case VECTOR_CMD:
bo=ipPrint_V((poly)d);
break;
case RING_CMD:
bo=ipPrint_RING((ring)d);
break;
case CRING_CMD:
bo=ipPrint_CRING((coeffs)d);
break;
default:
u->Print();
break;
}
char *s=SPrintEnd();
if (u->next==NULL)
{
int l=strlen(s);
if (s[l-1]=='\n') s[l-1]='\0';
}
res->data=(void*)s;
return bo;
}
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:765
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:63
IDEAL_CMD
@ IDEAL_CMD
Definition grammar.cc:285
MATRIX_CMD
@ MATRIX_CMD
Definition grammar.cc:287
INTMAT_CMD
@ INTMAT_CMD
Definition grammar.cc:280
MODUL_CMD
@ MODUL_CMD
Definition grammar.cc:288
VECTOR_CMD
@ VECTOR_CMD
Definition grammar.cc:293
RING_CMD
@ RING_CMD
Definition grammar.cc:282
id_Copy
ideal id_Copy(ideal h1, const ring r)
copy an ideal
Definition simpleideals.cc:542
ipPrint_RING
static BOOLEAN ipPrint_RING(ring r)
Definition ipprint.cc:195
ipPrint_V
static BOOLEAN ipPrint_V(poly u)
Definition ipprint.cc:226
ipPrint_MA
static BOOLEAN ipPrint_MA(leftv u)
Definition ipprint.cc:185
ipPrint_INTVEC
static BOOLEAN ipPrint_INTVEC(intvec *v)
Definition ipprint.cc:30
ipPrint_INTMAT
static BOOLEAN ipPrint_INTMAT(intvec *v)
Definition ipprint.cc:40
ipPrint_CRING
static BOOLEAN ipPrint_CRING(coeffs r)
Definition ipprint.cc:212
coeffs
The main handler for Singular numbers which are suitable for Singular polynomials.
SPrintStart
void SPrintStart()
Definition reporter.cc:250
SPrintEnd
char * SPrintEnd()
Definition reporter.cc:277
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition simpleideals.cc:123
id_Module2Matrix
matrix id_Module2Matrix(ideal mod, const ring R)
Definition simpleideals.cc:1594
CRING_CMD
@ CRING_CMD
Definition tok.h:56
INTVEC_CMD
@ 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.

{
/* ==================== betti ======================================== */
if ((u->Typ()==INTMAT_CMD)&&(strcmp((char *)v->Data(),"betti")==0))
{
SPrintStart();
ipPrintBetti(u);
char *s = SPrintEnd();
s[strlen(s)]='\0';
res->data=s;
}
else
/* ======================== end betti ================================= */
{
char* ns = omStrDup((char*) v->Data());
int dim = 1;
if (strlen(ns) == 3 && ns[1] == '2')
{
dim = 2;
ns[1] = ns[2];
ns[2] = '\0';
}
if (strcmp(ns,"%l") == 0)
{
res->data = (char*) u->String(NULL, TRUE, dim);
if (dim == 2)
{
char* ns = (char*) omAlloc(strlen((char*) res->data) + 2);
strcpy(ns, (char*) res->data);
omFree(res->data);
strcat(ns, "\n");
res->data = ns;
}
}
else if (strcmp(ns,"%t") == 0)
{
SPrintStart();
type_cmd(u);
res->data = SPrintEnd();
if (dim != 2)
((char*)res->data)[strlen((char*)res->data) -1] = '\0';
}
else if (strcmp(ns,"%;") == 0)
{
SPrintStart();
u->Print();
if (dim == 2) PrintLn();
res->data = SPrintEnd();
}
else if (strcmp(ns,"%p") == 0)
{
iiExprArith1(res, u, PRINT_CMD);
}
else if (strcmp(ns,"%b") == 0 && (u->Typ()==INTMAT_CMD))
{
SPrintStart();
ipPrintBetti(u);
if (dim == 2) PrintLn();
res->data = SPrintEnd();
}
else
{
res->data = u->String(NULL, FALSE, dim);
if (dim == 2)
{
char* ns = (char*) omAlloc(strlen((char*) res->data) + 2);
strcpy(ns, (char*) res->data);
omFree(res->data);
strcat(ns, "\n");
res->data = ns;
}
}
omFree(ns);
}
return FALSE;
}
iiExprArith1
BOOLEAN iiExprArith1(leftv res, leftv a, int op)
Definition iparith.cc:9365
ipPrintBetti
static void ipPrintBetti(leftv u)
Definition ipprint.cc:346
type_cmd
void type_cmd(leftv v)
Definition ipshell.cc:255
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263
PRINT_CMD
@ PRINT_CMD
Definition tok.h:156
dim
int dim(ideal I, ring r)
Definition tropicalStrategy.cc:23