Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'Help with Compile.' topicStudent Support Forum > General > Archives > "Help with Compile."

Next Comment >Help | Reply To Topic
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[{
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}] +
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 sub-table. 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

Is it a problem if km and Cpm are lists and not tables of dimension {1,1xx}



URL: ,

Subject (listing for 'Help with Compile.')
Author Date Posted
Help with Compile. Shawn Kelly 06/21/02 10:15am
Re: Help with Compile. Forum Modera... 07/03/02 4:59pm
Next Comment >Help | Reply To Topic