I need to define a function that takes an input and if and only if its a positive real, outputs the input. If not, the output should be 0. The input could be complex valued or indeterminate.
Heres what I defined;
myMax[x_] :=
Module[{},
If[x === Indeterminate, 0, If[Element[x, Reals], Max[0, x], 0]]];
This function is not compilable efficiently in mathematica. Is it possible to define such a function using just compilable functions?
myMax = Compile[{{x, _Complex}}, If[Im@x==0, Max[Re@x, 0], 0]]? $\endgroup$