[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #61565] nchoosek broken for integer inputs
From: |
Arun Giridhar |
Subject: |
[Octave-bug-tracker] [bug #61565] nchoosek broken for integer inputs |
Date: |
Fri, 26 Nov 2021 12:15:22 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0 |
Follow-up Comment #3, bug #61565 (project octave):
@OP, thank you for reporting this.
@jwe: Independent of the integer ranges in bug #61132, nchoosek can use the
freedom to mix and match types like this:
octave:1> nchoosek (uint8 (10), uint8 (5))
ans = 252
octave:2> nchoosek (uint8 (10), uint16 (5))
ans = 252
octave:3> nchoosek (uint8 (10), uint64 (5))
ans = 252
octave:4> nchoosek (uint8 (10), int64 (5))
ans = 252
octave:5> nchoosek (int8 (10), int64 (5))
ans = 252
This is not currently possible, with errors like this, which will persist even
if the integer range behavior is changed:
octave:1> nchoosek (int8 (10), int64 (5))
error: binary operator '-' not implemented for 'int8 scalar' by 'int64 scalar'
operations
error: called from
nchoosek at line 119 column 7
I have attached a small patch for nchoosek, with a BIST. It converts both v
and k to double for the binomial calculation. This allows for calling it with
all combinations of integers and floating points like the above, also solving
OP's problem. Please review and edit as required.
(file #52354)
_______________________________________________________
Additional Item Attachment:
File name: nchoosek.patch Size:0 KB
<https://file.savannah.gnu.org/file/nchoosek.patch?file_id=52354>
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?61565>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/