Changeset 4ff391 in git


Ignore:
Timestamp:
Mar 30, 2009, 8:36:35 PM (15 years ago)
Author:
Motsak Oleksandr <motsak@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
Children:
a9cdc23ba58cef8d67929bf916ec3db5a288899c
Parents:
6004f47987cad94bd0a8f07aac4035bb04fa0685
Message:
*motsak: sparseHomogIdeal


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/random.lib

    r6004f4 r4ff391  
    11//(GMG/BM, last modified 22.06.96)
    22///////////////////////////////////////////////////////////////////////////////
    3 version="$Id: random.lib,v 1.17 2006-07-20 15:19:35 Singular Exp $";
     3version="$Id: random.lib,v 1.18 2009-03-30 18:36:35 motsak Exp $";
    44category="General purpose";
    55info="
     
    1515 sparsepoly(u[,o,p,b]);  random sparse polynomial with terms of degree in [u,o]
    1616 sparsetriag(n,m[,.]);   nxm sparse lower-triag intmat with random coefficients
     17 sparseHomogIdeal(k,u,[,.]); ideal with k sparse homogeneous generators of degree in [u, o]
    1718 triagmatrix(n,m,o[,.]); nxm sparse lower-triag matrix of poly's of degree<=o
    1819 randomLast(b);          random transformation of the last variable
     
    149150   sparseid(3,0,4,90,9);
    150151}
     152
     153///////////////////////////////////////////////////////////////////////////////
     154proc sparseHomogIdeal (int k, int u, list #)
     155"USAGE:   sparseid(k,u[,o,p,b]);  k,u,o,p,b integers
     156RETURN:  ideal having k homogeneous generators, each of random degree in the
     157         interval [u,o], p percent of terms in degree d are 0, the remaining
     158         have random coefficients in the interval [1,b], (default: o=u, p=75,
     159         b=30000)
     160EXAMPLE: example sparseid; shows an example
     161"
     162{
     163//----------------------------- set defaults ----------------------------------
     164   if( size(#)>=3 ) { int o=#[1]; int p=#[2]; int b=#[3]; }
     165   if( size(#)==2 ) { int o=#[1]; int p=#[2]; int b=30000; }
     166   if( size(#)==1 ) { int o=#[1]; int p=75; int b=30000; }
     167   if( size(#)==0 ) { int o=u; int p=75; int b=30000; }
     168//------------------ use sparsemat for creation of sparseid -------------------
     169   int ii; ideal i; intmat m; ideal id;
     170
     171   for ( ii=k; ii>0; ii=ii-1)
     172   {
     173       id = maxideal(random(u, o)); // monomial basis of some degree
     174       m = sparsemat(size(id),1,p,b); // random coefficients       
     175       i[ii] = (matrix(id)*m)[1,1];
     176   }
     177   return(i);
     178}
     179example
     180{ "EXAMPLE:"; echo = 2;
     181   ring r = 0,(a,b,c,d),dp;
     182   sparseHomogIdeal(2,3);"";
     183   sparseHomogIdeal(3,0,4,90,9);
     184}
     185
     186
    151187///////////////////////////////////////////////////////////////////////////////
    152188
Note: See TracChangeset for help on using the changeset viewer.