octave-maintainers
[Top][All Lists]
Advanced

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

Re: diagonal matrices specializations


From: Jaroslav Hajek
Subject: Re: diagonal matrices specializations
Date: Wed, 3 Dec 2008 12:51:32 +0100

On Tue, Dec 2, 2008 at 8:56 AM, Søren Hauberg <address@hidden> wrote:
> tir, 02 12 2008 kl. 08:23 +0100, skrev Jaroslav Hajek:
>> 2. There was a prior debate how the special diagonal matrices should
>> be displayed & saved. Saving to external formats is out of question,
>> of course, but displaying and Octave's native saving is debatable.
>> Displaying a diagonal matrix by printing out just the diagonal (after
>> a notification of diagonality) is no doubt more informative than
>> displaying it as full. Similarly, when Octave saves a matrix in its
>> native format, it can be useful to preserve the diagonality
>> information rather than forgetting it. OTOH, there's compatibility.
>> In the patch presented, neither option is exploited, i.e. the matrix
>> is always converted to full.
>> My personal preference is to alter the printing and leave the saving,
>> but I'd like to hear more opinions about this.
>
> First of all, I very much agree with the rationale, that Octave should
> make it easy to write code that is easy to read.
>
> As to saving and displaying, I'd also prefer if diagonal matrices are
> displayed in a way where only the diagonal elements are shown.
> Obviously, it should be easy to tell whatever is printed from what is
> printed when displaying a vector.
>
> When it comes to saving, I believe diagonal matrices should be saved as
> such. I don't believe the Octave format has ever been backwards
> compatible. That is, I don't think there are any guaranties that you can
> load a file created by Octave 3.0 in Octave 2.0. When new things (such
> as function handles, objects, ...) have been added the the file format
> has just been extended (at least that's my understanding), and I think
> we should do the same thing here. Otherwise we would get two different
> behaviours when doing
>
>  some_computation
>  save my_file.mat
>  clear all
>  load my_file.mat
>  some_computation
>
> which I think would be confusing.
>

This is a good point.

>
> If you decide to save diagonal matrices as full matrices, then at least
> you should print a warning when saving such matrices.
>
> Thanks for doing stuff like this,
> Søren
>
>

Soren,

thanks for your comments.
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

or

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.
As a related question, what is the best way to display a permutation matrix?

regards

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



reply via email to

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