[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Diagonal v. sparse matrices [was Re: deprecated functions]
From: |
Jaroslav Hajek |
Subject: |
Re: Diagonal v. sparse matrices [was Re: deprecated functions] |
Date: |
Thu, 5 Mar 2009 08:37:53 +0100 |
On Wed, Mar 4, 2009 at 10:17 PM, John W. Eaton <address@hidden> wrote:
> On 4-Mar-2009, Jaroslav Hajek wrote:
>
> | Nope, I didn't break compatibility that much :) This is, in fact, the
> | standard Matlab way to create a sparse diagonal matrix. It would be
> | nice, however, to be able to write this as sparse(diag()) as well
> | without losing efficiency. It seems Jason is working on something
> | along that lines, so I'd leave it to him. Note that the proper
> | constructors are already defined in liboctave.
>
> What do you mean by "without losing efficiency"? Does
>
> a = diag (...);
> sparse (a);
>
> convert A to full first, then sparse?
... yes.
> If so, it seems that should be fairly easy to fix.
It was really quite straightforward - fix is online. It also uncovered
the fact that the diag -> sparse constructors were broken, so
everything should be OK now. sparse() now works efficiently on
diagonal and permutation matrices.
> In any case, I think the following change should
> be made to spdiag. This is much simpler than having to check
> arguments in spdiag, and will be efficient if the "sparse (diag)"
> constructor is fixed. But the important thing is that for
> compatibility with previous versions of Octave, spdiag returns a
> sparse matrix, not a diag matrix. Do you agree?
Agreed.
> diff --git a/scripts/deprecated/spdiag.m b/scripts/deprecated/spdiag.m
> --- a/scripts/deprecated/spdiag.m
> +++ b/scripts/deprecated/spdiag.m
> @@ -28,9 +28,9 @@
> if (! warned)
> warned = true;
> warning ("Octave:deprecated-function",
> - "spdiag is obsolete and will be removed from a future version of
> Octave; please use diag instead");
> + "spdiag is obsolete and will be removed from a future version of
> Octave; please use sparse (diag (...)) instead");
> endif
>
> - retval = diag (varargin{:});
> + retval = sparse (diag (varargin{:}));
>
> endfunction
>
>
> jwe
>
>
--
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
- Re: deprecated functions, (continued)
- Re: deprecated functions, Jason Riedy, 2009/03/04
- Re: deprecated functions, John W. Eaton, 2009/03/04
- Re: deprecated functions, Jason Riedy, 2009/03/04
- Re: deprecated functions, John W. Eaton, 2009/03/04
- Diagonal v. sparse matrices [was Re: deprecated functions], Jason Riedy, 2009/03/04
- Diagonal v. sparse matrices [was Re: deprecated functions], John W. Eaton, 2009/03/04
- Re: Diagonal v. sparse matrices [was Re: deprecated functions], Jaroslav Hajek, 2009/03/04
- Re: Diagonal v. sparse matrices [was Re: deprecated functions], John W. Eaton, 2009/03/04
- Re: Diagonal v. sparse matrices [was Re: deprecated functions], Jaroslav Hajek, 2009/03/04
- Re: Diagonal v. sparse matrices [was Re: deprecated functions], John W. Eaton, 2009/03/04
- Re: Diagonal v. sparse matrices [was Re: deprecated functions],
Jaroslav Hajek <=
- Re: Diagonal v. sparse matrices [was Re: deprecated functions], John W. Eaton, 2009/03/05
- Re: Diagonal v. sparse matrices [was Re: deprecated functions], Jaroslav Hajek, 2009/03/04
- Re: Diagonal v. sparse matrices, Jason Riedy, 2009/03/04
- Re: Diagonal v. sparse matrices, Jaroslav Hajek, 2009/03/04
- Re: Diagonal v. sparse matrices, Jaroslav Hajek, 2009/03/04
- Re: deprecated functions, Jaroslav Hajek, 2009/03/04
- Re: deprecated functions, John W. Eaton, 2009/03/04
- Re: deprecated functions, Jaroslav Hajek, 2009/03/04
- Re: deprecated functions, John W. Eaton, 2009/03/04
- Re: deprecated functions, Jaroslav Hajek, 2009/03/04