bugGNU Octave - Bugs: bug #41890, nchoosek(vector, 0) should return...

 
 

bug #41890: nchoosek(vector, 0) should return a 1x0 matrix instead of 0x0

Submitted by:  None
Submitted on:  Tue 18 Mar 2014 03:56:02 AM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Pedro AngeloOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.2.4
Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 03 Jun 2014 03:36:40 PM UTC, comment #4:

I added a built-in test to your patch to verify the new behavior, and to make sure something fails if someone accidently tries to revert the function to the old behavior. I also added your name to the list of Octave contributors which appears in the front of the manual. The changeset was committed to the development branch which will become the 4.2 release (http://hg.savannah.gnu.org/hgweb/octave/rev/1514f5337781). Thanks for the changeset.

Rik <rik5>
Project Administrator
Tue 18 Mar 2014 07:48:13 PM UTC, comment #3:

Submiting the same patch again, this time with mercurial.

(file #30942)

Pedro Angelo Medeiros Fonini <fonini>
Tue 18 Mar 2014 06:59:37 PM UTC, comment #2:

Submitting a patch, which does exactly what I said in the anonymous comment below.

Just for the record, I tested it, and matlab implements the correct behavior.

(file #30941)

Pedro Angelo Medeiros Fonini <fonini>
Tue 18 Mar 2014 04:42:15 AM UTC, comment #1:

This is just a matter of changing lines 83-84 in nchoosek.m from:

to:

Anonymous
Tue 18 Mar 2014 03:56:02 AM UTC, original submission:

If we have a vector `v' of length `n=length(v)', then the following inconsistency is observed

size(nchoosek(v, 0 ),1) != nchoosek(length(v), 0 )
size(nchoosek(v, 1 ),1) == nchoosek(length(v), 1 )
size(nchoosek(v, 2 ),1) == nchoosek(length(v), 2 )
...
size(nchoosek(v, N ),1) == nchoosek(length(v), N )

that is, for all values of K, the equality `size(nchoosek(v, K ),1) == nchoosek(length(v), K )' is valid, except for K==0.

This is taken from the nchoosek's help:

The resulting C has size `[nchoosek (length (N), K), K]'.

For the case K==0, the help is wrong; however, what really should be changed is the result of the function, not the help.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #30942:  bug41890.patch added by fonini (924B - text/x-patch - The same patch, but using hg.)
file #30941:  bug41890.patch added by fonini (371B - text/x-patch - change [] for zeros(1,0) in nchoosek.m)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by fonini (Updated the item)
  • -unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 03 Jun 2014 03:36:40 PM UTCrik5StatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Tue 18 Mar 2014 07:48:13 PM UTCfoniniAttached File-=>Added bug41890.patch, #30942
    Tue 18 Mar 2014 06:59:37 PM UTCfoniniAttached File-=>Added bug41890.patch, #30941

    Back to the top


    Powered by Savane 3.1-cleanup1