[Top][All Lists]

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

[Octave-bug-tracker] [bug #54562] numel should warn if the resulting dou

From: Colin Macdonald
Subject: [Octave-bug-tracker] [bug #54562] numel should warn if the resulting double might be inaccurate
Date: Thu, 23 Aug 2018 13:54:33 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0


                 Summary: numel should warn if the resulting double might be
                 Project: GNU Octave
            Submitted by: cbm
            Submitted on: Thu 23 Aug 2018 05:54:32 PM UTC
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Inaccurate Result
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: GNU/Linux



  * With 64-bit indexing, the maximum index value (on my system) is

  * flintmax is 9.0072e+15.

  * numel returns type double.

Thus if a matrix is large (maybe sparse), it can easily have enough elements
such that numel is larger than flintmax and thus the numel value is not

>> [a, maxint]= computer ()
a = x86_64-pc-linux-gnu
maxint = 9.2234e+18
>> flintmax
ans = 9.0072e+15

>> A = sprand(1e10+123, 1e7+123, 1e-13);
>> j = int64(1e10+123) * int64(1e7+123)
j = 100001231230015129

>> n = numel(A)   # note, below maxint but above flintmax
n = 1e+17
>> i = int64(n)
i = 100001231230015136

>> i - j   # uh oh
ans = 7

Note: Matlab's numel gives a warning: "Number of elements exceeds maximum
flint 2^53-1".  Its still imprecise but at least user is informed.


Reply to this item at:


  Message sent via Savannah

reply via email to

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