version 1.1.1.1, 1999/10/08 02:12:01 |
version 1.5, 2005/07/03 11:08:54 |
|
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/output.c,v 1.4 2003/08/26 12:46:05 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
|
#include <stdlib.h> |
|
#include <string.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "stackm.h" |
#include "stackm.h" |
#include "extern.h" |
#include "extern.h" |
Line 16 struct outputQueue { |
|
Line 19 struct outputQueue { |
|
static void putstr(char *s,struct outputQueue *oq); |
static void putstr(char *s,struct outputQueue *oq); |
|
|
static void putstr(s,oq) |
static void putstr(s,oq) |
char *s; |
char *s; |
struct outputQueue *oq; |
struct outputQueue *oq; |
{ |
{ |
int i; |
int i; |
char **tmp; |
char **tmp; |
Line 50 struct outputQueue *oq; |
|
Line 53 struct outputQueue *oq; |
|
#define multStr(c) (c==' '?" ":(c=='\0'?"":"*")) |
#define multStr(c) (c==' '?" ":(c=='\0'?"":"*")) |
|
|
char *POLYToString(f,multSym,brace) |
char *POLYToString(f,multSym,brace) |
POLY f; |
POLY f; |
int multSym; |
int multSym; |
int brace; |
int brace; |
{ |
{ |
extern int Wrap; |
extern int Wrap; |
int i,j,jj,fi; |
int i,j,jj,fi; |
|
|
/*print coefficient*/ |
/*print coefficient*/ |
if (fi == 0) { |
if (fi == 0) { |
if (isConstant(f)) { |
if (isConstant(f)) { |
putstr(coeffToString(f->coeffp),&oq); |
putstr(coeffToString(f->coeffp),&oq); |
}else if (isOne(f->coeffp)) { |
}else if (isOne(f->coeffp)) { |
/* do nothing */ |
/* do nothing */ |
}else if (isMinusOne(f->coeffp)) { |
}else if (isMinusOne(f->coeffp)) { |
putstr("-",&oq); |
putstr("-",&oq); |
}else{ |
}else{ |
putstr(coeffToString(f->coeffp),&oq); |
putstr(coeffToString(f->coeffp),&oq); |
putstr(multStr(multSym),&oq); |
putstr(multStr(multSym),&oq); |
} |
} |
}else{ |
}else{ |
if (isConstant(f)) { |
if (isConstant(f)) { |
if (isNegative(f->coeffp)) { |
if (isNegative(f->coeffp)) { |
putstr(coeffToString(f->coeffp),&oq); |
putstr(coeffToString(f->coeffp),&oq); |
}else{ |
}else{ |
putstr("+",&oq); |
putstr("+",&oq); |
putstr(coeffToString(f->coeffp),&oq); |
putstr(coeffToString(f->coeffp),&oq); |
} |
} |
} else if (isOne(f->coeffp)) { |
} else if (isOne(f->coeffp)) { |
putstr("+",&oq); |
putstr("+",&oq); |
}else if (isMinusOne(f->coeffp)) { |
}else if (isMinusOne(f->coeffp)) { |
putstr("-",&oq); |
putstr("-",&oq); |
}else{ |
}else{ |
if (!isNegative(f->coeffp)) putstr("+",&oq); |
if (!isNegative(f->coeffp)) putstr("+",&oq); |
putstr(coeffToString(f->coeffp),&oq); |
putstr(coeffToString(f->coeffp),&oq); |
putstr(multStr(multSym),&oq); |
putstr(multStr(multSym),&oq); |
} |
} |
} |
} |
|
|
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 (f->m->e[j].x) { |
vi++; |
vi++; |
if (vi != 1) putstr(multStr(multSym),&oq); |
if (vi != 1) putstr(multStr(multSym),&oq); |
putstr(xnames[j],&oq); |
putstr(xnames[j],&oq); |
if (f->m->e[j].x >= 2) { |
if (f->m->e[j].x >= 2) { |
putstr("^",&oq); |
putstr("^",&oq); |
putstr(intToString(f->m->e[j].x),&oq); |
putstr(intToString(f->m->e[j].x),&oq); |
}else if (f->m->e[j].x < 0) { |
}else if (f->m->e[j].x < 0) { |
putstr("^(",&oq); |
putstr("^(",&oq); |
putstr(intToString(f->m->e[j].x),&oq); |
putstr(intToString(f->m->e[j].x),&oq); |
putstr(")",&oq); |
putstr(")",&oq); |
} |
} |
} |
} |
}else { |
}else { |
j = j-n; |
j = j-n; |
if (f->m->e[j].D) { |
if (f->m->e[j].D) { |
vi++; |
vi++; |
if (vi != 1) putstr(multStr(multSym),&oq); |
if (vi != 1) putstr(multStr(multSym),&oq); |
putstr(dnames[j],&oq); |
putstr(dnames[j],&oq); |
if (f->m->e[j].D >= 2) { |
if (f->m->e[j].D >= 2) { |
putstr("^",&oq); |
putstr("^",&oq); |
putstr(intToString(f->m->e[j].D),&oq); |
putstr(intToString(f->m->e[j].D),&oq); |
}else if (f->m->e[j].D < 0) { |
}else if (f->m->e[j].D < 0) { |
putstr("^(",&oq); |
putstr("^(",&oq); |
putstr(intToString(f->m->e[j].D),&oq); |
putstr(intToString(f->m->e[j].D),&oq); |
putstr(")",&oq); |
putstr(")",&oq); |
} |
} |
} |
} |
} |
} |
} |
} |
fi++; |
fi++; |
|
|
} |
} |
|
|
char *KPOLYToString(f) |
char *KPOLYToString(f) |
POLY f; |
POLY f; |
{ |
{ |
extern int OutputStyle; |
extern int OutputStyle; |
return(POLYToString(f,OutputStyle,0)); |
return(POLYToString(f,OutputStyle,0)); |
} |
} |
|
|
isOne(c) |
isOne(c) |
struct coeff *c; |
struct coeff *c; |
{ |
{ |
switch(c->tag) { |
switch(c->tag) { |
case INTEGER: |
case INTEGER: |
Line 207 struct coeff *c; |
|
Line 210 struct coeff *c; |
|
} |
} |
} |
} |
isMinusOne(c) |
isMinusOne(c) |
struct coeff *c; |
struct coeff *c; |
{ |
{ |
switch(c->tag) { |
switch(c->tag) { |
case INTEGER: |
case INTEGER: |
Line 225 struct coeff *c; |
|
Line 228 struct coeff *c; |
|
|
|
} |
} |
isNegative(c) |
isNegative(c) |
struct coeff *c; |
struct coeff *c; |
{ |
{ |
switch(c->tag) { |
switch(c->tag) { |
case INTEGER: |
case INTEGER: |
Line 244 struct coeff *c; |
|
Line 247 struct coeff *c; |
|
} |
} |
|
|
isConstant(f) |
isConstant(f) |
POLY f; |
POLY f; |
{ |
{ |
int i; |
int i; |
int n; |
int n; |
|
|
return(1); |
return(1); |
} |
} |
|
|
|
int isConstantAll(POLY f) |
|
{ |
|
int i; |
|
int n; |
|
if (f == POLYNULL) return(1); |
|
while (f != POLYNULL) { |
|
if (!isConstant(f)) return 0; |
|
f = f->next; |
|
} |
|
return 1; |
|
} |
|
|
void errorOutput(s) |
void errorOutput(s) |
char *s; |
char *s; |
{ |
{ |
fprintf(stderr,"Error(output.c):%s\n",s); |
fprintf(stderr,"Error(output.c):%s\n",s); |
exit(15); |
exit(15); |