From help-request at octave dot org Tue Apr 11 08:52:40 2006 Subject: Re: ERROR: memory exhausted -- trying to return prompt From: "=?ISO-8859-1?Q?Rosa_Rud=F3_Maun=E9?=" To: David dot Bateman at motorola dot com, help@octave.org Date: Tue, 11 Apr 2006 15:50:05 +0200 ------=_Part_2700_7646232.1144763405958 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I'm using Octaver version 2.1.42-athlonatlas with Windows XP. In my file text, which is called "queries.mat.txt", I've got: -first line (information): 6042 100247 894990 The first integer is the number of rows in the matrix, the second integer is the number of columns in the matrix and the third integer is the total of non-zeros of the matrix. -other lines. The *(i+1)* st line contains information about the non-zero entries of the *i *th row of the matrix. The non-zero entries of each row are specified as a sparse-separated list of pairs. Each pair contains the column number followed by the value o= f that paricular column. For example: queries.mat.txt could be: 2 2 2 1 5 =3D> (1,1) = =3D 5 2 4 =3D> (2,2) = =3D 4 My aim is: Saving the sparse matrix in a variable, because I'll need it, for doing operations. My code is: disp(fix(clock)); fid=3Dfopen('queries.mat.txt'); tline=3Dfgetl(fid); capsalera=3Dstr2num(tline); n=3D0; while n <6042; tline0 =3D fgetl(fid); if tline0=3D=3D-1 break; endif tline=3Dstr2num(tline0); n=3Dn+1; matriulinea=3D[ones(length(tline)/2, 1) reshape(tline,2,length(tline)/2)']; matriusparse=3Dsparse(matriulinea(:,1), matriulinea(:,2), matriulinea(:,3),1,100247); if n=3D=3D1 matriuindexos=3Dmatriusparse; else matriuindexos=3D[matriuindexos; matriusparse]; endif endwhile matriuindexos=3Dsparse(matriuindexos); fclose(fid); disp(fix(clock)); Rosa Rud=F3 Maun=E9 On 4/11/06, David Bateman wrote: > > Rosa Rud=F3 Maun=E9 wrote: > > > Hello, > > > > I want to create a sparse matrix from a file. The file has got 100247 > > lines and 6042 columns. I read it line by line and I concatenate it, > > but when reaching line 73 the program stops and gives an error. The > > mistake is: > > > > ERROR: memory exhausted -- trying to return prompt > > > > Do you know how I can solve it? > > > > Rosa Rud=F3 Maun=E9 > > More information please... What version of octave? What is the format of > the lines of code? What is the code you are using to read the file? > > D. > > -- > David Bateman David dot Bateman at motorola dot com > 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 > > ------=_Part_2700_7646232.1144763405958 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
I'm using Octaver version 2.1.42-athlonatlas with Windows XP.
In my file text, which is called "queries.mat.txt", I've got= :
   -first line (information): 6042  100247  894990=
    The first integer is the number of rows in the matr= ix, the second integer is the number of columns in the matrix and the third= integer is the total of non-zeros of the matrix.
   -other lines.
    The (i+1) st line contains information abo= ut the non-zero entries of the i th row of the matrix.
    The non-zero entries of each row are specified as a= sparse-separated list of pairs. Each pair contains the column number follo= wed by the value of that paricular column.
   For example:
      queries.mat.txt could be:
      2 2 2
      1 5      =             &nb= sp;            =             &nb= sp;          =3D> (1,1) =3D= 5
      2 4      =             &nb= sp;            =             &nb= sp;          =3D> (2,2) =3D= 4
 
My aim is:
Saving the sparse matrix in a variable, because I'll need it, for doin= g operations.
 
My code is:
disp(fix(clock));
fid=3Dfopen('queries.mat.txt');
tline=3Dfgetl(= fid);
capsalera=3Dstr2num(tline);
     &nbs= p;  n=3D0;
        while n <6= 042; 
          =   tline0 =3D fgetl(fid);
       =      if tline0=3D=3D-1
            &nb= sp;   break;
        &= nbsp;   endif
        =     tline=3Dstr2num(tline0);
    &nbs= p;       n=3Dn+1;
    =         matriulinea=3D[ones(length(tline= )/2, 1) reshape(tline,2,length(tline)/2)'];
    &nbs= p;       matriusparse=3Dsparse(matriulinea(:,= 1), matriulinea(:,2), matriulinea(:,3),1,100247);
            if n= =3D=3D1
          &nbs= p;     matriuindexos=3Dmatriusparse;
  &nb= sp;         else
  &nb= sp;            = matriuindexos=3D[matriuindexos; matriusparse];
    =         endif
    = ;    endwhile
        = matriuindexos=3Dsparse(matriuindexos);
        fclose(fid);
disp(fix(clo= ck));
 
 
Rosa Rud=F3 Maun=E9
 


 
On 4/11/06, = David Bateman <David.B= ateman at motorola dot com> wrote:
Rosa Rud=F3 Maun=E9 wrote:
> Hello,
>
> I want to create a sparse matrix from a file.= The file has got 100247
> lines and 6042 columns. I read it line by line and I concatenate i= t,
> but when reaching line 73 the program stops and gives an error. = The
> mistake is:
>
> ERROR: memory exhausted -- trying t= o return prompt
>
> Do you know how I can solve it?
>
> Rosa Rud= =F3 Maun=E9

More information please... What version of octave? What = is the format of
the lines of code? What is the code you are using to re= ad the file?

D.

--
David Bateman      &n= bsp;            = ;            &n= bsp;David dot Bateman@motorola dot co= m
Motorola Labs - Paris       &nb= sp;            =     +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Com= mune de St Aubin    +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE       &n= bsp;          +33 1 69 35= 77 01 (Fax)

The information contained in this communication has bee= n classified as:

[x] General Business Information
[ ] Motorola In= ternal Use Only
[ ] Motorola Confidential Proprietary


------=_Part_2700_7646232.1144763405958-- ------------------------------------------------------------- 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 -------------------------------------------------------------