help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recursion


From: Kire Pudsje
Subject: Re: Recursion
Date: Tue, 7 Mar 2017 22:34:00 +0100



On Tue, Mar 7, 2017 at 9:24 PM, Thomas D. Dean <address@hidden> wrote:
On 03/06/2017 08:25 PM, Kire Pudsje wrote:


On Tue, Mar 7, 2017 at 4:24 AM, Thomas D. Dean <address@hidden
<mailto:address@hidden>> wrote:

    On 03/06/2017 07:06 PM, Thomas D. Dean wrote:

        I have an application that is called with two points and returns the
        distance between the points and a mid point.  One example returns a
        distance of 5474.  My function is not linear.  But, a more simple
        example illustrates my problem.

    Here is a better example, which produces the output I want to save.
    The printf(...) statement displays the data I want to keep, in the
    order I want it.


Do you really want to recurse?


I avoided this because of list copy/allocation.  My application has a larger list and this is the inner-most part of the application.

Be nice to vectorize...

Maybe the better way is to pre-allocate the list, recurse, and insert data into it where I have the print statement.

I do not know how large a list you are talking about, I checked, but with a reduced distance of 1, resulting in a list of 16385 points, the total time is dominated by the call to gcr. As your gcr function is probably more complex it will be even more skewed.
Be sure to check the bottlenecks with the profiler. Since octave is an interpreted language, optimizing can be non-intuitive. You would expect preallocation can help, but you probable need some extra code updating indices, which needs to be interpreted again, and can slow things down.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]