Skip to main content
1 of 2

Compile: Putting integers into a list

I started compiling in Mathematica a few weeks ago. In the code below, I want to put the integer value 0 into the list "Pre". If I "Print" the list, it will look like {0,0,....,0}. But the output of the code is {0.,0.,0.,....,0.}. So, my question is, how can I manage it, that the output looks like the "Print", i.e. I want the list to have integer values and not real numbers.

Thanks in advance!

In[1]:= CInit = Compile[{{v0, _Integer, 0}, {s0, _Integer, 0}},
          Module[{s = s0, v = v0, d, Pre},
          d = Table[$MaxMachineNumber, {v}];
          Pre = Table[0, {v}];
          Print[Pre];
          d[[s]] = 0.;
          {d, Pre}
          ], CompilationTarget -> "C"];
        CInit[5, 1]

 During evaluation of In[1]:= {0,0,0,0,0}

 Out[2]= {{0., 1.79769*10^308, 1.79769*10^308, 1.79769*10^308, 
         1.79769*10^308}, {0., 0., 0., 0., 0.}}