bugGNU Octave - Bugs: bug #45528, mapping: missing function roundn...

 
 

bug #45528: mapping: missing function roundn (implementation supplied)

Submitted by:  Markus Bergholz <markuman>
Submitted on:  Sat 11 Jul 2015 05:04:29 PM UTC  
 
Category: Octave Forge PackageSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Feature Request
Status: FixedAssigned to: Philip Nienhuis <philipnienhuis>
Originator Name: Open/Closed: Closed
Release: otherOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

(Jump to the original submission Jump to the original submission)

Sat 08 Aug 2015 08:11:49 PM UTC, comment #7:

@Ufos:
Can you be a bit more specific, please? I'm not sure what you mean to say, and if it relates to roundn() or core round(), or workarounds in old code relying on roundn.

Philip Nienhuis <philipnienhuis>
Project MemberIn charge of this item.
Sat 08 Aug 2015 01:40:36 PM UTC, comment #6:

I can't believe there's been more discussion, that the actual code required.

WORKAROUND:
a = 0.056787654
round_digit = 2
if exist('OCTAVE_VERSION', 'builtin') ~= 0;
a = a.*(10^(round_digit));
a = floor(a);
a = a.*(10^(-round_digit));
else
a = round(a, round_digit);
end

Ufos <ufos92>
Mon 13 Jul 2015 07:39:59 PM UTC, comment #5:

It's in a mapping-1.2.0 now on release tracker.

Thanks Markus for this contribution!

Philip Nienhuis <philipnienhuis>
Project MemberIn charge of this item.
Sun 12 Jul 2015 11:05:00 PM UTC, comment #4:

If a function is on a specific Matlab toolbox, then it should go in the matching Octave package. The idea of the packages is to be a drop-in replacement for the toolboxes, much like Octave core is for Matlab core.

That's where people will expect to find the function, even when the topic of the function is not directly related to that package subject.

But I agree that an improvement to core's round and have roundn wrap it is a better plan.

Carnë Draug <carandraug>
Project Member
Sun 12 Jul 2015 09:36:14 PM UTC, comment #3:

The mapping package release got a bit delayed, so maybe....

But even then I'm not sure if the mapping package is the right place for a fairly general function like roundn that has no direct relation with mapping other than that by some opaque and probably irreproducable process it ended up in a mapping toolbox.
I'm not against it, not at all, but we can do better than Matlab with respect to categorizing and assigning functions to packages. Maybe the miscellaneous package is a better home.
I'll ask our octave-forge guardian for his opinion (cc'd).

As to your second remark:
AFAICS it is especially Matlab that keeps old functions around, maybe related to that motive you gave. E.g., a while ago in old but still valid Matlab code I stumbled over "setstring" that turned out to be an ancient "char" predecessor. Octave doesn't even have it. At my work we have lots of 10-15 years old Matlab scripts that still run in 2015b containing more of such ancient functions.
Looks like TMW changed their policy - these days on their site I often see that function descriptions that used to show a warning "will be removed in a future Matlab release" now rather carry "not recommended".

Philip Nienhuis <philipnienhuis>
Project MemberIn charge of this item.
Sun 12 Jul 2015 06:54:36 PM UTC, comment #2:

"not recommended" is not "deprecated" (like depfun e.g.). But I don't know where mathworks makes the difference here.

However, imo to keep deprecated functions in Octave is a benefit. I bet many people don't update to a newer version of Matlab because their work may no longer run when functions have been removed. But the can change to Octave without abdominal pain.

I didn't noticed the difference in round(). But I agree, it'll be better to expand the core function in mapper.cc and wrap roundn around it.

Markus Bergholz <markuman>
Sun 12 Jul 2015 10:02:16 AM UTC, comment #1:

(this actually belongs on the patch tracker)

In
http://nl.mathworks.com/help/map/functionlist.html
there's no mention of "roundn".

However, in
http://nl.mathworks.com/help/map/ref/roundn.html
it says:
"roundn is not recommended. Use round instead."

...and below that there are some examples of rounding to the nearest power of 10.
Apparently roundn() is somewhat deprecated by Matlab as it has a better alternative.

Core Octave's round() doesn't have the options Matlab's round() has (see http://nl.mathworks.com/help/matlab/ref/round.html). That would imply a separate bug report / feature request to add that option to core Octave. As far as I'm concerned I'd rather have a roundn as a wrapper for a core Octave function.

So, what should we do with this roundn contribution?
While I'm not in favor of including deprecated functions even in octave-forge, it could be that code out there still relies on it.
Octave doesn't have an alternative yet.

BTW, yesterday I've uploaded mapping-1.2.0 to the package release tracker so this contribution comes just too late anyway.
No big deal, there are several other patches and contributions pending for the mapping package that all need polishing before they can be included, so roundn might be included in a next release.

Philip Nienhuis <philipnienhuis>
Project MemberIn charge of this item.
Sat 11 Jul 2015 05:04:29 PM UTC, original submission:

roundn() is part of the mapping toolbox in Matlab.

Neither I could not find it for Octave nor I know if it's related to a forge package or not.

Markus Bergholz <markuman>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #34426:  roundn.m added by markuman (2KiB - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by ufos92 (Posted a comment)
  • -unavailable- added by philipnienhuis
  • -unavailable- added by markuman (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 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 13 Jul 2015 07:39:59 PM UTCphilipnienhuisStatusNone=>Fixed
      Assigned toNone=>philipnienhuis
      Open/ClosedOpen=>Closed
    Sun 12 Jul 2015 11:05:00 PM UTCcarandraugRelease4.0.0=>other
    Sun 12 Jul 2015 09:36:14 PM UTCphilipnienhuisCarbon-Copy-=>Added carandraug
    Sat 11 Jul 2015 08:37:13 PM UTCcarandraugCategoryOctave Function=>Octave Forge Package
      SummaryMissing function roundn (implementation supplied)=>mapping: missing function roundn (implementation supplied)
    Sat 11 Jul 2015 05:04:29 PM UTCmarkumanAttached File-=>Added roundn.m, #34426

    Back to the top


    Powered by Savane 3.1-cleanup1