Using diagonal matrix as index

Jaroslav Hajek highegg at gmail.com
Sat Jan 10 01:46:32 CST 2009


On Fri, Jan 9, 2009 at 11:57 PM, John W. Eaton <jwe at octave.org> wrote:
> On  9-Jan-2009, Søren Hauberg wrote:
>
> | Ohh, I see. I thought it would be the same as
> |
> |   A (full (diag (true (1, 4)))) = 4
> |
> | which produces an error with the current code. So, I guess the bug is
> | that 'full' changes the class of diagonal matrices into 'double':
> |
> |   octave:28> class (diag (true (1, 4)))
> |   ans = logical
> |   octave:29> class (full (diag (true (1, 4))))
> |   ans = double
> |
> | I would assume that the latter should have produced 'logical'.
>
> Right, that's a bug.  It should not change the class.
>

diag (true (1, 4)) does not even produce a special matrix (only real &
complex implemented), so this bug apparently exists for much longer.
Full seems even convert floats to doubles. Uploaded is a fix for this
behaviour that also allows "full" to convert a diagonal or permutation
matrix:
http://hg.savannah.gnu.org/hgweb/octave/rev/aaf2b6d6813c


cheers
-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



More information about the Bug-octave mailing list