diagonal & permutation matrices
Ben Abbott
bpabbott at mac.com
Sun Nov 16 08:40:30 CST 2008
On Nov 16, 2008, at 6:42 AM, Jaroslav Hajek wrote:
> hi all,
>
> I'm working on patches allowing special treatment of diagonal and
> permutation matrices in the Octave interpreter.
>
> The motivation is that the natural syntax using diagonal & permutation
> matrices, e.g.
> D = norm (A, 'cols');
> A /= D;
> [Q,R,P] = qr (A); X = P' * R \ (Q' * B);
> is currently formidable if performance is of any concern.
> Multiplication & division by a permutation or diagonal matrix
> is orders of magnitude slower that the "direct" counterpart
> (subscripting by the permutation vector or using dmult).
> And even though Matlab does the same, I think it's a bit shameful.
>
> So my aim is to supply five octave_base_value subclasses:
> octave_diag_matrix, octave_float_diag_matrix,
> octave_complex_diag_matrix, octave_float_complex_diag_matrix,
> octave_permutation_matrix
> (it seems that a single permutation matrix subclass will be enough,
> provided it will remember its numeric class)
> and implement the necessary operations. Diagonal matrix support is
> already present in liboctave, permutation matrix support needs to be
> implemented (but I think it's no big deal, really).
>
> I've run into two issues:
>
> 1. What to do when printing/saving? To honor Matlab compatibility, we
> should display & save them as full matrices. However, it is certainly
> much more informational to print them specially, and seems a little
> bit weird for Octave to cripple its own data when saving variables.
If saving the mat-files then they will need to be converted to full,
but for octave's format(s) there is no need for compatibility. As this
is quite obvious, perhaps I am missing some point?
Regarding displaying the matrices, there are already differences.
For example, from Matlab
>> {'a','b','c',1,2,3}
ans =
'a' 'b' 'c' [1] [2] [3]
Now from Octave
octave:24> {'a','b','c',1,2,3}
ans =
{
[1,1] = a
[1,2] = b
[1,3] = c
[1,4] = 1
[1,5] = 2
[1,6] = 3
}
Notice the display doesn't even indicate whether 1,2,3 are numeric or
character.
So, I wouldn't worry about how things are displayed ... but, as
Thorsten has already asked, perhaps you can give us an example to
demonstrate what would be expected?
Ben
More information about the Octave-maintainers
mailing list