MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Compile Problem with Nested Sum

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123604] Compile Problem with Nested Sum
  • From: Julian Francis <julian.w.francis at gmail.com>
  • Date: Tue, 13 Dec 2011 05:39:15 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

Dear all,

I have a simple function which compiles fine:

fC1 = Compile[{{mx, _Integer}, {my, _Integer}, {mat, _Real, 2}},
  Sum[
   mat[[mx, my]] , {a, 0, 1}]
  ]

However, a sum within a sum doesn't compile:

fC2 = Compile[{{mx, _Integer}, {my, _Integer}, {mat, _Real, 2}},
  Sum[
   Sum[
    mat[[mx, my]] , {a, 0, 1}],
   {b, 1, 1}]
  ]

which generates the following error message:

Compile::noinfo: No information is available for compilation of \!\
(\*UnderoverscriptBox[\(\[Sum]\), \(b = 1\), \(1\)]\
((\*UnderoverscriptBox[\(\[Sum]\), \(a = 0\), \(1\)]mat[[mx, my]])\)
\). The compiler will use an external evaluation and make assumptions
about the return type. >>

I am confused as to why the first works, but the second doesn't.

Any help would be appreciated.

Thanks,
Julian Francis.



  • Prev by Date: symbolic integral with conditions
  • Next by Date: Re: ListLinePlot starting at x=0 rather than x=1
  • Previous by thread: Re: symbolic integral with conditions
  • Next by thread: Re: Compile Problem with Nested Sum