bugGNU Octave - Bugs: bug #46598, unable to get single eps when...

 
 

bug #46598: unable to get single eps when specifying class

Submitter:  Carnë Draug <carandraug>
Submitted:  Thu 03 Dec 2015 01:04:40 PM UTC
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Fri 04 Dec 2015 05:55:27 PM UTC, comment #3: 

> As for this bug, what would follow the principle of least surprise? Would it be to remove functionality and adopt the Matlab API for this function? Would it be to remove the 'eps (..., CLASS)' functionality and just support 'eps (CLASS)'


Least surprise is subjective. I'd argue that in this case, it would be expect the user to specify X.  At the moment, the problem arises because when the user calls "eps (M, N, K)", we do not know if M is the number of rows or the X argument.  Since we can't make an educated guess we should not be assuming a default.  Therefore I'd propose the following as the least surprise:

eps ()         => eps (1)
eps (CLASS)    => eps (1, CLASS)
eps (X, CLASS) => distance between X and next value in CLASS
eps (M, N, K)  => repmat (eps (M), N, K)
eps (M, N, K, CLASS) => repmat (eps (M, CLASS), N, K)

Carnë Draug <carandraug>
Project Member
Fri 04 Dec 2015 05:45:03 PM UTC, comment #2: 

I hate Matlab's desire to keep changing the API of perfectly good functions, especially when there is so little to be gained.

The syntax

Inf (N, M, K, ..., 'like', p)

can in most circumstances be replaced by

Inf (N, M, K, ..., class (p))

It's even the same number of characters so you're not saving on any typing.

As for this bug, what would follow the principle of least surprise?  Would it be to remove functionality and adopt the Matlab API for this function?  Would it be to remove the 'eps (..., CLASS)' functionality and just support 'eps (CLASS)'

Rik <rik5>
Project Administrator
Thu 03 Dec 2015 04:03:57 PM UTC, comment #1: 

Here's what Matlab is documented to do:

  http://www.mathworks.com/help/matlab/ref/eps.html

Maybe we should just match this behavior and nothing more?

I think I chose to also allow dimensions to be specified so that the definition of eps would be consistent with Inf and NaN, but then I missed this ambiguity.

http://www.mathworks.com/help/matlab/ref/inf.html?searchHighlight=inf

Oh, hey, now I notice that they have added even more baggage to the Inf and NaN functions (the "like" parameter, for example) so we are not compatible there now either.

TMW sure does seem to have a love affair with the overloaded function definitions...

John W. Eaton <jwe>
Project Administrator
Thu 03 Dec 2015 01:04:40 PM UTC, original submission:  

The eps function has the following interface:

 -- Built-in Function: eps
 -- Built-in Function: eps (X)
 -- Built-in Function: eps (N, M)
 -- Built-in Function: eps (N, M, K, ...)
 -- Built-in Function: eps (..., CLASS)

However, it is not possible to use "eps (X, CLASS)" because it thinks we are calling "eps (N, CLASS)"

Example:

octave> eps (5)
ans =    8.8818e-16
octave> eps (5, "double")
ans =

   2.2204e-16   2.2204e-16   2.2204e-16   2.2204e-16   2.2204e-16
   2.2204e-16   2.2204e-16   2.2204e-16   2.2204e-16   2.2204e-16
   2.2204e-16   2.2204e-16   2.2204e-16   2.2204e-16   2.2204e-16
   2.2204e-16   2.2204e-16   2.2204e-16   2.2204e-16   2.2204e-16
   2.2204e-16   2.2204e-16   2.2204e-16   2.2204e-16   2.2204e-16

octave> eps (5, "single")
ans =

   1.1921e-07   1.1921e-07   1.1921e-07   1.1921e-07   1.1921e-07
   1.1921e-07   1.1921e-07   1.1921e-07   1.1921e-07   1.1921e-07
   1.1921e-07   1.1921e-07   1.1921e-07   1.1921e-07   1.1921e-07
   1.1921e-07   1.1921e-07   1.1921e-07   1.1921e-07   1.1921e-07
   1.1921e-07   1.1921e-07   1.1921e-07   1.1921e-07   1.1921e-07

So in order to actually get 'eps (5, "single")', one needs to do

octave> eps (single (5))
ans =    4.7684e-07

I'm not sure if this should be a mistake of the documentation or if we should change the function to always require the X argument.  Also, the documentation does not make it obvious that 'eps (CLASS)' is valid (but I can see how the ellipsis in 'eps (..., CLASS)' includes the just eps()).

Carnë Draug <carandraug>
Project Member

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by carandraug (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.

     

     

     

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-12-04 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.9