help-octave
[Top][All Lists]
Advanced

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

Re: Is A\b using a sparse solver if A is sparse?


From: LUK ShunTim
Subject: Re: Is A\b using a sparse solver if A is sparse?
Date: Thu, 02 Feb 2006 14:29:26 +0800
User-agent: Debian Thunderbird 1.0.7 (X11/20051017)

Dmitri A. Sergatskov wrote:
> LUK ShunTim wrote:
> ...
> 
>> octave2.9:11> tic;A\r;toc
>> ans = 12.117
>> octave2.9:12> tic;fullA\r;toc
>> ans = 6.6568
> 
> 
> I just like to note a couple things:
> 
> -- The result of A\r is a full matrix
> this remains the case even if
>  b=speye (2500,1); r=A*b;
> and hence r becomes also a sparse.
> I am not sure if this conversion to a full
> matrix is a bug or a feature.

I think b and r being full make sense from a user's point of view. You
have Ab=r to solve. A is sparse but b and r are, of course, full
vectors. Conversion (to internal representation) should be something
transparent to the user.

> 
> -- On my computer the difference is about 20%
>   not a factor of 2. Do you have and use ATLAS?

A "ldd /usr/bin/octave2.9" does pick up the ATLAS blas and lapack; from
debian, not site-tuned stuff.

> 
> octave:1> A=sprand(2500,2500,0.03);
> octave:2> b=speye (2500,1);
> octave:3> r=A*b;
> octave:4> tic;C=A\r;toc
> ans = 5.0834
> octave:5> fullA=full(A);
> octave:6> tic;D=fullA\r;toc
> ans = 4.0818
> octave:7> whos C
> 
> *** local user variables:
> 
>   Prot Name        Size                     Bytes  Class
>   ==== ====        ====                     =====  =====
>    rwd C        2500x1                      20000  matrix
> 
> Total is 2500 elements using 20000 bytes
> 
> octave:8> CC=sparse (C);
> octave:9> whos CC
> 
> *** local user variables:
> 
>   Prot Name        Size                     Bytes  Class
>   ==== ====        ====                     =====  =====
>    rwd CC       2500x1                      30008  sparse matrix
> 
> Total is 2500 elements using 30008 bytes
> 
> (The sparse version is large than the full, perhaps the conversion to
> full does make sense.)

Since C is full, making it sparse would require additional house-keeping
stuff. But I'd expect fullA be larger than A; perhaps much larger.

> 
> Sincerely,
> 
> Dmitri.
> 

Thanks,
ST
--



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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