comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Matrix rank
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Matrix rank [message #57533] Fri, 14 December 2007 09:26 Go to next message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On Dec 14, 5:28 pm, Vince Hradil <hrad...@yahoo.com> wrote:
> On Dec 14, 9:42 am, Wox <nom...@hotmail.com> wrote:
>
>
>
>
>
>> On Fri, 14 Dec 2007 06:35:11 -0800 (PST), Vince Hradil
>
>> <hrad...@yahoo.com> wrote:
>>> IDL can do SVD, can you get the rank from that? Look up SVDC in the
>>> docs.
>
>> I could do this, but maybe there's a better way?
>
>> ; A: integers
>> ; B: floats
>> A = [[ 0,0,1], $
>> [ 0,1,0], $
>> [ 0,0,0]]
>> B = [0.25,0.5,1]
>
>> ; Decompose A
>> SVDC, A, W, U, V
>> ; Solve A.X=B
>> X=SVSOL(U, W, V, B)
>
>> ; Check
>> B2=A##X
>> ind=where(total(abs(A),1,/pres) ne 0)
>
>> if array_equal(B[ind],B2[ind]) then print,X
>
> Well, w contains the singular values, the number of these that are non-
> zero will be the rank:
> idx = where(w ne 0, rank)
> print, rank
> 2
>
> Does anyone else read the Help??????- Hide quoted text -
>
> - Show quoted text -

Huuum!!! what about NORM?
Re: Matrix rank [message #57534 is a reply to message #57533] Fri, 14 December 2007 09:19 Go to previous messageGo to next message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On Dec 14, 6:17 pm, Vince Hradil <hrad...@yahoo.com> wrote:
> On Dec 14, 10:35 am, David Fanning <n...@dfanning.com> wrote:
>
>> Vince Hradil writes:
>>> Does anyone else read the Help??????
>
>> Takes to long to boot up. :-(
>
>> Cheers,
>
>> David
>> --
>> David Fanning, Ph.D.
>> Fanning Software Consulting, Inc.
>> Coyote's Guide to IDL Programming:http://www.dfanning.com/
>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>
> Ha. Ha. Actually I used the IDL6.4 Help ;^)

yes i 100% agree with you!!!!
Re: Matrix rank [message #57535 is a reply to message #57534] Fri, 14 December 2007 09:17 Go to previous messageGo to next message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Dec 14, 10:35 am, David Fanning <n...@dfanning.com> wrote:
> Vince Hradil writes:
>> Does anyone else read the Help??????
>
> Takes to long to boot up. :-(
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

Ha. Ha. Actually I used the IDL6.4 Help ;^)
Re: Matrix rank [message #57536 is a reply to message #57535] Fri, 14 December 2007 08:35 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Vince Hradil writes:

> Does anyone else read the Help??????

Takes to long to boot up. :-(

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Matrix rank [message #57537 is a reply to message #57536] Fri, 14 December 2007 08:28 Go to previous messageGo to next message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Dec 14, 9:42 am, Wox <nom...@hotmail.com> wrote:
> On Fri, 14 Dec 2007 06:35:11 -0800 (PST), Vince Hradil
>
> <hrad...@yahoo.com> wrote:
>> IDL can do SVD, can you get the rank from that? Look up SVDC in the
>> docs.
>
> I could do this, but maybe there's a better way?
>
> ; A: integers
> ; B: floats
> A = [[ 0,0,1], $
> [ 0,1,0], $
> [ 0,0,0]]
> B = [0.25,0.5,1]
>
> ; Decompose A
> SVDC, A, W, U, V
> ; Solve A.X=B
> X=SVSOL(U, W, V, B)
>
> ; Check
> B2=A##X
> ind=where(total(abs(A),1,/pres) ne 0)
>
> if array_equal(B[ind],B2[ind]) then print,X

Well, w contains the singular values, the number of these that are non-
zero will be the rank:
idx = where(w ne 0, rank)
print, rank
2

Does anyone else read the Help??????
Re: Matrix rank [message #57540 is a reply to message #57537] Fri, 14 December 2007 07:57 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Wox writes:

> Seems like I have a twin brother somewhere... :-p

That's why, even when I feel like I am the only one
in the world who is struggling to understand something,
I still post. If my e-mail is correct, it's not just
a twin brother, but a whole family of fertility treatments
gone very, very wrong.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Matrix rank [message #57541 is a reply to message #57540] Fri, 14 December 2007 07:44 Go to previous messageGo to next message
Wox is currently offline  Wox
Messages: 184
Registered: August 2006
Senior Member
On Fri, 14 Dec 2007 07:41:01 -0800 (PST), d.poreh@gmail.com wrote:

> Hi
> I had seen SVDC. But i did not understand which parameter belong to
> rank of a matrix. Could you please specify with an example?
> Thanks for any help in advance
> Cheers


Seems like I have a twin brother somewhere... :-p
Re: Matrix rank [message #57542 is a reply to message #57541] Fri, 14 December 2007 07:42 Go to previous messageGo to next message
Wox is currently offline  Wox
Messages: 184
Registered: August 2006
Senior Member
On Fri, 14 Dec 2007 06:35:11 -0800 (PST), Vince Hradil
<hradilv@yahoo.com> wrote:

> IDL can do SVD, can you get the rank from that? Look up SVDC in the
> docs.


I could do this, but maybe there's a better way?

; A: integers
; B: floats
A = [[ 0,0,1], $
[ 0,1,0], $
[ 0,0,0]]
B = [0.25,0.5,1]

; Decompose A
SVDC, A, W, U, V
; Solve A.X=B
X=SVSOL(U, W, V, B)

; Check
B2=A##X
ind=where(total(abs(A),1,/pres) ne 0)

if array_equal(B[ind],B2[ind]) then print,X
Re: Matrix rank [message #57543 is a reply to message #57542] Fri, 14 December 2007 07:41 Go to previous messageGo to next message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On Dec 14, 3:35 pm, Vince Hradil <hrad...@yahoo.com> wrote:
> On Dec 14, 8:16 am, Wox <nom...@hotmail.com> wrote:
>
>> Hi IDLers,
>
>> Is there a routine available which calculates the rank of an (integer)
>> matrix? Couldn't find it in the help and I would be surprised if it's
>> not there. It's for knowing whether sets of linear equations have no
>> solution, 1 solution or an infinite number of solutions.
>
>> Thanks.
>
> IDL can do SVD, can you get the rank from that? Look up SVDC in the
> docs.

Hi
I had seen SVDC. But i did not understand which parameter belong to
rank of a matrix. Could you please specify with an example?
Thanks for any help in advance
Cheers
Re: Matrix rank [message #57544 is a reply to message #57543] Fri, 14 December 2007 07:25 Go to previous messageGo to next message
Wox is currently offline  Wox
Messages: 184
Registered: August 2006
Senior Member
On Fri, 14 Dec 2007 06:35:11 -0800 (PST), Vince Hradil
<hradilv@yahoo.com> wrote:

> IDL can do SVD, can you get the rank from that? Look up SVDC in the
> docs.

It doesn't return the rank. It returns three arrays. Not sure what
they represent, but I'll check whether I can derive some conclusions
from them.
Re: Matrix rank [message #57546 is a reply to message #57544] Fri, 14 December 2007 06:35 Go to previous messageGo to next message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Dec 14, 8:16 am, Wox <nom...@hotmail.com> wrote:
> Hi IDLers,
>
> Is there a routine available which calculates the rank of an (integer)
> matrix? Couldn't find it in the help and I would be surprised if it's
> not there. It's for knowing whether sets of linear equations have no
> solution, 1 solution or an infinite number of solutions.
>
> Thanks.

IDL can do SVD, can you get the rank from that? Look up SVDC in the
docs.
Re: Matrix rank [message #57620 is a reply to message #57537] Fri, 14 December 2007 10:06 Go to previous message
Steve Eddins is currently offline  Steve Eddins
Messages: 9
Registered: July 2001
Junior Member
Vince Hradil wrote:
> On Dec 14, 9:42 am, Wox <nom...@hotmail.com> wrote:
>> On Fri, 14 Dec 2007 06:35:11 -0800 (PST), Vince Hradil
>>
>> <hrad...@yahoo.com> wrote:
>>> IDL can do SVD, can you get the rank from that? Look up SVDC in the
>>> docs.
>> I could do this, but maybe there's a better way?
>>
>> ; A: integers
>> ; B: floats
>> A = [[ 0,0,1], $
>> [ 0,1,0], $
>> [ 0,0,0]]
>> B = [0.25,0.5,1]
>>
>> ; Decompose A
>> SVDC, A, W, U, V
>> ; Solve A.X=B
>> X=SVSOL(U, W, V, B)
>>
>> ; Check
>> B2=A##X
>> ind=where(total(abs(A),1,/pres) ne 0)
>>
>> if array_equal(B[ind],B2[ind]) then print,X
>
> Well, w contains the singular values, the number of these that are non-
> zero will be the rank:
> idx = where(w ne 0, rank)
> print, rank
> 2

Since this is all in floating-point, it's appropriate to use a tolerance
instead of comparing exactly with 0. See, for example, the algorithm
used in the MATLAB rank function, which uses a tolerance based on the
size of the matrix and the maximum singular value. It's described here:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/ra nk.html

I assume this is straightforward to express in IDL.

---
Steve Eddins
http://blogs.mathworks.com/steve/
Re: Matrix rank [message #57622 is a reply to message #57533] Fri, 14 December 2007 09:49 Go to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Dec 14, 11:26 am, d.po...@gmail.com wrote:
> On Dec 14, 5:28 pm, Vince Hradil <hrad...@yahoo.com> wrote:
>
>
>
>> On Dec 14, 9:42 am, Wox <nom...@hotmail.com> wrote:
>
>>> On Fri, 14 Dec 2007 06:35:11 -0800 (PST), Vince Hradil
>
>>> <hrad...@yahoo.com> wrote:
>>>> IDL can do SVD, can you get the rank from that? Look up SVDC in the
>>>> docs.
>
>>> I could do this, but maybe there's a better way?
>
>>> ; A: integers
>>> ; B: floats
>>> A = [[ 0,0,1], $
>>> [ 0,1,0], $
>>> [ 0,0,0]]
>>> B = [0.25,0.5,1]
>
>>> ; Decompose A
>>> SVDC, A, W, U, V
>>> ; Solve A.X=B
>>> X=SVSOL(U, W, V, B)
>
>>> ; Check
>>> B2=A##X
>>> ind=where(total(abs(A),1,/pres) ne 0)
>
>>> if array_equal(B[ind],B2[ind]) then print,X
>
>> Well, w contains the singular values, the number of these that are non-
>> zero will be the rank:
>> idx = where(w ne 0, rank)
>> print, rank
>> 2
>
>> Does anyone else read the Help??????- Hide quoted text -
>
>> - Show quoted text -
>
> Huuum!!! what about NORM?

Well...
2-norm would be the maximum Singular Value: max(w)
trace norm would be the sum of the SVs: total(w)
Frobenius norm would be the sqrt of the sum of the squares of the SVs:
sqrt(total(w*w))
I think... see: http://en.wikipedia.org/wiki/Singular_value_decomposition
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Off Topic Computer Post
Next Topic: Compiling error in Envi batch mode

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:17:06 PDT 2025

Total time taken to generate the page: 0.00499 seconds