Author 
Comment/Response 
Shawn Kelly

06/21/02 10:15am
I have been attempting to use the Compile command to Compile a function that performs some calculations and fills a matrix. The nested do loops are shown below:
Kmatfunc[m_, k_] := Do[{
Do[{
Ws1[nl],
Ifs1[j],
Ifs2[j],
If[tst == 1,
Do[K[[NLtrans[[nl, m, k, i]], SNLtrans[[nl, m, k, i, j]]]] = co1*
co2*Fo[nl, m, k, i, j, 0], {j, 1, 4}]],
K[[NLtrans[[nl, m, k, i]], NLtrans[[nl, m, k, i]]]] =
co1*(co4 + (Sum[co3*co1*Fo[nl, m, k, i, j, Ifs3[j]], {j, 1, 4}] +
co5*2*h*
dt/(rho*dx*Cpm[[NLtrans[[nl, m, k, i]]]])))}, {i, 1,
L[nl, m, k]}]}, {nl, 1, 13}]
Ws1[j] is a Which statement that defines the variable con, where n is a number from 1 to 5.; i.e co1, co5...Contained in Ws1[j] are definitions for Ifs1[j],Ifs2[j]...
Fo[nl,m,k,i,j,Ifs3[j]] is a previosly defined function. The Table NLtrans and SNLtrans are also previously defined. km and Cpm are lists. L[nl,m,k] is a function to define the length of a subtable. And finally, K is the table of interest...what I am filling. It has been previously defined, it is also square.
I guess my question is, when I define variables, do I define everything used in the calculation
i.e., I would define a function
kamt=Compile[{{m,_integer},{k,_integer},{K,_real,2}},....Do[{Do[{stuff}...]
Is it a problem if km and Cpm are lists and not tables of dimension {1,1xx}
Thanks
Shawn
URL: , 
