I am trying to use Module wrapped in a Compile to produce two outputs. One is a vector, the other is a matrix. My actual example is rather complicated, but I managed to find a simple example problem that shows my problem.
I want the compiled function hi
to give me a list with two entries. One is a vector the other is a matrix. I attempted the following
hi = Compile[{{n, _Integer}},
Module[{a, b},
a = ConstantArray[2.0, {n, n}];
b = ConstantArray[3.0, {n}];
{a, b}
]
];
When I evaluate for instance hi[2]
I get a message saying
CompiledFunction::cfex: Could not complete external evaluation at instruction 4; proceeding with uncompiled evaluation.
I understand that compile
cannot deal with irregular arrays, but I only need this at the very end.