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

D.2.9.6 sparsemat

Procedure from library random.lib (see random_lib).

Usage:
sparsemat(n,m[,p,b]); n,m,p,b integers

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

Example:
 
LIB "random.lib";
sparsemat(5,5);"";
==> 0,0,0,0,0,
==> 0,1,0,0,1,
==> 0,0,0,1,0,
==> 0,1,0,0,0,
==> 0,1,0,1,1 
==> 
sparsemat(5,5,95);"";
==> 1,0,0,0,0,
==> 0,0,0,0,0,
==> 0,0,0,0,0,
==> 0,0,0,0,0,
==> 0,0,0,1,0 
==> 
sparsemat(5,5,5);"";
==> 1,1,1,1,1,
==> 1,1,1,1,1,
==> 1,1,1,1,1,
==> 1,0,1,1,1,
==> 1,1,1,1,0 
==> 
sparsemat(5,5,50,100);
==> 0,17,24,80,0,
==> 0,13,30,45,0,
==> 19,0,0,0,0,
==> 93,0,23,0,69,
==> 0,88,44,31,0