Changeset 6f2edc in git for Singular/LIB/random.lib
- Timestamp:
- Apr 28, 1997, 9:27:25 PM (27 years ago)
- Branches:
- (u'spielwiese', 'e7cc1ebecb61be8b9ca6c18016352af89940b21a')
- Children:
- 8c5a578cc8481c8a133a58030c4c4c8227d82bb1
- Parents:
- 6d09c564c80f079b501f7187cf6984d040603849
- 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:26obachman Exp $1 // $Id: random.lib,v 1.2 1997-04-28 19:27:23 obachman Exp $ 2 2 //system("random",787422842); 3 //(GMG +BM)3 //(GMG/BM, last modified 22.06.96) 4 4 /////////////////////////////////////////////////////////////////////////////// 5 5 … … 20 20 21 21 proc genericid (id, list #) 22 USAGE: genericid(id,[,p,b]); id ideal/module, p,b integers23 RETURN: system of generators of id which are generic, sparse, tri gonal linear22 USAGE: genericid(id,[,p,b]); id ideal/module, k,p,b integers 23 RETURN: system of generators of id which are generic, sparse, triagonal linear 24 24 combinations of given generators with coefficients in [1,b] and 25 25 sparsety p percent, bigger p being sparser (default: p=75, b=30000) … … 32 32 if( size(#)==0 ) { int p=75; int b=30000; } 33 33 //---------------- use sparsetriag for creation of genericid ------------------ 34 def i = simplify(id,10); 34 def i = simplify(id,10); 35 35 i = i*sparsetriag(ncols(i),ncols(i),p,b); 36 36 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 } 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]; 44 44 print(genericid(m)); 45 45 } … … 59 59 if( size(#)==0 ) { int k=size(id); int b=30000; } 60 60 //--------------------------- create randomid --------------------------------- 61 def i = id; 61 def i = id; 62 62 i = matrix(id)*random(b,ncols(id),k); 63 63 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 } 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]; 70 70 show(randomid(m)); 71 71 } … … 88 88 int g=ncols(id); 89 89 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) 91 91 { 92 92 ra = id*random(b,g,m); … … 102 102 A=randommat(2,3); 103 103 print(A); 104 } 104 } 105 105 /////////////////////////////////////////////////////////////////////////////// 106 106 107 107 proc sparseid (int k, int u, list #) 108 108 USAGE: 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 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 111 111 in the interval [1,b], (default: o=u=d, p=75, b=30000) 112 112 EXAMPLE: example sparseid; shows an example … … 119 119 //------------------ use sparsemat for creation of sparseid ------------------- 120 120 int ii; ideal i; intmat m; 121 for ( ii=u; ii<=o; ii ++)122 { 121 for ( ii=u; ii<=o; ii=ii+1) 122 { 123 123 m = sparsemat(size(maxideal(ii)),k,p,b); 124 124 i = i+ideal(matrix(maxideal(ii))*m); … … 131 131 sparseid(3,4);""; 132 132 sparseid(2,2,5,90,9); 133 } 133 } 134 134 /////////////////////////////////////////////////////////////////////////////// 135 135 … … 153 153 if( p<40 ) 154 154 { 155 for( ii=1; ii<=t; ii ++)155 for( ii=1; ii<=t; ii=ii+1 ) 156 156 { r=( random(1,100)>p ); v[1,ii]=r*random(1,b); h=h+r; } 157 157 } … … 173 173 example 174 174 { "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);""; 178 178 sparsemat(5,5,50,100); 179 } 179 } 180 180 /////////////////////////////////////////////////////////////////////////////// 181 181 … … 183 183 USAGE: sparsepoly(u[,o,p,b]); u,o,p,b integers 184 184 RETURN: 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), 186 186 (defaults: o=u=d, p=75, b=30000) 187 187 EXAMPLE: example sparsepoly; shows an example … … 194 194 int ii; poly f; 195 195 //----------------- 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]; } 197 197 return(f); 198 198 } … … 202 202 sparsepoly(5);""; 203 203 sparsepoly(3,5,90,9); 204 } 204 } 205 205 /////////////////////////////////////////////////////////////////////////////// 206 206 … … 222 222 if( n<=m ) { min=n-1; M[n,n]=1; } 223 223 else { min=m; } 224 for( ii=1; ii<=min; ii ++)224 for( ii=1; ii<=min; ii=ii+1 ) 225 225 { 226 226 l=r+1; r=r+n-ii; … … 231 231 example 232 232 { "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);""; 236 236 sparsetriag(5,5,50,100); 237 } 238 /////////////////////////////////////////////////////////////////////////////// 237 } 238 ///////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.