diagonal matrices specializations
Søren Hauberg
soren at hauberg.org
Wed Dec 3 06:40:31 CST 2008
ons, 03 12 2008 kl. 12:51 +0100, skrev Jaroslav Hajek:
> What do you consider to be the best way of displaying a diagonal matrix?
> One option is
>
> ans =
> diagonal matrix (5x5)
> diagonal = 1 2 3 4 5
>
> or
>
> ans =
> diagonal matrix (5x5)
> diagonal =
> 1
> 2
> 3
> 4
> 5
I think I'd prefer the latter of these two (perhaps, the numbers should
be indented with a space or two, though). I don't have a strong opinion
here, but in general I find column vectors easier to read than row
vectors. Especially when the elements are complex and have many digits,
like '1.2345 + 6.78901i'
> ans =
> diagonal matrix (5x5)
> 1 .. 0
> 2
> : 3 :
> 4
> 0 .. 5
>
> the last form seems attractive, but maybe requires a bit more thinking
> about how to place the dots etc.
This I don't think will work. It would be very hard to read a 20x20
matrix in a terminal with a width of 80 chars. But I agree, that it
looks nice for small matrices.
> As a related question, what is the best way to display a permutation matrix?
Hmm, I'm not sure. Perhaps something like
ans =
permutation matrix (5x5)
1 --> 5
2 --> 4
3 --> 3
4 --> 2
5 --> 1
for the matrix
0 0 0 0 1
0 0 0 1 0
0 0 1 0 0
0 1 0 0 0
1 0 0 0 0
But I'm not sure.
Søren
More information about the Octave-maintainers
mailing list