help-octave
[Top][All Lists]
Advanced

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

Re: help sprandsym


From: David Bateman
Subject: Re: help sprandsym
Date: Tue, 23 Jan 2007 15:26:49 +0100
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

Riccardo Corradini wrote:
> Dear all,
> I am using octave2.9.9 CVS when I ru the following program
> n = 500; density = 0.1; knum=0.5;
>
> for i=1:5
>     density = density*0.5;
>     X = sprandsym(n,density);
>     y = randn(n,1);
>     tic; b = X\y; time1 = toc;
>     xf = full(X);
>     tic; b = xf\y; time2 = toc;
>     fprintf('# of non-zero elements in X = %6d \n',nnz(X));
>     fprintf('sparse matrix solution time = %8.3f \n',time1);
>     fprintf('full matrix solution   time = %8.3f \n',time2);
> endfor
>
> I obtain
>
> error: number of rows must match (251 != 250) near line 69, column 47
> error: evaluating assignment expression near line 68, column 9
> error: evaluating if command near line 64, column 5
> error: evaluating if command near line 36, column 3
> error: called from `sprandsym' in file
> `/usr/share/octave/2.9.9+/m/sparse/sprandsym.m'
> error: evaluating assignment expression near line 6, column 4
> error: evaluating for command near line 4, column 1
> error: near line 14 of file `example22.m'
>
> Could you please help me?
> Thanks a lot
> Riccardo
>
> ------------------------------------------------------------------------
> Vinci i biglietti per FIFA World Cup in Germania!
> <http://us.rd.yahoo.com/mail_it/taglines/*http://it.rd.yahoo.com/evt=39978/*http://advision.webevents.yahoo.com/fifaworldcup_it/>
oppps, seems you've found a bug.. sprandsym doesn't currently work for
even values of "n"... The attached patch fixes it..

D.

-- 
David Bateman                                address@hidden
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary

*** ./scripts/sparse/sprandsym.m.orig25 2006-10-10 18:10:29.000000000 +0200
--- ./scripts/sparse/sprandsym.m        2007-01-23 15:24:33.247271272 +0100
***************
*** 39,45 ****
      S = S + tril(S,-1)';
    elseif nargin == 2
      m1 = floor(n/2);
!     n1 = m1 + 1;
      mn1 = m1*n1;
      k1 = round(d*mn1);
      idx1=unique(fix(rand(min(k1*1.01,k1+10),1)*mn1))+1; 
--- 39,45 ----
      S = S + tril(S,-1)';
    elseif nargin == 2
      m1 = floor(n/2);
!     n1 = m1 + rem(n,2);
      mn1 = m1*n1;
      k1 = round(d*mn1);
      idx1=unique(fix(rand(min(k1*1.01,k1+10),1)*mn1))+1; 

reply via email to

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