[Date Index]
[Thread Index]
[Author Index]
Re: Sparse Matrix, Memory Allocation
*To*: mathgroup at smc.vnet.net
*Subject*: [mg31654] Re: [mg31608] Sparse Matrix, Memory Allocation
*From*: Daniel Lichtblau <danl at wolfram.com>
*Date*: Fri, 23 Nov 2001 05:46:25 -0500 (EST)
*References*: <200111161138.GAA07073@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Inkyu Rhee wrote:
>
> I have a 70000 by 70000(or more) banded sparse matrix.
> and this matrix will be updated by specific law for 50 loops.
> In each loop, I need to linear solution of this.
>
> My prblems are:
>
> I could not specify this matrix:
>
> K=Table[0,{70000},{70000}];(* Initialize the matrix K *)
>
> when I trying this in my machines ((1) sun:ram 750M, swap 2665M,
> (2) window:A800mhz, 128Mb),
> machine gives me 'Out of Memory, Exiting'.
> How do you specify this matrix efficiently?
>
> If this works well, I will update these components of matrix
> using certain law. Then I need to solve the equations.
>
> Developer`SparseLinearSolve[K,x]
>
> I tried this part using 10000 by 10000 instead of 70000.
> It also give me 'Out of Memory ...'.
>
> Thanks for any help,
>
> I. Rhee
In[3]:= ?Developer`SparseLinearSolve
SparseLinearSolve[smat, vec] solves a sparse linear system; the matrix
smat is
represented in the form {{i1, j1}->a1, {i2, j2}->a2, ... }, so that
the
element at position ik, jk has value ak and all unspecified elements
are
taken to be zero.
So we need to get the matrix appropriately formatted. Code below will
generate a tridiagonal matrix, first as three vectors and then put into
the form of a sparse matrix representation.
tridiagonal[n_] := {Table[Random[],{n-1}], Table[Random[],{n}],
Table[Random[],{n-1}]}
toSparseMat[td_] := With[{n=Length[td[[2]]]},
Join[Table[{i,i+1}->td[[1,i]], {i,n-1}],
Table[{i,i}->td[[2,i]], {i,n}],
Table[{i+1,i}->td[[3,i]], {i,n-1}]]]
Now we generate a particular example of dimension 100000 .
n = 100000;
SeedRandom[1111];
td = tridiagonal[n];
smat = toSparseMat[td];
rhs = Table[Random[], {n}];
In[28]:= Timing[soln = Developer`SparseLinearSolve[smat, rhs];]
Out[28]= {78.42 Second, Null}
A bit slow perhaps but it seems to work.
Daniel Lichtblau
Wolfram Research
Prev by Date:
**Re: Sparse Matrix, Memory Allocation**
Next by Date:
**Re: Zero does not equal zero et al.**
Previous by thread:
**Sparse Matrix, Memory Allocation**
Next by thread:
**Re: Sparse Matrix, Memory Allocation**
| |