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


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

ConstantArray dimensions in Compiled functions

From jliu.blueta@gmail.com
Newsgroups comp.soft-sys.math.mathematica
Subject ConstantArray dimensions in Compiled functions
Date 2013-08-24 08:16 +0000
Message-ID <kv9q43$67j$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


Hi, 

Mathematica seems to always assume ConstantArray returns {_Real,2}

f = Compile[{{x, _Real}}, Module[{m (*= {{{0.0}}}*)},
   m = ConstantArray[0.0, {2, 2, 2}];
   m[[1, 1, 1]] = x;
   m
   ]
  ]

Compile::part: Part specification m[[1,1,1]] cannot be compiled since the argument is not a tensor of sufficient rank. Evaluation will use the uncompiled function. >>




If I initialize m to {_Real, 3},

f = Compile[{{x, _Real}}, Module[{m = {{{0.0}}}},
   m = ConstantArray[0.0, {2, 2, 2}];
   m[[1, 1, 1]] = x;
   m
   ]
  ]

f[1.0]

Compile::cset: Variable m of type {_Real,3} encountered in assignment of type {_Real,2}. >>



Same error even if I specifically say ConstantArray[] returns a 3-d array.

f = Compile[{{x, _Real}}, Module[{m = {{{0.0}}}},
   m = ConstantArray[0.0, {2, 2, 2}];
   m[[1, 1, 1]] = x;
   m
   ], {{ConstantArray[___], _Real, 3}}
  ]

f[1.0]

Compile::cset: Variable m of type {_Real,3} encountered in assignment of type {_Real,2}. >>


I'd appreciate any help!

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


Thread

ConstantArray dimensions in Compiled functions jliu.blueta@gmail.com - 2013-08-24 08:16 +0000

csiph-web