MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Re: Limit to length of lists?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34188] RE: [mg34161] Re: [mg34140] Limit to length of lists?
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Thu, 9 May 2002 05:15:47 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

> -----Original Message-----
> From: Bob Harris [mailto:nitlion at mindspring.com]
To: mathgroup at smc.vnet.net
> Sent: Tuesday, May 07, 2002 9:54 AM
> To: mathgroup at smc.vnet.net
> Subject: [mg34188] [mg34161] Re: [mg34140] Limit to length of lists?
> 
> 
> I wrote:
> > I'm running into a problem where it seems like you just 
> aren't allowed to
> > assign a list of 40 thousand integers to a variable.
> 
> The first replies that are coming in show me that I didn't describe my
> problem very well.  Probably because I still had some 
> remnants in there of
> what I was originally trying to do.  At the time I posted 
> that example, I
> thought the size of the numbers within my list mattered;  but 
> I now know
> they don't.
> 
> Allan Hayes replied:
> > Below I simulate your process as I understand it - apart 
> from the cut and
> > pasting, which I don't see the need for. ...
> 
> The cut and paste is what causes the problem.  The steps you 
> show work fine
> on my machine, too.
> 
> David Park replied:
> > Unfortunately, you are not telling us exactly what you did. 
> It looks like ss
> > did not get set to a list. If you feed ss to the kernel 
> what do you get?
> > 
> > Anyway, on a Windows98 machine there is no problem in 
> storing a list of that
> > size. Here I make a 40000 long list of your maximum number size. ...
> 
> Yep, those steps work fine on my machine, too.
> 
> Let me make may example more specific.
> 
> The problem seems to be that you can't define a large list 
> just by listing
> its entries.
> 
> Create a table with a lot of entries:
> 
>   in:=  tt = Table[1, {40000}]
>   out:= {1,1,...,1}
> 
>   in:=  Length[tt]
>   out:= 40000
> 
> So far so good.  Now, try to make a new list by cutting and 
> pasting that
> result.
> 
>   in:=  ss = {1,1,...,1}
>   out:=                     << no output, which is the first clue
> 
>   in:=  Length[ss]
>   out:= 0
> 
>   in:=  ss[[1]]
>       Part::partd:
>        Part specification ss[[1]] is longer than depth of object.
>   out:= ss[[1]]
> 
> While a cut and paste in this example seems silly, it models 
> what I was
> originally trying to do-- create a large list with some other 
> program, and
> import it into Mathematica.  I've tried a variety of 
> techniques and they all
> fail in their own ways.  When I got to the point where cut 
> and paste failed,
> I realized there seems to be something intrinsically wrong in 
> handling large
> lists, and not in my methods.
> 
> The next thing I tried, just to try to understand what's 
> going on, was to
> save the notebook (which takes up 268K as a file), quit 
> mathematica, and
> launch the notebook again.  Before doing anything, I did 
> MemoryInUse[], and
> it says 998084 bytes are in use for the session.  My OS tells me that
> mathematica is using about 4MBytes (this discrepancy is 
> probably explained
> by the fact that the executable is about 3MBytes).  I've 
> allowed a 20 MByte
> memory partition for mathematica, so it's got 16MBytes to 
> spare.  That seems
> like plenty of elbow room for a list with 40 thousand entries.
> 
> I then tried to assign to ss (the assignment was still in the 
> notebook, so I
> didn't have to bother with tt), not by cutting and pasting, 
> but by clicking
> on the assignment and hitting shift-return.  I get the same 
> result-- ss
> didn't seem to get assigned.  MemoryInUse[] now says 1024860 
> bytes are in
> use.  The attempt to assign to ss seems to have used up about 
> 26KBytes.
> 
> Hopefully that's a better description.
> 
> Thanks for any help,
> Bob H
> 
> 

I tried to simulate your actions, but everything went as expected. In
particular Mathematica is not to blame. So it is definitely *not*
 
> "The problem seems to be that you can't define a large list 
>  just by listing its entries."
 


Here is are my records:

69280 K (Memory in use as shown from Windows NT Task-Manager, before start
of Mathematica)
In[1]:= m0 = MemoryInUse[]
Out[1]= 1263920
76988 K (from Task-Manager)
In[2]:= t = Range[100000]; // Timing
Out[2]= {0. Second, Null}
In[3]:= m1 = MemoryInUse[]
Out[3]= 1666744
77388 K (from Task-Manager) 
In[4]:= m1 - m0
Out[4]= 402824   (* memory occupied by 100000 Integers *)
In[5]:= d0 = Date[0]
Out[5]= {2002, 5, 7, 12, 23, 13}
In[6]:= t
Out[6]= {1, 2, 3, ..., 99999, 100000}
In[7]:= d1=Date[0]
Out[7]= {2002,5,7,12,23,49}
In[8]:= d1-d0
Out[8]= {0,0,0,0,0,36} (* it took 36 seconds to display those 100000
integers *)
In[9]:= MemoryInUse[]
Out[9]= 1691512
94964 K (from Task-Manager)
(* here I copied the integers to notepad, removed the backslashes, and the
"Out[6] = ", copied to the clipboard again. *)
98180 K (from Task-Manager)
In[11]:= d2=Date[0]
Out[11]= {2002,5,7,12,34,17}
         s = {1, 2, 3, ..., 99999, 100000}
         (* just pasted here, not yet executed *)
In[12]:= d3=Date[0]
Out[12]= {2002,5,7,12,34,43}
In[13]:= d3-d2
Out[13]= {0,0,0,0,0,26}
(* it took 26 seconds to paste *)
In[14]:= MemoryInUse[]
Out[14]= 1695312
(* now press Shift+Return *)
In[15]:= s = {1, 2, 3, ..., 99999, 100000}
Out[15]= {1, 2, 3, ..., 99999, 100000}
In[16]:= MemoryInUse[]
Out[16]= 12492528
In[17]:= %-%%%
Out[17]= 10797216
In[18]:= s[[-1]]
Out[18]= 100000
121432 K (from Task-Manager)
117456 K (after terminating notepad and clearing the clipboard)
In[19]:= $Version
Out[19]= 4.1 for Microsoft Windows (November 2, 2000)

What you report looks like you did/could/n't execute your assignment. You
have to find out yourself why. Is your clipboard OK? Are your data in format
of a Mathematica expression? Are they contaminated with invisible
characters? are they *formatted*? I, myself, when pasting code e.g. from a
post in MathGroup, convert it to Mathematica text first (by Alt+7) look at
it, and then convert it back to an expression (by Alt+9).  There is a lot of
overall memory involved, as you see from my observation, did you really have
enough? The records you gave are not original. Which version of Mathematica
do you use? Is it an old 16-bit Version 2.2 for Windows 3.x ?

But perhaps al this is futile. Pasting is certainly not the right way to do
that, anyway. Use Read or Import, but first try with simple and small
examples! Follow the book!

Good luck,
Hartmut



  • Prev by Date: Re: Sequence and Or
  • Next by Date: Q: Displaying Current time/date in Page headers
  • Previous by thread: Re: Limit to length of lists?
  • Next by thread: ContourIntegral in Mathematica 4.1