Using diagonal matrix as index

John W. Eaton jwe at octave.org
Mon Jan 12 00:01:57 CST 2009


On 10-Jan-2009, Jaroslav Hajek wrote:

| 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.

I didn't mean to imply that the bug was new, or necessarily the result
of the recent diagonal matrix changes, just that this was not correct
or expected behavior.

| 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

Is indexing the permutation or diagonal matrix the best way to convert
to full?

Should we add a "full" member function to the octave_value class so
that the dispatch can be handled there?

Thanks,

jwe



More information about the Bug-octave mailing list