I sometimes obtain an unexpected error when trying to call a compiled version of Total
with compensated summation turned on. More specifically I define
f1 = Compile[{{x,_Real,1}},Total[x],CompilationTarget->"C"];
f2 = Compile[{{x,_Real,1}},Total[x,Method->"CompensatedSummation"],CompilationTarget->"C"];
When I call the functions via
x=RandomReal[{0,1},10^5]
f1[x]
f2[x]
I sometimes, but not always, obtain a CompiledFunction::cfte
error, informing me that the
"Compiled expression [some large number of order $10^{5}$] should be a rank 1 tensor of machine-size real numbers."
I have studied the documentation of that error but have been unable to isolate the problem any further. The results of f1
and f2
differ by up to $1\times 10^{-9}$ and the difference becomes even larger for larger input vectors, so I'd quite like to be able to use the (presumably more accurate) version with compensated summation turned on.
Question: What causes the CompiledFunction::cfte
error and how can I avoid it when compiling Total
with compensated summation?
In case it matters I am using version 9.0 for Linux x86 (64-bit).
Comments
Post a Comment