version 1.26, 2004/08/23 08:33:55 |
version 1.32, 2004/09/09 11:42:22 |
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport0.c,v 1.25 2004/08/22 12:52:34 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport0.c,v 1.31 2004/09/09 03:14:46 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "stackm.h" |
#include "stackm.h" |
Line 919 struct object KdataConversion(obj,key) |
|
Line 919 struct object KdataConversion(obj,key) |
|
return(rob); |
return(rob); |
}else if (strcmp(key,"poly") == 0) { |
}else if (strcmp(key,"poly") == 0) { |
rob = KpoPOLY(ZERO); |
rob = KpoPOLY(ZERO); |
|
return rob; |
|
}else if (strcmp(key,"array") == 0) { |
|
rob = newObjectArray(0); |
|
return rob; |
}else{ |
}else{ |
warningKan("Sorry. The data conversion from null to this data type has not supported yet.\n"); |
warningKan("Sorry. The data conversion from null to this data type has not supported yet.\n"); |
} |
} |
Line 1015 struct object KdataConversion(obj,key) |
|
Line 1019 struct object KdataConversion(obj,key) |
|
if (strcmp(key,"array") == 0) { |
if (strcmp(key,"array") == 0) { |
return(rob); |
return(rob); |
}else if (strcmp(key,"list") == 0) { |
}else if (strcmp(key,"list") == 0) { |
rob = *( arrayToList(obj) ); |
rob = KarrayToList(obj); |
return(rob); |
return(rob); |
}else if (strcmp(key,"arrayOfPOLY")==0) { |
}else if (strcmp(key,"arrayOfPOLY")==0) { |
rob = KpoArrayOfPOLY(arrayToArrayOfPOLY(obj)); |
rob = KpoArrayOfPOLY(arrayToArrayOfPOLY(obj)); |
Line 1108 struct object KdataConversion(obj,key) |
|
Line 1112 struct object KdataConversion(obj,key) |
|
break; |
break; |
case Slist: |
case Slist: |
if (strcmp(key,"array") == 0) { |
if (strcmp(key,"array") == 0) { |
rob = listToArray(&obj); |
rob = KlistToArray(obj); |
return(rob); |
return(rob); |
} |
} |
break; |
break; |
case SuniversalNumber: |
case SuniversalNumber: |
if ((strcmp(key,"universalNumber")==0) || (strcmp(key,"numerator")==0)) { |
if ((strcmp(key,"universalNumber")==0) || (strcmp(key,"numerator")==0)) { |
|
rob = obj; |
return(rob); |
return(rob); |
}else if (strcmp(key,"integer")==0) { |
}else if (strcmp(key,"integer")==0) { |
rob = KpoInteger(coeffToInt(obj.lc.universalNumber)); |
rob = KpoInteger(coeffToInt(obj.lc.universalNumber)); |
Line 1210 struct object KdataConversion(obj,key) |
|
Line 1215 struct object KdataConversion(obj,key) |
|
} |
} |
return(NullObject); |
return(NullObject); |
} |
} |
|
|
|
/* cf. macro to_int32 */ |
|
struct object Kto_int32(struct object ob) { |
|
int n,i; |
|
struct object otmp; |
|
struct object rob; |
|
if (ob.tag == SuniversalNumber) return KdataConversion(ob,"integer"); |
|
if (ob.tag == Sarray) { |
|
n = getoaSize(ob); |
|
rob = newObjectArray(n); |
|
for (i=0; i<n; i++) { |
|
otmp = Kto_int32(getoa(ob,i)); |
|
putoa(rob,i,otmp); |
|
} |
|
return rob; |
|
} |
|
return ob; |
|
} |
/* conversion functions between primitive data and objects. |
/* conversion functions between primitive data and objects. |
If it's not time critical, it is recommended to use these functions */ |
If it's not time critical, it is recommended to use these functions */ |
struct object KpoInteger(k) |
struct object KpoInteger(k) |
Line 1578 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
Line 1600 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
outputVars[i] = i; |
outputVars[i] = i; |
} |
} |
} |
} |
|
|
|
ob4 = Kto_int32(ob4); /* order matrix */ |
oasize = getoaSize(ob4); |
oasize = getoaSize(ob4); |
order = (int *)sGC_malloc(sizeof(int)*((2*n)*oasize+1)); |
order = (int *)sGC_malloc(sizeof(int)*((2*n)*oasize+1)); |
if (order == (int *)NULL) errorKan1("%s\n","No memory."); |
if (order == (int *)NULL) errorKan1("%s\n","No memory."); |
Line 2927 struct object KdefaultPolyRing(struct object ob) { |
|
Line 2950 struct object KdefaultPolyRing(struct object ob) { |
|
} |
} |
|
|
|
|
|
struct object Krest(struct object ob) { |
|
struct object rob; |
|
struct object *op; |
|
int n,i; |
|
if (ob.tag == Sarray) { |
|
n = getoaSize(ob); |
|
if (n == 0) return ob; |
|
rob = newObjectArray(n-1); |
|
for (i=1; i<n; i++) { |
|
putoa(rob,i-1,getoa(ob,i)); |
|
} |
|
return rob; |
|
}else if ((ob.tag == Slist) || (ob.tag == Snull)) { |
|
return Kcdr(ob); |
|
}else{ |
|
errorKan1("%s\n","Krest(ob): ob must be an array or a list."); |
|
} |
|
} |
|
struct object Kjoin(struct object ob1, struct object ob2) { |
|
struct object rob; |
|
int n1,n2,i; |
|
if ((ob1.tag == Sarray) && (ob2.tag == Sarray)) { |
|
n1 = getoaSize(ob1); n2 = getoaSize(ob2); |
|
rob = newObjectArray(n1+n2); |
|
for (i=0; i<n1; i++) { |
|
putoa(rob,i,getoa(ob1,i)); |
|
} |
|
for (i=n1; i<n1+n2; i++) { |
|
putoa(rob,i,getoa(ob2,i-n1)); |
|
} |
|
return rob; |
|
}else if ((ob1.tag == Slist) || (ob1.tag == Snull)) { |
|
if ((ob2.tag == Slist) || (ob2.tag == Snull)) { |
|
return KvJoin(ob1,ob2); |
|
}else{ |
|
errorKan1("%s\n","Kjoin: both argument must be a list."); |
|
} |
|
}else{ |
|
errorKan1("%s\n","Kjoin: arguments must be arrays."); |
|
} |
|
} |
|
|
|
|
|
|
Line 2953 errorKan1(str,message) |
|
Line 3017 errorKan1(str,message) |
|
if (ErrorMessageMode != 1) { |
if (ErrorMessageMode != 1) { |
fprintf(stderr,"\nERROR(kanExport[0|1].c): "); |
fprintf(stderr,"\nERROR(kanExport[0|1].c): "); |
fprintf(stderr,str,message); |
fprintf(stderr,str,message); |
|
(void) traceShowStack(); traceClearStack(); |
} |
} |
/* fprintf(stderr,"Hello "); */ |
/* fprintf(stderr,"Hello "); */ |
if (GotoP) { |
if (GotoP) { |