version 1.4, 2003/08/26 12:46:05 |
version 1.8, 2020/10/06 11:33:46 |
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/output.c,v 1.3 2001/05/04 01:06:24 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/output.c,v 1.7 2011/10/05 05:46:14 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
|
#include <stdlib.h> |
|
#include <string.h> |
|
#include <ctype.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "stackm.h" |
#include "stackm.h" |
#include "extern.h" |
#include "extern.h" |
Line 56 char *POLYToString(f,multSym,brace) |
|
Line 59 char *POLYToString(f,multSym,brace) |
|
int brace; |
int brace; |
{ |
{ |
extern int Wrap; |
extern int Wrap; |
|
extern int UseDsmall; |
|
extern int COutput; |
int i,j,jj,fi; |
int i,j,jj,fi; |
int printed = 0; |
int printed = 0; |
int vi; /* index for variables */ |
int vi; /* index for variables */ |
Line 84 char *POLYToString(f,multSym,brace) |
|
Line 89 char *POLYToString(f,multSym,brace) |
|
printed = 1; |
printed = 1; |
xnames = dnames = (char **)NULL; |
xnames = dnames = (char **)NULL; |
}else{ |
}else{ |
ringp = f->m->ringp; xnames = f->m->ringp->x; dnames = f->m->ringp->D; |
ringp = f->m->ringp; xnames = f->m->ringp->x; |
|
if (UseDsmall) dnames = f->m->ringp->Dsmall; |
|
else dnames = f->m->ringp->D; |
n = ringp->n; |
n = ringp->n; |
xout = ringp->outputOrder; |
xout = ringp->outputOrder; |
} |
} |
Line 125 char *POLYToString(f,multSym,brace) |
|
Line 132 char *POLYToString(f,multSym,brace) |
|
for (jj=0; jj<n*2; jj++) { |
for (jj=0; jj<n*2; jj++) { |
j = xout[jj]; |
j = xout[jj]; |
if (j <n) { |
if (j <n) { |
if (f->m->e[j].x) { |
if (COutput) { |
vi++; |
if (f->m->e[j].x) { |
if (vi != 1) putstr(multStr(multSym),&oq); |
vi++; |
putstr(xnames[j],&oq); |
if (vi != 1) putstr(multStr(multSym),&oq); |
if (f->m->e[j].x >= 2) { |
if (f->m->e[j].x == 1) { |
putstr("^",&oq); |
putstr(xnames[j],&oq); |
putstr(intToString(f->m->e[j].x),&oq); |
} else { |
}else if (f->m->e[j].x < 0) { |
putstr("sm1power(",&oq); |
putstr("^(",&oq); |
putstr(xnames[j],&oq); |
putstr(intToString(f->m->e[j].x),&oq); |
putstr(",",&oq); |
putstr(")",&oq); |
putstr(intToString(f->m->e[j].x),&oq); |
} |
putstr(")",&oq); |
} |
} |
|
} |
|
}else{ |
|
if (f->m->e[j].x) { |
|
vi++; |
|
if (vi != 1) putstr(multStr(multSym),&oq); |
|
putstr(xnames[j],&oq); |
|
if (f->m->e[j].x >= 2) { |
|
putstr("^",&oq); |
|
putstr(intToString(f->m->e[j].x),&oq); |
|
}else if (f->m->e[j].x < 0) { |
|
putstr("^(",&oq); |
|
putstr(intToString(f->m->e[j].x),&oq); |
|
putstr(")",&oq); |
|
} |
|
} |
|
} |
}else { |
}else { |
j = j-n; |
if (COutput) { |
if (f->m->e[j].D) { |
j = j-n; |
vi++; |
if (f->m->e[j].D) { |
if (vi != 1) putstr(multStr(multSym),&oq); |
vi++; |
putstr(dnames[j],&oq); |
if (vi != 1) putstr(multStr(multSym),&oq); |
if (f->m->e[j].D >= 2) { |
if (f->m->e[j].D == 1) { |
putstr("^",&oq); |
putstr(dnames[j],&oq); |
putstr(intToString(f->m->e[j].D),&oq); |
}else { |
}else if (f->m->e[j].D < 0) { |
if (f->m->e[j].D) putstr("sm1power(",&oq); |
putstr("^(",&oq); |
putstr(dnames[j],&oq); |
putstr(intToString(f->m->e[j].D),&oq); |
putstr(",",&oq); |
putstr(")",&oq); |
putstr(intToString(f->m->e[j].D),&oq); |
} |
putstr(")",&oq); |
} |
} |
|
} |
|
}else{ |
|
j = j-n; |
|
if (f->m->e[j].D) { |
|
vi++; |
|
if (vi != 1) putstr(multStr(multSym),&oq); |
|
putstr(dnames[j],&oq); |
|
if (f->m->e[j].D >= 2) { |
|
putstr("^",&oq); |
|
putstr(intToString(f->m->e[j].D),&oq); |
|
}else if (f->m->e[j].D < 0) { |
|
putstr("^(",&oq); |
|
putstr(intToString(f->m->e[j].D),&oq); |
|
putstr(")",&oq); |
|
} |
|
} |
|
} |
} |
} |
} |
} |
fi++; |
fi++; |
Line 189 char *KPOLYToString(f) |
|
Line 229 char *KPOLYToString(f) |
|
return(POLYToString(f,OutputStyle,0)); |
return(POLYToString(f,OutputStyle,0)); |
} |
} |
|
|
isOne(c) |
int isOne(c) |
struct coeff *c; |
struct coeff *c; |
{ |
{ |
switch(c->tag) { |
switch(c->tag) { |
|
|
errorCoeff("not yet"); |
errorCoeff("not yet"); |
} |
} |
} |
} |
isMinusOne(c) |
int isMinusOne(c) |
struct coeff *c; |
struct coeff *c; |
{ |
{ |
switch(c->tag) { |
switch(c->tag) { |
|
|
} |
} |
|
|
} |
} |
isNegative(c) |
int isNegative(c) |
struct coeff *c; |
struct coeff *c; |
{ |
{ |
switch(c->tag) { |
switch(c->tag) { |
|
|
} |
} |
} |
} |
|
|
isConstant(f) |
int isConstant(f) |
POLY f; |
POLY f; |
{ |
{ |
int i; |
int i; |
Line 274 void errorOutput(s) |
|
Line 314 void errorOutput(s) |
|
{ |
{ |
fprintf(stderr,"Error(output.c):%s\n",s); |
fprintf(stderr,"Error(output.c):%s\n",s); |
exit(15); |
exit(15); |
|
} |
|
|
|
char **makeDsmall(char **dvars,int n) { |
|
char **ans; |
|
int i; |
|
ans = (char **) sGC_malloc(sizeof(char *)*(n+1)); |
|
for (i=0; i<n; i++) { |
|
ans[i] = (char *) sGC_malloc(sizeof(char)*(strlen(dvars[i])+1)); |
|
strcpy(ans[i],dvars[i]); |
|
ans[i][0] = tolower(ans[i][0]); |
|
} |
|
ans[n] = NULL; |
|
return ans; |
} |
} |