SVDC in IDL 5.0 [message #9884] |
Wed, 17 September 1997 00:00  |
f055
Messages: 29 Registered: April 1995
|
Junior Member |
|
|
A quick question about SVDC:
Most singular value decomposition routines I have used/read about
appear to return a diagonal matrix of singular values (or just a
list), in which the singular values are in descending order. When
I use the IDL routine SVDC,A,W,U,V, the list of values in W is not in
such an order (for one example I get W=[0,0.33,0.29E-7,0.12E-7,
0.14E-7,... etc.]).
Am I doing something wrong, or is this just how the IDL routine
works? Can I re-order them into descending order by simply sorting
them and switching the singular vectors (columns) of U & V in the
same way?
Thanks for any help
Tim
......................... Dr Tim Osborn . t.osborn@uea.ac.uk
.... ___/.. __ /.. /.. /. Senior Research Associate . phone:01603 592089
... /..... /. /.. /.. /.. Climatic Research Unit . fax: 01603 507784
.. /..... __/.. /.. /... School of Environmental Sciences.
. /..... /\ ... /.. /.... University of East Anglia .
____/.._/..\_..____/..... Norwich NR4 7TJ .
......................... UK .
|
|
|
Re: SVDC in IDL 5.0 [message #9970 is a reply to message #9884] |
Thu, 18 September 1997 00:00  |
Henry Chapman
Messages: 10 Registered: February 1997
|
Junior Member |
|
|
T.Osborn wrote:
>
> A quick question about SVDC:
>
> Most singular value decomposition routines I have used/read about
> appear to return a diagonal matrix of singular values (or just a
> list), in which the singular values are in descending order. When
> I use the IDL routine SVDC,A,W,U,V, the list of values in W is not in
> such an order (for one example I get W=[0,0.33,0.29E-7,0.12E-7,
> 0.14E-7,... etc.]).
>
> Am I doing something wrong, or is this just how the IDL routine
> works? Can I re-order them into descending order by simply sorting
> them and switching the singular vectors (columns) of U & V in the
> same way?
>
> Thanks for any help
>
> Tim
This is just the way IDL does it, and you can certainly reorder as you
guessed. Here's a routine to do it:
PRO svdc_sort, m, diag, u, v
;Singular value decomposition with diagonal elements ordered from
;largest to smallest
;
;written by Henry Chapman, AMP, LLNL
;November, 1996
svdc, m, diag, u, v
s = reverse(sort(diag))
n = n_elements(diag)
rr = fltarr(n, n)
i = indgen(n)
rr[i, s[i]] = 1.
v = v##rr
u = u##rr
diag = diag[s]
return
END
--
Henry Chapman
mailto:chapman9@llnl.gov
Advanced Microtechnology Program
Lawrence Livermore National Lab
L-395, P.O. Box 808, Livermore CA 94550
|
|
|