[Date Index]
[Thread Index]
[Author Index]
help in speeding up code involving a recursive function
*To*: mathgroup at smc.vnet.net
*Subject*: [mg43907] help in speeding up code involving a recursive function
*From*: "Salman Durrani" <s4001586 at student.uq.edu.au>
*Date*: Fri, 10 Oct 2003 03:06:39 -0400 (EDT)
*Organization*: The University of Queensland, Australia
*Reply-to*: "Salman Durrani" <s4001586 at student.uq.edu.au>
*Sender*: owner-wri-mathgroup at wolfram.com
Hi,
In the code below, the input variables are L and a.
The code executes correctly and almost instantaneously for L=1 and a=5.
However when I run it for L=2 and a=5, the execution is very slow.
I ran it on a 2.5 GHz machine for L=2 and a=5 for over 48 hours, without the
execution finishing.
In the end, I was forced to abort the execution.
Can someone please suggest how to speed up the execution.
The code can also be downloaded from
http://www.itee.uq.edu.au/~dsalman/_downloads/test.nb
Thanks in advance.
Salman
\!\(\(betacoeff =
Function[{k, r, L}, \[IndentingNewLine]If[k == 0,
outp = 1, \[IndentingNewLine]\(If[r == 1,
outp = 1\/\(k!\), \[IndentingNewLine]\(If[k == 1,
outp = r, \[IndentingNewLine]\(outp =
Sum[betacoeff[i, r - 1, L]\ 1\/\(\((k - i)\)!\)\ If[
i >= 0 && i <= \((\((r - 1)\)\ \((L - 1)\))\),
1,
0], {i, k - \((L - 1)\),
k}];\)\[IndentingNewLine]];\)\[IndentingNewLine]];\)\
\[IndentingNewLine]]; \[IndentingNewLine]outp\[IndentingNewLine]];\)\)
\!\(\(ansOUT = {};\)\[IndentingNewLine]
\(For[a = 5, a <= 15,
a += 5\/1, \[IndentingNewLine]L = 1; \[IndentingNewLine]y =
10; \[IndentingNewLine]x =
N[10\^\(y\/10\), 64]; \[IndentingNewLine]M =
64; \[IndentingNewLine]m = 1; \[IndentingNewLine]K =
Log[2, M]; \[IndentingNewLine]Ku = a; \[IndentingNewLine]Nc =
256; \[IndentingNewLine]X = K\/L\ x; \[IndentingNewLine]rho\ =
X\/\(1 + \(2\/\(3\ Nc\)\) X\ \((Ku\ L - 1)\)\); \[IndentingNewLine]p
\
= \(\(M/2\)\/\(M - 1\)\)
1\/Gamma[m\ L]\ Sum[\ \((\(-1\))\)\^\(n + 1\)\ \((Binomial[M - 1,
n])\)\ \((m\/\(\((\(n\/\(n + 1\)\) rho)\) + m\))\)\^\(m\ \
L\)\ \ Sum[\ Sum[\[IndentingNewLine]\ \((Binomial[k, i])\) \((betacoeff[k,
n,
L])\)\ \((\(Gamma[L + k]\ Gamma[\((m\ L)\)\ + \
i]\)\
\/\(\((n + 1)\)\^\(L + k\)\ Gamma[L + i]\))\) \((rho\/\(n \((rho + m)\) + \
m\
\))\)\^i, {i, \ 0, \ k}], {k, 0, n \((L - 1)\)}], {n, 1,
M - 1}]; \[IndentingNewLine]AppendTo[
ansOUT, {N[a, 4], N[p, 8]}];\[IndentingNewLine]];\)\)
TableForm[ansOUT]
\!\(\*
TagBox[GridBox[{
{"5.`", "0.059290035286915295`"},
{"10.`", "0.08414846730969132`"},
{"15.`", "0.10697647648324377`"}
},
RowSpacings->1,
ColumnSpacings->3,
RowAlignments->Baseline,
ColumnAlignments->{Left}],
(TableForm[ #]&)]\)
Prev by Date:
**Re: piecewise definition of a function**
Next by Date:
**plotting streamlines from vector data**
Previous by thread:
**Classless and Cleaver and Free?**
Next by thread:
**Re: help in speeding up code involving a recursive function**
| |