I'm trying to use the Mathematica C Code Generator package to generate code that is to be included in a web application by a developer. I don't know any C, and this seems to be the only way to integrate my model with the web-app. I am having a lot of difficulties getting off the ground.
A persistent error seems to be that my iteration indices are not recognised as integers. Here's an example:
Needs["CCodeGenerator`"]
funct = Compile[{{M, _Real, 2}, {l, _Integer}},
Module[{matrix = M, lag = l },
columns = Length[Transpose[matrix]];
Flatten[
Join[ {{{Table[1, {columns - lag + 1}]}},
Table[matrix[[;; , lag - i + 1 ;; columns - i + 1]] , {i, 1, lag}]} ] , 2]
], {{i, _Integer}}
]
This produces the following error:
Compile::cpintlt
: "1;;All at position 2 ofmatrix[[1;;All,lag-i+1;;columns+i+1]]
should be either a nonzero integer or a vector of nonzero integers; evaluation will use the uncompiled function."
Finally when I export the C code, I get errors like
CCodeGenerate::wmreq
: "The expressionFunction[{M,l,iCompile$18},Block[{i=iCompile$18},{All,i}]]
requires Mathematica to be evaluated. The function will be generated but can be expected to fail with a nonzero error code when executed. "
Any help would be greatly appreciated.