Changeset 60763e in git
- Timestamp:
- Jun 10, 1999, 11:01:17 AM (24 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- dfd346fefacb74ceabb45bd6bcb026bc23d9acf0
- Parents:
- 28f2d302b56d434cf41693253b775ee4d0d1703d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/sparsmat.cc
r28f2d3 r60763e 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: sparsmat.cc,v 1. 7 1999-06-04 13:06:28pohl Exp $ */4 /* $Id: sparsmat.cc,v 1.8 1999-06-10 09:01:17 pohl Exp $ */ 5 5 6 6 /* … … 44 44 45 45 /* declare internal 'C' stuff */ 46 static void smDebug() { int k=0; }47 46 static void smExactPolyDiv(poly, poly); 48 47 static BOOLEAN smIsScalar(const poly); … … 88 87 int crd; // number of reduced columns (start: 0) 89 88 int tored; // border for rows to reduce 89 int inred; // unreducable part 90 90 int rpiv, cpiv; // position of the pivot 91 91 unsigned short *perm;// permutation of rows … … 308 308 } 309 309 sign = 1; 310 act = ncols;310 inred = act = ncols; 311 311 crd = 0; 312 312 tored = nrows; // without border … … 463 463 if (act < y) 464 464 { 465 if (act != 0) 466 { 467 this->smCopToRes(); 468 } 465 this->smCopToRes(); 469 466 return; 470 467 } … … 499 496 if (act < y) 500 497 { 501 if (act != 0) 502 { 503 this->smCopToRes(); 504 } 505 else 506 tored = crd; 498 this->smCopToRes(); 507 499 return; 508 500 } … … 525 517 if (act < y) 526 518 { 527 if (act != 0) 528 { 529 this->smCopToRes(); 530 } 519 this->smCopToRes(); 531 520 return; 532 521 } … … 562 551 if (act < y) 563 552 { 564 if (act != 0) 565 { 566 this->smFinalMult(); 567 this->smCopToRes(); 568 } 569 else 570 tored = crd; 553 this->smFinalMult(); 554 this->smCopToRes(); 571 555 return; 572 556 } … … 1257 1241 if (m_act[i]->pos > tored) 1258 1242 { 1259 m_res[ crd] = m_act[i];1260 crd++;1243 m_res[inred] = m_act[i]; 1244 inred--; 1261 1245 break; 1262 1246 } … … 1269 1253 if (m_act[i]->pos > tored) 1270 1254 { 1271 m_res[ crd] = m_act[i];1272 crd++;1255 m_res[inred] = m_act[i]; 1256 inred--; 1273 1257 } 1274 1258 else … … 1287 1271 void sparse_mat::smCopToRes() 1288 1272 { 1289 smpoly p, r, ap, a, h; 1290 int c, i; 1291 1292 if (act == 0) return; 1293 if (act > 1) 1294 { 1295 Werror("Not implemented"); 1296 } 1297 crd++; 1298 c = crd; 1299 p = m_res[c] = m_act[act]; 1300 do 1301 { 1302 r = m_row[p->pos]; 1303 m_row[p->pos] = NULL; 1304 perm[c] = p->pos; 1305 p->pos = c; 1306 while (r != NULL) 1307 { 1308 ap = m_res[r->pos]; 1273 smpoly a,ap,r,h; 1274 int i,j,k,l; 1275 1276 i = 0; 1277 if (act) 1278 { 1279 a = m_act[act]; // init perm 1280 do 1281 { 1282 i++; 1283 perm[crd+i] = a->pos; 1284 a = a->n; 1285 } while (a != NULL); 1286 for (j=act-1;j;j--) // load all positions of perm 1287 { 1288 a = m_act[j]; 1289 k = 1; 1309 1290 loop 1310 1291 { 1311 a = ap->n; 1312 if (a == NULL) 1313 { 1314 ap->n = h = r; 1315 r = r->n; 1316 h->n = a; 1317 h->pos = c; 1292 if (perm[crd+k] >= a->pos) 1293 { 1294 if (perm[crd+k] > a->pos) 1295 { 1296 for (l=i;l>=k;l--) perm[crd+l+1] = perm[crd+l]; 1297 perm[crd+k] = a->pos; 1298 i++; 1299 } 1300 a = a->n; 1301 if (a == NULL) break; 1302 } 1303 k++; 1304 if (k > i) 1305 { 1306 do 1307 { 1308 i++; 1309 perm[crd+i] = a->pos; 1310 a = a->n; 1311 } while (a != NULL); 1318 1312 break; 1319 1313 } 1320 ap = a; 1321 } 1322 } 1323 c++; 1324 p = p->n; 1325 } while (p != NULL); 1326 for (i=1;i<=nrows;i++) 1327 { 1328 if(m_row[i] != NULL) 1329 { 1330 r = m_row[i]; 1331 m_row[i] = NULL; 1314 } 1315 } 1316 } 1317 tored = crd+i; // the number or permuted rows 1318 for (j=act;j;j--) // renumber m_act 1319 { 1320 k = 1; 1321 a = m_act[j]; 1322 do 1323 { 1324 if (perm[crd+k] == a->pos) 1325 { 1326 a->pos = crd+k; 1327 a = a->n; 1328 } 1329 k++; 1330 } while (a != NULL); 1331 } 1332 for(k=1;k<=i;k++) // clean this from m_row 1333 { 1334 j = perm[crd+k]; 1335 if (m_row[j] != NULL) 1336 { 1337 r = m_row[j]; 1338 m_row[j] = NULL; 1332 1339 do 1333 1340 { … … 1338 1345 if (a == NULL) 1339 1346 { 1340 ap->n = h= r;1347 h = ap->n = r; 1341 1348 r = r->n; 1342 h->n = a;1343 h->pos = c ;1349 h->n = NULL; 1350 h->pos = crd+k; 1344 1351 break; 1345 1352 } … … 1347 1354 } 1348 1355 } while (r!=NULL); 1349 c++; 1350 } 1351 } 1352 tored = c-1; 1356 } 1357 } 1358 while(act) // clean m_act 1359 { 1360 crd++; 1361 m_res[crd] = m_act[act]; 1362 act--; 1363 } 1364 for (i=1;i<=nrows;i++) // take the rest of m_row 1365 { 1366 if(m_row[i] != NULL) 1367 { 1368 tored++; 1369 r = m_row[i]; 1370 m_row[i] = NULL; 1371 perm[tored] = i; 1372 do 1373 { 1374 ap = m_res[r->pos]; 1375 loop 1376 { 1377 a = ap->n; 1378 if (a == NULL) 1379 { 1380 h = ap->n = r; 1381 r = r->n; 1382 h->n = NULL; 1383 h->pos = tored; 1384 break; 1385 } 1386 ap = a; 1387 } 1388 } while (r!=NULL); 1389 } 1390 } 1391 while (inred < ncols) // take unreducable 1392 { 1393 crd++; 1394 inred++; 1395 m_res[crd] = m_res[inred]; 1396 } 1353 1397 } 1354 1398
Note: See TracChangeset
for help on using the changeset viewer.