Loading...
Searching...
No Matches
ipprint.h File Reference
`#include "kernel/structs.h"`

Go to the source code of this file.

## Typedefs

typedef sleftv * | leftv

## 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.

{
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
m
int m
Definition cfEzgcd.cc:128
i
int i
Definition cfEzgcd.cc:132
k
int k
Definition cfEzgcd.cc:99
Print
#define Print
Definition emacs.cc:80
s
const CanonicalForm int s
Definition facAbsFact.cc:51
j
int j
Definition facHensel.cc:110
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
PrintS
void PrintS(const char *s)
Definition reporter.cc:288
StringEndS
char * StringEndS()
Definition reporter.cc:151
PrintLn
void PrintLn()
Definition reporter.cc:314
colmax
EXTERN_VAR int colmax
Definition reporter.h:17

## 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
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
sleftv::Typ
int Typ()
Definition subexpr.cc:1048
sleftv::Data
void * Data()
Definition subexpr.cc:1192
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
INT_CMD
@ INT_CMD
Definition tok.h:96

## 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;
}
intvec
Definition intvec.h:24
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::Name
const char * Name()
Definition subexpr.h:120
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_MA0
void ipPrint_MA0(matrix m, const char *name)
Definition ipprint.cc:57
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
matrix
ip_smatrix * matrix
Definition matpol.h:43
coeffs
The main handler for Singular numbers which are suitable for Singular polynomials.
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
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;
}
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
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