inconsistent row <-> column sub-vector behavior

Sergei Steshenko sergstesh at yahoo.com
Fri Aug 22 10:10:31 CDT 2008


Hello All,

here is a small session:

"
GNU Octave, version 3.0.2
Copyright (C) 2008 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTIBILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type `warranty'.

Octave was configured for "i686-pc-linux-gnu".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/help-wanted.html

Report bugs to <bug at octave.org> (but first, please read
http://www.octave.org/bugs.html to learn how to write a helpful report).

For information about changes from previous versions, type `news'.

octave:1> vector_length = 4
vector_length =  4
octave:2> column_vector = zeros(vector_length, 1)
column_vector =

   0
   0
   0
   0

octave:3> row_vector = ones(1, vector_length)
row_vector =

   1   1   1   1

octave:4> column_vector(2:vector_length) = row_vector(2:vector_length)
column_vector =

   0
   1
   1
   1

octave:5> column_vector(2:vector_length) += row_vector(2:vector_length)
error: operator +: nonconformant arguments (op1 is 3x1, op2 is 1x3)
error: assignment failed, or no method for `matrix += matrix'
error: evaluating assignment expression near line 5, column 32
octave:5>                   
".

I think that 'octave' behavior is counterintuitive and inconsistent - 
either it should allow both

column_vector(2:vector_length) = row_vector(2:vector_length)
column_vector(2:vector_length) += row_vector(2:vector_length)

or it should disallow both.

Or is it for compatibility with Matlab ? I do not have Matlab, so I can't
check.

Thanks,
  Sergei.


      


More information about the Bug-octave mailing list