Changeset 6f2edc in git for Singular/LIB/random.lib


Ignore:
Timestamp:
Apr 28, 1997, 9:27:25 PM (27 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'spielwiese', 'e7cc1ebecb61be8b9ca6c18016352af89940b21a')
Children:
8c5a578cc8481c8a133a58030c4c4c8227d82bb1
Parents:
6d09c564c80f079b501f7187cf6984d040603849
Message:
Mon Apr 28 21:00:07 1997  Olaf Bachmann
<obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)>

     * dunno why I am committing these libs -- have not modified any
       of them


git-svn-id: file:///usr/local/Singular/svn/trunk@205 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/random.lib

    r6d09c56 r6f2edc  
    1 // $Id: random.lib,v 1.1.1.1 1997-04-25 15:13:26 obachman Exp $
     1// $Id: random.lib,v 1.2 1997-04-28 19:27:23 obachman Exp $
    22//system("random",787422842);
    3 //(GMG+BM)
     3//(GMG/BM, last modified 22.06.96)
    44///////////////////////////////////////////////////////////////////////////////
    55
     
    2020
    2121proc genericid (id, list #)
    22 USAGE:   genericid(id,[,p,b]);  id ideal/module, p,b integers
    23 RETURN:  system of generators of id which are generic, sparse, trigonal linear
     22USAGE:   genericid(id,[,p,b]);  id ideal/module, k,p,b integers
     23RETURN:  system of generators of id which are generic, sparse, triagonal linear
    2424         combinations of given generators with coefficients in [1,b] and
    2525         sparsety p percent, bigger p being sparser (default: p=75, b=30000)
     
    3232   if( size(#)==0 ) { int p=75; int b=30000; }
    3333//---------------- use sparsetriag for creation of genericid ------------------
    34    def i = simplify(id,10);                         
     34   def i = simplify(id,10);
    3535   i = i*sparsetriag(ncols(i),ncols(i),p,b);
    3636   return(i);
    37 }               
    38 example
    39 { "EXAMPLE:"; echo = 2;
    40    ring r=0,(t,x,y,z),ds; 
    41    ideal i= x3+y4,z4+yx,t+x+y+z;         
    42    genericid(i,0,10);         
    43    module m=[x,0,0,0],[0,y2,0,0],[0,0,z3,0],[0,0,0,t4]; 
     37}
     38example
     39{ "EXAMPLE:"; echo = 2;
     40   ring r=0,(t,x,y,z),ds;
     41   ideal i= x3+y4,z4+yx,t+x+y+z;
     42   genericid(i,0,10);
     43   module m=[x,0,0,0],[0,y2,0,0],[0,0,z3,0],[0,0,0,t4];
    4444   print(genericid(m));
    4545}
     
    5959   if( size(#)==0 ) { int k=size(id); int b=30000; }
    6060//--------------------------- create randomid ---------------------------------
    61    def i = id;                         
     61   def i = id;
    6262   i = matrix(id)*random(b,ncols(id),k);
    6363   return(i);
    64 }               
    65 example
    66 { "EXAMPLE:"; echo = 2;
    67    ring r=0,(x,y,z),dp;           
    68    randomid(maxideal(2),2,9);         
    69    module m=[x,0,1],[0,y2,0],[y,0,z3]; 
     64}
     65example
     66{ "EXAMPLE:"; echo = 2;
     67   ring r=0,(x,y,z),dp;
     68   randomid(maxideal(2),2,9);
     69   module m=[x,0,1],[0,y2,0],[y,0,z3];
    7070   show(randomid(m));
    7171}
     
    8888   int g=ncols(id);
    8989   matrix rand[n][m]; matrix ra[1][m];
    90    for (int k=1; k<=n; k++)
     90   for (int k=1; k<=n; k=k+1)
    9191   {
    9292      ra = id*random(b,g,m);
     
    102102   A=randommat(2,3);
    103103   print(A);
    104 }               
     104}
    105105///////////////////////////////////////////////////////////////////////////////
    106106
    107107proc sparseid (int k, int u, list #)
    108108USAGE:   sparseid(k,u[,o,p,b]);  k,u,o,p,b integers
    109 RETURN:  ideal having k generators in each degree d, u<=d<=o, p percent of 
    110          terms in degree d are 0, the remaining have random coefficients 
     109RETURN:  ideal having k generators in each degree d, u<=d<=o, p percent of
     110         terms in degree d are 0, the remaining have random coefficients
    111111         in the interval [1,b], (default: o=u=d, p=75, b=30000)
    112112EXAMPLE: example sparseid; shows an example
     
    119119//------------------ use sparsemat for creation of sparseid -------------------
    120120   int ii; ideal i; intmat m;
    121    for ( ii=u; ii<=o; ii++)
    122    { 
     121   for ( ii=u; ii<=o; ii=ii+1)
     122   {
    123123       m = sparsemat(size(maxideal(ii)),k,p,b);
    124124       i = i+ideal(matrix(maxideal(ii))*m);
     
    131131   sparseid(3,4);"";
    132132   sparseid(2,2,5,90,9);
    133 }               
     133}
    134134///////////////////////////////////////////////////////////////////////////////
    135135
     
    153153   if( p<40 )
    154154   {
    155       for( ii=1; ii<=t; ii++ )
     155      for( ii=1; ii<=t; ii=ii+1 )
    156156      { r=( random(1,100)>p ); v[1,ii]=r*random(1,b); h=h+r; }
    157157   }
     
    173173example
    174174{ "EXAMPLE:"; echo = 2;
    175    sparsemat(5,5);
    176    sparsemat(5,5,95);
    177    sparsemat(5,5,5);
     175   sparsemat(5,5);"";
     176   sparsemat(5,5,95);"";
     177   sparsemat(5,5,5);"";
    178178   sparsemat(5,5,50,100);
    179 }               
     179}
    180180///////////////////////////////////////////////////////////////////////////////
    181181
     
    183183USAGE:   sparsepoly(u[,o,p,b]);  u,o,p,b integers
    184184RETURN:  poly having only terms in degree d, u<=d<=o, p percent of the terms
    185          in degree d are 0, the remaining have random coefficients in [1,b), 
     185         in degree d are 0, the remaining have random coefficients in [1,b),
    186186         (defaults: o=u=d, p=75, b=30000)
    187187EXAMPLE:  example sparsepoly; shows an example
     
    194194   int ii; poly f;
    195195//----------------- use sparseid for creation of sparsepoly -------------------
    196    for( ii=u; ii<=o; ii++ ) { f=f+sparseid(1,ii,ii,p,b)[1]; }
     196   for( ii=u; ii<=o; ii=ii+1 ) { f=f+sparseid(1,ii,ii,p,b)[1]; }
    197197   return(f);
    198198}
     
    202202   sparsepoly(5);"";
    203203   sparsepoly(3,5,90,9);
    204 }               
     204}
    205205///////////////////////////////////////////////////////////////////////////////
    206206
     
    222222   if( n<=m ) { min=n-1; M[n,n]=1; }
    223223   else { min=m; }
    224    for( ii=1; ii<=min; ii++ )
     224   for( ii=1; ii<=min; ii=ii+1 )
    225225   {
    226226      l=r+1; r=r+n-ii;
     
    231231example
    232232{ "EXAMPLE:"; echo = 2;
    233    sparsetriag(5,7);
    234    sparsetriag(7,5,90);
    235    sparsetriag(5,5,0);
     233   sparsetriag(5,7);"";
     234   sparsetriag(7,5,90);"";
     235   sparsetriag(5,5,0);"";
    236236   sparsetriag(5,5,50,100);
    237 }               
    238 ///////////////////////////////////////////////////////////////////////////////
     237}
     238///////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.