Compiling Expressions "Macro like"

Hello

I am trying to set up both, a plain together with compiled versions of a function.

In particular the function operates on lists of coordinates, returning the unitized cumulative distance between points.

Things work as expected for the plain (non compiled) version.
Same ist true if I copy&paste the expression inside a Compile[ ].
Specifying the same stuff twice is not so nice …
How can I reference the non compiled version from within a Compile[ ]?
Like referencing a macro or meta programming …
Tried a lot of things Hold, Evaluate, … no success so far.

The functions are called:

EstimatedArc (* plain *)

EstimatedArcC (* compiled copy&paste *)

EstimatedArcM (* macro like reference *)

Any hints how this could be accomplished?

Hi Robert,

You need to specify the type of the value returned by the external function

EstimatedArcM = 
  Compile[{{l, _Real, 2}}, EstimatedArc[l], {{EstimatedArc[_], _Real, 1}}];

{0, 0}, {1., 0}, {10., 0}} // EstimatedArcM
(* {0., 0.1, 1.} *)

For details, take a look at this.

Thank you Rohit, at a first glance it seems to compile but …

r = RandomReal[{-1, 1}, {1000000, 2}];

r // EstimatedArc; // AbsoluteTiming

r // EstimatedArcC; // AbsoluteTiming


r // EstimatedArcM; // AbsoluteTiming


(*

{0.591217, Null}

{0.095182, Null}

{0.657469, Null}

*)

… it performs even slower than the non compiled version.