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

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

[Octave-bug-tracker] [bug #51871] loading '-ascii' format files is slow


From: Dan Sebald
Subject: [Octave-bug-tracker] [bug #51871] loading '-ascii' format files is slow
Date: Fri, 24 Nov 2017 22:57:50 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0

Follow-up Comment #38, bug #51871 (project octave):

Efficiency always counts.  In this age of big data where someone might want to
use Octave to analyze thousands of files, there's a big difference between,
say, a 2 hour batch process and 8 hour batch process.

The speed-up-load-ascii-v4.patch does not compile, so I'm attaching a
speed-up-load-ascii-v5.patch which is the same as speed-up-load-ascii-v4.patch
with the following additional hunk:


   std::ios::iostate status = is.rdstate ();
   if (status & std::ios::failbit)
     {
-      // Convert MAX_VAL returned by C++ streams for very large numbers to
Inf
-      if (val == std::numeric_limits<T>::max ())
+      // Convert +/- HUGE_VALF returned by C++ strtof for very large numbers
to Inf
+      if (val == HUGE_VALF)
         {
-          if (neg)
-            val = -std::numeric_limits<T>::infinity ();
-          else
-            val = std::numeric_limits<T>::infinity ();
+          val = std::numeric_limits<T>::infinity ();
+          is.clear (status & ~std::ios::failbit);
+        }
+      else if (val == -HUGE_VALF)
+        {
+          val = -std::numeric_limits<T>::infinity ();
           is.clear (status & ~std::ios::failbit);
         }
       else


For reference on HUGE_VALF, see

http://www.cplusplus.com/reference/cmath/HUGE_VALF/
http://www.cplusplus.com/reference/cstdlib/strtof/?kw=strtof

(ERANGE could have been used to determine either HUGE_VALF or -HUGE_VALF, but
I didn't want to complicate the use of failbit at the moment.)  I've not
tested this with any out-of-range data, but that's not the focus right now.

(file #42475)
    _______________________________________________________

Additional Item Attachment:

File name: speed-up-load-ascii-v5.patch   Size:10 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51871>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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