Changeset c616d1 in git
- Timestamp:
- Sep 30, 1998, 4:12:48 PM (25 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- d3e295ae509633cf6ba993a8680945f24b9ab5ec
- Parents:
- 8f14736613d731d65fa80a0322e2debe3dd2a3b0
- Location:
- Singular
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/ideals.cc
r8f1473 rc616d1 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ideals.cc,v 1.3 7 1998-09-29 21:14:43 siebertExp $ */4 /* $Id: ideals.cc,v 1.38 1998-09-30 14:12:47 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT - all basic methods to manipulate ideals … … 25 25 26 26 27 // #define WITH_OLD_MINOR 28 27 29 static poly * idpower; 28 30 /*collects the monomials in makemonoms, must be allocated befor*/ … … 37 39 * initialise an ideal 38 40 */ 39 #ifdef MDEBUG41 #ifdef PDEBUG 40 42 ideal idDBInit(int idsize, int rank, char *f, int l) 41 43 #else … … 44 46 { 45 47 /*- initialise an ideal -*/ 46 #if def MDEBUG48 #if defined(MDEBUG) && defined(PDEBUG) 47 49 ideal hh = (ideal )mmDBAllocBlock(sizeof(*hh),f,l); 48 50 #else … … 54 56 if (idsize>0) 55 57 { 56 #if def MDEBUG58 #if defined(MDEBUG) && defined(PDEBUG) 57 59 hh->m = (poly *)mmDBAllocBlock0(idsize*sizeof(poly),f,l); 58 60 #else … … 86 88 * deletes an ideal/matrix 87 89 */ 88 #ifdef MDEBUG90 #ifdef PDEBUG 89 91 void idDBDelete (ideal* h, char *f, int l) 90 92 #else … … 100 102 do 101 103 { 102 #ifdef MDEBUG104 #ifdef PDEBUG 103 105 pDBDelete(&((*h)->m[--j]),f,l); 104 106 #else … … 107 109 } 108 110 while (j>0); 109 #if def MDEBUG111 #if defined(MDEBUG) && defined(PDEBUG) 110 112 mmDBFreeBlock((ADDRESS)((*h)->m),sizeof(poly)*elems,f,l); 111 113 #else … … 113 115 #endif 114 116 } 115 #if def MDEBUG117 #if defined(MDEBUG) && defined(PDEBUG) 116 118 mmDBFreeBlock((ADDRESS)(*h),sizeof(**h),f,l); 117 119 #else … … 298 300 * copy an ideal 299 301 */ 300 #ifdef MDEBUG302 #ifdef PDEBUG 301 303 ideal idDBCopy(ideal h1,char *f,int l) 302 304 #else … … 310 312 if (h1 == NULL) 311 313 { 312 #ifdef MDEBUG314 #ifdef PDEBUG 313 315 h2=idDBInit(1,1,f,l); 314 316 #else … … 319 321 //#endif 320 322 { 321 #ifdef MDEBUG323 #ifdef PDEBUG 322 324 h2=idDBInit(IDELEMS(h1),h1->rank,f,l); 323 325 #else … … 325 327 #endif 326 328 for (i=IDELEMS(h1)-1; i>=0; i--) 327 #ifdef MDEBUG329 #ifdef PDEBUG 328 330 h2->m[i] = pDBCopy(h1->m[i],f,l); 329 331 #else … … 2268 2270 } 2269 2271 2272 //void idEnterSet (poly p,ideal r, int * next) 2273 //{ 2274 // 2275 // if ((*next) == IDELEMS(r)-1) 2276 // { 2277 // pEnlargeSet(&(r->m),IDELEMS(r),16); 2278 // IDELEMS(r)+=16; 2279 // } 2280 // int at; 2281 // int i; 2282 // if (*next==0) at=0; 2283 // else 2284 // { 2285 // int an = 0; 2286 // int en= *next-1; 2287 // int c; 2288 // if (pComp0(r->m[(*next)-1],p)!= 1) 2289 // at=*next; 2290 // else 2291 // { 2292 // loop 2293 // { 2294 // if (an >= en-1) 2295 // { 2296 // if (pComp0(r->m[an],p) == 1) 2297 // { 2298 // at=an; break; 2299 // } 2300 // else 2301 // { 2302 // at=en; break; 2303 // } 2304 // } 2305 // i=(an+en) / 2; 2306 // if (pComp0(r->m[i],p) == 1) en=i; 2307 // else an=i; 2308 // } 2309 // } 2310 // } 2311 // if (pComp(r->m[at],p)==0) 2312 // { 2313 // pDelete(&p); 2314 // } 2315 // else 2316 // { 2317 // (*next)++; 2318 // for (i=(*next); i>=at+1; i--) 2319 // { 2320 // r->m[i] = r->m[i-1]; 2321 // } 2322 // /*- save result -*/ 2323 // r->m[at] = p; 2324 // } 2325 //} 2270 2326 /*3 2271 2327 * produces recursively the ideal of all arxar-minors of a … … 2278 2334 if((ar<0) || (ar>min(a->ncols,a->nrows)-1)) 2279 2335 { 2336 idDelete((ideal *)&a); 2337 pDelete(barDiv); 2280 2338 return; 2281 2339 } … … 2283 2341 /*--- initializing temporary structures-------------------*/ 2284 2342 int i,j,r=rowToChose,c,newi,newp,k; 2285 poly p=NULL ,pp;2343 poly p=NULL; 2286 2344 2287 2345 if (ar==0) … … 2295 2353 if (p!=NULL) 2296 2354 { 2355 //idEnterSet(p,result,nextPlace); 2297 2356 if (*nextPlace>=IDELEMS(result)) 2298 2357 { 2299 pEnlargeSet(&(result->m),IDELEMS(result), 16);2300 IDELEMS(result) += 16;2358 pEnlargeSet(&(result->m),IDELEMS(result),IDELEMS(result)); 2359 IDELEMS(result) *=2; 2301 2360 } 2302 MATELEM(a,i,j) = NULL;2303 2361 result->m[*nextPlace] = p; 2304 2362 (*nextPlace)++; 2363 MATELEM(a,i,j) = NULL; 2305 2364 } 2306 2365 } … … 2308 2367 idTest(result); 2309 2368 idDelete((ideal*)&a); 2369 pDelete(barDiv); 2310 2370 return; 2311 2371 } 2312 2372 /*--- ar>0, we perform one step of the Bareiss algorithm--*/ 2313 2373 p = pCopy(*barDiv); //we had to store barDiv for the remaining loops 2314 pp = pCopy(p); //we had to store barDiv for the remaining loops2315 2374 matrix nextStep = mpOneStepBareiss(a,barDiv,&r,&c); 2316 2375 //Print("next row is: %d, next col: %d\n",r,c); 2317 /*--- there is no pivot - the matrix is zero -------------*/2376 /*--- there is no pivot - the det of matrix is zero -------------*/ 2318 2377 if ((r*c==0) || (MATELEM(nextStep,nextStep->nrows,nextStep->ncols)==NULL)) 2319 2378 { 2379 idDelete((ideal*)&nextStep); 2320 2380 idDelete((ideal*)&a); 2321 idDelete((ideal*)&nextStep); 2381 pDelete(&p); 2382 // pDelete(barDiv); barDiv==NULL in this case 2322 2383 return; 2323 2384 } … … 2339 2400 next = NULL; 2340 2401 } 2402 if ((*barDiv)!=NULL) pDelete(barDiv); 2341 2403 /*--- now we have to take out the r-th row...------------*/ 2342 2404 if (((a->nrows)>1) && (rowToChose==0)) 2343 2405 { 2406 if (nextStep!=NULL) idDelete((ideal*)&nextStep); 2344 2407 nextStep = mpNew(a->nrows-1,a->ncols); 2345 2408 for (i=r-1;i>0;i--) … … 2358 2421 } 2359 2422 /*--- and to perform the algorithm with the rest---------*/ 2360 idRecMin(nextStep,ar,&p,result,nextPlace); 2423 poly q=pCopy(p); 2424 idRecMin(nextStep,ar,&q,result,nextPlace); 2425 assume(q==NULL); 2361 2426 nextStep = NULL; 2362 2427 } … … 2364 2429 if ((a->nrows)>1) 2365 2430 { 2431 if (nextStep!=NULL) idDelete((ideal*)&nextStep); 2366 2432 nextStep = mpNew(a->nrows,a->ncols-1); 2367 2433 for (i=a->nrows;i>0;i--) … … 2384 2450 idDelete((ideal*)&a); 2385 2451 idRecMin(nextStep,ar,&p,result,nextPlace,r); 2452 //assume(p==NULL); 2386 2453 nextStep = NULL; 2387 2454 } 2388 2455 /*--- deleting temporary structures and returns----------*/ 2389 pDelete(barDiv);2390 2456 pDelete(&p); 2391 pDelete(&pp);2392 2457 return; 2393 2458 } 2394 2459 2460 #ifdef WITH_OLD_MINOR 2461 /*2 2462 * compute all ar-minors of the matrix a 2463 */ 2464 ideal idMinors(matrix a, int ar) 2465 { 2466 int i,j,k,size; 2467 int *rowchoise,*colchoise; 2468 BOOLEAN rowch,colch; 2469 ideal result; 2470 matrix tmp; 2471 poly p; 2472 2473 i = binom(a->rows(),ar); 2474 j = binom(a->cols(),ar); 2475 2476 rowchoise=(int *)Alloc(ar*sizeof(int)); 2477 colchoise=(int *)Alloc(ar*sizeof(int)); 2478 if ((i>512) || (j>512) || (i*j >512)) size=512; 2479 else size=i*j; 2480 result=idInit(size,1); 2481 tmp=mpNew(ar,ar); 2482 k = 0; /* the index in result*/ 2483 idInitChoise(ar,1,a->rows(),&rowch,rowchoise); 2484 while (!rowch) 2485 { 2486 idInitChoise(ar,1,a->cols(),&colch,colchoise); 2487 while (!colch) 2488 { 2489 for (i=1; i<=ar; i++) 2490 { 2491 for (j=1; j<=ar; j++) 2492 { 2493 MATELEM(tmp,i,j) = MATELEM(a,rowchoise[i-1],colchoise[j-1]); 2494 } 2495 } 2496 p = mpDetBareiss(tmp); 2497 if (p!=NULL) 2498 { 2499 if (k>=size) 2500 { 2501 pEnlargeSet(&result->m,size,32); 2502 size += 32; 2503 } 2504 result->m[k] = p; 2505 k++; 2506 } 2507 idGetNextChoise(ar,a->cols(),&colch,colchoise); 2508 } 2509 idGetNextChoise(ar,a->rows(),&rowch,rowchoise); 2510 } 2511 /*delete the matrix tmp*/ 2512 for (i=1; i<=ar; i++) 2513 { 2514 for (j=1; j<=ar; j++) MATELEM(tmp,i,j) = NULL; 2515 } 2516 idDelete((ideal*)&tmp); 2517 if (k==0) 2518 { 2519 k=1; 2520 result->m[0]=NULL; 2521 } 2522 Free((ADDRESS)rowchoise,ar*sizeof(int)); 2523 Free((ADDRESS)colchoise,ar*sizeof(int)); 2524 pEnlargeSet(&result->m,size,k-size); 2525 IDELEMS(result) = k; 2526 return (result); 2527 } 2528 #else 2395 2529 /*2 2396 2530 * compute all ar-minors of the matrix a … … 2407 2541 poly barDiv=NULL; 2408 2542 ideal result=idInit(16,1); 2409 2410 idRecMin(mpCopy(a),ar-1,&barDiv,result,&i); 2543 if (a->ncols>=a->nrows) 2544 { 2545 idRecMin(mpCopy(a),ar-1,&barDiv,result,&i); 2546 } 2547 else 2548 { 2549 idRecMin(mpTransp(a),ar-1,&barDiv,result,&i); 2550 } 2411 2551 idSkipZeroes(result); 2412 2552 return result; 2413 2553 } 2554 #endif 2555 2414 2556 2415 2557 /*2 -
Singular/matpol.cc
r8f1473 rc616d1 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: matpol.cc,v 1. 19 1998-09-29 21:14:45 siebertExp $ */4 /* $Id: matpol.cc,v 1.20 1998-09-30 14:12:48 Singular Exp $ */ 5 5 6 6 /* … … 91 91 t = a->m[i]; 92 92 pNormalize(t); 93 #ifdef MDEBUG94 // b->m[i] = pDBCopy(t,f,l);95 93 b->m[i] = pCopy(t); 96 #else97 b->m[i] = pCopy(t);98 #endif99 94 } 100 95 b->rank=a->rank; … … 392 387 393 388 /* step of Bareiss */ 394 if(( row&& Bareiss->mpPivotRow(&w,row-1)) || Bareiss->mpPivotBareiss(&w))389 if(((row!=0) && Bareiss->mpPivotRow(&w,row-1)) || Bareiss->mpPivotBareiss(&w)) 395 390 { 396 391 Bareiss->mpElimBareiss(div); … … 580 575 } 581 576 } 582 p = mpDet (tmp);577 p = mpDetBareiss(tmp); 583 578 if ((k+l) & 1) p=pNeg(p); 584 579 MATELEM(result,l,k) = p; … … 1413 1408 } 1414 1409 y = nDiv(pGetCoeff(r),x); 1410 nNormalize(y); 1415 1411 pSetCoeff(r,y); 1416 1412 pIter(r);
Note: See TracChangeset
for help on using the changeset viewer.