Home Online Manual
Top
Back: sparseid
Forward: sparsemat
FastBack:
FastForward:
Up: random_lib
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

D.2.9.5 sparsematrix

Procedure from library random.lib (see random_lib).

Usage:
sparsematrix(n,m,o[,u,pe,pp,b]); n,m,o,u,pe,pp,b integers

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)]

Example:
 
LIB "random.lib";
ring r = 0,(a,b,c,d),dp;
// sparse matrix of sparse polys of degree <=2:
print(sparsematrix(3,4,2));"";
==> 17a2+30ab+94bc+19b+45d,88a2+44bc+13d2+31a,0,                           0,
==> 0,                     0,                 6c2+16b+64c+76,              0,
==> 14ab+20bc+79cd+30b,    32a2+97bc+5b,      23bc+73c2+ad+48cd+73b+59d+25,0 
==> 
// dense matrix of sparse linear forms:
print(sparsematrix(3,3,1,1,0,55,9));
==> 9a+5b+9c,2a+9d,2d,   
==> 7c+d,    a+6b, 2b+2d,
==> 9b+7c+8d,9b+9d,5a