Mercurial > hg > octave-nkf
diff scripts/sparse/sprandsym.m @ 13213:544304a09e42
Fix offbyones and typos in sprandsym.m
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Sun, 25 Sep 2011 02:35:55 -0500 |
parents | e81b93284605 |
children | 410de573089a |
line wrap: on
line diff
--- a/scripts/sparse/sprandsym.m +++ b/scripts/sparse/sprandsym.m @@ -66,7 +66,7 @@ offdiag = randperm (n*(n - 1)/2, m); ## Row index - i = lookup (cumsum (1:n), offdiag) + 2; + i = lookup (cumsum (0:n), offdiag - 1) + 1; ## Column index j = offdiag - (i - 1).*(i - 2)/2; @@ -125,7 +125,7 @@ d = [mod(k,2):2:min(n,k)-2]; m = (k - d)/2; q = (n - d).*(n - d - 1).*m ./ (d + 2)./(d + 1)./(a - m + 1); - c = [1 cumprod (q)]; + c = [1 cumprod(q)]; s = sum (c); p = c/s;