octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #61300] integer range might exceed upper limit


From: Arun Giridhar
Subject: [Octave-bug-tracker] [bug #61300] integer range might exceed upper limit
Date: Mon, 29 Nov 2021 11:23:09 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0

Follow-up Comment #31, bug #61300 (project octave):

@Markus: Thank you for rearranging the BISTs in range.tst. They are much more
compact now.

Re primes.m, since Octave's generation of primes is limited to all primes less
than a given input, limiting it to flintmax is not a problem at all since
memory and time will preclude outputs that big. If it were a different case,
like "generate all primes from A to B, where A and B can be around 1e17" then
it would not work but Octave has no plans for such a function (nor Matlab).
Typically for high arbitrary ranges, such as (int64 (10)^17 + (1:100)),
isprime() is a better function. For more serious applications involving prime
numbers in general, I use the external tool primesieve
(https://github.com/kimwalisch/primesieve) which uses very complicated sieves
with heavy CPU-specific optimization. That is outside the scope of Octave
though.

Performance using integer ranges inside primes is about half the speed of
using double:

octave:1> n = 1e9; tic; p1 = primes(n); toc, tic; p2 = primes(uint64(n)); toc,
assert (isequal(p1,p2))
Elapsed time is 3.78581 seconds.
Elapsed time is 7.02282 seconds.


Performance with the internal cast to double is closer to equal:

octave:2> n = 1e9; tic; p1 = primes(n); toc, tic; p2 = primes(uint64(n)); toc,
assert (isequal(p1,p2))
Elapsed time is 3.7974 seconds.
Elapsed time is 3.9996 seconds.



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?61300>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]