Using diagonal matrix as index

John W. Eaton jwe at octave.org
Fri Jan 9 15:47:32 CST 2009


On  9-Jan-2009, Søren Hauberg wrote:

|   With a recent checkout I get the following IMHO quite odd behaviour:
| 
| octave:18> A = magic (5)
| A =
| 
|    17   24    1    8   15
|    23    5    7   14   16
|     4    6   13   20   22
|    10   12   19   21    3
|    11   18   25    2    9
| 
| octave:19> A (diag (true (1, 4))) = 4
| A =
| 
|     4    4    4    4   15
|    23    5    7   14   16
|     4    6   13   20   22
|    10   12   19   21    3
|    11   18   25    2    9
| 
| Shouldn't this have produced an error since I'm using a 4x4 matrix as
| index in a 5x5 matrix? Also, why are the elements placed in first row,
| instead of along the diagonal?

It's the same as if you had done

  A(find (diag (true (1, 4)))) = 4

If we change this behavior, then people will likely complain when they
try to run the code they wrote for the other leading brand in Octave.
So if you think it is a bug, complain to those other guys.

jwe



More information about the Bug-octave mailing list