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: Rik
Subject: [Octave-bug-tracker] [bug #56659] Symmetry of linspace (-a, a, n)
Date: Thu, 19 Sep 2019 12:10:51 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko

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

@Marco: Take a look at a different implementation which constructs all
linspaces as symmetric regardless of the endpoints (Attached file
linspace.dbl.diff).  I think this is preferable over having several special
cases (such as x1 == -x2) because, depending on round-off error, symmettry is
preserved.  See below for an Octave session with the patch applied.


octave:1> x = linspace (-1.25, +0.75, 11);
octave:2> x = x + 0.25
x =

 Columns 1 through 9:

  -1.00000  -0.80000  -0.60000  -0.40000  -0.20000   0.00000   0.20000  
0.40000   0.60000

 Columns 10 and 11:

   0.80000   1.00000

octave:3> x == -fliplr (x)
ans =

  1  1  1  1  1  1  1  1  1  1  1



I think some sort of change should be made.  I checked with Matlab and the
linspaces they construct are symmettric for the examples given in this bug
report.



(file #47551)
    _______________________________________________________

Additional Item Attachment:

File name: linspace.dbl.diff              Size:0 KB
    <https://savannah.gnu.org/file/linspace.dbl.diff?file_id=47551>



    _______________________________________________________

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]