Re: issue with LinearSolve[] when using SparseArray
- To: mathgroup at smc.vnet.net
- Subject: [mg113753] Re: issue with LinearSolve[] when using SparseArray
- From: Virgil Stokes <vs at it.uu.se>
- Date: Wed, 10 Nov 2010 06:30:08 -0500 (EST)
On 09-Nov-2010 09:55, Oliver Ruebenkoenig wrote:
> $MinPrecision=$MachinePrecision;$MaxPrecision=$MachinePrecision;
> > Share[];
> >
> > (* make sparse A*)
> > makeA[n_?(IntegerQ[#]&&Positive[#]&)]:=Module[{r,off,block},
> > r=Table[-4,{i,n}];
> > off=Table[1,{i,n-1}];
> >
> > block =DiagonalMatrix[r,0]+DiagonalMatrix[off,1]+DiagonalMatrix[off,-1];
> >
> > SparseArray[{Band[{1,1}]->ConstantArray[block,{n}],Band[{1,n+1}]->1,Band[{n+1,1}]->1}]
> > ];
> >
> > (* f(x,y) *)
> > force[i_?(IntegerQ[#]&),j_?(IntegerQ[#]&),h_?(NumericQ[#]&&Positive[#]
> > &)]:=Module[{x=i*h,y=j*h},
> > N@Exp[-(x-0.25)2-(y-0.6)2]
> > ];
> >
> > (*n=127; h=2-7;*) (*these values are OK *)
> > (*n=255; h=2-8;*) (*these values are OK *)
> > n=511; h=2-9; (*these cause problem *)
> >
> > A=N[makeA[n]];
> >
> > (* fill in f vector, in correct order for problem*)
> > f=Table[0,{i,n2}];
> > For[j=1,j<=n,j++,
> > For[i=1,i<=n,i++,
> > f[[j+n*(i-1)]]=force[i,j,h]
> > ]
> > ];
> >
> > Print["before solver, MemoryInUse[]=",MemoryInUse[]];
> > {cpu,sol}=Timing[LinearSolve[A,f]];
> > Print["after solver, MemoryInUse[]=",MemoryInUse[]];
> > Print["after solver, cpu=",cpu];
Ok Oliver,
I got the following message after a few seconds when I executed this code:
*No more memory available.
Mathematica kernel has shut down.
Try quitting other applications and then retry.*
This is a summary of the relevant features of my system:
*Processor:* Inter(R) Core(TM)2 Duo CPU E8500 @ 3.16GHz 3.17 GHz
*Memory (RAM):* 4.00 GB
*System type:* 32-bit Windows Vista
*Mathematica:* "7.0 for Microsoft Windows (32-bit) (February 18, 2009)"
--V