octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: diagonal matrices specializations


From: Søren Hauberg
Subject: Re: diagonal matrices specializations
Date: Wed, 03 Dec 2008 13:40:31 +0100

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.

Soren



reply via email to

[Prev in Thread] Current Thread [Next in Thread]