I am looking for a way to speed up code and thus would like to use a compiled function in an ImplicitRegion
. Here is an example of a region that can be plotted normally, but fails when I try to use a compiled function. Is there a way to make this work?
RegionPlot3D[
ImplicitRegion[-x y z > 0, {{x, -5, 5}, {y, -5, 5}, {z, -5, 5}}]]
(*works*)
TEST=Compile[{{x, _Real}, {y, _Real}, {z, _Real}}, -x y z];
RegionPlot3D[
ImplicitRegion[TEST > 0, {{x, -5, 5}, {y, -5, 5}, {z, -5, 5}}]]
(*fails*)
RegionPlot3D[ ImplicitRegion[TEST[x,y,z] > 0, {{x, -5, 5}, {y, -5, 5}, {z, -5, 5}}]]
? $\endgroup$cf = Compile[{{x, _Real}, {y, _Real}, {z, _Real}}, -x y z]; TEST[x_?NumericQ, y_?NumericQ, z_?NumericQ] := cf[x, y, z]; RegionPlot3D[ ImplicitRegion[ TEST[x, y, z] > 0, {{x, -5, 5}, {y, -5, 5}, {z, -5, 5}}]]
$\endgroup$RegionPlot3D
compile its function anyway? $\endgroup$RegionPlot3D[ImplicitRegion[-x y z > 0, {{x, -5, 5}, {y, -5, 5}, {z, -5, 5}}]] // RepeatedTiming
etc. I found this original plot was slightly faster than blockwave's compiled version. $\endgroup$