[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Opinions for linspace behavior
From: |
Juan Pablo Carbajal |
Subject: |
Re: Opinions for linspace behavior |
Date: |
Wed, 26 Aug 2015 23:12:10 +0200 |
On Wed, Aug 26, 2015 at 10:39 PM, rik <address@hidden> wrote:
> 8/26/15
>
> All,
>
> While fixing bug #45820 (https://savannah.gnu.org/bugs/?45820) I found that
> Octave implements a superset of Matlab's linspace behavior. For linspace
> (A, B, N), Matlab only accepts scalars while Octave will also accept row or
> column vectors. The current behavior is to transform everything into a
> column vector and then expand. For example,
>
> linspace ([1 2], 3, 5)
> ans =
>
> 1.0000 1.5000 2.0000 2.5000 3.0000
> 2.0000 2.2500 2.5000 2.7500 3.0000
>
> This goes against my intuition. I would expect that a row vector would be
> expanded "down" to increase the number of rows while a column vector would
> be expanded "right" to increase the number of columns. I've created a
> patch that does this and the results are shown below.
>
> octave:2> linspace ([1 2], 3, 5)
> ans =
>
> 1.0000 2.0000
> 1.5000 2.2500
> 2.0000 2.5000
> 2.5000 2.7500
> 3.0000 3.0000
>
> octave:3> linspace ([1 2]', 3, 5)
> ans =
>
> 1.0000 1.5000 2.0000 2.5000 3.0000
> 2.0000 2.2500 2.5000 2.7500 3.0000
>
> What are people's opinions about this change? Is anyone actually using
> this feature of Octave in their code?
>
> Cheers,
> Rik
>
I did not know about this feature (ergo never used it). nevertheless
your fix looks correct and intuitive to me.