octave-maintainers
[Top][All Lists]
Advanced

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

Re: Preserving signbit for range operator


From: Daniel J Sebald
Subject: Re: Preserving signbit for range operator
Date: Mon, 25 Feb 2013 14:03:59 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16

On 02/25/2013 01:14 PM, Rik wrote:
2/25/13

All,

Michael Godfrey and I are working on the stemleaf.m code and we noticed
that the range operator is not preserving the signbit on 0.

As an example, [-3:-0] produces [-3 -2 -1 0] or [-0:3] which produces [0 1
2 3].

First, should we be trying to preserve the signbit or is this just too much
work for too little gain?

Maybe.  Here is the "definition" of the range operation in the DOC:

"A range expression is defined by the value of the first
element in the range, an optional value for the increment between
elements, and a maximum value which the elements of the range will not
exceed."

Note that the right most number is the *maximum* value not exceeding the right limit, e.g.,

octave:23> 1:3:5
ans =

   1   4

and not the end of range specification itself. With that I would think that perhaps the following should be the results of your examples.

[-3:-0] -> [-3 -2 -1 0]
[-0:3] -> [-0 1 2 3]

Dan

PS: There may be some broken links in the DOC, but I've never been good at navigating DOC, so I'll look at the source code later today. In "doc" I navigate to

* Operator Index::              An item for each documented operator.

and hit return. That takes me to the index of operators. I then navigate to

* ::                                     Ranges.              (line   6)

and hit return.  That takes me to GNU Octave menu.  These two

* : <1>:                                 Operator Overloading.
                                                              (line  10)
* : <2>:                                 Index Expressions.   (line   6)

just jump down the page to

* <:                                     Comparison Ops.      (line  23)


reply via email to

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