Changeset 6fd69c in git
- Timestamp:
- Mar 22, 2011, 10:02:35 AM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 47a8626627fa6ec583d0e0d8c844f3fdce6e2930
- Parents:
- a50dd10b43b308045bb85fb3ef03438d27949214
- git-author:
- Hans Schoenemann <hannes@mathematik.uni-kl.de>2011-03-22 10:02:35+01:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:04:08+01:00
- Location:
- libpolys/polys/ext_fields
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/ext_fields/longalg.cc
ra50dd10 r6fd69c 31 31 { 32 32 int anz; 33 napoly *liste;33 poly *liste; 34 34 }; 35 35 typedef struct snaIdeal * naIdeal; … … 40 40 41 41 int naNumbOfPar; 42 napoly naMinimalPoly;42 poly naMinimalPoly; 43 43 #define naParNames (currRing->parameter) 44 44 static int naIsChar0; … … 52 52 #endif 53 53 54 number (*naMap)(number from); 55 /* procedure variables */ 56 static numberfunc 57 nacMult, nacSub, nacAdd, nacDiv, nacIntDiv; 58 static number (*nacGcd)(number a, number b, const ring r); 59 static number (*nacLcm)(number a, number b, const ring r); 60 static number (*nacInit)(int i, const ring r); 61 static int (*nacInt)(number &n, const ring r); 62 static void (*nacDelete)(number *a, const ring r); 63 #undef n_Delete 64 #define n_Delete(A,R) nacDelete(A,R) 65 void (*nacNormalize)(number &a); 66 static number (*nacNeg)(number a); 67 number (*nacCopy)(number a); 68 static number (*nacInvers)(number a); 69 BOOLEAN (*nacIsZero)(number a); 70 static BOOLEAN (*nacIsOne)(number a); 71 static BOOLEAN (*nacIsMOne)(number a); 72 static BOOLEAN (*nacGreaterZero)(number a); 73 static const char * (*nacRead) (const char *s, number *a); 74 static napoly napRedp(napoly q); 75 static napoly napTailred(napoly q); 76 static BOOLEAN napDivPoly(napoly p, napoly q); 77 static int napExpi(int i, napoly a, napoly b); 78 ring nacRing; 79 80 void naCoefNormalize(number pp); 81 82 #define napCopy(p) p_Copy(p,nacRing) 54 naIdeal naI = NULL; 55 poly naMinimalPoly; 56 omBin snaIdeal_bin = omGetSpecBin(sizeof(snaIdeal)); 57 number (*naMap)(number from); 58 //omBin lnumber_bin = omGetSpecBin(sizeof(slnumber)); 59 //omBin rnumber_bin = omGetSpecBin(sizeof(snumber)); 60 61 void redefineFunctionPointers() 62 { 63 n_Procs_s* n = currRing->cf; 64 /* re-defining function pointers */ 65 n->cfDelete = naDelete; 66 n->nNormalize = naNormalize; 67 n->cfInit = naInit; 68 n->nPar = naPar; 69 n->nParDeg = naParDeg; 70 n->n_Int = naInt; 71 n->nAdd = naAdd; 72 n->nSub = naSub; 73 n->nMult = naMult; 74 n->nDiv = naDiv; 75 n->nExactDiv = naDiv; 76 n->nIntDiv = naIntDiv; 77 n->nNeg = naNeg; 78 n->nInvers = naInvers; 79 n->nCopy = naCopy; 80 n->cfCopy = na_Copy; 81 n->nGreater = naGreater; 82 n->nEqual = naEqual; 83 n->nIsZero = naIsZero; 84 n->nIsOne = naIsOne; 85 n->nIsMOne = naIsMOne; 86 n->nGreaterZero = naGreaterZero; 87 n->nGreater = naGreater; 88 n->cfWrite = naWrite; 89 n->nRead = naRead; 90 n->nPower = naPower; 91 n->nGcd = naGcd; 92 n->nLcm = naLcm; 93 n->cfSetMap = naSetMap; 94 n->nName = naName; 95 n->nSize = naSize; 96 n->cfGetDenom = napGetDenom; 97 n->cfGetNumerator = napGetNumerator; 98 #ifdef LDEBUG 99 n->nDBTest = naDBTest; 100 #endif 101 /* re-defining global function pointers */ 102 nNormalize=naNormalize; 103 nPar = naPar; 104 nParDeg= nParDeg; 105 n_Int = naInt; 106 nAdd = naAdd; 107 nSub = naSub; 108 nMult = naMult; 109 nDiv = naDiv; 110 nExactDiv= naDiv; 111 nIntDiv= naIntDiv; 112 nNeg = naNeg; 113 nInvers= naInvers; 114 nCopy = naCopy; 115 nGreater = naGreater; 116 nEqual = naEqual; 117 nIsZero = naIsZero; 118 nIsOne = naIsOne; 119 nIsMOne = naIsMOne; 120 nGreaterZero = naGreaterZero; 121 nGreater = naGreater; 122 nRead = naRead; 123 nPower = naPower; 124 nGcd = naGcd; 125 nLcm = naLcm; 126 nName= naName; 127 nSize = naSize; 128 } 83 129 84 130 static number nadGcd( number a, number b, const ring r) { return nacInit(1,r); } … … 93 139 for (j=naI->anz-1; j>=0; j--) 94 140 p_Delete (&naI->liste[j],nacRing); 95 omFreeSize((void *)naI->liste,naI->anz*sizeof( napoly));141 omFreeSize((void *)naI->liste,naI->anz*sizeof(poly)); 96 142 omFreeBin((void *)naI, snaIdeal_bin); 97 143 naI=NULL; … … 112 158 naI=(naIdeal)omAllocBin(snaIdeal_bin); 113 159 naI->anz=IDELEMS(r->minideal); 114 naI->liste=( napoly*)omAlloc(naI->anz*sizeof(napoly));160 naI->liste=(poly*)omAlloc(naI->anz*sizeof(poly)); 115 161 int j; 116 162 for (j=naI->anz-1; j>=0; j--) … … 1019 1065 if (lb==NULL) return naCopy(la); 1020 1066 1021 napoly x, y;1067 poly x, y; 1022 1068 lnumber lu; 1023 1069 lnumber a = (lnumber)la; … … 1031 1077 if (a->n!=NULL) y = pp_Mult_qq(b->z, a->n,nacRing); 1032 1078 else y = napCopy(b->z); 1033 napoly res = napAdd(x, y);1079 poly res = napAdd(x, y); 1034 1080 if (res==NULL) 1035 1081 { … … 1096 1142 #endif 1097 1143 1098 napoly x, y;1144 poly x, y; 1099 1145 if (b->n!=NULL) x = pp_Mult_qq(a->z, b->n,nacRing); 1100 1146 else x = napCopy(a->z); 1101 1147 if (a->n!=NULL) y = p_Mult_q(napCopy(b->z), napCopyNeg(a->n),nacRing); 1102 1148 else y = napCopyNeg(b->z); 1103 napoly res = napAdd(x, y);1149 poly res = napAdd(x, y); 1104 1150 if (res==NULL) 1105 1151 { … … 1144 1190 lnumber b = (lnumber)lb; 1145 1191 lnumber lo; 1146 napoly x;1192 poly x; 1147 1193 1148 1194 #ifdef LDEBUG … … 1251 1297 lnumber a = (lnumber)la; 1252 1298 lnumber b = (lnumber)lb; 1253 napoly x;1299 poly x; 1254 1300 1255 1301 if (a==NULL) … … 1331 1377 lnumber lo; 1332 1378 lnumber b = (lnumber)a; 1333 napoly x;1379 poly x; 1334 1380 1335 1381 if (b==NULL) … … 1462 1508 const char *naRead(const char *s, number *p) 1463 1509 { 1464 napoly x;1510 poly x; 1465 1511 lnumber a; 1466 1512 s = napRead(s, &x); … … 1561 1607 { 1562 1608 lnumber a = (lnumber)za; 1563 napoly x, y;1609 poly x, y; 1564 1610 number t; 1565 1611 if (a==NULL) return FALSE; … … 1619 1665 { 1620 1666 lnumber a = (lnumber)za; 1621 napoly x, y;1667 poly x, y; 1622 1668 number t; 1623 1669 if (a==NULL) return FALSE; … … 1682 1728 setCharacteristic( c ); 1683 1729 1684 napoly rz=napGcd(x->z, y->z);1730 poly rz=napGcd(x->z, y->z); 1685 1731 CanonicalForm F, G, R; 1686 1732 R=convSingPFactoryP(rz,r->algring); … … 1836 1882 naCoefNormalize(pp); 1837 1883 p->s = 2; 1838 napoly x = p->z;1839 napoly y = p->n;1884 poly x = p->z; 1885 poly y = p->n; 1840 1886 1841 1887 BOOLEAN norm=FALSE; … … 1875 1921 for (i=naNumbOfPar-1; i>=0; i--) 1876 1922 { 1877 napoly xx=x;1878 napoly yy=y;1923 poly xx=x; 1924 poly yy=y; 1879 1925 int m = napExpi(i, yy, xx); 1880 1926 if (m != 0) // in this case xx!=NULL!=yy … … 1914 1960 if (naNumbOfPar == 1) /* apply built-in gcd */ 1915 1961 { 1916 napoly x1,y1;1962 poly x1,y1; 1917 1963 if (p_GetExp(x,1,nacRing) >= p_GetExp(y,1,nacRing)) 1918 1964 { … … 1925 1971 y1 = napCopy(x); 1926 1972 } 1927 napoly r;1973 poly r; 1928 1974 loop 1929 1975 { … … 1986 2032 #endif 1987 2033 { 1988 napoly xx,yy;2034 poly xx,yy; 1989 2035 singclap_algdividecontent(x,y,xx,yy); 1990 2036 if (xx!=NULL) … … 2071 2117 naTest(la); 2072 2118 naTest(lb); 2073 napoly x = p_Copy(a->z, r->algring);2119 poly x = p_Copy(a->z, r->algring); 2074 2120 number t = napLcm(b->z); // get all denom of b->z 2075 2121 if (!nacIsOne(t)) 2076 2122 { 2077 2123 number bt, rr; 2078 napoly xx=x;2124 poly xx=x; 2079 2125 while (xx!=NULL) 2080 2126 { … … 2123 2169 lnumber h; 2124 2170 number a; 2125 napoly x;2171 poly x; 2126 2172 2127 2173 naI=(naIdeal)omAllocBin(snaIdeal_bin); 2128 2174 naI->anz=IDELEMS(I); 2129 naI->liste=( napoly*)omAlloc(naI->anz*sizeof(napoly));2175 naI->liste=(poly*)omAlloc(naI->anz*sizeof(poly)); 2130 2176 for (i=IDELEMS(I)-1; i>=0; i--) 2131 2177 { … … 2156 2202 lnumber l=(lnumber)omAllocBin(rnumber_bin); 2157 2203 l->s=2; 2158 l->z=( napoly)p_Init(nacRing);2204 l->z=(poly)p_Init(nacRing); 2159 2205 int i=(int)((long)c); 2160 2206 if (i>((long)naMapRing->ch>>2)) i-=(long)naMapRing->ch; … … 2172 2218 lnumber l=(lnumber)omAllocBin(rnumber_bin); 2173 2219 l->s=0; 2174 l->z=( napoly)p_Init(nacRing);2220 l->z=(poly)p_Init(nacRing); 2175 2221 pGetCoeff(l->z)=nlCopy(c); 2176 2222 l->n=NULL; … … 2186 2232 lnumber l=(lnumber)omAllocBin(rnumber_bin); 2187 2233 l->s=2; 2188 l->z=( napoly)p_Init(nacRing);2234 l->z=(poly)p_Init(nacRing); 2189 2235 pGetCoeff(l->z)=c; /* omit npCopy, because npCopy is a no-op */ 2190 2236 l->n=NULL; … … 2204 2250 lnumber l=(lnumber)omAllocBin(rnumber_bin); 2205 2251 l->s=2; 2206 l->z=( napoly)p_Init(nacRing);2252 l->z=(poly)p_Init(nacRing); 2207 2253 pGetCoeff(l->z)=n; 2208 2254 l->n=NULL; … … 2221 2267 lnumber l=(lnumber)omAllocBin(rnumber_bin); 2222 2268 l->s=2; 2223 l->z=( napoly)p_Init(nacRing);2269 l->z=(poly)p_Init(nacRing); 2224 2270 pGetCoeff(l->z)=n; 2225 2271 l->n=NULL; … … 2537 2583 omCheckAddrSize(a, sizeof(snumber)); 2538 2584 #endif 2539 napoly p = x->z;2585 poly p = x->z; 2540 2586 if (p==NULL) 2541 2587 { -
libpolys/polys/ext_fields/longalg.h
ra50dd10 r6fd69c 10 10 #include <coeffs/coeffs.h> 11 11 #include <coeffs/longrat.h> 12 #include <polys/monomials/ring.h> 12 13 #include <polys/monomials/polys-impl.h> 13 14 #include <polys/ext_fields/longtrans.h> … … 25 26 struct slnumber 26 27 { 27 napoly z; 28 napoly n; 29 BOOLEAN s; 28 int anz; 29 poly *liste; 30 30 }; 31 32 extern napoly naMinimalPoly;33 extern ring nacRing;34 31 typedef struct snaIdeal * naIdeal; 32 extern omBin snaIdeal_bin; 33 extern naIdeal naI; 34 extern poly naMinimalPoly; 35 35 36 36 void naSetChar(int p, ring r); -
libpolys/polys/ext_fields/longtrans.cc
ra50dd10 r6fd69c 115 115 for (j=naI->anz-1; j>=0; j--) 116 116 p_Delete (&naI->liste[j],nacRing); 117 omFreeSize((ADDRESS)naI->liste,naI->anz*sizeof( napoly));117 omFreeSize((ADDRESS)naI->liste,naI->anz*sizeof(poly)); 118 118 omFreeBin((ADDRESS)naI, snaIdeal_bin); 119 119 naI=NULL; … … 159 159 160 160 #ifdef LDEBUG 161 void napTest( napoly p)161 void napTest(poly p) 162 162 { 163 163 if (ntIsChar0) … … 174 174 #endif 175 175 176 /* creates a new napoly that consists of a176 /* creates a new poly that consists of a 177 177 single coefficient (provided as a number); 178 178 the provided number is NOT const */ 179 napoly napInitz(number z)180 { 181 napoly a = (napoly)p_Init(nacRing);179 poly napInitz(number z) 180 { 181 poly a = (poly)p_Init(nacRing); 182 182 pGetCoeff(a) = z; 183 183 return a; 184 184 } 185 185 186 /* creates a new napoly which is the186 /* creates a new poly which is the 187 187 negative inverse of the argument; 188 188 keeps p */ 189 napoly napCopyNeg(const napoly p)190 { 191 napoly r = napCopy(p);192 r = ( napoly)p_Neg((poly)r, nacRing);189 poly napCopyNeg(const poly p) 190 { 191 poly r = napCopy(p); 192 r = (poly)p_Neg((poly)r, nacRing); 193 193 return r; 194 194 } 195 195 196 /* modifies the napoly p to p*z, i.e.196 /* modifies the poly p to p*z, i.e. 197 197 in-place multiplication of p with the number z; 198 198 keeps z */ 199 void napMultN( napoly p, const number z)199 void napMultN(poly p, const number z) 200 200 { 201 201 number t; … … 216 216 in f is greater than or equal to that in g 217 217 sets q, r; destroys f; keeps g */ 218 void napDivMod( napoly f, const napoly g, napoly *q, napoly *r)219 { 220 napoly a, h, b, qq;221 222 qq = ( napoly)p_Init(nacRing);218 void napDivMod(poly f, const poly g, poly *q, poly *r) 219 { 220 poly a, h, b, qq; 221 222 qq = (poly)p_Init(nacRing); 223 223 pNext(qq) = b = NULL; 224 224 p_Normalize(g, nacRing); … … 253 253 in f is greater than or equal to that in g 254 254 destroys f; keeps g; returns r */ 255 napoly napRemainder(napoly f, const napoly g)256 { 257 napoly a, h, qq;258 259 qq = ( napoly)p_Init(nacRing);255 poly napRemainder(poly f, const poly g) 256 { 257 poly a, h, qq; 258 259 qq = (poly)p_Init(nacRing); 260 260 pNext(qq) = NULL; 261 261 p_Normalize(g, nacRing); … … 286 286 some intermediate version of x is returned; 287 287 modifies x; keeps c */ 288 napoly napInvers(napoly x, const napoly c)289 { 290 napoly y, r, qa, qn, q;288 poly napInvers(poly x, const poly c) 289 { 290 poly y, r, qa, qn, q; 291 291 number t; 292 292 … … 391 391 } 392 392 393 /* the degree of a napoly, i.e. the393 /* the degree of a poly, i.e. the 394 394 maximum of all terms' degrees; 395 395 keeps p */ 396 int napMaxDeg( napoly p)396 int napMaxDeg(poly p) 397 397 { 398 398 int d = 0; … … 405 405 } 406 406 407 /* the degree of a napoly, i.e. the407 /* the degree of a poly, i.e. the 408 408 maximum of all terms' degrees; 409 409 fills l with the number of terms; 410 410 keeps p */ 411 int napMaxDegLen( napoly p, int &l)411 int napMaxDegLen(poly p, int &l) 412 412 { 413 413 int d = 0; … … 423 423 424 424 425 /* writes a napoly, i.e. a number in the ground field;425 /* writes a poly, i.e. a number in the ground field; 426 426 if has_denom is TRUE, the output is ready to be 427 427 followed by a non-trivial denominator; … … 429 429 or transcendental field extension; 430 430 keeps all arguments */ 431 void napWrite( napoly p, const BOOLEAN has_denom, const ring r)431 void napWrite(poly p, const BOOLEAN has_denom, const ring r) 432 432 { 433 433 ring nacring = r->algring; … … 484 484 485 485 /* helper for napRead */ 486 const char* napHandleMons(const char* s, int i, napoly ex)486 const char* napHandleMons(const char* s, int i, poly ex) 487 487 { 488 488 int j; … … 502 502 503 503 /* helper for napRead */ 504 const char* napHandlePars(const char *s, int i, napoly ex)504 const char* napHandlePars(const char *s, int i, poly ex) 505 505 { 506 506 if (strcmp(s, ntParNames[i]) == 0) … … 512 512 } 513 513 514 /* reads a monomial into the napoly b;514 /* reads a monomial into the poly b; 515 515 returns the latter portion of s which 516 516 comes "after" the monomial that has 517 517 just been read; 518 518 modifies b */ 519 const char* napRead(const char *s, napoly *b)520 { 521 napoly a;519 const char* napRead(const char *s, poly *b) 520 { 521 poly a; 522 522 int i; 523 a = ( napoly)p_Init(nacRing);523 a = (poly)p_Init(nacRing); 524 524 if ((*s >= '0') && (*s <= '9')) 525 525 { … … 564 564 assumes a != NULL, b != NULL; 565 565 keeps a and b */ 566 int napExp( napoly a, napoly b)566 int napExp(poly a, poly b) 567 567 { 568 568 assume(a != NULL); … … 580 580 used to find it in a fraction; 581 581 keeps a and b */ 582 int napExpi(int i, napoly a, napoly b)582 int napExpi(int i, poly a, poly b) 583 583 { 584 584 if (a == NULL || b == NULL) return 0; … … 610 610 assumes that ph != NULL; 611 611 modifies ph */ 612 void napContent( napoly ph)612 void napContent(poly ph) 613 613 { 614 614 number h, d; 615 napoly p;615 poly p; 616 616 617 617 assume(ph != NULL); … … 650 650 if char != 0, then nothing is done; 651 651 modifies ph */ 652 void napCleardenom( napoly ph)652 void napCleardenom(poly ph) 653 653 { 654 654 number d, h; 655 napoly p;655 poly p; 656 656 657 657 if (!ntIsChar0) return; … … 684 684 assumes a != NULL, b != NULL; 685 685 keeps a, keeps b */ 686 napoly napGcd0(napoly a, napoly b)686 poly napGcd0(poly a, poly b) 687 687 { 688 688 number x, y; … … 719 719 if a != 0 = b, then a is returned; 720 720 keeps a, keeps b */ 721 napoly napGcd(napoly a, napoly b)721 poly napGcd(poly a, poly b) 722 722 { 723 723 int i; 724 napoly g, x, y, h; 725 if (a == NULL) 726 { 727 if (b == NULL) return p_ISet(1,nacRing); 728 else return napCopy(b); 729 } 730 else if (b == NULL) return napCopy(a); 724 poly g, x, y, h; 725 if ((a==NULL) 726 || ((pNext(a)==NULL)&&(nacIsZero(pGetCoeff(a))))) 727 { 728 if ((b==NULL) 729 || ((pNext(b)==NULL)&&(nacIsZero(pGetCoeff(b))))) 730 { 731 return p_ISet(1,nacRing); 732 } 733 return napCopy(b); 734 } 735 else 736 if ((b==NULL) 737 || ((pNext(b)==NULL)&&(nacIsZero(pGetCoeff(b))))) 738 return napCopy(a); 731 739 732 740 if (naMinimalPoly != NULL) … … 791 799 if a = 0, then the constant poly 1 is returned; 792 800 keeps a */ 793 number napLcm( napoly a)801 number napLcm(poly a) 794 802 { 795 803 number h = nacInit(1,nacRing); … … 797 805 { 798 806 number d; 799 napoly b = a; 807 poly b = a; 808 800 809 while (b!=NULL) 801 810 { … … 814 823 * doesn't delete p and q 815 824 */ 816 BOOLEAN napDivPoly ( napoly p, napoly q)825 BOOLEAN napDivPoly (poly p, poly q) 817 826 { 818 827 int j=1; /* evtl. von naNumber.. -1 abwaerts zaehlen */ … … 833 842 * modifies q and returns it 834 843 */ 835 napoly napRedp (napoly q)836 { 837 napoly h = (napoly)p_Init(nacRing);844 poly napRedp (poly q) 845 { 846 poly h = (poly)p_Init(nacRing); 838 847 int i=0,j; 839 848 … … 878 887 * modifies q and returns it 879 888 */ 880 napoly napTailred (napoly q)881 { 882 napoly h;889 poly napTailred (poly q) 890 { 891 poly h; 883 892 884 893 h = pNext(q); … … 893 902 } 894 903 895 napoly napMap(napoly p)896 { 897 napoly w, a;904 poly napMap(poly p) 905 { 906 poly w, a; 898 907 899 908 if (p==NULL) return NULL; 900 a = w = ( napoly)p_Init(nacRing);909 a = w = (poly)p_Init(nacRing); 901 910 int i; 902 911 for(i=1;i<=ntParsToCopy;i++) … … 908 917 pIter(p); 909 918 if (p==NULL) break; 910 pNext(a) = ( napoly)p_Init(nacRing);919 pNext(a) = (poly)p_Init(nacRing); 911 920 pIter(a); 912 921 for(i=1;i<=ntParsToCopy;i++) … … 919 928 } 920 929 921 napoly napPerm(napoly p,const int *par_perm,const ring src_ring,const nMapFunc nMap)922 { 923 napoly w;930 poly napPerm(poly p,const int *par_perm,const ring src_ring,const nMapFunc nMap) 931 { 932 poly w; 924 933 925 934 if (p==NULL) return NULL; 926 w = ( napoly)p_Init(nacRing);935 w = (poly)p_Init(nacRing); 927 936 int i; 928 937 BOOLEAN not_null=TRUE; … … 966 975 967 976 /*2 968 * convert a napoly number into a poly977 * convert a poly number into a poly 969 978 */ 970 979 poly napPermNumber(number z, int * par_perm, int P, ring oldRing) … … 973 982 poly res=NULL; 974 983 poly p; 975 napoly za=((lnumber)z)->z;976 napoly zb=((lnumber)z)->n;984 poly za=((lnumber)z)->z; 985 poly zb=((lnumber)z)->n; 977 986 nMapFunc nMap=naSetMap(oldRing,currRing); /* todo: check naSetMap 978 987 vs. ntSetMap */ … … 990 999 //for(i=pVariables;i;i--) pSetExp(p,i, 0); // done by pInit 991 1000 //if (rRing_has_Comp(currRing)) pSetComp(p, 0); // done by pInit 992 napoly pa=NULL;1001 poly pa=NULL; 993 1002 lnumber pan; 994 1003 if (currRing->parameter!=NULL) … … 1116 1125 * returns r and destroys f 1117 1126 */ 1118 napoly ntRemainder(napoly f, const napoly g)1119 { 1120 napoly a, h, qq;1121 1122 qq = ( napoly)p_Init(nacRing);1127 poly ntRemainder(poly f, const poly g) 1128 { 1129 poly a, h, qq; 1130 1131 qq = (poly)p_Init(nacRing); 1123 1132 pNext(qq) = NULL; 1124 1133 p_Normalize(g, nacRing); … … 1242 1251 if (lb==NULL) return ntCopy(la); 1243 1252 1244 napoly x, y;1253 poly x, y; 1245 1254 lnumber lu; 1246 1255 lnumber a = (lnumber)la; … … 1254 1263 if (a->n!=NULL) y = pp_Mult_qq(b->z, a->n,nacRing); 1255 1264 else y = napCopy(b->z); 1256 napoly res = napAdd(x, y);1265 poly res = napAdd(x, y); 1257 1266 if (res==NULL) 1258 1267 { … … 1319 1328 #endif 1320 1329 1321 napoly x, y;1330 poly x, y; 1322 1331 if (b->n!=NULL) x = pp_Mult_qq(a->z, b->n,nacRing); 1323 1332 else x = napCopy(a->z); 1324 1333 if (a->n!=NULL) y = p_Mult_q(napCopy(b->z), napCopyNeg(a->n),nacRing); 1325 1334 else y = napCopyNeg(b->z); 1326 napoly res = napAdd(x, y);1335 poly res = napAdd(x, y); 1327 1336 if (res==NULL) 1328 1337 { … … 1367 1376 lnumber b = (lnumber)lb; 1368 1377 lnumber lo; 1369 napoly x;1378 poly x; 1370 1379 1371 1380 #ifdef LDEBUG … … 1466 1475 lnumber a = (lnumber)la; 1467 1476 lnumber b = (lnumber)lb; 1468 napoly x;1477 poly x; 1469 1478 1470 1479 if (a==NULL) … … 1527 1536 lnumber lo; 1528 1537 lnumber b = (lnumber)a; 1529 napoly x;1538 poly x; 1530 1539 1531 1540 if (b==NULL) … … 1662 1671 const char *ntRead(const char *s, number *p) 1663 1672 { 1664 napoly x;1673 poly x; 1665 1674 lnumber a; 1666 1675 s = napRead(s, &x); … … 1860 1869 setCharacteristic( c ); 1861 1870 1862 napoly rz=napGcd(x->z, y->z);1871 poly rz=napGcd(x->z, y->z); 1863 1872 CanonicalForm F, G, R; 1864 1873 R=convSingPFactoryP(rz,r->algring); … … 2013 2022 ntCoefNormalize(pp); 2014 2023 p->s = 2; 2015 napoly x = p->z;2016 napoly y = p->n;2024 poly x = p->z; 2025 poly y = p->n; 2017 2026 2018 2027 if (y==NULL) return; … … 2023 2032 for (i=ntNumbOfPar-1; i>=0; i--) 2024 2033 { 2025 napoly xx=x;2026 napoly yy=y;2034 poly xx=x; 2035 poly yy=y; 2027 2036 int m = napExpi(i, yy, xx); 2028 2037 if (m != 0) // in this case xx!=NULL!=yy … … 2062 2071 if (ntNumbOfPar == 1) /* apply built-in gcd */ 2063 2072 { 2064 napoly x1,y1;2073 poly x1,y1; 2065 2074 if (p_GetExp(x,1,nacRing) >= p_GetExp(y,1,nacRing)) 2066 2075 { … … 2073 2082 y1 = napCopy(x); 2074 2083 } 2075 napoly r;2084 poly r; 2076 2085 loop 2077 2086 { … … 2134 2143 #endif 2135 2144 { 2136 napoly xx,yy;2145 poly xx,yy; 2137 2146 singclap_algdividecontent(x,y,xx,yy); 2138 2147 if (xx!=NULL) … … 2213 2222 ntTest(la); 2214 2223 ntTest(lb); 2215 napoly x = p_Copy(a->z, r->algring);2224 poly x = p_Copy(a->z, r->algring); 2216 2225 number t = napLcm(b->z); // get all denom of b->z 2217 2226 if (!nacIsOne(t)) 2218 2227 { 2219 2228 number bt, rr; 2220 napoly xx=x;2229 poly xx=x; 2221 2230 while (xx!=NULL) 2222 2231 { … … 2254 2263 lnumber l=ALLOC_LNUMBER(); 2255 2264 l->s=2; 2256 l->z=( napoly)p_Init(nacRing);2265 l->z=(poly)p_Init(nacRing); 2257 2266 int i=(int)((long)c); 2258 2267 if (i>((long)ntMapRing->ch>>2)) i-=(long)ntMapRing->ch; … … 2270 2279 lnumber l=ALLOC_LNUMBER(); 2271 2280 l->s=0; 2272 l->z=( napoly)p_Init(nacRing);2281 l->z=(poly)p_Init(nacRing); 2273 2282 pGetCoeff(l->z)=nlCopy(c); 2274 2283 l->n=NULL; … … 2284 2293 lnumber l=ALLOC_LNUMBER(); 2285 2294 l->s=2; 2286 l->z=( napoly)p_Init(nacRing);2295 l->z=(poly)p_Init(nacRing); 2287 2296 pGetCoeff(l->z)=c; /* omit npCopy, because npCopy is a no-op */ 2288 2297 l->n=NULL; … … 2302 2311 lnumber l=ALLOC_LNUMBER(); 2303 2312 l->s=2; 2304 l->z=( napoly)p_Init(nacRing);2313 l->z=(poly)p_Init(nacRing); 2305 2314 pGetCoeff(l->z)=n; 2306 2315 l->n=NULL; … … 2319 2328 lnumber l=ALLOC_LNUMBER(); 2320 2329 l->s=2; 2321 l->z=( napoly)p_Init(nacRing);2330 l->z=(poly)p_Init(nacRing); 2322 2331 pGetCoeff(l->z)=n; 2323 2332 l->n=NULL; … … 2416 2425 2417 2426 /*2 2418 * convert a napoly number into a poly2427 * convert a poly number into a poly 2419 2428 */ 2420 2429 poly ntPermNumber(number z, int * par_perm, int P, ring oldRing) … … 2423 2432 poly res=NULL; 2424 2433 poly p; 2425 napoly za=((lnumber)z)->z;2426 napoly zb=((lnumber)z)->n;2434 poly za=((lnumber)z)->z; 2435 poly zb=((lnumber)z)->n; 2427 2436 nMapFunc nMap=ntSetMap(oldRing,currRing); 2428 2437 if (currRing->parameter!=NULL) … … 2440 2449 pSetExp(p,i, 0); 2441 2450 if (rRing_has_Comp(currRing)) pSetComp(p, 0); 2442 napoly pa=NULL;2451 poly pa=NULL; 2443 2452 lnumber pan; 2444 2453 if (currRing->parameter!=NULL) … … 2541 2550 omCheckAddrSize(a, sizeof(slnumber)); 2542 2551 #endif 2543 napoly p = x->z;2552 poly p = x->z; 2544 2553 if (p==NULL) 2545 2554 { -
libpolys/polys/ext_fields/longtrans.h
ra50dd10 r6fd69c 43 43 */ 44 44 45 typedef polyrec * napoly;46 45 struct slnumber; 47 46 typedef struct slnumber * lnumber; 48 47 struct slnumber 49 48 { 50 napoly z;51 napoly n;49 poly z; 50 poly n; 52 51 BOOLEAN s; 53 52 }; … … 97 96 BOOLEAN ntDBTest(number a, const char *f,const int l); 98 97 #endif 99 napoly ntRemainder(napoly f, const napoly g);98 poly ntRemainder(poly f, const poly g); 100 99 void ntSetIdeal(ideal I); 101 100 void ntCoefNormalize(number pp); … … 135 134 #define napSetCoeff(p,n) {n_Delete(&pGetCoeff(p),nacRing);pGetCoeff(p)=n;} 136 135 #define napComp(p,q) p_LmCmp((poly)p,(poly)q, nacRing) 137 #define napMultT(A,E) A=( napoly)p_Mult_mm((poly)A,(poly)E,nacRing)136 #define napMultT(A,E) A=(poly)p_Mult_mm((poly)A,(poly)E,nacRing) 138 137 #define napDeg(p) (int)p_Totaldegree(p, nacRing) 139 138 number napGetDenom(number &n, const ring r); 140 139 number napGetNumerator(number &n, const ring r); 141 void napTest( napoly p);142 napoly napInitz(number z);143 napoly napCopyNeg(const napoly p);144 void napMultN( napoly p, const number z);145 void napDivMod( napoly f, const napoly g, napoly *q, napoly *r);146 napoly napRemainder(napoly f, const napoly g);147 napoly napInvers(napoly x, const napoly c);148 int napMaxDeg( napoly p);149 int napMaxDegLen( napoly p, int &l);150 void napWrite( napoly p,const BOOLEAN has_denom, const ring r);151 int napExp( napoly a, napoly b);152 int napExpi(int i, napoly a, napoly b);153 void napContent( napoly ph);154 void napCleardenom( napoly ph);155 napoly napGcd0(napoly a, napoly b);156 napoly napGcd(napoly a, napoly b);157 number napLcm( napoly a);158 BOOLEAN napDivPoly ( napoly p, napoly q);159 napoly napRedp (napoly q);160 napoly napTailred (napoly q);161 napoly napMap(napoly p);162 napoly napPerm(napoly p, const int *par_perm, const ring src_ring,140 void napTest(poly p); 141 poly napInitz(number z); 142 poly napCopyNeg(const poly p); 143 void napMultN(poly p, const number z); 144 void napDivMod(poly f, const poly g, poly *q, poly *r); 145 poly napRemainder(poly f, const poly g); 146 poly napInvers(poly x, const poly c); 147 int napMaxDeg(poly p); 148 int napMaxDegLen(poly p, int &l); 149 void napWrite(poly p,const BOOLEAN has_denom, const ring r); 150 int napExp(poly a, poly b); 151 int napExpi(int i, poly a, poly b); 152 void napContent(poly ph); 153 void napCleardenom(poly ph); 154 poly napGcd0(poly a, poly b); 155 poly napGcd(poly a, poly b); 156 number napLcm(poly a); 157 BOOLEAN napDivPoly (poly p, poly q); 158 poly napRedp (poly q); 159 poly napTailred (poly q); 160 poly napMap(poly p); 161 poly napPerm(poly p, const int *par_perm, const ring src_ring, 163 162 const nMapFunc nMap); 164 const char* napHandleMons(const char *s, int i, napoly ex);165 const char* napHandlePars(const char *s, int i, napoly ex);166 const char* napRead(const char *s, napoly *b);163 const char* napHandleMons(const char *s, int i, poly ex); 164 const char* napHandlePars(const char *s, int i, poly ex); 165 const char* napRead(const char *s, poly *b); 167 166 168 167 #endif
Note: See TracChangeset
for help on using the changeset viewer.