Mercurial > hg > octave-nkf
changeset 18983:1514f5337781
nchoosek.m: nchoosek(N,0) now returns [](1x0) when N is a vector (bug #41890).
* nchoosek.m: The help message for nchoosek specifies that if N is a vector,
then the number of rows of nchoosek(N,K) must be nchoosek(length(N),K), but the
previous implementation was returning a matrix with 0 rows when K==0.
Add %!test for new behavior.
* contributors.in: Add Pedro Angelo to list of Octave contributors.
author | Pedro Angelo <fonini@poli.ufrj.br> |
---|---|
date | Tue, 18 Mar 2014 16:42:45 -0300 |
parents | 03c2671493f9 |
children | dd57ca9ef7e4 |
files | doc/interpreter/contributors.in scripts/specfun/nchoosek.m |
diffstat | 2 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/contributors.in +++ b/doc/interpreter/contributors.in @@ -3,6 +3,7 @@ Adam H. Aitkenhead Giles Anderson Joel Andersson +Pedro Angelo Muthiah Annamalai Markus Appel Branden Archer
--- a/scripts/specfun/nchoosek.m +++ b/scripts/specfun/nchoosek.m @@ -109,7 +109,7 @@ warning ("nchoosek", "nchoosek: possible loss of precision"); endif elseif (k == 0) - A = []; + A = zeros (1,0); elseif (k == 1) A = v(:); elseif (k == n) @@ -142,6 +142,7 @@ %!assert (nchoosek (80,10), bincoeff (80,10)) %!assert (nchoosek (1:5,3), [1:3;1,2,4;1,2,5;1,3,4;1,3,5;1,4,5;2:4;2,3,5;2,4,5;3:5]) +%!assert (size (nchoosek (1:5,0)), [1 0]) %% Test input validation %!warning nchoosek (100,45);