Changeset 81384b in git
- Timestamp:
- Feb 13, 2013, 4:27:51 PM (10 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
- Children:
- 5417fff5d4d977443ea13f49a1da1d9de9a2a171
- Parents:
- 26b71347b556b24c26b980182b98e5bd3b5dc27b
- git-author:
- Yue Ren <ren@mathematik.uni-kl.de>2013-02-13 16:27:51+01:00
- git-committer:
- Yue Ren <ren@mathematik.uni-kl.de>2013-03-14 15:32:21+01:00
- Files:
-
- 13 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile.am
r26b713 r81384b 2 2 3 3 if ENABLE_FACTORY 4 USE_FACTORY = factory 4 USE_FACTORY = factory 5 5 else 6 6 USE_FACTORY = 7 7 endif 8 9 PACKAGES=findexec omalloc $(USE_FACTORY) libpolys kernel numeric Singular IntegerProgramming dyn_modules 8 9 PACKAGES=findexec omalloc $(USE_FACTORY) libpolys kernel numeric Singular IntegerProgramming dyn_modules gfanlib 10 10 11 11 SUBDIRS=$(PACKAGES) -
configure.ac
r26b713 r81384b 54 54 AC_PROG_INSTALL 55 55 56 # AM_PROG_AR57 56 LT_INIT 58 57 59 58 # Checks for libraries. 60 59 LB_CHECK_GMP(3.1.1,,AC_MSG_ERROR([Unable to find GMP on your machine: please use --with-gmp=PATH_TO_DIR_CONTAINING_LIB_AND_INCLUDE (see also ./configure --help if you do not understand what we are talking about)])) … … 87 86 SING_CHECK_READLINE 88 87 SING_CHECK_DBM 88 SING_CHECK_GFANLIB 89 89 90 90 # CFLAGS … … 149 149 fi 150 150 151 AC_CONFIG_SUBDIRS([findexec]) 151 AC_CONFIG_SUBDIRS([findexec]) 152 152 AC_CONFIG_SUBDIRS([omalloc]) 153 153 … … 165 165 AC_CONFIG_FILES([dyn_modules/bigintm/Makefile]) 166 166 AC_CONFIG_FILES([dyn_modules/syzextra/Makefile]) 167 if test "x$ENABLE_GFANLIB" = xyes; then 168 AC_CONFIG_SUBDIRS([gfanlib]) 169 AC_CONFIG_FILES([dyn_modules/callgfanlib/Makefile]) 170 fi 167 171 AC_CONFIG_FILES([libsingular-config]) 168 172 -
dyn_modules/Makefile.am
r26b713 r81384b 1 1 ACLOCAL_AMFLAGS = -I ../m4 2 2 3 PACKAGES=bigintm syzextra 3 PACKAGES=bigintm syzextra callgfanlib 4 4 SUBDIRS=$(PACKAGES) 5 5 -
libpolys/coeffs/bigintmat.cc
r26b713 r81384b 49 49 { 50 50 assume (C == NULL || C == basecoeffs()); 51 assume (i > 0 && j >0);51 assume (i >= 0 && j >= 0); 52 52 assume (i <= rows() && j <= cols()); 53 53 … … 65 65 number bigintmat::get(int i, int j) const 66 66 { 67 assume (i > 0 && j >0);67 assume (i >= 0 && j >= 0); 68 68 assume (i <= rows() && j <= cols()); 69 69 … … 354 354 char* bigintmat::String() 355 355 { 356 assume (rows() > 0);357 assume (cols() > 0);358 359 356 StringSetS(""); 360 357 const int l = cols()*rows(); … … 374 371 } 375 372 376 int intArrSum(int * a, int length) 377 { 378 int sum = 0; 379 for (int i=0; i<length; i++) 380 sum += a[i]; 381 return sum; 382 } 383 384 int findLongest(int * a, int length) 385 { 386 int l = 0; 387 int index; 388 for (int i=0; i<length; i++) 389 { 390 if (a[i] > l) 391 { 392 l = a[i]; 393 index = i; 394 } 395 } 396 return index; 397 } 398 399 int getShorter (int * a, int l, int j, int cols, int rows) 400 { 401 int sndlong = 0; 402 int min; 403 for (int i=0; i<rows; i++) 404 { 405 int index = cols*i+j; 406 if ((a[index] > sndlong) && (a[index] < l)) 407 { 408 min = floor(log10(cols))+floor(log10(rows))+5; 409 if ((a[index] < min) && (min < l)) 410 sndlong = min; 411 else 412 sndlong = a[index]; 413 } 414 } 415 if (sndlong == 0) 416 { 417 min = floor(log10(cols))+floor(log10(rows))+5; 418 if (min < l) 419 sndlong = min; 420 else 421 sndlong = 1; 422 } 423 return sndlong; 424 } 425 426 427 int * bigintmat::getwid(int maxwid) 428 { 429 int const c = /*2**/(col-1)+1; 430 if (col + c > maxwid-1) return NULL; 431 int * wv = (int*)omAlloc(sizeof(int)*col*row); 432 int * cwv = (int*)omAlloc(sizeof(int)*col); 433 for (int j=0; j<col; j++) 434 { 435 cwv[j] = 0; 436 for (int i=0; i<row; i++) 437 { 438 StringSetS(""); 439 n_Write(v[col*i+j], basecoeffs()); 440 char * tmp = StringEndS(); 441 const int _nl = strlen(tmp); 442 wv[col*i+j] = _nl; 443 if (_nl > cwv[j]) 444 cwv[j]=_nl; 445 omFree(tmp); 446 } 447 } 448 449 // Groesse verkleinern, bis < maxwid 450 while (intArrSum(cwv, col)+c > maxwid) 451 { 452 int j = findLongest(cwv, col); 453 cwv[j] = getShorter(wv, cwv[j], j, col, row); 454 } 455 omFree(wv); 456 return cwv; 457 } 458 459 void bigintmat::pprint(int maxwid) 373 char* bigintmat::StringAsPrinted() 460 374 { 461 375 if ((col==0) || (row==0)) … … 463 377 else 464 378 { 465 int * colwid = getwid(maxwid); 379 int * colwid = getwid(80); 380 char * ps; 466 381 if (colwid == NULL) 467 382 { 468 383 WerrorS("not enough space to print bigintmat"); 469 return;470 }471 char * ps;384 WerrorS("try string(...) for a unformatted output"); 385 return ps; 386 } 472 387 int slength = 0; 473 388 for (int j=0; j<col; j++) … … 530 445 omFree(ts); // Hier ts zerstören 531 446 } 447 return(ps); 448 // omFree(ps); 449 } 450 // if ((col==0) || (row==0)) 451 // return 0; 452 // int * colwid = getwid(80); 453 // if (colwid == NULL) 454 // { 455 // WerrorS("not enough space to print bigintmat"); 456 // WerrorS("try string(...) for a unformatted output"); 457 // return 0; 458 // } 459 // char * ps; 460 // int slength = 0; 461 // for (int j=0; j<col; j++) 462 // slength += colwid[j]*row; 463 // slength += 2*(col-1)*row+2*row-1; 464 // ps = (char*) omAlloc0(sizeof(char)*(slength)); 465 // int pos = 0; 466 // for (int i=0; i<col*row; i++) 467 // { 468 // StringSetS(""); 469 // n_Write(v[i], basecoeffs()); 470 // char * temp = StringAppendS(""); 471 // char * ts = omStrDup(temp); 472 // int nl = strlen(ts); 473 // int cj = i%col; 474 // if (nl > colwid[cj]) 475 // { 476 // StringSetS(""); 477 // int ci = floor(i/col); 478 // StringAppend("[%d,%d]", ci+1, cj+1); 479 // char *tmp = StringAppendS(""); 480 // char * ph = omStrDup(tmp); 481 // int phl = strlen(ph); 482 // if (phl > colwid[cj]) 483 // { 484 // for (int j=0; j<colwid[cj]; j++) 485 // ps[pos+j] = '*'; 486 // } 487 // else 488 // { 489 // for (int j=0; j<colwid[cj]-phl; j++) 490 // ps[pos+j] = ' '; 491 // for (int j=0; j<phl; j++) 492 // ps[pos+colwid[cj]-phl+j] = ph[j]; 493 // } 494 // omFree(ph); 495 // } 496 // else // Mit Leerzeichen auffÃŒllen und Zahl reinschreiben 497 // { 498 // for (int j=0; j<colwid[cj]-nl; j++) 499 // ps[pos+j] = ' '; 500 // for (int j=0; j<nl; j++) 501 // ps[pos+colwid[cj]-nl+j] = ts[j]; 502 // } 503 // // ", " oder "\n" einfÃŒgen 504 // if ((i+1)%col == 0) 505 // { 506 // if (i != col*row-1) 507 // { 508 // ps[pos+colwid[cj]] = ','; 509 // ps[pos+colwid[cj]+1] = '\n'; 510 // pos += colwid[cj]+2; 511 // } 512 // } 513 // else 514 // { 515 // ps[pos+colwid[cj]] = ','; 516 // ps[pos+colwid[cj]+1] = ' '; 517 // pos += colwid[cj]+2; 518 // } 519 // omFree(ts); 520 // } 521 // return ps; 522 } 523 524 int intArrSum(int * a, int length) 525 { 526 int sum = 0; 527 for (int i=0; i<length; i++) 528 sum += a[i]; 529 return sum; 530 } 531 532 int findLongest(int * a, int length) 533 { 534 int l = 0; 535 int index; 536 for (int i=0; i<length; i++) 537 { 538 if (a[i] > l) 539 { 540 l = a[i]; 541 index = i; 542 } 543 } 544 return index; 545 } 546 547 int getShorter (int * a, int l, int j, int cols, int rows) 548 { 549 int sndlong = 0; 550 int min; 551 for (int i=0; i<rows; i++) 552 { 553 int index = cols*i+j; 554 if ((a[index] > sndlong) && (a[index] < l)) 555 { 556 min = floor(log10(cols))+floor(log10(rows))+5; 557 if ((a[index] < min) && (min < l)) 558 sndlong = min; 559 else 560 sndlong = a[index]; 561 } 562 } 563 if (sndlong == 0) 564 { 565 min = floor(log10(cols))+floor(log10(rows))+5; 566 if (min < l) 567 sndlong = min; 568 else 569 sndlong = 1; 570 } 571 return sndlong; 572 } 573 574 575 int * bigintmat::getwid(int maxwid) 576 { 577 int const c = /*2**/(col-1)+1; 578 if (col + c > maxwid-1) return NULL; 579 int * wv = (int*)omAlloc(sizeof(int)*col*row); 580 int * cwv = (int*)omAlloc(sizeof(int)*col); 581 for (int j=0; j<col; j++) 582 { 583 cwv[j] = 0; 584 for (int i=0; i<row; i++) 585 { 586 StringSetS(""); 587 n_Write(v[col*i+j], basecoeffs()); 588 char * tmp = StringEndS(); 589 const int _nl = strlen(tmp); 590 wv[col*i+j] = _nl; 591 if (_nl > cwv[j]) 592 cwv[j]=_nl; 593 omFree(tmp); 594 } 595 } 596 597 // Groesse verkleinern, bis < maxwid 598 while (intArrSum(cwv, col)+c > maxwid) 599 { 600 int j = findLongest(cwv, col); 601 cwv[j] = getShorter(wv, cwv[j], j, col, row); 602 } 603 omFree(wv); 604 return cwv; 605 } 606 607 void bigintmat::pprint(int maxwid) 608 { 609 if ((col==0) || (row==0)) 610 PrintS(""); 611 else 612 { 613 int * colwid = getwid(maxwid); 614 if (colwid == NULL) 615 { 616 WerrorS("not enough space to print bigintmat"); 617 return; 618 } 619 char * ps; 620 int slength = 0; 621 for (int j=0; j<col; j++) 622 slength += colwid[j]*row; 623 slength += col*row+row; 624 ps = (char*) omAlloc0(sizeof(char)*(slength)); 625 int pos = 0; 626 for (int i=0; i<col*row; i++) 627 { 628 StringSetS(""); 629 n_Write(v[i], basecoeffs()); 630 char * ts = StringEndS(); 631 const int _nl = strlen(ts); 632 int cj = i%col; 633 if (_nl > colwid[cj]) 634 { 635 StringSetS(""); 636 int ci = floor(i/col); 637 StringAppend("[%d,%d]", ci+1, cj+1); 638 char * ph = StringEndS(); 639 int phl = strlen(ph); 640 if (phl > colwid[cj]) 641 { 642 for (int j=0; j<colwid[cj]-1; j++) 643 ps[pos+j] = ' '; 644 ps[pos+colwid[cj]-1] = '*'; 645 } 646 else 647 { 648 for (int j=0; j<colwid[cj]-phl; j++) 649 ps[pos+j] = ' '; 650 for (int j=0; j<phl; j++) 651 ps[pos+colwid[cj]-phl+j] = ph[j]; 652 } 653 omFree(ph); 654 } 655 else // Mit Leerzeichen auffÃŒllen und zahl reinschreiben 656 { 657 for (int j=0; j<colwid[cj]-_nl; j++) 658 ps[pos+j] = ' '; 659 for (int j=0; j<_nl; j++) 660 ps[pos+colwid[cj]-_nl+j] = ts[j]; 661 } 662 // ", " und (evtl) "\n" einfÃŒgen 663 if ((i+1)%col == 0) 664 { 665 if (i != col*row-1) 666 { 667 ps[pos+colwid[cj]] = ','; 668 ps[pos+colwid[cj]+1] = '\n'; 669 pos += colwid[cj]+2; 670 } 671 } 672 else 673 { 674 ps[pos+colwid[cj]] = ','; 675 pos += colwid[cj]+1; 676 } 677 678 omFree(ts); // Hier ts zerstören 679 } 532 680 PrintS(ps); 533 681 // omFree(ps); -
libpolys/coeffs/bigintmat.h
r26b713 r81384b 175 175 176 176 char * String(); 177 /*** 178 * Returns a string as it would have been printed in the interpreter. 179 * Used e.g. in print functions of various blackbox types. 180 **/ 181 char * StringAsPrinted(); 177 182 void pprint(int maxwid); 178 183 int compare(const bigintmat* op) const;
Note: See TracChangeset
for help on using the changeset viewer.