Changeset 43580ac in git
- Timestamp:
- Apr 14, 1998, 5:26:12 PM (25 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- fd0608510d11eb671d534d98bbfe452dfc598852
- Parents:
- b7c8bdcf3068d073e49fa3669429999b074c12d0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/ideals.cc
rb7c8bd r43580ac 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ideals.cc,v 1.2 0 1998-02-27 16:27:58Singular Exp $ */4 /* $Id: ideals.cc,v 1.21 1998-04-14 15:26:12 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT - all basic methods to manipulate ideals … … 149 149 j = 0; 150 150 else 151 { 151 { 152 152 for (k=j+1; k<IDELEMS(ide); k++) 153 153 ide->m[k] = NULL; … … 2152 2152 tmpR.wvhdl = wv; 2153 2153 rComplete(&tmpR); 2154 2154 2155 2155 // change into the new ring 2156 2156 pChangeRing(pVariables,currRing->OrdSgn,ord,block0,block1,wv); … … 2197 2197 } 2198 2198 2199 /*22200 * compute all ar-minors of the matrix a2201 */2202 ideal idMinors(matrix a, int ar)2203 {2204 if(ar<=0)2205 {2206 Werror("%d-th minor ",ar);2207 return NULL;2208 }2209 int i,j,k,size;2210 int *rowchoise,*colchoise;2211 BOOLEAN rowch,colch;2212 ideal result;2213 matrix tmp;2214 poly p;2215 2216 i = binom(a->rows(),ar);2217 j = binom(a->cols(),ar);2218 2219 rowchoise=(int *)Alloc(ar*sizeof(int));2220 colchoise=(int *)Alloc(ar*sizeof(int));2221 if ((i>512) || (j>512) || (i*j >512)) size=512;2222 else size=i*j;2223 result=idInit(size,1);2224 tmp=mpNew(ar,ar);2225 k = 0; /* the index in result*/2226 idInitChoise(ar,1,a->rows(),&rowch,rowchoise);2227 while (!rowch)2228 {2229 idInitChoise(ar,1,a->cols(),&colch,colchoise);2230 while (!colch)2231 {2232 for (i=1; i<=ar; i++)2233 {2234 for (j=1; j<=ar; j++)2235 {2236 MATELEM(tmp,i,j) = MATELEM(a,rowchoise[i-1],colchoise[j-1]);2237 }2238 }2239 p = mpDet(tmp);2240 if (p!=NULL)2241 {2242 if (k>=size)2243 {2244 pEnlargeSet(&result->m,size,32);2245 size += 32;2246 }2247 result->m[k] = p;2248 k++;2249 }2250 idGetNextChoise(ar,a->cols(),&colch,colchoise);2251 }2252 idGetNextChoise(ar,a->rows(),&rowch,rowchoise);2253 }2254 /*delete the matrix tmp*/2255 for (i=1; i<=ar; i++)2256 {2257 for (j=1; j<=ar; j++) MATELEM(tmp,i,j) = NULL;2258 }2259 idDelete((ideal*)&tmp);2260 if (k==0)2261 {2262 k=1;2263 result->m[0]=NULL;2264 }2265 Free((ADDRESS)rowchoise,ar*sizeof(int));2266 Free((ADDRESS)colchoise,ar*sizeof(int));2267 pEnlargeSet(&result->m,size,k-size);2268 IDELEMS(result) = k;2269 return (result);2270 }2271 2272 2199 /*3 2273 2200 * produces recursively the ideal of all arxar-minors of a 2274 2201 */ 2275 2202 static void idRecMin(matrix a,int ar,poly *barDiv,ideal result, 2276 int * nextPlace, int vec * pfRows, intvec * iv)2203 int * nextPlace, int rowToChose=0) 2277 2204 { 2278 2205 //Print("Level: %d\n",ar); … … 2284 2211 2285 2212 /*--- initializing temporary structures-------------------*/ 2286 int i,j,r ,c,newi,newp,k;2213 int i,j,r=rowToChose,c,newi,newp,k; 2287 2214 poly p=NULL,pp; 2288 BOOLEAN justChosen=FALSE;2289 2215 2290 2216 if (ar==0) … … 2304 2230 } 2305 2231 MATELEM(a,i,j) = NULL; 2306 //if ((*nextPlace==21) || (*nextPlace==37))2307 //{2308 // Print("Hier sind sie!\n");2309 //}2310 //pWrite(p);2311 2232 result->m[*nextPlace] = p; 2312 2233 (*nextPlace)++; … … 2314 2235 } 2315 2236 } 2237 idTest(result); 2316 2238 idDelete((ideal*)&a); 2317 2239 return; … … 2321 2243 pp = pCopy(p); //we had to store barDiv for the remaining loops 2322 2244 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(); 2245 //Print("next row is: %d, next col: %d\n",r,c); 2246 /*--- there is no pivot - the matrix is zero -------------*/ 2247 if (r*c==0) 2248 { 2249 idDelete((ideal*)&a); 2250 return; 2251 } 2345 2252 /*--- we read out the r-1 x c-1 matrix for the next step--*/ 2346 2253 if ((a->nrows-1)*(a->ncols-1)>0) … … 2357 2264 idDelete((ideal*)&nextStep); 2358 2265 /*--- we call the next Step------------------------------*/ 2359 idRecMin(next,ar-1,barDiv,result,nextPlace ,pfRows,iv);2266 idRecMin(next,ar-1,barDiv,result,nextPlace); 2360 2267 next = NULL; 2361 2268 } 2362 2269 /*--- 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)) 2270 if (((a->nrows)>1) && (rowToChose==0)) 2368 2271 { 2369 2272 nextStep = mpNew(a->nrows-1,a->ncols); … … 2383 2286 } 2384 2287 /*--- and to perform the algorithm with the rest---------*/ 2385 idRecMin(nextStep,ar,&p,result,nextPlace ,pfRows,iv);2288 idRecMin(nextStep,ar,&p,result,nextPlace); 2386 2289 nextStep = NULL; 2387 2290 } 2388 2291 /*--- 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 2292 if ((a->nrows)>1) 2393 2293 { … … 2409 2309 } 2410 2310 } 2311 /*--- and to perform the algorithm with the rest---------*/ 2411 2312 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); 2313 idRecMin(nextStep,ar,&p,result,nextPlace,r); 2415 2314 nextStep = NULL; 2416 2315 } 2417 2316 /*--- deleting temporary structures and returns----------*/ 2418 if (!justChosen) (*pfRows)[newp] = 0;2419 2317 pDelete(barDiv); 2420 2318 pDelete(&p); … … 2427 2325 * the caller of idRecMin 2428 2326 */ 2429 ideal idMinors 1(matrix a, int ar)2327 ideal idMinors(matrix a, int ar) 2430 2328 { 2431 2329 if((ar<=0) || (ar>min(a->ncols,a->nrows))) … … 2435 2333 } 2436 2334 int i=0; 2437 intvec * iv=new intvec(a->nrows+1);2438 intvec * pv=new intvec(a->nrows+1);2439 2335 poly barDiv=NULL; 2440 ideal result=idInit(16,0); 2441 2442 idRecMin(mpCopy(a),ar-1,&barDiv,result,&i,pv,iv); 2336 ideal result=idInit(16,1); 2337 idTest(result); 2338 2339 idRecMin(mpCopy(a),ar-1,&barDiv,result,&i); 2443 2340 idSkipZeroes(result); 2444 delete iv;2445 delete pv;2446 2341 return result; 2447 2342 } … … 3191 3086 return res; 3192 3087 } 3088
Note: See TracChangeset
for help on using the changeset viewer.