Compile SparseArray help
- To: mathgroup at smc.vnet.net
- Subject: [mg61115] Compile SparseArray help
- From: weloma <weloma at yahoo.com>
- Date: Tue, 11 Oct 2005 03:20:07 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi to all group members,
i am working with Sparse Matrices, but i can not
compile any equation with them. A normal Matrix can be
compiled as Compile[ {Matrix, _Real, 2}.... so i tried
to compile it as below where D and L are SparseArrays.
Compile[ {w, {D, _Real, 2}, {L, _Real, 2}...
and it is fallowed by the error;
CompiledFunction::cfta: Argument \<<1>> at position 2
should be a rank 2 tensor of machine-size real
numbers.
Is anybody can help me, how can i compile the
SparseArrays?
P.S. I write below what i try to do;
(*w is a real number; D,U and L are SparseArrays,
P[i]is a vector*)
(*In detail,i have a big square matrix say A,
(50000*50000) with a few non-zero elements. So i
define it as a SparseArray, D is the diagonalmatrix of
A,U and L are the upperdiagonal and lowerdiagonal
matrices of A respectively*)
(*i am trying to compute P[40]*)
n=50000;
P[1] = Table[1/n, {i, n}];
test = Compile[ {w, {D, _Real, 2}, {L, _Real, 2}, {U,
_Real, 2}},
For[i=1,i<40,i++,
P[i + 1\2]=Inverse[(-D - w*L)].((1 - w)*-D +
w*U).P[i]//N;
P[i+1]=Inverse[(-D - w*U)].((1 - w)*-D +
w*L).P[i+1/2]//N;
]]
test[1.4, D, L, U] // Timing
Ozgur Ozer
Ms.Student
Bogazici University
Istanbul
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com