I declare my compiled function:
Gapped = Compile[{{angle, _Complex}},
Module[{c1, c2, c3, cond, Phi, theta, phi},
theta = Re[angle];
phi = Im[angle];
{c1, c2, c3} = 1 - 3 Sin[theta]^2 Cos[phi - 2 Pi (# - 1)/3]^2 & /@ {1, 2, 3};
cond = ((c2 + c3)^2 - c1^2)/(4 c2 c3);
If[0 <= cond <= 1, {theta, phi}, Null]]];
And then I perform a calculation
res = 2;
AngleArray =
Transpose[Table[theta + I phi, {theta, 0, Pi, Pi/res}, {phi, 0, 2 Pi, Pi/res}]];
start = AbsoluteTime[];
array = Map[Gapped, AngleArray, {2}];
end = AbsoluteTime[] - start
ArrayPlot[array, ColorRules -> {Null -> Green}]
First time I hit evaluate on the second block of code I get error warnings [1] but the second time I hit evaluate the error warning dissapear (and it seems to work properly as it evaluates much faster). What is going on here? Thanks very much.
[1] error warnings:
CompiledFunction::cfse: Compiled expression {0., 0.} should be a machine-size real number. >>
CompiledFunction::cfex: Could not complete external evaluation at instruction 51; proceeding with uncompiled evaluation. >>