Changeset 2fce0e in git for libpolys/polys/linalg_from_matpol.cc
 Timestamp:
 Sep 9, 2011, 4:02:38 PM (12 years ago)
 Branches:
 (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
 Children:
 e48172b11af08005e2d025ff5a132809d88b6ea5
 Parents:
 9d5ba2ee7540ee4eb709cfef410629f44c00e75b
 gitauthor:
 Oleksandr Motsak <motsak@mathematik.unikl.de>20110909 16:02:38+02:00
 gitcommitter:
 Mohamed Barakat <mohamed.barakat@rwthaachen.de>20111109 16:12:39+01:00
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

libpolys/polys/linalg_from_matpol.cc
r9d5ba2 r2fce0e 167 167 } 168 168 } 169 170 171 /*172 /// entries of a are minors and go to result (only if not in R)173 void mp_MinorToResult(ideal result, int &elems, matrix a, int r, int c,174 ideal R, const ring R)175 {176 poly *q1;177 int e=IDELEMS(result);178 int i,j;179 180 if (R != NULL)181 {182 for (i=r1;i>=0;i)183 {184 q1 = &(a>m)[i*a>ncols];185 for (j=c1;j>=0;j)186 {187 if (q1[j]!=NULL) q1[j] = kNF(R,currQuotient,q1[j]);188 }189 }190 }191 for (i=r1;i>=0;i)192 {193 q1 = &(a>m)[i*a>ncols];194 for (j=c1;j>=0;j)195 {196 if (q1[j]!=NULL)197 {198 if (elems>=e)199 {200 if(e<SIZE_OF_SYSTEM_PAGE)201 {202 pEnlargeSet(&(result>m),e,e);203 e += e;204 }205 else206 {207 pEnlargeSet(&(result>m),e,SIZE_OF_SYSTEM_PAGE);208 e += SIZE_OF_SYSTEM_PAGE;209 }210 IDELEMS(result) =e;211 }212 result>m[elems] = q1[j];213 q1[j] = NULL;214 elems++;215 }216 }217 }218 }219 220 /// produces recursively the ideal of all arxarminors of a221 void mp_RecMin(int ar,ideal result,int &elems,matrix a,int lr,int lc,222 poly barDiv, ideal R, const ring R)223 {224 int k;225 int kr=lr1,kc=lc1;226 matrix nextLevel=mpNew(kr,kc);227 228 loop229 {230 //  look for an optimal row and bring it to last position 231 if(mpPrepareRow(a,lr,lc)==0) break;232 //  now take all pivots from the last row 233 k = lc;234 loop235 {236 if(mpPreparePiv(a,lr,k)==0) break;237 mpElimBar(a,nextLevel,barDiv,lr,k);238 k;239 if (ar>1)240 {241 mpRecMin(ar1,result,elems,nextLevel,kr,k,a>m[kr*a>ncols+k],R);242 mpPartClean(nextLevel,kr,k);243 }244 else mpMinorToResult(result,elems,nextLevel,kr,k,R);245 if (ar>k1) break;246 }247 if (ar>=kr) break;248 //  now we have to take out the last row...249 lr = kr;250 kr;251 }252 mpFinalClean(nextLevel);253 }254 */255 256 257 169 258 170 /* … … 322 234 /*2 323 235 *returns the determinant of the matrix m; 324 *uses Bareiss algorithm325 */326 poly mp_DetBareiss (matrix a, const ring R)327 {328 int s;329 poly div, res;330 if (MATROWS(a) != MATCOLS(a))331 {332 Werror("det of %d x %d matrix",MATROWS(a),MATCOLS(a));333 return NULL;334 }335 matrix c = mp_Copy(a, R);336 mp_permmatrix *Bareiss = new mp_permmatrix(c, R);337 row_col_weight w(Bareiss>mpGetRdim(), Bareiss>mpGetCdim());338 339 /* Bareiss */340 div = NULL;341 while(Bareiss>mpPivotBareiss(&w))342 {343 Bareiss>mpElimBareiss(div);344 div = Bareiss>mpGetElem(Bareiss>mpGetRdim(), Bareiss>mpGetCdim());345 }346 Bareiss>mpRowReorder();347 Bareiss>mpColReorder();348 Bareiss>mpSaveArray();349 s = Bareiss>mpGetSign();350 delete Bareiss;351 352 /* result */353 res = MATELEM(c,1,1);354 MATELEM(c,1,1) = NULL;355 id_Delete((ideal *)&c, R);356 if (s < 0)357 res = p_Neg(res, R);358 return res;359 }360 361 362 363 /*2364 *returns the determinant of the matrix m;365 236 *uses Newtons formulea for symmetric functions 366 237 */ … … 447 318 } 448 319 449 /*2450 * compute all arminors of the matrix a451 */452 matrix mp_Wedge(matrix a, int ar, const ring R)453 {454 int i,j,k,l;455 int *rowchoise,*colchoise;456 BOOLEAN rowch,colch;457 matrix result;458 matrix tmp;459 poly p;460 461 i = binom(a>nrows,ar);462 j = binom(a>ncols,ar);463 464 rowchoise=(int *)omAlloc(ar*sizeof(int));465 colchoise=(int *)omAlloc(ar*sizeof(int));466 result =mpNew(i,j);467 tmp=mpNew(ar,ar);468 l = 1; /* k,l:the index in result*/469 idInitChoise(ar,1,a>nrows,&rowch,rowchoise);470 while (!rowch)471 {472 k=1;473 idInitChoise(ar,1,a>ncols,&colch,colchoise);474 while (!colch)475 {476 for (i=1; i<=ar; i++)477 {478 for (j=1; j<=ar; j++)479 {480 MATELEM(tmp,i,j) = MATELEM(a,rowchoise[i1],colchoise[j1]);481 }482 }483 p = mp_DetBareiss(tmp, R);484 if ((k+l) & 1) p=p_Neg(p, R);485 MATELEM(result,l,k) = p;486 k++;487 idGetNextChoise(ar,a>ncols,&colch,colchoise);488 }489 idGetNextChoise(ar,a>nrows,&rowch,rowchoise);490 l++;491 }492 493 /*delete the matrix tmp*/494 for (i=1; i<=ar; i++)495 {496 for (j=1; j<=ar; j++) MATELEM(tmp,i,j) = NULL;497 }498 id_Delete((ideal *) &tmp, R);499 return (result);500 }501 320 502 321 ///*2
Note: See TracChangeset
for help on using the changeset viewer.