@c ---content LibInfo---
@comment This file was generated by doc2tex.pl from d2t_singular/random_lib.doc
@comment DO NOT EDIT DIRECTLY, BUT EDIT d2t_singular/random_lib.doc INSTEAD
@c library version: (1.16.2.1,2002/02/20)
@c library file: ../Singular/LIB/random.lib
@cindex random.lib
@cindex random_lib
@table @asis
@item @strong{Library:}
random.lib
@item @strong{Purpose:}
    Creating Random and Sparse Matrices, Ideals, Polys

@end table

@strong{Procedures:}
@menu
* genericid:: generic sparse linear combinations of generators of i
* randomid:: random linear combinations of generators of id
* randommat:: nxm matrix of random linear combinations of id
* sparseid:: ideal of k random sparse poly's of degree d [u<=d<=o]
* sparsematrix:: nxm sparse matrix of polynomials of degree<=o
* sparsemat:: nxm sparse integer matrix with random coefficients
* sparsepoly:: random sparse polynomial with terms of degree in [u,o]
* sparsetriag:: nxm sparse lower-triag intmat with random coefficients
* triagmatrix:: nxm sparse lower-triag matrix of poly's of degree<=o
* randomLast:: random transformation of the last variable
* randomBinomial:: binomial ideal, k random generators of degree >=u
@end menu
@c ---end content LibInfo---

@c ------------------- genericid -------------
@node genericid, randomid,, random_lib
@subsubsection genericid
@cindex genericid
@c ---content genericid---
Procedure from library @code{random.lib} (@pxref{random_lib}).

@table @asis
@item @strong{Usage:}
genericid(id,[,p,b]); id ideal/module, k,p,b integers

@item @strong{Return:}
system of generators of id which are generic, sparse, triagonal linear
combinations of given generators with coefficients in [1,b] and
sparseness p percent, bigger p being sparser (default: p=75, b=30000)

@item @strong{Note:}
For performance reasons try small bound b in characteristic 0

@end table
@strong{Example:}
@smallexample
@c computed example genericid d2t_singular/random_lib.doc:52 
LIB "random.lib";
ring r=0,(t,x,y,z),ds;
ideal i= x3+y4,z4+yx,t+x+y+z;
genericid(i,0,10);
@expansion{} _[1]=3t+3x+3y+3z+2xy+x3+y4+2z4
@expansion{} _[2]=4t+4x+4y+4z+xy+z4
@expansion{} _[3]=t+x+y+z
module m=[x,0,0,0],[0,y2,0,0],[0,0,z3,0],[0,0,0,t4];
print(genericid(m));
@expansion{} x,      0,      0, 0,
@expansion{} 17904y2,y2,     0, 0,
@expansion{} 0,      24170z3,z3,0,
@expansion{} 0,      0,      0, t4
@c end example genericid d2t_singular/random_lib.doc:52
@end smallexample
@c ---end content genericid---

@c ------------------- randomid -------------
@node randomid, randommat, genericid, random_lib
@subsubsection randomid
@cindex randomid
@c ---content randomid---
Procedure from library @code{random.lib} (@pxref{random_lib}).

@table @asis
@item @strong{Usage:}
randomid(id,[k,b]); id ideal/module, b,k integers

@item @strong{Return:}
ideal/module having k generators which are random linear combinations
of generators of id with coefficients in the interval [-b,b]
(default: b=30000, k=size(id))

@item @strong{Note:}
For performance reasons try small bound b in characteristic 0

@end table
@strong{Example:}
@smallexample
@c computed example randomid d2t_singular/random_lib.doc:85 
LIB "random.lib";
ring r=0,(x,y,z),dp;
randomid(maxideal(2),2,9);
@expansion{} _[1]=-5x2-9xy+6y2-8xz-8yz+4z2
@expansion{} _[2]=-9xy+2y2+xz+yz-z2
module m=[x,0,1],[0,y2,0],[y,0,z3];
show(randomid(m));
@expansion{} // module, 3 generator(s)
@expansion{} [1369x-11685y,-4481y2,-11685z3+1369]
@expansion{} [-642x-13756y,25342y2,-13756z3-642]
@expansion{} [2536x-6355y,8285y2,-6355z3+2536]
@c end example randomid d2t_singular/random_lib.doc:85
@end smallexample
@c ---end content randomid---

@c ------------------- randommat -------------
@node randommat, sparseid, randomid, random_lib
@subsubsection randommat
@cindex randommat
@c ---content randommat---
Procedure from library @code{random.lib} (@pxref{random_lib}).

@table @asis
@item @strong{Usage:}
randommat(n,m[,id,b]); n,m,b integers, id ideal

@item @strong{Return:}
nxm matrix, entries are random linear combinations of elements
of id and coefficients in [-b,b]
@*[default: (id,b) = (maxideal(1),30000)]

@item @strong{Note:}
For performance reasons try small bound b in char 0

@end table
@strong{Example:}
@smallexample
@c computed example randommat d2t_singular/random_lib.doc:117 
LIB "random.lib";
ring r=0,(x,y,z),dp;
matrix A=randommat(3,3,maxideal(2),9);
print(A);
@expansion{} 9x2-2xy-8y2-9xz+yz+4z2, 9x2-4xy+y2-5xz+6yz-z2,   8x2+xy-9y2+2yz-8z2,    
@expansion{} -x2+5xy-8y2-7xz+4yz-3z2,x2+xy-4y2-xz+5z2,        5x2-8xy+8y2+6xz+yz+7z2,
@expansion{} 4x2-5xy-6y2-4yz-5z2,    -4x2-6xy-4y2-8xz+3yz+5z2,2x2+3xy+y2+4xz-3yz+2z2 
A=randommat(2,3);
print(A);
@expansion{} 15276x+9897y+7526z,  6495x-24178y+11295z,-5745x-14754y+15979z,
@expansion{} 20788x-28366y-20283z,24911x-10978y+3341z,12412x+11216y+15344z 
@c end example randommat d2t_singular/random_lib.doc:117
@end smallexample
@c ---end content randommat---

@c ------------------- sparseid -------------
@node sparseid, sparsematrix, randommat, random_lib
@subsubsection sparseid
@cindex sparseid
@c ---content sparseid---
Procedure from library @code{random.lib} (@pxref{random_lib}).

@table @asis
@item @strong{Usage:}
sparseid(k,u[,o,p,b]); k,u,o,p,b integers

@item @strong{Return:}
ideal having k generators, each of degree d, u<=d<=o, p percent of
terms in degree d are 0, the remaining have random coefficients
in the interval [1,b], (default: o=u=d, p=75, b=30000)

@end table
@strong{Example:}
@smallexample
@c computed example sparseid d2t_singular/random_lib.doc:147 
LIB "random.lib";
ring r = 0,(a,b,c,d),ds;
sparseid(2,3);"";
@expansion{} _[1]=12773a3+24263a2c+20030abc+17904b2c+26359c3
@expansion{} _[2]=24004a3+6204b2c+24170bc2+19505c2d+21962bd2
@expansion{} 
sparseid(3,0,4,90,9);
@expansion{} _[1]=1+4a2+8b2c+3c3+4a3b+4a2b2+5abc2+3ac3
@expansion{} _[2]=a+a2+7ab2+6a2c+3c3+5a3b+9ab3+2c4+3c3d+8ad3
@expansion{} _[3]=5a+ab+2ac2+2b3c+8abcd
@c end example sparseid d2t_singular/random_lib.doc:147
@end smallexample
@c ---end content sparseid---

@c ------------------- sparsematrix -------------
@node sparsematrix, sparsemat, sparseid, random_lib
@subsubsection sparsematrix
@cindex sparsematrix
@c ---content sparsematrix---
Procedure from library @code{random.lib} (@pxref{random_lib}).

@table @asis
@item @strong{Usage:}
sparsematrix(n,m,o[,u,pe,pp,b]); n,m,o,u,pe,pp,b integers

@item @strong{Return:}
nxm matrix, about pe percent of the entries are 0, the remaining
are random polynomials of degree d, u<=d<=o, with pp percent of
the terms being 0, the remaining have random coefficients
in the interval [1,b] [default: (pe,u,pp,b) = (0,50,75,100)]

@end table
@strong{Example:}
@smallexample
@c computed example sparsematrix d2t_singular/random_lib.doc:176 
LIB "random.lib";
ring r = 0,(a,b,c,d),dp;
// sparse matrix of sparse polys of degree <=2:
print(sparsematrix(3,4,2));"";
@expansion{} 14ab+20bc+79cd+30b,    32a2+97bc+5b,      0,             0,
@expansion{} 0,                     0,                 6c2+16b+64c+76,0,
@expansion{} 17a2+30ab+94bc+19b+45d,88a2+44bc+13d2+31a,59ac,          0 
@expansion{} 
// dense matrix of sparse linear forms:
print(sparsematrix(3,3,1,1,0,55,9));
@expansion{} 9b+7c+8d,9b+9d,5a,   
@expansion{} 7c+d,    a+6b, 2b+2d,
@expansion{} 9a+5b+9c,2a+9d,2d    
@c end example sparsematrix d2t_singular/random_lib.doc:176
@end smallexample
@c ---end content sparsematrix---

@c ------------------- sparsemat -------------
@node sparsemat, sparsepoly, sparsematrix, random_lib
@subsubsection sparsemat
@cindex sparsemat
@c ---content sparsemat---
Procedure from library @code{random.lib} (@pxref{random_lib}).

@table @asis
@item @strong{Usage:}
sparsemat(n,m[,p,b]); n,m,p,b integers

@item @strong{Return:}
nxm integer matrix, p percent of the entries are 0, the remaining
are random coefficients >=1 and <= b; [defaults: (p,b) = (75,1)]

@end table
@strong{Example:}
@smallexample
@c computed example sparsemat d2t_singular/random_lib.doc:205 
LIB "random.lib";
sparsemat(5,5);"";
@expansion{} 0,0,0,0,0,
@expansion{} 0,1,0,0,1,
@expansion{} 0,0,0,1,0,
@expansion{} 0,1,0,0,0,
@expansion{} 0,1,0,1,1 
@expansion{} 
sparsemat(5,5,95);"";
@expansion{} 1,0,0,0,0,
@expansion{} 0,0,0,0,0,
@expansion{} 0,0,0,0,0,
@expansion{} 0,0,0,0,0,
@expansion{} 0,0,0,1,0 
@expansion{} 
sparsemat(5,5,5);"";
@expansion{} 1,1,1,1,1,
@expansion{} 1,1,1,1,1,
@expansion{} 1,1,1,1,1,
@expansion{} 1,0,1,1,1,
@expansion{} 1,1,1,1,0 
@expansion{} 
sparsemat(5,5,50,100);
@expansion{} 0,17,24,80,0,
@expansion{} 0,13,30,45,0,
@expansion{} 19,0,0,0,0,
@expansion{} 93,0,23,0,69,
@expansion{} 0,88,44,31,0 
@c end example sparsemat d2t_singular/random_lib.doc:205
@end smallexample
@c ---end content sparsemat---

@c ------------------- sparsepoly -------------
@node sparsepoly, sparsetriag, sparsemat, random_lib
@subsubsection sparsepoly
@cindex sparsepoly
@c ---content sparsepoly---
Procedure from library @code{random.lib} (@pxref{random_lib}).

@table @asis
@item @strong{Usage:}
sparsepoly(u[,o,p,b]); u,o,p,b integers

@item @strong{Return:}
poly having only terms in degree d, u<=d<=o, p percent of the terms
in degree d are 0, the remaining have random coefficients in [1,b),
(defaults: o=u=d, p=75, b=30000)

@end table
@strong{Example:}
@smallexample
@c computed example sparsepoly d2t_singular/random_lib.doc:234 
LIB "random.lib";
ring r=0,(x,y,z),dp;
sparsepoly(5);"";
@expansion{} 24263xy4+24170x4z+21962x3yz+26642xy3z+5664xy2z2+17904xz4
@expansion{} 
sparsepoly(3,5,90,9);
@expansion{} 8x3z2+2y3z2+3xyz3+2xy3+yz3+xy2
@c end example sparsepoly d2t_singular/random_lib.doc:234
@end smallexample
@c ---end content sparsepoly---

@c ------------------- sparsetriag -------------
@node sparsetriag, triagmatrix, sparsepoly, random_lib
@subsubsection sparsetriag
@cindex sparsetriag
@c ---content sparsetriag---
Procedure from library @code{random.lib} (@pxref{random_lib}).

@table @asis
@item @strong{Usage:}
sparsetriag(n,m[,p,b]); n,m,p,b integers

@item @strong{Return:}
nxm lower triagonal integer matrix, diagonal entries equal to 1, about
p percent of lower diagonal entries are 0, the remaining are random
integers >=1 and <= b; [defaults: (p,b) = (75,1)]

@end table
@strong{Example:}
@smallexample
@c computed example sparsetriag d2t_singular/random_lib.doc:262 
LIB "random.lib";
sparsetriag(5,7);"";
@expansion{} 1,0,0,0,0,0,0,
@expansion{} 0,1,0,0,0,0,0,
@expansion{} 0,1,1,0,0,0,0,
@expansion{} 0,0,0,1,0,0,0,
@expansion{} 1,1,0,0,1,0,0 
@expansion{} 
sparsetriag(7,5,90);"";
@expansion{} 1,0,0,0,0,
@expansion{} 0,1,0,0,0,
@expansion{} 0,1,1,0,0,
@expansion{} 0,0,0,1,0,
@expansion{} 0,0,0,0,1,
@expansion{} 0,0,0,1,0,
@expansion{} 0,1,0,0,0 
@expansion{} 
sparsetriag(5,5,0);"";
@expansion{} 1,0,0,0,0,
@expansion{} 1,1,0,0,0,
@expansion{} 1,1,1,0,0,
@expansion{} 1,1,1,1,0,
@expansion{} 1,1,1,1,1 
@expansion{} 
sparsetriag(5,5,50,100);
@expansion{} 1,0,0,0,0,
@expansion{} 73,1,0,0,0,
@expansion{} 0,79,1,0,0,
@expansion{} 14,0,0,1,0,
@expansion{} 0,48,23,0,1 
@c end example sparsetriag d2t_singular/random_lib.doc:262
@end smallexample
@c ---end content sparsetriag---

@c ------------------- triagmatrix -------------
@node triagmatrix, randomLast, sparsetriag, random_lib
@subsubsection triagmatrix
@cindex triagmatrix
@c ---content triagmatrix---
Procedure from library @code{random.lib} (@pxref{random_lib}).

@table @asis
@item @strong{Usage:}
triagmatrix(n,m,o[,u,pe,pp,b]); n,m,o,u,pe,pp,b integers

@item @strong{Return:}
nxm lower triagonal matrix, diagonal entries equal to 1, about
p percent of lower diagonal entries are 0, the remaining
are random polynomials of degree d, u<=d<=o, with pp percent of
the terms being 0, the remaining have random coefficients
in the interval [1,b] [default: (pe,u,pp,b) = (0,50,75,100)]

@end table
@strong{Example:}
@smallexample
@c computed example triagmatrix d2t_singular/random_lib.doc:293 
LIB "random.lib";
ring r = 0,(a,b,c,d),dp;
// sparse triagonal matrix of sparse polys of degree <=2:
print(triagmatrix(3,4,2));"";
@expansion{} 1,                                 0,0,0,
@expansion{} 52ac+54cd+14c,                     1,0,0,
@expansion{} 17a2+19b2+45ac+94bc+50b+87c+54d+21,0,1,0 
@expansion{} 
// dense triagonal matrix of sparse linear forms:
print(triagmatrix(3,3,1,1,0,55,9));
@expansion{} 1,       0,    0,
@expansion{} 7a+8d,   1,    0,
@expansion{} 9b+7c+4d,7b+9d,1 
@c end example triagmatrix d2t_singular/random_lib.doc:293
@end smallexample
@c ---end content triagmatrix---

@c ------------------- randomLast -------------
@node randomLast, randomBinomial, triagmatrix, random_lib
@subsubsection randomLast
@cindex randomLast
@c ---content randomLast---
Procedure from library @code{random.lib} (@pxref{random_lib}).

@table @asis
@item @strong{Usage:}
randomLast(b); b int

@item @strong{Return:}
ideal = maxideal(1), but the last variable is exchanged by a random
linear combination of all variables, with coefficients in the
interval [-b,b].

@end table
@strong{Example:}
@smallexample
@c computed example randomLast d2t_singular/random_lib.doc:323 
LIB "random.lib";
ring  r = 0,(x,y,z),lp;
ideal i = randomLast(10);
i;
@expansion{} i[1]=x
@expansion{} i[2]=y
@expansion{} i[3]=-x+z
@c end example randomLast d2t_singular/random_lib.doc:323
@end smallexample
@c ---end content randomLast---

@c ------------------- randomBinomial -------------
@node randomBinomial,, randomLast, random_lib
@subsubsection randomBinomial
@cindex randomBinomial
@c ---content randomBinomial---
Procedure from library @code{random.lib} (@pxref{random_lib}).

@table @asis
@item @strong{Usage:}
randomBinomial(k,u[,o,b]); k,u,o,b integers

@item @strong{Return:}
binomial ideal, k homogeneous generators of degree d, u<=d<=o, with
randomly chosen monomials and coefficients in the interval [-b,b]
(default: u=o, b=10).

@end table
@strong{Example:}
@smallexample
@c computed example randomBinomial d2t_singular/random_lib.doc:351 
LIB "random.lib";
ring  r = 0,(x,y,z),lp;
ideal i = randomBinomial(4,5,6);
i;
@expansion{} i[1]=-x4z-xz4
@expansion{} i[2]=8x2y3+8xy3z
@expansion{} i[3]=-4x2y2z2-4xy5
@expansion{} i[4]=5x3yz2+5xz5
@c end example randomBinomial d2t_singular/random_lib.doc:351
@end smallexample
@c ---end content randomBinomial---
