Changeset f930d8 in git
 Timestamp:
 Aug 21, 2006, 7:08:47 PM (17 years ago)
 Branches:
 (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
 Children:
 1b12fcd48b5731ac61772169e5ec7e9fd745bda5
 Parents:
 e9657f200f11e748fef7f426e99de6046f10f1db
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

kernel/tgbgauss.cc
re9657f rf930d8 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: tgbgauss.cc,v 1. 7 20050517 15:26:27 brickenExp $ */4 /* $Id: tgbgauss.cc,v 1.8 20060821 17:08:47 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: gauss implementation for F4 … … 15 15 static const int bundle_size=100; 16 16 17 mac_poly mac_p_add_ff_qq(mac_poly a, number f,mac_poly b){ 17 mac_poly mac_p_add_ff_qq(mac_poly a, number f,mac_poly b) 18 { 18 19 mac_poly erg; 19 20 mac_poly* set_this; 20 21 set_this=&erg; 21 while((a!=NULL) &&(b!=NULL)){ 22 if (a>exp<b>exp){ 22 while((a!=NULL) &&(b!=NULL)) 23 { 24 if (a>exp<b>exp) 25 { 23 26 (*set_this)=a; 24 27 a=a>next; 25 28 set_this= &((*set_this)>next); 26 } 27 else{ 28 if (a>exp>b>exp){ 29 mac_poly in =new mac_poly_r(); 30 in>exp=b>exp; 31 in>coef=nMult(b>coef,f); 32 (*set_this)=in; 33 b=b>next; 34 set_this= &((*set_this)>next); 35 } 36 else { 37 //a>exp==b>ecp 38 number n=nMult(b>coef,f); 39 number n2=nAdd(a>coef,n); 40 nDelete(&n); 41 nDelete(&(a>coef)); 42 if (nIsZero(n2)){ 43 nDelete(&n2); 44 mac_poly ao=a; 45 a=a>next; 46 delete ao; 47 b=b>next; 48 49 } else { 50 a>coef=n2; 51 b=b>next; 52 (*set_this)=a; 53 a=a>next; 54 set_this= &((*set_this)>next); 55 } 56 57 } 58 59 } 60 } 61 if((a==NULL)&&(b==NULL)){ 29 } 30 else 31 { 32 if (a>exp>b>exp) 33 { 34 mac_poly in =new mac_poly_r(); 35 in>exp=b>exp; 36 in>coef=nMult(b>coef,f); 37 (*set_this)=in; 38 b=b>next; 39 set_this= &((*set_this)>next); 40 } 41 else 42 { 43 //a>exp==b>ecp 44 number n=nMult(b>coef,f); 45 number n2=nAdd(a>coef,n); 46 nDelete(&n); 47 nDelete(&(a>coef)); 48 if (nIsZero(n2)) 49 { 50 nDelete(&n2); 51 mac_poly ao=a; 52 a=a>next; 53 delete ao; 54 b=b>next; 55 } 56 else 57 { 58 a>coef=n2; 59 b=b>next; 60 (*set_this)=a; 61 a=a>next; 62 set_this= &((*set_this)>next); 63 } 64 } 65 } 66 } 67 if((a==NULL)&&(b==NULL)) 68 { 62 69 (*set_this)=NULL; 63 70 return erg; 64 71 } 65 if (b==NULL) { 72 if (b==NULL) 73 { 66 74 (*set_this=a); 67 75 return erg; 68 76 } 69 77 70 78 //a==NULL 71 while(b!=NULL){ 79 while(b!=NULL) 80 { 72 81 mac_poly mp= new mac_poly_r(); 73 82 mp>exp=b>exp; … … 79 88 (*set_this)=NULL; 80 89 return erg; 81 82 } 83 void mac_mult_cons(mac_poly p,number c){ 84 while(p){ 90 } 91 92 void mac_mult_cons(mac_poly p,number c) 93 { 94 while(p) 95 { 85 96 number m=nMult(p>coef,c); 86 97 nDelete(&(p>coef)); … … 88 99 p=p>next; 89 100 } 90 91 } 92 int mac_length(mac_poly p){ 101 } 102 103 int mac_length(mac_poly p) 104 { 93 105 int l=0; 94 106 while(p){ … … 98 110 return l; 99 111 } 112 100 113 //contrary to delete on the mac_poly_r, the coefficients are also destroyed here 101 void mac_destroy(mac_poly p){ 114 void mac_destroy(mac_poly p) 115 { 102 116 mac_poly iter=p; 103 117 while(iter) … … 110 124 } 111 125 112 void simple_gauss(tgb_sparse_matrix* mat, slimgb_alg* c){ 126 void simple_gauss(tgb_sparse_matrix* mat, slimgb_alg* c) 127 { 113 128 int col, row; 114 129 int* row_cache=(int*) omalloc(mat>get_rows()*sizeof(int)); … … 120 135 int* area=(int*) omalloc(sizeof(int)*((matcol1)/bundle_size+1)); 121 136 const int max_area_index=(matcol1)/bundle_size; 122 //rows are divided in areas 137 //rows are divided in areas 123 138 //if row begins with columns col, it is located in [area[col/bundle_size],area[col/bundle_size+1]1] 124 139 assume(pn>0); … … 132 147 if(i!=pn){i;} 133 148 } 134 149 135 150 } 136 151 mat>sort_rows(); … … 149 164 int j; 150 165 for(j=last_area+1;j<=this_area;j++) 151 166 area[j]=i; 152 167 last_area=this_area; 153 168 } … … 157 172 area[i]=pn; 158 173 } 159 while(row<pn1){ 174 while(row<pn1) 175 { 160 176 //row is the row where pivot should be 161 177 // row== pn1 means we have only to act on one row so no red nec. 162 178 //we assume further all rows till the pn1 row are nonzero 163 179 164 180 //select column 165 181 166 182 //col=mat>min_col_not_zero_in_row(row); 167 183 int max_in_area; … … 170 186 assume(tai<=max_area_index); 171 187 if(tai==max_area_index) 172 188 max_in_area=pn1; 173 189 else 174 190 max_in_area=area[tai+1]1; 175 191 } 176 192 assume(row_cache[row]==mat>min_col_not_zero_in_row(row)); 177 193 col=row_cache[row]; 178 194 179 180 195 assume(col!=matcol); 181 196 int found_in_row; 182 197 183 198 found_in_row=row; 184 199 BOOLEAN must_reduce=FALSE; 185 200 assume(pn<=mat>get_rows()); 186 for(i=row+1;i<=max_in_area;i++){ 201 for(i=row+1;i<=max_in_area;i++) 202 { 187 203 int first;//=mat>min_col_not_zero_in_row(i); 188 204 assume(row_cache[i]==mat>min_col_not_zero_in_row(i)); … … 191 207 if(first<col) 192 208 { 193 col=first; 194 found_in_row=i; 195 must_reduce=FALSE; 196 } 197 else { 198 if(first==col) 199 must_reduce=TRUE; 209 col=first; 210 found_in_row=i; 211 must_reduce=FALSE; 212 } 213 else 214 { 215 if(first==col) 216 must_reduce=TRUE; 200 217 } 201 218 } … … 204 221 if(must_reduce) 205 222 { 206 for(i=found_in_row+1;i<=max_in_area;i++){ 207 assume(mat>min_col_not_zero_in_row(i)>=col); 208 int first; 209 assume(row_cache[i]==mat>min_col_not_zero_in_row(i)); 210 first=row_cache[i]; 211 assume(first!=matcol); 212 // if((!(mat>is_zero_entry(i,col)))&&(mat>non_zero_entries(i)<act_l)) 213 int nz; 214 if((row_cache[i]==col)&&((nz=nSize(mat>get(i,col))*mat>non_zero_entries(i))<act_l)) 215 { 216 found_in_row=i; 217 act_l=nz; 218 } 219 223 for(i=found_in_row+1;i<=max_in_area;i++) 224 { 225 assume(mat>min_col_not_zero_in_row(i)>=col); 226 int first; 227 assume(row_cache[i]==mat>min_col_not_zero_in_row(i)); 228 first=row_cache[i]; 229 assume(first!=matcol); 230 // if((!(mat>is_zero_entry(i,col)))&&(mat>non_zero_entries(i)<act_l)) 231 int nz; 232 if((row_cache[i]==col)&&((nz=nSize(mat>get(i,col))*mat>non_zero_entries(i))<act_l)) 233 { 234 found_in_row=i; 235 act_l=nz; 236 } 237 220 238 } 221 239 } … … 225 243 row_cache[found_in_row]=h; 226 244 227 228 229 if(!must_reduce){ 245 if(!must_reduce) 246 { 230 247 row++; 231 248 continue; … … 248 265 if(row_cache[i]==col) 249 266 { 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 else 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 267 268 number c1=mat>get(i,col); 269 number c2=mat>get(row,col); 270 number n1=c1; 271 number n2=c2; 272 273 ksCheckCoeff(&n1,&n2); 274 //nDelete(&c1); 275 n1=nNeg(n1); 276 mat>mult_row(i,n2); 277 mat>add_lambda_times_row(i,row,n1); 278 nDelete(&n1); 279 nDelete(&n2); 280 assume(mat>is_zero_entry(i,col)); 281 row_cache[i]=mat>min_col_not_zero_in_row(i); 282 assume(mat>min_col_not_zero_in_row(i)>col); 283 if(row_cache[i]==matcol) 284 { 285 int index; 286 index=i; 287 int last_in_area; 288 int this_cai=col_area_index; 289 while(this_cai<max_area_index) 290 { 291 last_in_area=area[this_cai+1]1; 292 int h_c=row_cache[last_in_area]; 293 row_cache[last_in_area]=row_cache[index]; 294 row_cache[index]=h_c; 295 mat>perm_rows(index,last_in_area); 296 index=last_in_area; 297 this_cai++; 298 area[this_cai]; 299 } 300 mat>perm_rows(index,pn1); 301 row_cache[index]=row_cache[pn1]; 302 row_cache[pn1]=matcol; 303 pn; 304 } 305 else 306 { 307 int index; 308 index=i; 309 int last_in_area; 310 int this_cai=col_area_index; 311 int final_cai=row_cache[index]/bundle_size; 312 assume(final_cai<=max_area_index); 313 while(this_cai<final_cai) 314 { 315 last_in_area=area[this_cai+1]1; 316 int h_c=row_cache[last_in_area]; 317 row_cache[last_in_area]=row_cache[index]; 318 row_cache[index]=h_c; 319 mat>perm_rows(index,last_in_area); 320 index=last_in_area; 321 this_cai++; 322 area[this_cai]; 323 } 324 } 308 325 } 309 326 else 310 assume(mat>min_col_not_zero_in_row(i)>col); 311 } 312 327 assume(mat>min_col_not_zero_in_row(i)>col); 328 } 313 329 // for(i=row+1;i<pn;i++) 314 330 // { … … 318 334 // if(row_cache[i]==matcol) 319 335 // { 320 // 321 // 322 // 323 // 324 // 325 // 336 // assume(mat>zero_row(i)); 337 // mat>perm_rows(i,pn1); 338 // row_cache[i]=row_cache[pn1]; 339 // row_cache[pn1]=matcol; 340 // pn; 341 // if(i!=pn){i;} 326 342 // } 327 343 // } 328 344 #ifdef TGB_DEBUG 329 345 { 330 int last=1; 331 for(i=0;i<pn;i++) 332 { 333 int act=mat>min_col_not_zero_in_row(i); 334 assume(act>last); 335 336 } 337 for(i=pn;i<mat>get_rows();i++) 338 { 339 assume(mat>zero_row(i)); 340 341 } 342 343 346 int last=1; 347 for(i=0;i<pn;i++) 348 { 349 int act=mat>min_col_not_zero_in_row(i); 350 assume(act>last); 351 } 352 for(i=pn;i<mat>get_rows();i++) 353 { 354 assume(mat>zero_row(i)); 355 } 344 356 } 345 357 #endif … … 349 361 omfree(row_cache); 350 362 } 351 void simple_gauss2(tgb_matrix* mat){ 363 364 void simple_gauss2(tgb_matrix* mat) 365 { 352 366 int col, row; 353 367 col=0; … … 370 384 // row== pn1 means we have only to act on one row so no red nec. 371 385 //we assume further all rows till the pn1 row are nonzero 372 386 373 387 //select column 374 388 375 389 // col=mat>min_col_not_zero_in_row(row); 376 390 assume(col!=mat>get_columns()); 377 391 int found_in_row=1; 378 392 379 393 // found_in_row=row; 380 394 assume(pn<=mat>get_rows()); … … 383 397 // int first=mat>min_col_not_zero_in_row(i); 384 398 // if(first<col) 385 if(!(mat>is_zero_entry(i,col))) {386 387 388 399 if(!(mat>is_zero_entry(i,col))) 400 { 401 found_in_row=i; 402 break; 389 403 } 390 404 } … … 395 409 for(i=i+1;i<pn;i++) 396 410 { 397 int vgl; 398 assume(mat>min_col_not_zero_in_row(i)>=col); 399 if((!(mat>is_zero_entry(i,col)))&&((vgl=mat>non_zero_entries(i))<act_l)) 400 { 401 found_in_row=i; 402 act_l=vgl; 403 } 404 411 int vgl; 412 assume(mat>min_col_not_zero_in_row(i)>=col); 413 if((!(mat>is_zero_entry(i,col))) 414 &&((vgl=mat>non_zero_entries(i))<act_l)) 415 { 416 found_in_row=i; 417 act_l=vgl; 418 } 419 405 420 } 406 421 mat>perm_rows(row,found_in_row); 407 408 422 409 423 //reduction 410 424 for(i=row+1;i<pn;i++){ 411 assume(mat>min_col_not_zero_in_row(i)>=col); 412 if(!(mat>is_zero_entry(i,col))) 413 { 414 415 number c1=nNeg(nCopy(mat>get(i,col))); 416 number c2=mat>get(row,col); 417 number n1=c1; 418 number n2=c2; 419 420 ksCheckCoeff(&n1,&n2); 421 nDelete(&c1); 422 mat>mult_row(i,n2); 423 mat>add_lambda_times_row(i,row,n1); 424 assume(mat>is_zero_entry(i,col)); 425 426 } 427 assume(mat>min_col_not_zero_in_row(i)>col); 425 assume(mat>min_col_not_zero_in_row(i)>=col); 426 if(!(mat>is_zero_entry(i,col))) 427 { 428 number c1=nNeg(nCopy(mat>get(i,col))); 429 number c2=mat>get(row,col); 430 number n1=c1; 431 number n2=c2; 432 433 ksCheckCoeff(&n1,&n2); 434 nDelete(&c1); 435 mat>mult_row(i,n2); 436 mat>add_lambda_times_row(i,row,n1); 437 assume(mat>is_zero_entry(i,col)); 438 } 439 assume(mat>min_col_not_zero_in_row(i)>col); 428 440 } 429 441 row++; … … 434 446 // if(mat>zero_row(i)) 435 447 // { 436 // 437 // 438 // 448 // mat>perm_rows(i,pn1); 449 // pn; 450 // if(i!=pn){i;} 439 451 // } 440 452 // } 441 442 } 443 } 444 445 tgb_matrix::tgb_matrix(int i, int j){ 453 } 454 } 455 456 457 tgb_matrix::tgb_matrix(int i, int j) 458 { 446 459 n=(number**) omalloc(i*sizeof (number*));; 447 460 int z; … … 459 472 free_numbers=FALSE; 460 473 } 461 tgb_matrix::~tgb_matrix(){ 474 475 tgb_matrix::~tgb_matrix() 476 { 462 477 int z; 463 478 for(z=0;z<rows;z++) … … 467 482 if(free_numbers) 468 483 { 469 470 471 472 473 484 int z2; 485 for(z2=0;z2<columns;z2++) 486 { 487 nDelete(&(n[z][z2])); 488 } 474 489 } 475 490 omfree(n[z]); … … 478 493 omfree(n); 479 494 } 480 void tgb_matrix::print(){ 495 496 void tgb_matrix::print() 497 { 481 498 int i; 482 499 int j; 483 Print ("\n");500 PrintLn(); 484 501 for(i=0;i<rows;i++) 485 502 { … … 495 512 } 496 513 } 514 497 515 //transfers ownership of n to the matrix 498 void tgb_matrix::set(int i, int j, number n){ 516 void tgb_matrix::set(int i, int j, number n) 517 { 499 518 assume(i<rows); 500 519 assume(j<columns); 501 520 this>n[i][j]=n; 502 521 } 503 int tgb_matrix::get_rows(){ 522 523 int tgb_matrix::get_rows() 524 { 504 525 return rows; 505 526 } 506 int tgb_matrix::get_columns(){ 527 528 int tgb_matrix::get_columns() 529 { 507 530 return columns; 508 531 } 509 number tgb_matrix::get(int i, int j){ 532 533 number tgb_matrix::get(int i, int j) 534 { 510 535 assume(i<rows); 511 536 assume(j<columns); 512 537 return n[i][j]; 513 538 } 514 BOOLEAN tgb_matrix::is_zero_entry(int i, int j){ 539 540 BOOLEAN tgb_matrix::is_zero_entry(int i, int j) 541 { 515 542 return (nIsZero(n[i][j])); 516 543 } 517 void tgb_matrix::perm_rows(int i, int j){ 544 545 void tgb_matrix::perm_rows(int i, int j) 546 { 518 547 number* h; 519 548 h=n[i]; … … 521 550 n[j]=h; 522 551 } 523 int tgb_matrix::min_col_not_zero_in_row(int row){ 552 553 int tgb_matrix::min_col_not_zero_in_row(int row) 554 { 524 555 int i; 525 556 for(i=0;i<columns;i++) … … 530 561 return columns;//error code 531 562 } 532 int tgb_matrix::next_col_not_zero(int row,int pre){ 563 564 int tgb_matrix::next_col_not_zero(int row,int pre) 565 { 533 566 int i; 534 567 for(i=pre+1;i<columns;i++) … … 539 572 return columns;//error code 540 573 } 541 BOOLEAN tgb_matrix::zero_row(int row){ 574 575 BOOLEAN tgb_matrix::zero_row(int row) 576 { 542 577 int i; 543 578 for(i=0;i<columns;i++) … … 548 583 return TRUE; 549 584 } 550 int tgb_matrix::non_zero_entries(int row){ 585 586 int tgb_matrix::non_zero_entries(int row) 587 { 551 588 int i; 552 589 int z=0; … … 558 595 return z; 559 596 } 597 560 598 //row add_to=row add_to +row summand*factor 561 void tgb_matrix::add_lambda_times_row(int add_to,int summand,number factor){ 562 int i; 563 for(i=0;i<columns;i++){ 599 void tgb_matrix::add_lambda_times_row(int add_to,int summand,number factor) 600 { 601 int i; 602 for(i=0;i<columns;i++) 603 { 564 604 if(!(nIsZero(n[summand][i]))) 565 605 { … … 572 612 } 573 613 } 574 void tgb_matrix::mult_row(int row,number factor){ 614 615 void tgb_matrix::mult_row(int row,number factor) 616 { 575 617 if (nIsOne(factor)) 576 618 return; 577 619 int i; 578 for(i=0;i<columns;i++){ 620 for(i=0;i<columns;i++) 621 { 579 622 if(!(nIsZero(n[row][i]))) 580 623 { … … 585 628 } 586 629 } 587 void tgb_matrix::free_row(int row, BOOLEAN free_non_zeros){ 630 631 void tgb_matrix::free_row(int row, BOOLEAN free_non_zeros) 632 { 588 633 int i; 589 634 for(i=0;i<columns;i++) … … 594 639 } 595 640 596 597 tgb_sparse_matrix::tgb_sparse_matrix(int i, int j, ring rarg){641 tgb_sparse_matrix::tgb_sparse_matrix(int i, int j, ring rarg) 642 { 598 643 mp=(mac_poly*) omalloc(i*sizeof (mac_poly));; 599 644 int z; … … 608 653 r=rarg; 609 654 } 610 tgb_sparse_matrix::~tgb_sparse_matrix(){ 655 656 tgb_sparse_matrix::~tgb_sparse_matrix() 657 { 611 658 int z; 612 659 for(z=0;z<rows;z++) 613 660 { 614 if(mp[z] )661 if(mp[z]!=NULL) 615 662 { 616 663 if(free_numbers) 617 664 { 618 665 mac_destroy(mp[z]); 619 666 } 620 667 else { 621 while(mp[z]) 622 { 623 624 mac_poly next=mp[z]>next; 625 delete mp[z]; 626 mp[z]=next; 627 } 668 while(mp[z]!=NULL) 669 { 670 mac_poly next=mp[z]>next; 671 delete mp[z]; 672 mp[z]=next; 673 } 628 674 } 629 675 } … … 631 677 omfree(mp); 632 678 } 633 static int row_cmp_gen(const void* a, const void* b){ 679 680 static int row_cmp_gen(const void* a, const void* b) 681 { 634 682 const mac_poly ap= *((mac_poly*) a); 635 683 const mac_poly bp=*((mac_poly*) b); … … 639 687 return 1; 640 688 } 641 void tgb_sparse_matrix::sort_rows(){ 689 690 void tgb_sparse_matrix::sort_rows() 691 { 642 692 qsort(mp,rows,sizeof(mac_poly),row_cmp_gen); 643 693 } 644 void tgb_sparse_matrix::print(){ 694 695 void tgb_sparse_matrix::print() 696 { 645 697 int i; 646 698 int j; … … 660 712 } 661 713 } 714 662 715 //transfers ownership of n to the matrix 663 void tgb_sparse_matrix::set(int i, int j, number n){ 716 void tgb_sparse_matrix::set(int i, int j, number n) 717 { 664 718 assume(i<rows); 665 719 assume(j<columns); … … 691 745 (*set_this)=dt>next; 692 746 delete dt; 693 694 695 747 } 696 748 return; 697 749 } 698 750 699 700 701 int tgb_sparse_matrix::get_rows(){ 751 int tgb_sparse_matrix::get_rows() 752 { 702 753 return rows; 703 754 } 704 int tgb_sparse_matrix::get_columns(){ 755 756 int tgb_sparse_matrix::get_columns() 757 { 705 758 return columns; 706 759 } 707 number tgb_sparse_matrix::get(int i, int j){ 760 761 number tgb_sparse_matrix::get(int i, int j) 762 { 708 763 assume(i<rows); 709 764 assume(j<columns); … … 719 774 return r>coef; 720 775 } 721 BOOLEAN tgb_sparse_matrix::is_zero_entry(int i, int j){ 776 777 BOOLEAN tgb_sparse_matrix::is_zero_entry(int i, int j) 778 { 722 779 assume(i<rows); 723 780 assume(j<columns); … … 732 789 assume(r>exp==j); 733 790 return FALSE; 734 735 } 736 737 int tgb_sparse_matrix::min_col_not_zero_in_row(int row){791 } 792 793 int tgb_sparse_matrix::min_col_not_zero_in_row(int row) 794 { 738 795 if(mp[row]!=NULL) 739 796 { … … 742 799 } 743 800 else 744 745 746 return columns;//error code 747 } 748 int tgb_sparse_matrix::next_col_not_zero(int row,int pre){ 801 return columns;//error code 802 } 803 804 int tgb_sparse_matrix::next_col_not_zero(int row,int pre) 805 { 749 806 mac_poly r=mp[row]; 750 807 while((r!=NULL)&&(r>exp<=pre)) … … 757 814 return columns;//error code 758 815 } 759 BOOLEAN tgb_sparse_matrix::zero_row(int row){ 816 817 BOOLEAN tgb_sparse_matrix::zero_row(int row) 818 { 760 819 assume((mp[row]==NULL)(!nIsZero(mp[row]>coef))); 761 820 if (mp[row]==NULL) … … 764 823 return FALSE; 765 824 } 766 void tgb_sparse_matrix::row_normalize(int row){ 825 826 void tgb_sparse_matrix::row_normalize(int row) 827 { 767 828 if (!rField_has_simple_inverse(r)) /* Z/p, GF(p,n), R, long R/C */ 768 829 { 769 830 mac_poly m=mp[row]; 770 while (m!=NULL) 771 { 772 if (currRing==r) {nTest(m>coef);} 773 n_Normalize(m>coef,r); 774 m=m>next; 775 } 776 } 777 } 778 void tgb_sparse_matrix::row_content(int row){ 779 831 while (m!=NULL) 832 { 833 if (currRing==r) {nTest(m>coef);} 834 n_Normalize(m>coef,r); 835 m=m>next; 836 } 837 } 838 } 839 840 void tgb_sparse_matrix::row_content(int row) 841 { 780 842 mac_poly ph=mp[row]; 781 843 number h,d; … … 791 853 { 792 854 nNormalize(ph>coef); 793 if(!nGreaterZero(ph>coef)) { 855 if(!nGreaterZero(ph>coef)) 856 { 794 857 //ph = pNeg(ph); 795 858 p=ph; 796 while(p )797 { 798 799 800 } 801 } 802 859 while(p!=NULL) 860 { 861 p>coef=nNeg(p>coef); 862 p=p>next; 863 } 864 } 865 803 866 h=nCopy(ph>coef); 804 867 p = ph>next; 805 868 806 869 while (p!=NULL) 807 870 { … … 822 885 while (p!=NULL) 823 886 { 824 825 887 d = nIntDiv(pGetCoeff(p),h); 826 888 nDelete(&p>coef); 827 889 p>coef=d; 828 890 p=p>next; … … 830 892 } 831 893 nDelete(&h); 832 833 } 834 } 835 int tgb_sparse_matrix::non_zero_entries(int row){ 836 894 } 895 } 896 int tgb_sparse_matrix::non_zero_entries(int row) 897 { 837 898 return mac_length(mp[row]); 838 899 } 900 839 901 //row add_to=row add_to +row summand*factor 840 void tgb_sparse_matrix::add_lambda_times_row(int add_to,int summand,number factor){ 902 void tgb_sparse_matrix::add_lambda_times_row(int add_to,int summand,number factor) 903 { 841 904 mp[add_to]= mac_p_add_ff_qq(mp[add_to], factor,mp[summand]); 842 843 } 844 void tgb_sparse_matrix::mult_row(int row,number factor){ 905 } 906 907 void tgb_sparse_matrix::mult_row(int row,number factor) 908 { 845 909 if (nIsZero(factor)) 846 910 { 847 911 mac_destroy(mp[row]); 848 912 mp[row]=NULL; 849 913 850 914 return; 851 915 } … … 854 918 mac_mult_cons(mp[row],factor); 855 919 } 856 void tgb_sparse_matrix::free_row(int row, BOOLEAN free_non_zeros){ 920 921 void tgb_sparse_matrix::free_row(int row, BOOLEAN free_non_zeros) 922 { 857 923 if(free_non_zeros) 858 924 mac_destroy(mp[row]); 859 925 else 860 926 { 861 while(mp[row]) 862 { 863 927 while(mp[row]!=NULL) 928 { 864 929 mac_poly next=mp[row]>next; 865 930 delete mp[row];
Note: See TracChangeset
for help on using the changeset viewer.