Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7161

Compile Problem with Nested Sum

From Julian Francis <julian.w.francis@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Compile Problem with Nested Sum
Date 2011-12-13 10:41 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jc7a56$on6$1@smc.vnet.net> (permalink)

Show all headers | View raw


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.

Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Compile Problem with Nested Sum Julian Francis <julian.w.francis@gmail.com> - 2011-12-13 10:41 +0000
  Re: Compile Problem with Nested Sum Frank K <fkampas@gmail.com> - 2011-12-19 12:19 +0000
    Re: Compile Problem with Nested Sum Szabolcs <szhorvat@gmail.com> - 2011-12-20 08:10 +0000

csiph-web