Changeset 2f5547 in git for libpolys/polys/simpleideals.cc
 Timestamp:
 Apr 14, 2011, 7:02:41 PM (12 years ago)
 Branches:
 (u'spielwiese', '91fdef05f09f54b8d58d92a472e9c4a43aa4656f')
 Children:
 a2d9930b40d71c14be3fcc86d7741866ea06a6df
 Parents:
 a665ebdc0e6f023769cadc08a35bd0eb3f3ad935
 gitauthor:
 Hans Schoenemann <hannes@mathematik.unikl.de>20110414 19:02:41+02:00
 gitcommitter:
 Mohamed Barakat <mohamed.barakat@rwthaachen.de>20111109 12:30:33+01:00
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

libpolys/polys/simpleideals.cc
ra665eb r2f5547 16 16 #include <misc/intvec.h> 17 17 #include <polys/simpleideals.h> 18 19 static poly * idpower; 20 /*collects the monomials in makemonoms, must be allocated befor*/ 21 static int idpowerpoint; 22 /*index of the actual monomial in idpower*/ 23 static poly * givenideal; 24 /*the ideal from which a power is computed*/ 18 25 19 26 /*2 … … 714 721 * return the maximal component number found in any polynomial in s 715 722 */ 716 long id RankFreeModule (ideal s, ring lmRing, ring tailRing)723 long id_RankFreeModule (ideal s, ring lmRing, ring tailRing) 717 724 { 718 725 if (s!=NULL) … … 808 815 } 809 816 810 /*3811 *multiplies p with t (!cas) or (t1)812 *the index of t is:1, so we have to shift all variables813 *p is NOT in the actual ring, it has no t814 */815 static poly p_MultWithT (poly p,BOOLEAN cas, const ring r)816 {817 /*qp is the working pointer in p*/818 /*result is the result, qresult is the working pointer*/819 /*pp is p in the actual ring(shifted), qpp the working pointer*/820 poly result,qp,pp;821 poly qresult=NULL;822 poly qpp=NULL;823 int i,j,lex;824 number n;825 826 pp = NULL;827 result = NULL;828 qp = p;829 while (qp != NULL)830 {831 i = 0;832 if (result == NULL)833 {/*first monomial*/834 result = p_Init(r);835 qresult = result;836 }837 else838 {839 qresult>next = p_Init(r);840 pIter(qresult);841 }842 for (j=rVar(r)1; j>0; j)843 {844 lex = p_GetExp(qp,j,r);845 p_SetExp(qresult,j+1,lex,r);/*copy all variables*/846 }847 lex = p_GetComp(qp,r);848 p_SetComp(qresult,lex,r);849 n=n_Copy(pGetCoeff(qp),r>cf);850 pSetCoeff0(qresult,n);851 qresult>next = NULL;852 p_Setm(qresult,r);853 /*qresult is now qp brought into the actual ring*/854 if (cas)855 { /*case: mult with t1*/856 p_SetExp(qresult,1,0,r);857 p_Setm(qresult,r);858 if (pp == NULL)859 { /*first monomial*/860 pp = p_Copy(qresult,r);861 qpp = pp;862 }863 else864 {865 qpp>next = p_Copy(qresult,r);866 pIter(qpp);867 }868 pGetCoeff(qpp)=n_Neg(pGetCoeff(qpp),r>cf);869 /*now qpp contains 1*qp*/870 }871 p_SetExp(qresult,1,1,r);/*this is mult. by t*/872 p_Setm(qresult,r);873 pIter(qp);874 }875 /*876 *now p is processed:877 *result contains t*p878 * if cas: pp contains 1*p (in the new ring)879 */880 if (cas) qresult>next = pp;881 /* else qresult>next = NULL;*/882 return result;883 }884 885 /*2886 * verschiebt die Indizees der Modulerzeugenden um i887 */888 void pShift (poly * p,int i)889 {890 poly qp1 = *p,qp2 = *p;/*working pointers*/891 int j = pMaxComp(*p),k = pMinComp(*p);892 893 if (j+i < 0) return ;894 while (qp1 != NULL)895 {896 if ((pGetComp(qp1)+i > 0)  ((j == i) && (j == k)))897 {898 pAddComp(qp1,i);899 pSetmComp(qp1);900 qp2 = qp1;901 pIter(qp1);902 }903 else904 {905 if (qp2 == *p)906 {907 pIter(*p);908 pLmDelete(&qp2);909 qp2 = *p;910 qp1 = *p;911 }912 else913 {914 qp2>next = qp1>next;915 if (qp1!=NULL) pLmDelete(&qp1);916 qp1 = qp2>next;917 }918 }919 }920 }921 922 817 /*2 923 818 *initialized a field with r numbers between beg and end for the … … 1027 922 *the free module of rank i 1028 923 */ 1029 ideal id FreeModule (int i)924 ideal id_FreeModule (int i, const ring r) 1030 925 { 1031 926 int j; … … 1036 931 { 1037 932 h>m[j] = p_One(r); 1038 p SetComp(h>m[j],j+1);1039 p SetmComp(h>m[j]);933 p_SetComp(h>m[j],j+1,r); 934 p_SetmComp(h>m[j],r); 1040 935 } 1041 936 return h; 1042 }1043 1044 ideal idSectWithElim (ideal h1,ideal h2)1045 // does not destroy h1,h21046 {1047 if (TEST_OPT_PROT) PrintS("intersect by elimination method\n");1048 assume(!idIs0(h1));1049 assume(!idIs0(h2));1050 assume(IDELEMS(h1)<=IDELEMS(h2));1051 assume(idRankFreeModule(h1)==0);1052 assume(idRankFreeModule(h2)==0);1053 // add a new variable:1054 int j;1055 ring origRing=currRing;1056 ring r=rCopy0(origRing);1057 r>N++;1058 r>block0[0]=1;1059 r>block1[0]= r>N;1060 omFree(r>order);1061 r>order=(int*)omAlloc0(3*sizeof(int*));1062 r>order[0]=ringorder_dp;1063 r>order[1]=ringorder_C;1064 char **names=(char**)omAlloc0(rVar(r) * sizeof(char_ptr));1065 for (j=0;j<r>N1;j++) names[j]=r>names[j];1066 names[r>N1]=omStrDup("@");1067 omFree(r>names);1068 r>names=names;1069 rComplete(r,TRUE);1070 // fetch h1, h21071 ideal h;1072 h1=idrCopyR(h1,origRing,r);1073 h2=idrCopyR(h2,origRing,r);1074 // switch to temp. ring r1075 rChangeCurrRing(r);1076 // create 1t, t1077 poly omt=p_One(r);1078 pSetExp(omt,r>N,1);1079 poly t=pCopy(omt);1080 pSetm(omt);1081 omt=pNeg(omt);1082 omt=pAdd(omt,p_One(r));1083 // compute (1t)*h11084 h1=(ideal)mpMultP((matrix)h1,omt);1085 // compute t*h21086 h2=(ideal)mpMultP((matrix)h2,pCopy(t));1087 // (1t)h1 + t*h21088 h=idInit(IDELEMS(h1)+IDELEMS(h2),1);1089 int l;1090 for (l=IDELEMS(h1)1; l>=0; l)1091 {1092 h>m[l] = h1>m[l]; h1>m[l]=NULL;1093 }1094 j=IDELEMS(h1);1095 for (l=IDELEMS(h2)1; l>=0; l)1096 {1097 h>m[l+j] = h2>m[l]; h2>m[l]=NULL;1098 }1099 idDelete(&h1);1100 idDelete(&h2);1101 // eliminate t:1102 1103 ideal res=idElimination(h,t);1104 // cleanup1105 idDelete(&h);1106 res=idrMoveR(res,r,origRing);1107 rChangeCurrRing(origRing);1108 rKill(r);1109 return res;1110 937 } 1111 938 … … 1122 949 *monomdeg is the actual degree of the monomial in consideration 1123 950 */ 1124 static void makemonoms(int vars,int actvar,int deg,int monomdeg )951 static void makemonoms(int vars,int actvar,int deg,int monomdeg, const ring r) 1125 952 { 1126 953 poly p; … … 1136 963 if (deg == monomdeg) 1137 964 { 1138 p Setm(idpower[idpowerpoint]);965 p_Setm(idpower[idpowerpoint],r); 1139 966 idpowerpoint++; 1140 967 return; … … 1142 969 if (actvar == vars) 1143 970 { 1144 p SetExp(idpower[idpowerpoint],actvar,degmonomdeg);1145 p Setm(idpower[idpowerpoint]);1146 p Test(idpower[idpowerpoint]);971 p_SetExp(idpower[idpowerpoint],actvar,degmonomdeg,r); 972 p_Setm(idpower[idpowerpoint],r); 973 p_Test(idpower[idpowerpoint],r); 1147 974 idpowerpoint++; 1148 975 return; … … 1150 977 else 1151 978 { 1152 p = p Copy(idpower[idpowerpoint]);1153 makemonoms(vars,actvar+1,deg,monomdeg );979 p = p_Copy(idpower[idpowerpoint],r); 980 makemonoms(vars,actvar+1,deg,monomdeg,r); 1154 981 idpower[idpowerpoint] = p; 1155 982 } 1156 983 monomdeg++; 1157 p SetExp(idpower[idpowerpoint],actvar,pGetExp(idpower[idpowerpoint],actvar)+1);1158 p Setm(idpower[idpowerpoint]);1159 p Test(idpower[idpowerpoint]);984 p_SetExp(idpower[idpowerpoint],actvar,p_GetExp(idpower[idpowerpoint],actvar,r)+1,r); 985 p_Setm(idpower[idpowerpoint],r); 986 p_Test(idpower[idpowerpoint],r); 1160 987 i++; 1161 988 } … … 1179 1006 if (deg == 1) 1180 1007 { 1181 return id MaxIdeal(r);1008 return id_MaxIdeal(r); 1182 1009 } 1183 1010 … … 1188 1015 idpower = id>m; 1189 1016 idpowerpoint = 0; 1190 makemonoms(vars,1,deg,0 );1017 makemonoms(vars,1,deg,0,r); 1191 1018 idpower = NULL; 1192 1019 idpowerpoint = 0; … … 1202 1029 *gendeg is the actual degree of the generator in consideration 1203 1030 */ 1204 static void makepotence(int elms,int actelm,int deg,int gendeg )1031 static void makepotence(int elms,int actelm,int deg,int gendeg, const ring r) 1205 1032 { 1206 1033 poly p; … … 1221 1048 if (actelm == elms) 1222 1049 { 1223 p=p Power(pCopy(givenideal[actelm1]),deggendeg);1224 idpower[idpowerpoint]=p Mult(idpower[idpowerpoint],p);1050 p=p_Power(p_Copy(givenideal[actelm1],r),deggendeg,r); 1051 idpower[idpowerpoint]=p_Mult_q(idpower[idpowerpoint],p,r); 1225 1052 idpowerpoint++; 1226 1053 return; … … 1228 1055 else 1229 1056 { 1230 p = p Copy(idpower[idpowerpoint]);1231 makepotence(elms,actelm+1,deg,gendeg );1057 p = p_Copy(idpower[idpowerpoint],r); 1058 makepotence(elms,actelm+1,deg,gendeg,r); 1232 1059 idpower[idpowerpoint] = p; 1233 1060 } 1234 1061 gendeg++; 1235 idpower[idpowerpoint]=p Mult(idpower[idpowerpoint],pCopy(givenideal[actelm1]));1062 idpower[idpowerpoint]=p_Mult_q(idpower[idpowerpoint],p_Copy(givenideal[actelm1],r),r); 1236 1063 i++; 1237 1064 }
Note: See TracChangeset
for help on using the changeset viewer.