octave-maintainers
[Top][All Lists]
Advanced

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

Opinions for linspace behavior


From: rik
Subject: Opinions for linspace behavior
Date: Wed, 26 Aug 2015 13:39:14 -0700

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



reply via email to

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