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

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

[Octave-bug-tracker] [bug #53489] logspace return value for corner case


From: Mike Miller
Subject: [Octave-bug-tracker] [bug #53489] logspace return value for corner case of inputs (Inf, Inf) is different than Matlab
Date: Tue, 27 Mar 2018 18:45:14 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0

Follow-up Comment #2, bug #53489 (project octave):

I wonder if it might be more useful to have a special case to handle equal
endpoints that may be ±∞. Something like this change


--- a/liboctave/array/dRowVector.cc
+++ b/liboctave/array/dRowVector.cc
@@ -275,7 +275,7 @@ linspace (double x1, double x2, octave_i
 
   retval(0) = x1;
 
-  double delta = (x2 - x1) / (n - 1);
+  double delta = (x1 == x2) ? 0 : ((x2 - x1) / (n - 1));
   for (octave_idx_type i = 1; i < n-1; i++)
     retval(i) = x1 + i*delta;
 


and applied to all of the linspace implementations.

    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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