version 1.42, 2005/06/09 05:46:57 |
version 1.47, 2006/12/21 05:29:49 |
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport0.c,v 1.41 2004/11/15 08:27:27 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport0.c,v 1.46 2005/09/27 06:10:43 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 30 struct object KooAdd(ob1,ob2) |
|
Line 32 struct object KooAdd(ob1,ob2) |
|
POLY r; |
POLY r; |
int s,i; |
int s,i; |
objectp f1,f2,g1,g2; |
objectp f1,f2,g1,g2; |
struct object nn,dd; |
struct object nn = OINIT; |
|
struct object dd = OINIT; |
|
|
switch (Lookup[ob1.tag][ob2.tag]) { |
switch (Lookup[ob1.tag][ob2.tag]) { |
case SintegerSinteger: |
case SintegerSinteger: |
Line 161 struct object KooSub(ob1,ob2) |
|
Line 164 struct object KooSub(ob1,ob2) |
|
int s,i; |
int s,i; |
objectp f1,f2,g1,g2; |
objectp f1,f2,g1,g2; |
extern struct coeff *UniversalZero; |
extern struct coeff *UniversalZero; |
struct object nn,dd; |
struct object nn = OINIT; |
|
struct object dd = OINIT; |
|
|
switch (Lookup[ob1.tag][ob2.tag]) { |
switch (Lookup[ob1.tag][ob2.tag]) { |
case SintegerSinteger: |
case SintegerSinteger: |
Line 292 struct object KooMult(ob1,ob2) |
|
Line 296 struct object KooMult(ob1,ob2) |
|
POLY r; |
POLY r; |
int i,s; |
int i,s; |
objectp f1,f2,g1,g2; |
objectp f1,f2,g1,g2; |
struct object dd,nn; |
struct object dd = OINIT; |
|
struct object nn = OINIT; |
|
|
|
|
switch (Lookup[ob1.tag][ob2.tag]) { |
switch (Lookup[ob1.tag][ob2.tag]) { |
Line 438 struct object KoNegate(obj) |
|
Line 443 struct object KoNegate(obj) |
|
{ |
{ |
struct object rob = NullObject; |
struct object rob = NullObject; |
extern struct ring SmallRing; |
extern struct ring SmallRing; |
struct object tob; |
struct object tob = OINIT; |
switch(obj.tag) { |
switch(obj.tag) { |
case Sinteger: |
case Sinteger: |
rob = obj; |
rob = obj; |
Line 480 struct object KoInverse(obj) |
|
Line 485 struct object KoInverse(obj) |
|
struct object rob = NullObject; |
struct object rob = NullObject; |
extern struct coeff *UniversalOne; |
extern struct coeff *UniversalOne; |
objectp onep; |
objectp onep; |
struct object tob; |
struct object tob = OINIT; |
switch(obj.tag) { |
switch(obj.tag) { |
case Spoly: |
case Spoly: |
tob.tag = SuniversalNumber; |
tob.tag = SuniversalNumber; |
Line 546 struct object KaoMult(aa,bb) |
|
Line 551 struct object KaoMult(aa,bb) |
|
POLY tmp; |
POLY tmp; |
POLY fik; |
POLY fik; |
POLY gkj; |
POLY gkj; |
struct object rob; |
struct object rob = OINIT; |
int r1,r2; |
int r1,r2; |
int rsize; |
int rsize; |
struct object tob; |
struct object tob = OINIT; |
struct object ob1; |
struct object ob1 = OINIT; |
extern struct ring SmallRing; |
extern struct ring SmallRing; |
|
|
m = getoaSize(aa); m2 = getoaSize(bb); |
m = getoaSize(aa); m2 = getoaSize(bb); |
Line 610 struct object KaoMult(aa,bb) |
|
Line 615 struct object KaoMult(aa,bb) |
|
r1 = isMatrix(aa,m,n); r2 = isMatrix(bb,m2,n2); |
r1 = isMatrix(aa,m,n); r2 = isMatrix(bb,m2,n2); |
if (r1 == -1 || r2 == -1) { |
if (r1 == -1 || r2 == -1) { |
/* Object multiplication. Elements are not polynomials. */ |
/* Object multiplication. Elements are not polynomials. */ |
struct object ofik,ogkj,otmp; |
struct object ofik = OINIT; |
|
struct object ogkj = OINIT; |
|
struct object otmp = OINIT; |
rob = newObjectArray(m); |
rob = newObjectArray(m); |
for (i=0; i<m; i++) { |
for (i=0; i<m; i++) { |
getoa(rob,i) = newObjectArray(n2); |
getoa(rob,i) = newObjectArray(n2); |
Line 685 KooEqualQ(obj1,obj2) |
|
Line 692 KooEqualQ(obj1,obj2) |
|
struct object obj1; |
struct object obj1; |
struct object obj2; |
struct object obj2; |
{ |
{ |
struct object ob; |
struct object ob = OINIT; |
int i; |
int i; |
extern int Verbose; |
extern int Verbose; |
if (obj1.tag != obj2.tag) { |
if (obj1.tag != obj2.tag) { |
Line 774 struct object KooGreater(obj1,obj2) |
|
Line 781 struct object KooGreater(obj1,obj2) |
|
struct object obj1; |
struct object obj1; |
struct object obj2; |
struct object obj2; |
{ |
{ |
struct object ob; |
struct object ob = OINIT; |
int tt; |
int tt; |
if (obj1.tag != obj2.tag) { |
if (obj1.tag != obj2.tag) { |
errorKan1("%s\n","You cannot compare different kinds of objects."); |
errorKan1("%s\n","You cannot compare different kinds of objects."); |
Line 808 struct object KooGreater(obj1,obj2) |
|
Line 815 struct object KooGreater(obj1,obj2) |
|
case Sarray: |
case Sarray: |
{ |
{ |
int i,m1,m2; |
int i,m1,m2; |
struct object rr; |
struct object rr = OINIT; |
m1 = getoaSize(obj1); m2 = getoaSize(obj2); |
m1 = getoaSize(obj1); m2 = getoaSize(obj2); |
for (i=0; i< (m1>m2?m2:m1); i++) { |
for (i=0; i< (m1>m2?m2:m1); i++) { |
rr=KooGreater(getoa(obj1,i),getoa(obj2,i)); |
rr=KooGreater(getoa(obj1,i),getoa(obj2,i)); |
Line 864 struct object KooLess(obj1,obj2) |
|
Line 871 struct object KooLess(obj1,obj2) |
|
case Sarray: |
case Sarray: |
{ |
{ |
int i,m1,m2; |
int i,m1,m2; |
struct object rr; |
struct object rr = OINIT; |
m1 = getoaSize(obj1); m2 = getoaSize(obj2); |
m1 = getoaSize(obj1); m2 = getoaSize(obj2); |
for (i=0; i< (m1>m2?m2:m1); i++) { |
for (i=0; i< (m1>m2?m2:m1); i++) { |
rr=KooLess(getoa(obj1,i),getoa(obj2,i)); |
rr=KooLess(getoa(obj1,i),getoa(obj2,i)); |
Line 890 struct object KdataConversion(obj,key) |
|
Line 897 struct object KdataConversion(obj,key) |
|
{ |
{ |
char tmps[128]; /* Assume that double is not more than 128 digits */ |
char tmps[128]; /* Assume that double is not more than 128 digits */ |
char intstr[100]; /* Assume that int is not more than 100 digits */ |
char intstr[100]; /* Assume that int is not more than 100 digits */ |
struct object rob; |
struct object rob = OINIT; |
extern struct ring *CurrentRingp; |
extern struct ring *CurrentRingp; |
extern struct ring SmallRing; |
extern struct ring SmallRing; |
int flag; |
int flag; |
struct object rob1,rob2; |
struct object rob1 = OINIT; |
|
struct object rob2 = OINIT; |
char *s; |
char *s; |
int i; |
int i; |
double f; |
double f; |
Line 1238 struct object KdataConversion(obj,key) |
|
Line 1246 struct object KdataConversion(obj,key) |
|
/* cf. macro to_int32 */ |
/* cf. macro to_int32 */ |
struct object Kto_int32(struct object ob) { |
struct object Kto_int32(struct object ob) { |
int n,i; |
int n,i; |
struct object otmp; |
struct object otmp = OINIT; |
struct object rob; |
struct object rob = OINIT; |
if (ob.tag == SuniversalNumber) return KdataConversion(ob,"integer"); |
if (ob.tag == SuniversalNumber) return KdataConversion(ob,"integer"); |
if (ob.tag == Sarray) { |
if (ob.tag == Sarray) { |
n = getoaSize(ob); |
n = getoaSize(ob); |
Line 1257 struct object Kto_int32(struct object ob) { |
|
Line 1265 struct object Kto_int32(struct object ob) { |
|
struct object KpoInteger(k) |
struct object KpoInteger(k) |
int k; |
int k; |
{ |
{ |
struct object obj; |
struct object obj = OINIT; |
obj.tag = Sinteger; |
obj.tag = Sinteger; |
obj.lc.ival = k; obj.rc.ival = 0; |
obj.lc.ival = k; obj.rc.ival = 0; |
return(obj); |
return(obj); |
Line 1265 struct object KpoInteger(k) |
|
Line 1273 struct object KpoInteger(k) |
|
struct object KpoString(s) |
struct object KpoString(s) |
char *s; |
char *s; |
{ |
{ |
struct object obj; |
struct object obj = OINIT; |
obj.tag = Sdollar; |
obj.tag = Sdollar; |
obj.lc.str = s; obj.rc.ival = 0; |
obj.lc.str = s; obj.rc.ival = 0; |
return(obj); |
return(obj); |
Line 1273 struct object KpoString(s) |
|
Line 1281 struct object KpoString(s) |
|
struct object KpoPOLY(f) |
struct object KpoPOLY(f) |
POLY f; |
POLY f; |
{ |
{ |
struct object obj; |
struct object obj = OINIT; |
obj.tag = Spoly; |
obj.tag = Spoly; |
obj.lc.poly = f; obj.rc.ival = 0; |
obj.lc.poly = f; obj.rc.ival = 0; |
return(obj); |
return(obj); |
Line 1281 struct object KpoPOLY(f) |
|
Line 1289 struct object KpoPOLY(f) |
|
struct object KpoArrayOfPOLY(ap) |
struct object KpoArrayOfPOLY(ap) |
struct arrayOfPOLY *ap ; |
struct arrayOfPOLY *ap ; |
{ |
{ |
struct object obj; |
struct object obj = OINIT; |
obj.tag = SarrayOfPOLY; |
obj.tag = SarrayOfPOLY; |
obj.lc.arrayp = ap; obj.rc.ival = 0; |
obj.lc.arrayp = ap; obj.rc.ival = 0; |
return(obj); |
return(obj); |
Line 1290 struct object KpoArrayOfPOLY(ap) |
|
Line 1298 struct object KpoArrayOfPOLY(ap) |
|
struct object KpoMatrixOfPOLY(mp) |
struct object KpoMatrixOfPOLY(mp) |
struct matrixOfPOLY *mp ; |
struct matrixOfPOLY *mp ; |
{ |
{ |
struct object obj; |
struct object obj = OINIT; |
obj.tag = SmatrixOfPOLY; |
obj.tag = SmatrixOfPOLY; |
obj.lc.matrixp = mp; obj.rc.ival = 0; |
obj.lc.matrixp = mp; obj.rc.ival = 0; |
return(obj); |
return(obj); |
Line 1299 struct object KpoMatrixOfPOLY(mp) |
|
Line 1307 struct object KpoMatrixOfPOLY(mp) |
|
struct object KpoRingp(ringp) |
struct object KpoRingp(ringp) |
struct ring *ringp; |
struct ring *ringp; |
{ |
{ |
struct object obj; |
struct object obj = OINIT; |
obj.tag = Sring; |
obj.tag = Sring; |
obj.lc.ringp = ringp; |
obj.lc.ringp = ringp; |
return(obj); |
return(obj); |
Line 1308 struct object KpoRingp(ringp) |
|
Line 1316 struct object KpoRingp(ringp) |
|
struct object KpoUniversalNumber(u) |
struct object KpoUniversalNumber(u) |
struct coeff *u; |
struct coeff *u; |
{ |
{ |
struct object obj; |
struct object obj = OINIT; |
obj.tag = SuniversalNumber; |
obj.tag = SuniversalNumber; |
obj.lc.universalNumber = u; |
obj.lc.universalNumber = u; |
return(obj); |
return(obj); |
Line 1316 struct object KpoUniversalNumber(u) |
|
Line 1324 struct object KpoUniversalNumber(u) |
|
struct object KintToUniversalNumber(n) |
struct object KintToUniversalNumber(n) |
int n; |
int n; |
{ |
{ |
struct object rob; |
struct object rob = OINIT; |
extern struct ring SmallRing; |
extern struct ring SmallRing; |
rob.tag = SuniversalNumber; |
rob.tag = SuniversalNumber; |
rob.lc.universalNumber = intToCoeff(n,&SmallRing); |
rob.lc.universalNumber = intToCoeff(n,&SmallRing); |
Line 1329 struct object arrayOfPOLYToArray(aa) |
|
Line 1337 struct object arrayOfPOLYToArray(aa) |
|
{ |
{ |
POLY *a; |
POLY *a; |
int size; |
int size; |
struct object r; |
struct object r = OINIT; |
int j; |
int j; |
struct object tmp; |
struct object tmp = OINIT; |
|
|
size = aa->n; a = aa->array; |
size = aa->n; a = aa->array; |
r = newObjectArray(size); |
r = newObjectArray(size); |
Line 1346 struct object arrayOfPOLYToArray(aa) |
|
Line 1354 struct object arrayOfPOLYToArray(aa) |
|
struct object matrixOfPOLYToArray(pmat) |
struct object matrixOfPOLYToArray(pmat) |
struct matrixOfPOLY *pmat; |
struct matrixOfPOLY *pmat; |
{ |
{ |
struct object r; |
struct object r = OINIT; |
struct object tmp; |
struct object tmp = OINIT; |
int i,j; |
int i,j; |
int m,n; |
int m,n; |
POLY *mat; |
POLY *mat; |
Line 1370 struct arrayOfPOLY *arrayToArrayOfPOLY(oa) |
|
Line 1378 struct arrayOfPOLY *arrayToArrayOfPOLY(oa) |
|
POLY *a; |
POLY *a; |
int size; |
int size; |
int i; |
int i; |
struct object tmp; |
struct object tmp = OINIT; |
struct arrayOfPOLY *ap; |
struct arrayOfPOLY *ap; |
|
|
if (oa.tag != Sarray) errorKan1("KarrayToArrayOfPOLY(): %s", |
if (oa.tag != Sarray) errorKan1("KarrayToArrayOfPOLY(): %s", |
Line 1398 struct matrixOfPOLY *arrayToMatrixOfPOLY(oa) |
|
Line 1406 struct matrixOfPOLY *arrayToMatrixOfPOLY(oa) |
|
int i,j; |
int i,j; |
struct matrixOfPOLY *ma; |
struct matrixOfPOLY *ma; |
|
|
struct object tmp,tmp2; |
struct object tmp = OINIT; |
|
struct object tmp2 = OINIT; |
if (oa.tag != Sarray) errorKan1("KarrayToMatrixOfPOLY(): %s", |
if (oa.tag != Sarray) errorKan1("KarrayToMatrixOfPOLY(): %s", |
"Argument is not array\n"); |
"Argument is not array\n"); |
m = getoaSize(oa); |
m = getoaSize(oa); |
Line 1436 int objArrayToOrderMatrix(oA,order,n,oasize) |
|
Line 1445 int objArrayToOrderMatrix(oA,order,n,oasize) |
|
{ |
{ |
int size; |
int size; |
int k,j; |
int k,j; |
struct object tmpOa; |
struct object tmpOa = OINIT; |
struct object obj; |
struct object obj = OINIT; |
if (oA.tag != Sarray) { |
if (oA.tag != Sarray) { |
warningKan("The argument should be of the form [ [...] [...] ... [...]]."); |
warningKan("The argument should be of the form [ [...] [...] ... [...]]."); |
return(-1); |
return(-1); |
Line 1525 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
Line 1534 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
#define RP_LIMIT 5000 |
#define RP_LIMIT 5000 |
{ |
{ |
int i; |
int i; |
struct object ob; |
struct object ob = OINIT; |
int c,l,m,n; |
int c,l,m,n; |
int cc,ll,mm,nn; |
int cc,ll,mm,nn; |
int p; |
int p; |
Line 1548 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
Line 1557 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
extern char *F_mpMult; |
extern char *F_mpMult; |
char *fmp_mult_saved; |
char *fmp_mult_saved; |
char *mpMultName = NULL; |
char *mpMultName = NULL; |
struct object rob; |
struct object rob = OINIT; |
struct ring *savedCurrentRingp; |
struct ring *savedCurrentRingp; |
|
|
/* To get the ring structure. */ |
/* To get the ring structure. */ |
Line 1650 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
Line 1659 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
newRingp->cc = cc; |
newRingp->cc = cc; |
newRingp->x = xvars; |
newRingp->x = xvars; |
newRingp->D = dvars; |
newRingp->D = dvars; |
|
newRingp->Dsmall = makeDsmall(dvars,n); |
/* You don't need to set order and orderMatrixSize here. |
/* You don't need to set order and orderMatrixSize here. |
It was set by setOrder(). */ |
It was set by setOrder(). */ |
setFromTo(newRingp); |
setFromTo(newRingp); |
Line 1723 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
Line 1733 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
errorKan1("%s\n","An array of array should be given. (degreeShift)"); |
errorKan1("%s\n","An array of array should be given. (degreeShift)"); |
} |
} |
{ |
{ |
struct object ods; |
struct object ods = OINIT; |
struct object ods2; |
struct object ods2 = OINIT; |
int dssize,k,j,nn; |
int dssize,k,j,nn; |
ods=getoa(ob5,i+1); |
ods=getoa(ob5,i+1); |
if ((getoaSize(ods) < 1) || (getoa(ods,0).tag != Sarray)) { |
if ((getoaSize(ods) < 1) || (getoa(ods,0).tag != Sarray)) { |
Line 1752 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
Line 1762 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
errorKan1("%s\n","An array of array should be given. (partialEcart)"); |
errorKan1("%s\n","An array of array should be given. (partialEcart)"); |
} |
} |
{ |
{ |
struct object odv; |
struct object odv = OINIT; |
struct object ovv; |
struct object ovv = OINIT; |
int k,j,nn; |
int k,j,nn; |
char *vname; |
char *vname; |
odv=getoa(ob5,i+1); |
odv=getoa(ob5,i+1); |
Line 1831 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
Line 1841 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
struct object KsetVariableNames(struct object ob,struct ring *rp) |
struct object KsetVariableNames(struct object ob,struct ring *rp) |
{ |
{ |
int n,i; |
int n,i; |
struct object ox; |
struct object ox = OINIT; |
struct object otmp; |
struct object otmp = OINIT; |
char **xvars; |
char **xvars; |
char **dvars; |
char **dvars; |
if (ob.tag != Sarray) { |
if (ob.tag != Sarray) { |
Line 1877 struct object KswitchFunction(ob1,ob2) |
|
Line 1887 struct object KswitchFunction(ob1,ob2) |
|
struct object ob1,ob2; |
struct object ob1,ob2; |
{ |
{ |
char *ans ; |
char *ans ; |
struct object rob; |
struct object rob = OINIT; |
int needWarningForAvoidTheSameRing = 0; |
int needWarningForAvoidTheSameRing = 0; |
extern int AvoidTheSameRing; |
extern int AvoidTheSameRing; |
if ((ob1.tag != Sdollar) || (ob2.tag != Sdollar)) { |
if ((ob1.tag != Sdollar) || (ob2.tag != Sdollar)) { |
Line 1919 struct object KoReplace(of,rule) |
|
Line 1929 struct object KoReplace(of,rule) |
|
struct object of; |
struct object of; |
struct object rule; |
struct object rule; |
{ |
{ |
struct object rob; |
struct object rob = OINIT; |
POLY f; |
POLY f; |
POLY lRule[N0*2]; |
POLY lRule[N0*2]; |
POLY rRule[N0*2]; |
POLY rRule[N0*2]; |
POLY r; |
POLY r; |
int i; |
int i; |
int n; |
int n; |
struct object trule; |
struct object trule = OINIT; |
|
|
|
|
if (rule.tag != Sarray) { |
if (rule.tag != Sarray) { |
Line 1982 struct object Kparts(f,v) |
|
Line 1992 struct object Kparts(f,v) |
|
{ |
{ |
POLY ff; |
POLY ff; |
POLY vv; |
POLY vv; |
struct object obj; |
struct object obj = OINIT; |
struct matrixOfPOLY *co; |
struct matrixOfPOLY *co; |
/* check the data type */ |
/* check the data type */ |
if (f.tag != Spoly || v.tag != Spoly) |
if (f.tag != Spoly || v.tag != Spoly) |
Line 1999 struct object Kparts2(f,v) |
|
Line 2009 struct object Kparts2(f,v) |
|
{ |
{ |
POLY ff; |
POLY ff; |
POLY vv; |
POLY vv; |
struct object obj; |
struct object obj = OINIT; |
struct matrixOfPOLY *co; |
struct matrixOfPOLY *co; |
/* check the data type */ |
/* check the data type */ |
if (f.tag != Spoly || v.tag != Spoly) |
if (f.tag != Spoly || v.tag != Spoly) |
Line 2047 struct object Ksp(ob1,ob2) |
|
Line 2057 struct object Ksp(ob1,ob2) |
|
struct object ob1,ob2; |
struct object ob1,ob2; |
{ |
{ |
struct spValue sv; |
struct spValue sv; |
struct object rob,cob; |
struct object rob = OINIT; |
|
struct object cob = OINIT; |
POLY f; |
POLY f; |
if (ob1.tag != Spoly || ob2.tag != Spoly) |
if (ob1.tag != Spoly || ob2.tag != Spoly) |
errorKan1("%s\n","Ksp(): The arguments must be polynomials."); |
errorKan1("%s\n","Ksp(): The arguments must be polynomials."); |
Line 2077 struct object Keval(obj) |
|
Line 2088 struct object Keval(obj) |
|
{ |
{ |
char *key; |
char *key; |
int size; |
int size; |
struct object rob; |
struct object rob = OINIT; |
rob = NullObject; |
rob = NullObject; |
|
|
if (obj.tag != Sarray) |
if (obj.tag != Sarray) |
Line 2122 char *KremoveSpace(str) |
|
Line 2133 char *KremoveSpace(str) |
|
struct object KtoRecords(ob) |
struct object KtoRecords(ob) |
struct object ob; |
struct object ob; |
{ |
{ |
struct object obj; |
struct object obj = OINIT; |
struct object tmp; |
struct object tmp = OINIT; |
int i; |
int i; |
int size; |
int size; |
char **argv; |
char **argv; |
Line 2219 int KtoArgvbyCurryBrace(str,argv,limit) |
|
Line 2230 int KtoArgvbyCurryBrace(str,argv,limit) |
|
} |
} |
|
|
struct object KstringToArgv(struct object ob) { |
struct object KstringToArgv(struct object ob) { |
struct object rob; |
struct object rob = OINIT; |
char *s; |
char *s; |
int n,wc,i,inblank; |
int n,wc,i,inblank; |
char **argv; |
char **argv; |
Line 2259 struct object KstringToArgv(struct object ob) { |
|
Line 2270 struct object KstringToArgv(struct object ob) { |
|
return(rob); |
return(rob); |
} |
} |
|
|
|
struct object KstringToArgv2(struct object ob,struct object oseparator) { |
|
struct object rob = OINIT; |
|
char *s; |
|
int n,wc,i,inblank; |
|
char **argv; |
|
int separator; |
|
if (ob.tag != Sdollar) |
|
errorKan1("%s\n","KstringToArgv2(): the argument must be a string."); |
|
if (oseparator.tag == Sinteger) { |
|
separator = KopInteger(oseparator); |
|
}else if (oseparator.tag == Sdollar) { |
|
s = KopString(oseparator); |
|
separator=s[0]; |
|
}else { |
|
errorKan1("%s\n","KstringToArgv2(ob,separator):the argument must be strings."); |
|
} |
|
n = strlen(KopString(ob)); |
|
s = (char *) sGC_malloc(sizeof(char)*(n+2)); |
|
if (s == NULL) errorKan1("%s\n","KstringToArgv(): No memory."); |
|
strcpy(s,KopString(ob)); |
|
inblank = 1; wc = 0; |
|
for (i=0; i<n; i++) { |
|
if (inblank && (s[i] != separator)) { |
|
wc++; inblank = 0; |
|
}else if ((!inblank) && (s[i] == separator)) { |
|
inblank = 1; |
|
} |
|
} |
|
argv = (char **) sGC_malloc(sizeof(char *)*(wc+2)); |
|
argv[0] = NULL; |
|
inblank = 1; wc = 0; |
|
for (i=0; i<n; i++) { |
|
if (inblank && (s[i] != separator)) { |
|
argv[wc] = &(s[i]); argv[wc+1]=NULL; |
|
wc++; inblank = 0; |
|
}else if ((inblank == 0) && (s[i] == separator)) { |
|
inblank = 1; s[i] = 0; |
|
}else if (inblank && (s[i] == separator)) { |
|
s[i] = 0; |
|
} |
|
} |
|
|
|
rob = newObjectArray(wc); |
|
for (i=0; i<wc; i++) { |
|
putoa(rob,i,KpoString(argv[i])); |
|
/* printf("%s\n",argv[i]); */ |
|
} |
|
return(rob); |
|
} |
|
|
static void checkDuplicateName(xvars,dvars,n) |
static void checkDuplicateName(xvars,dvars,n) |
char *xvars[]; |
char *xvars[]; |
char *dvars[]; |
char *dvars[]; |
Line 2281 static void checkDuplicateName(xvars,dvars,n) |
|
Line 2342 static void checkDuplicateName(xvars,dvars,n) |
|
} |
} |
|
|
struct object KooPower(struct object ob1,struct object ob2) { |
struct object KooPower(struct object ob1,struct object ob2) { |
struct object rob; |
struct object rob = OINIT; |
/* Bug. It has not yet been implemented. */ |
/* Bug. It has not yet been implemented. */ |
if (QuoteMode) { |
if (QuoteMode) { |
rob = powerTree(ob1,ob2); |
rob = powerTree(ob1,ob2); |
Line 2403 struct object KgbExtension(struct object obj) |
|
Line 2464 struct object KgbExtension(struct object obj) |
|
{ |
{ |
char *key; |
char *key; |
int size; |
int size; |
struct object keyo; |
struct object keyo = OINIT; |
struct object rob = NullObject; |
struct object rob = NullObject; |
struct object obj1,obj2,obj3; |
struct object obj1 = OINIT; |
|
struct object obj2 = OINIT; |
|
struct object obj3 = OINIT; |
POLY f1; |
POLY f1; |
POLY f2; |
POLY f2; |
POLY f3; |
POLY f3; |
Line 2574 struct object KmpzExtension(struct object obj) |
|
Line 2637 struct object KmpzExtension(struct object obj) |
|
{ |
{ |
char *key; |
char *key; |
int size; |
int size; |
struct object keyo; |
struct object keyo = OINIT; |
struct object rob = NullObject; |
struct object rob = NullObject; |
struct object obj0,obj1,obj2,obj3; |
struct object obj0 = OINIT; |
|
struct object obj1 = OINIT; |
|
struct object obj2 = OINIT; |
|
struct object obj3 = OINIT; |
MP_INT *f; |
MP_INT *f; |
MP_INT *g; |
MP_INT *g; |
MP_INT *h; |
MP_INT *h; |
Line 2805 struct object KmpzExtension(struct object obj) |
|
Line 2871 struct object KmpzExtension(struct object obj) |
|
/** : context */ |
/** : context */ |
struct object KnewContext(struct object superObj,char *name) { |
struct object KnewContext(struct object superObj,char *name) { |
struct context *cp; |
struct context *cp; |
struct object ob; |
struct object ob = OINIT; |
if (superObj.tag != Sclass) { |
if (superObj.tag != Sclass) { |
errorKan1("%s\n","The argument of KnewContext must be a Class.Context"); |
errorKan1("%s\n","The argument of KnewContext must be a Class.Context"); |
} |
} |
Line 2824 struct object KcreateClassIncetance(struct object ob1, |
|
Line 2890 struct object KcreateClassIncetance(struct object ob1, |
|
struct object ob3) |
struct object ob3) |
{ |
{ |
/* [class-tag super-obj] size [class-tag] cclass */ |
/* [class-tag super-obj] size [class-tag] cclass */ |
struct object ob4; |
struct object ob4 = OINIT; |
int size,size2,i; |
int size,size2,i; |
struct object ob5; |
struct object ob5 = OINIT; |
struct object rob; |
struct object rob = OINIT; |
|
|
if (ob1.tag != Sarray) |
if (ob1.tag != Sarray) |
errorKan1("%s\n","cclass: The first argument must be an array."); |
errorKan1("%s\n","cclass: The first argument must be an array."); |
Line 2880 struct object KpoDouble(double a) { |
|
Line 2946 struct object KpoDouble(double a) { |
|
double toDouble0(struct object ob) { |
double toDouble0(struct object ob) { |
double r; |
double r; |
int r3; |
int r3; |
struct object ob2; |
struct object ob2 = OINIT; |
struct object ob3; |
struct object ob3 = OINIT; |
switch(ob.tag) { |
switch(ob.tag) { |
case Sinteger: |
case Sinteger: |
return( (double) (KopInteger(ob)) ); |
return( (double) (KopInteger(ob)) ); |
Line 2910 double toDouble0(struct object ob) { |
|
Line 2976 double toDouble0(struct object ob) { |
|
} |
} |
|
|
struct object KpoGradedPolySet(struct gradedPolySet *grD) { |
struct object KpoGradedPolySet(struct gradedPolySet *grD) { |
struct object rob; |
struct object rob = OINIT; |
rob.tag = Sclass; |
rob.tag = Sclass; |
rob.lc.ival = CLASSNAME_GradedPolySet; |
rob.lc.ival = CLASSNAME_GradedPolySet; |
rob.rc.voidp = (void *) grD; |
rob.rc.voidp = (void *) grD; |
Line 2927 static char *getspace0(int a) { |
|
Line 2993 static char *getspace0(int a) { |
|
return(s); |
return(s); |
} |
} |
struct object KdefaultPolyRing(struct object ob) { |
struct object KdefaultPolyRing(struct object ob) { |
struct object rob; |
struct object rob = OINIT; |
int i,j,k,n; |
int i,j,k,n; |
struct object ob1,ob2,ob3,ob4,ob5; |
struct object ob1 = OINIT; |
struct object t1; |
struct object ob2 = OINIT; |
|
struct object ob3 = OINIT; |
|
struct object ob4 = OINIT; |
|
struct object ob5 = OINIT; |
|
struct object t1 = OINIT; |
char *s1; |
char *s1; |
extern struct ring *CurrentRingp; |
extern struct ring *CurrentRingp; |
static struct ring *a[N0]; |
static struct ring *a[N0]; |
Line 3020 struct object Krest(struct object ob) { |
|
Line 3090 struct object Krest(struct object ob) { |
|
} |
} |
} |
} |
struct object Kjoin(struct object ob1, struct object ob2) { |
struct object Kjoin(struct object ob1, struct object ob2) { |
struct object rob; |
struct object rob = OINIT; |
int n1,n2,i; |
int n1,n2,i; |
if ((ob1.tag == Sarray) && (ob2.tag == Sarray)) { |
if ((ob1.tag == Sarray) && (ob2.tag == Sarray)) { |
n1 = getoaSize(ob1); n2 = getoaSize(ob2); |
n1 = getoaSize(ob1); n2 = getoaSize(ob2); |
Line 3044 struct object Kjoin(struct object ob1, struct object o |
|
Line 3114 struct object Kjoin(struct object ob1, struct object o |
|
} |
} |
|
|
struct object Kget(struct object ob1, struct object ob2) { |
struct object Kget(struct object ob1, struct object ob2) { |
struct object rob; |
struct object rob = OINIT; |
struct object tob; |
struct object tob = OINIT; |
int i,j,size,n; |
int i,j,size,n; |
if (ob2.tag == Sinteger) { |
if (ob2.tag == Sinteger) { |
i =ob2.lc.ival; |
i =ob2.lc.ival; |
Line 3102 struct object Kget(struct object ob1, struct object ob |
|
Line 3172 struct object Kget(struct object ob1, struct object ob |
|
struct object newByteArray(int size,struct object obj) { |
struct object newByteArray(int size,struct object obj) { |
unsigned char *ba; |
unsigned char *ba; |
unsigned char *ba2; |
unsigned char *ba2; |
struct object rob,tob; |
struct object rob = OINIT; |
|
struct object tob = OINIT; |
int i,n; |
int i,n; |
ba = NULL; |
ba = NULL; |
if (size > 0) { |
if (size > 0) { |
Line 3135 struct object newByteArray(int size,struct object obj) |
|
Line 3206 struct object newByteArray(int size,struct object obj) |
|
} |
} |
struct object newByteArrayFromStr(char *s,int size) { |
struct object newByteArrayFromStr(char *s,int size) { |
unsigned char *ba; |
unsigned char *ba; |
struct object rob; |
struct object rob = OINIT; |
int i; |
int i; |
ba = NULL; |
ba = NULL; |
if (size > 0) { |
if (size > 0) { |
Line 3151 struct object newByteArrayFromStr(char *s,int size) { |
|
Line 3222 struct object newByteArrayFromStr(char *s,int size) { |
|
|
|
struct object byteArrayToArray(struct object obj) { |
struct object byteArrayToArray(struct object obj) { |
int n,i; unsigned char *ba; |
int n,i; unsigned char *ba; |
struct object rob; |
struct object rob = OINIT; |
if (obj.tag != SbyteArray) errorKan1("%s\n","byteArrayToArray: argument is not an byteArray."); |
if (obj.tag != SbyteArray) errorKan1("%s\n","byteArrayToArray: argument is not an byteArray."); |
n = getByteArraySize(obj); |
n = getByteArraySize(obj); |
rob = newObjectArray(n); |
rob = newObjectArray(n); |
Line 3161 struct object byteArrayToArray(struct object obj) { |
|
Line 3232 struct object byteArrayToArray(struct object obj) { |
|
} |
} |
|
|
struct object KgetAttributeList(struct object ob){ |
struct object KgetAttributeList(struct object ob){ |
struct object rob; |
struct object rob = OINIT; |
if (ob.attr != NULL) rob = *(ob.attr); |
if (ob.attr != NULL) rob = *(ob.attr); |
else rob = NullObject; |
else rob = NullObject; |
return rob; |
return rob; |
} |
} |
struct object KputAttributeList(struct object ob,struct object attr) { |
struct object KsetAttributeList(struct object ob,struct object attr) { |
ob.attr = newObject(); |
ob.attr = newObject(); |
*(ob.attr) = attr; |
*(ob.attr) = attr; |
return ob; |
return ob; |
} |
} |
struct object KgetAttribute(struct object ob,struct object key) { |
struct object KgetAttribute(struct object ob,struct object key) { |
struct object rob; |
struct object rob = OINIT; |
struct object alist; |
struct object alist = OINIT; |
int n,i; |
int n,i; |
struct object tob; |
struct object tob = OINIT; |
char *s; |
char *s; |
rob = NullObject; |
rob = NullObject; |
if (ob.attr == NULL) return rob; |
if (ob.attr == NULL) return rob; |
Line 3195 struct object KgetAttribute(struct object ob,struct ob |
|
Line 3266 struct object KgetAttribute(struct object ob,struct ob |
|
} |
} |
return rob; |
return rob; |
} |
} |
/* ob (key) (value) putAttribute /ob set. They are not destructive. */ |
/* ob (key) (value) setAttribute /ob set. They are not destructive. */ |
struct object KputAttribute(struct object ob,struct object key,struct object value) { |
struct object KsetAttribute(struct object ob,struct object key,struct object value) { |
struct object rob; |
struct object rob = OINIT; |
struct object alist; |
struct object alist = OINIT; |
int n,i; |
int n,i; |
char *s = ""; |
char *s = ""; |
struct object tob; |
struct object tob = OINIT; |
rob = ob; |
rob = ob; |
if (ob.attr == NULL) { |
if (ob.attr == NULL) { |
rob.attr = newObject(); |
rob.attr = newObject(); |