Changeset d353551 in git
- Timestamp:
- Feb 18, 1998, 12:38:26 PM (26 years ago)
- Branches:
- (u'spielwiese', 'ec94ef7a30b928574c0c3daf41f6804dff5f6b69')
- Children:
- 5ae93aa2a4a8bf691b76d100c0f7289317d4dc57
- Parents:
- a28e0e917128c027c3071c68affbca085dcb3bd9
- Location:
- Singular
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/ideals.cc
ra28e0e9 rd353551 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ideals.cc,v 1.1 6 1998-01-12 18:59:47 obachmanExp $ */4 /* $Id: ideals.cc,v 1.17 1998-02-18 11:38:26 siebert Exp $ */ 5 5 /* 6 6 * ABSTRACT - all basic methods to manipulate ideals … … 2270 2270 } 2271 2271 2272 /*3 2273 * produces recursively the ideal of all arxar-minors of a 2274 */ 2275 static void idRecMin(matrix a,int ar,poly *barDiv,ideal result, 2276 int * nextPlace, intvec * pfRows, intvec * iv) 2277 { 2278 Print("Level: %d\n",ar); 2279 /*--- there is no non-zero minor coming from a------------*/ 2280 if((ar<0) || (ar>min(a->ncols,a->nrows)-1)) 2281 { 2282 return; 2283 } 2284 2285 /*--- initializing temporary structures-------------------*/ 2286 int i,j,r,c,newi,newp,k; 2287 poly p=NULL,pp; 2288 BOOLEAN justChosen=FALSE; 2289 2290 if (ar==0) 2291 { 2292 /*--- ar is 0, the matrix-entres are minors---------------*/ 2293 for (i=a->nrows;i>0;i--) 2294 { 2295 for (j=a->ncols;j>0;j--) 2296 { 2297 p = MATELEM(a,i,j); 2298 if (p!=NULL) 2299 { 2300 if (*nextPlace>=IDELEMS(result)) 2301 { 2302 pEnlargeSet(&(result->m),IDELEMS(result),16); 2303 IDELEMS(result) += 16; 2304 } 2305 MATELEM(a,i,j) = NULL; 2306 if ((*nextPlace==21) || (*nextPlace==37)) 2307 { 2308 Print("Hier sind sie!\n"); 2309 } 2310 pWrite(p); 2311 result->m[*nextPlace] = p; 2312 (*nextPlace)++; 2313 } 2314 } 2315 } 2316 idDelete((ideal*)&a); 2317 return; 2318 } 2319 /*--- ar>0, we perform one step of the Bareiss algorithm--*/ 2320 p = pCopy(*barDiv); //we had to store barDiv for the remaining loops 2321 pp = pCopy(p); //we had to store barDiv for the remaining loops 2322 matrix nextStep = mpOneStepBareiss(a,barDiv,&r,&c); 2323 /*--- we compute the row-index of the chosen row r -------*/ 2324 newi = 0; 2325 while ((newi<iv->length()) && ((*iv)[newi]!=0)) newi++; 2326 k = (*iv)[newi] = r; 2327 for (j=newi-1;j>0;j--) 2328 { 2329 if (k>=(*iv)[j]) k++; 2330 } 2331 newp = 0; 2332 while ((newp<pfRows->length()) && ((*pfRows)[newp]!=0)) 2333 { 2334 if ((*pfRows)[newp]==k) 2335 { 2336 justChosen = TRUE; 2337 Print("just chosen\n"); 2338 break; 2339 } 2340 newp++; 2341 } 2342 if (!justChosen) (*pfRows)[newp] = k; 2343 Print("Chosen: ");pfRows->show();PrintLn(); 2344 Print("Deleted: ");iv->show();PrintLn(); 2345 /*--- we read out the r-1 x c-1 matrix for the next step--*/ 2346 if ((a->nrows-1)*(a->ncols-1)>0) 2347 { 2348 matrix next = mpNew(a->nrows-1,a->ncols-1); 2349 for (i=a->nrows-1;i>0;i--) 2350 { 2351 for (j=a->ncols-1;j>0;j--) 2352 { 2353 MATELEM(next,i,j) = MATELEM(nextStep,i,j); 2354 MATELEM(nextStep,i,j) =NULL; 2355 } 2356 } 2357 idDelete((ideal*)&nextStep); 2358 /*--- we call the next Step------------------------------*/ 2359 idRecMin(next,ar-1,barDiv,result,nextPlace,pfRows,iv); 2360 next = NULL; 2361 } 2362 /*--- now we have to take out the r-th row...------------*/ 2363 Print("back for rows on Level: %d\n",ar); 2364 Print("The actual row was %d\n",k); 2365 Print("Chosen: ");pfRows->show();PrintLn(); 2366 Print("Deleted: ");iv->show();PrintLn(); 2367 if (((a->nrows)>1) && (!justChosen)) 2368 { 2369 nextStep = mpNew(a->nrows-1,a->ncols); 2370 for (i=r-1;i>0;i--) 2371 { 2372 for (j=a->ncols;j>0;j--) 2373 { 2374 MATELEM(nextStep,i,j) = pCopy(MATELEM(a,i,j)); 2375 } 2376 } 2377 for (i=a->nrows;i>r;i--) 2378 { 2379 for (j=a->ncols;j>0;j--) 2380 { 2381 MATELEM(nextStep,i-1,j) = pCopy(MATELEM(a,i,j)); 2382 } 2383 } 2384 /*--- and to perform the algorithm with the rest---------*/ 2385 idRecMin(nextStep,ar,&p,result,nextPlace,pfRows,iv); 2386 nextStep = NULL; 2387 } 2388 /*--- now we have to take out the c-th col...------------*/ 2389 Print("back for cols on Level: %d\n",ar); 2390 Print("Chosen: ");pfRows->show();PrintLn(); 2391 Print("Deleted: ");iv->show();PrintLn(); 2392 if ((a->nrows)>1) 2393 { 2394 nextStep = mpNew(a->nrows,a->ncols-1); 2395 for (i=a->nrows;i>0;i--) 2396 { 2397 for (j=c-1;j>0;j--) 2398 { 2399 MATELEM(nextStep,i,j) = MATELEM(a,i,j); 2400 MATELEM(a,i,j) = NULL; 2401 } 2402 } 2403 for (i=a->nrows;i>0;i--) 2404 { 2405 for (j=a->ncols;j>c;j--) 2406 { 2407 MATELEM(nextStep,i,j-1) = MATELEM(a,i,j); 2408 MATELEM(a,i,j) = NULL; 2409 } 2410 } 2411 idDelete((ideal*)&a); 2412 /*--- and to perform the algorithm with the rest---------*/ 2413 (*iv)[newi] = 0; 2414 idRecMin(nextStep,ar,&p,result,nextPlace,pfRows,iv); 2415 nextStep = NULL; 2416 } 2417 /*--- deleting temporary structures and returns----------*/ 2418 if (!justChosen) (*pfRows)[newp] = 0; 2419 pDelete(barDiv); 2420 pDelete(&p); 2421 pDelete(&pp); 2422 return; 2423 } 2424 2425 /*2 2426 * compute all ar-minors of the matrix a 2427 * the caller of idRecMin 2428 */ 2429 ideal idMinors1(matrix a, int ar) 2430 { 2431 if((ar<=0) || (ar>min(a->ncols,a->nrows))) 2432 { 2433 Werror("%d-th minor ",ar); 2434 return NULL; 2435 } 2436 int i=0; 2437 intvec * iv=new intvec(a->nrows+1); 2438 intvec * pv=new intvec(a->nrows+1); 2439 poly barDiv=NULL; 2440 ideal result=idInit(16,0); 2441 2442 idRecMin(mpCopy(a),ar-1,&barDiv,result,&i,pv,iv); 2443 idSkipZeroes(result); 2444 delete iv; 2445 delete pv; 2446 return result; 2447 } 2448 2272 2449 /*2 2273 2450 *returns TRUE if p is a unit element in the current ring -
Singular/matpol.cc
ra28e0e9 rd353551 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: matpol.cc,v 1. 8 1998-01-12 17:32:48 SingularExp $ */4 /* $Id: matpol.cc,v 1.9 1998-02-18 11:35:31 siebert Exp $ */ 5 5 6 6 /* … … 331 331 void mpElimBareiss(poly); 332 332 int mpPivotBareiss(row_col_weight *); 333 int mpPivotRow(row_col_weight *, int); 333 334 void mpToIntvec(intvec *); 334 335 void mpRowReorder(); … … 388 389 mp_permmatrix *Bareiss = new mp_permmatrix(re); 389 390 row_col_weight w(Bareiss->mpGetRdim(), Bareiss->mpGetCdim()); 391 int row = *r; 390 392 391 393 /* step of Bareiss */ 392 if( Bareiss->mpPivotBareiss(&w))394 if((row && Bareiss->mpPivotRow(&w,row-1)) || Bareiss->mpPivotBareiss(&w)) 393 395 { 394 396 Bareiss->mpElimBareiss(div); … … 1112 1114 } 1113 1115 1116 /*2 1117 * pivot strategy for Bareiss algorithm with defined row 1118 */ 1119 int mp_permmatrix::mpPivotRow(row_col_weight *C, int row) 1120 { 1121 poly p, *a; 1122 int j, iopt, jopt; 1123 float sum, f1, f2, fo, r, ro, lp; 1124 float *dr = C->wrow, *dc = C->wcol; 1125 1126 fo = 1.0e20; 1127 ro = 0.0; 1128 iopt = jopt = -1; 1129 1130 s_n--; 1131 s_m--; 1132 if (s_m == 0) 1133 return 0; 1134 if (s_n == 0) 1135 { 1136 p = this->mpRowAdr(row)[qcol[0]]; 1137 if (p) 1138 { 1139 f1 = mpPolyWeight(p); 1140 if (f1 < fo) 1141 { 1142 fo = f1; 1143 if (iopt >= 0) 1144 pDelete(&(this->mpRowAdr(iopt)[qcol[0]])); 1145 iopt = row; 1146 } 1147 else 1148 pDelete(&(this->mpRowAdr(row)[qcol[0]])); 1149 } 1150 if (iopt >= 0) 1151 mpReplace(iopt, s_m, sign, qrow); 1152 return 0; 1153 } 1154 this->mpRowWeight(dr); 1155 this->mpColWeight(dc); 1156 sum = 0.0; 1157 for(j=s_m; j>=0; j--) 1158 sum += dr[j]; 1159 r = dr[row]; 1160 a = this->mpRowAdr(row); 1161 for(j=s_n; j>=0; j--) 1162 { 1163 p = a[qcol[j]]; 1164 if (p) 1165 { 1166 lp = mpPolyWeight(p); 1167 ro = r - lp; 1168 f1 = ro * (dc[j]-lp); 1169 if (f1 != 0.0) 1170 { 1171 f2 = lp * (sum - ro - dc[j]); 1172 f2 += f1; 1173 } 1174 else 1175 f2 = lp-r-dc[j]; 1176 if (f2 < fo) 1177 { 1178 fo = f2; 1179 iopt = row; 1180 jopt = j; 1181 } 1182 } 1183 } 1184 if (iopt < 0) 1185 return 0; 1186 mpReplace(iopt, s_m, sign, qrow); 1187 mpReplace(jopt, s_n, sign, qcol); 1188 return 1; 1189 } 1190 1114 1191 void mp_permmatrix::mpToIntvec(intvec *v) 1115 1192 {
Note: See TracChangeset
for help on using the changeset viewer.