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

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

[Octave-bug-tracker] [bug #56659] Symmetry of linspace (-a, a, n)


From: Michael Leitner
Subject: [Octave-bug-tracker] [bug #56659] Symmetry of linspace (-a, a, n)
Date: Tue, 23 Jul 2019 08:19:28 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0

Follow-up Comment #1, bug #56659 (project octave):

I was going to answer: because first this works only if BASE and LIMIT (in the
sense of linspace's documentation) are symmetric with respect to zero, which
will be fulfilled only in the minority of cases, and second because this
converts a range unnecessarily to a full vector. But I have just seen that
linspace does output a full vector! Is there a reason for that?

So the point is that linspace seems to construct a range by


(0:N-1)*((LIMIT-BASE)/N)+BASE


and to return the conversion of this range to a full vector. And you see, this
expression is not symmetric around zero. However, it is the most accurate
expression for the case where BASE==0. Of course, you could code optimized
expressions for all conceivable special cases into the internal functions. But
I think it is more sensible to leave that to the user: if they really feel the
need to shear off the last eps/2, then they shouldn't use a general purpose
function like linspace(). For your specific example, just use 


x=(-5:5)/5


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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