changeset 18828: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	Mon Jun 02 11:17:59 2014 -0700
+++ b/doc/interpreter/contributors.in	Tue Mar 18 16:42:45 2014 -0300
@@ -3,6 +3,7 @@
 Adam H. Aitkenhead
 Giles Anderson
 Joel Andersson
+Pedro Angelo
 Muthiah Annamalai
 Markus Appel
 Branden Archer
--- a/scripts/specfun/nchoosek.m	Mon Jun 02 11:17:59 2014 -0700
+++ b/scripts/specfun/nchoosek.m	Tue Mar 18 16:42:45 2014 -0300
@@ -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);