patchGNU Octave - Patches: patch #8248, In (element-wise) power op....


patch #8248: In (element-wise) power op. functions, do range check before casting to int.

Submitted by:  Philipp Kutin <pkutin>
Submitted on:  Thu 28 Nov 2013 11:02:12 AM UTC  
Category: Core : otherPriority: 5 - Normal
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open

Add a New Comment(Rich Markup)

You are not logged in

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


Thu 28 Nov 2013 11:02:12 AM UTC, original submission:
  • lo-mappers.h: add two "fits-into-int" predicates, one symmetric

[INT_MIN+1, INT_MAX], the other "regular" [INT_MIN, INT_MAX].

  •, use them where appropriate.


As discussed in


- Cases where xisint() was used were not touched as they are already correct (but may be a little too strict). This is for ease of review, plus my understanding is that the interpreter has now to be kept in sync with the JIT compiler. Thus, no well-defined behavior should have been changed.
- I only tested an Octave-default build without the JIT compiler, as that one gave build errors for an LLVM from SVN (is Octave following a particular LLVM build, such as one available with a distro's package management?)
- The predicates use ceil() as that one is declared inline (see below)

Additional attachments:

- xpow_tests.m: an annotated M script containing Sanitizer output before the cleanup and some other annotations
- a very simple C++ test file for timing the predicates when run in a loop. Results: inlining seems to give a noticeable speedup (hence ceil()), my versions compile to somewhat shorter code.

xpow_test.m also shows something curious: running
a = -single([1,2;3,4]); b=single([1 1; 1 2^32]); a.^b
calls the
(const FloatNDArray& a, const FloatNDArray& b)
overload, not the FloatMatrix one. Not a big deal I guess, since the former is more general, but maybe noteworthy.

Philipp Kutin <pkutin>


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

Attach File(s):

Attached Files
file #29725:  pow-range-checks.patch added by pkutin (7KiB - text/x-patch)
file #29726: added by pkutin (2KiB - text/x-c++src)
file #29727:  xpow_tests.m added by pkutin (6KiB - application/vnd.wolfram.mathematica.package)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by lachlan (Updated the item)
  • -unavailable- added by pkutin (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 logged-in users 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
    Thu 07 Jul 2016 11:21:13 PM UTClachlanCategoryNone=>Core : other
    Thu 28 Nov 2013 11:02:12 AM UTCpkutinAttached File-=>Added pow-range-checks.patch, #29725
      Attached File-=>Added, #29726
      Attached File-=>Added xpow_tests.m, #29727

    Back to the top

    Powered by Savane 3.1-cleanup1