Changeset 9c72f1 in git
- Timestamp:
- Nov 23, 1999, 3:20:48 PM (24 years ago)
- Branches:
- (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
- Children:
- 97d5bb385c5af151596b34fb820eb8e832c8bc5f
- Parents:
- 6555d42eff22ff0c27fe1a1e3f90213afeffd2ae
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/tst.lib
r6555d4 r9c72f1 1 // $Id: tst.lib,v 1.2 1 1999-11-23 14:13:21obachman Exp $1 // $Id: tst.lib,v 1.22 1999-11-23 14:20:48 obachman Exp $ 2 2 //(obachman, last modified 6/30/98) 3 3 ///////////////////////////////////////////////////////////////////////////// 4 4 5 version="$Id: tst.lib,v 1.2 1 1999-11-23 14:13:21obachman Exp $";5 version="$Id: tst.lib,v 1.22 1999-11-23 14:20:48 obachman Exp $"; 6 6 info=" 7 7 LIBRARY: tst.lib PROCEDURES FOR RUNNING AUTOMATIC TST TESTS … … 529 529 } 530 530 531 /////////////////////////////////////////////////////////////////////////////532 //533 // Here are still a couple of procedures which used to be in534 // Tst/Old535 proc prideal (ideal id)536 {537 "// ideal";538 for (int @i=1; @i<=nrows(id); @i=@i+1)539 {540 "//id[" + string(@i) + "] : "+ string(id[@i]);541 }542 "// dim :", dim(id);543 "// mult :", multiplicity(id);544 return();545 }546 547 proc formmat (matrix m)548 {549 int @elems = 0;550 int @mlen = 0;551 int @slen = 0;552 int @c;553 for (int @r=1; @r<=nrows(m); @r=@r+1)554 {555 for (@c=1; @c<=ncols(m); @c=@c+1)556 {557 @elems = @elems + 1;558 string @s(@elems) = string(m[@r,@c]);559 @slen = size(@s(@elems));560 if (@slen > @mlen)561 {562 @mlen = @slen;563 }564 }565 }566 @elems = 0;567 string @aus = "";568 string @sep = " ";569 if (@mlen * ncols(m) >= pagewidth)570 {571 @sep = newline;572 }573 for (@r=1; @r<=nrows(m); @r=@r+1)574 {575 for (@c=1; @c<=ncols(m); @c=@c+1)576 {577 @elems = @elems + 1;578 @slen = size(@s(@elems));579 @aus = @aus + @s(@elems)[1,@mlen] + @sep;580 }581 @aus = @aus + newline;582 // @aus = "";583 }584 return(@aus);585 }586 proc fixmat (matrix m,int l)587 {588 string @aus;589 string @tmp;590 int @ll;591 int @c;592 for (int @r=1; @r<=nrows(m); @r=@r+1)593 {594 @aus = "";595 for (@c=1; @c<=ncols(m); @c=@c+1)596 {597 @tmp = string(m[@r,@c]);598 @aus = @aus + @tmp[1,l] + " ";599 }600 @aus;601 }602 }603 proc stransp (int r, int c, list #)604 {605 // transpose a submatrix606 matrix @m[r][c];607 int @ii = 1;608 int @j;609 for (int @i = 1; @i<=r; @i=@i+1)610 {611 for (@j = 1; @j<=c; @j=@j+1)612 {613 @m[@i,@j] = #[@ii];614 @ii=@ii+1;615 }616 }617 return(transpose(@m));618 }619 proc unitmat (int r, list #)620 {621 // create an unit matrix, # is optional622 poly @p = 1;623 if (size(#) == 1)624 {625 @p = #[1];626 }627 matrix @m[r][r];628 return (@m + @p);629 }630 //631 // declare a ring with a different dialog632 // using defaults etc;633 //634 635 proc permute (int n, list #)636 {637 //if (#ARGS == 2)638 //{639 // string @actionstring = #action +"();";640 //}641 if (defined(PERMUTE_DATA) or defined(PERMUTE_WORK))642 {643 "permute: PERMUTE_WORK/DATA already defined, please kill them!";644 return();645 }646 //647 // initialize global data648 //649 intvec PERMUTE_DATA = n; // must be global650 intvec PERMUTE_WORK = 1; // must be global651 export PERMUTE_DATA, PERMUTE_WORK;652 for (int @i=#n-1; @i>0; @i=@i-1)653 {654 PERMUTE_DATA = PERMUTE_DATA, @i;655 PERMUTE_WORK = PERMUTE_WORK, 1;656 }657 int @done = 0;658 while (@done == 0)659 {660 "permute", PERMUTE_DATA; // this could be an action call661 //if (#ARGS == 2)662 //{663 // execute @actionstring;664 //}665 @done = next_permute(n);666 }667 kill PERMUTE_DATA, PERMUTE_WORK;668 return ("-----------");669 }670 671 proc next_permute (int n)672 {673 int @rc = 1;674 if (n > 1)675 {676 if(PERMUTE_WORK[n] < n)677 {678 PERMUTE_DATA[PERMUTE_WORK[n]] = PERMUTE_DATA[PERMUTE_WORK[n] + 1];679 PERMUTE_DATA[PERMUTE_WORK[n] + 1] = n;680 PERMUTE_WORK[n] = PERMUTE_WORK[n] + 1;681 return(0);682 }683 @rc = next_permute(n-1);684 for(int @i=n-1; @i>=1; @i=@i-1)685 {686 PERMUTE_DATA[@i+1] = PERMUTE_DATA[@i];687 }688 PERMUTE_DATA[1] = n;689 PERMUTE_WORK[n] = 1;690 return(@rc);691 }692 return (@rc);693 }694 //695 // permutations as described in:696 // data structures, algorithms, and program style using c697 // james f. korsh698 // leonard j. garrett699 // pp. 162700 //701 proc permute1 (int n)702 {703 int @done = 0;704 while (@done == 0)705 {706 "permute", all; // this could be an action call707 @done = next(n);708 }709 return ("-----------");710 }711 proc next (int n)712 {713 int @rc = 1;714 if (n > 1)715 {716 if(l[n] < n)717 {718 all[l[n]] = all[l[n] + 1];719 all[l[n] + 1] = n;720 l[n] = l[n] + 1;721 return(0);722 }723 @rc = next(n-1);724 for(int @i=n-1; @i>=1; @i=@i-1)725 {726 all[@i+1] = all[@i];727 }728 all[1] = n;729 l[n] = 1;730 return(@rc);731 }732 return (@rc);733 }
Note: See TracChangeset
for help on using the changeset viewer.