I am trying to compile a function that operates on an initial array (doing some sequential operation) to produce a matrix (which consists of N iterations of the initial array).
Below is a minimal working example:
NT = 10^1; NM = 2;
minitial = 2 RandomInteger[{}, NM] - 1.;
mzero = ConstantArray[0, {NT, NM}];
networkStep =
Compile[{{minitial, _Integer,
1}, {NT, _Integer}, {NM, _Integer}, {mzero, _Real, 2}},
Block[{md = minitial, moo = mzero},
Rescale@Table[
Do[md[[j]] = Sign[RandomReal[{-1, 1}]], {j, Range@NM}];
moo[[i, ;;]] = md, {i, 1, NT}]]];
mm = networkStep[minitial, NT, NM, mzero]
What prevents this function from compiling? Everything seems localized and appropriately defined to me.
Rescaleisn't compilable: https://mathematica.stackexchange.com/a/1101/1871;;(whoseFullFormis1;;All) cannot be compiled, either: https://mathematica.stackexchange.com/a/61651/1871 – xzczd Dec 24 '20 at 07:57Rescaleresults in aMainEvaluatein the output ofCompilePrint, but given it's called only once, it doesn't cause significant slowing down. – xzczd Dec 24 '20 at 10:25