[Scilab-users] The numderivative function
Samuel Gougeon
sgougeon at free.fr
Sun Nov 19 17:12:22 CET 2017
Hello Hermes,
As stated in my first answer, the only actually valuable thing to do to
shorten the execution time is
exec(SCI+"/modules/optimization/macros/numderivative.sci",-1)
before the first call to numderivative() (through ode(), in your case).
This will decrease the execution time by a factor of 2,33 (*105s*/45s,
not 145/45. I made a mistake in my first answer).
But this is not compatible with putting some "clear" instructions
everywhere, as matlabers do.
Any "clear" clears the redefinition done with exec() and so cancels the
gain in speed.
So if you are a "clear" addict, you should put it /before/ the exec().
Otherwise, each call to numderivative() will use it from it library and
take 105s (in all) instead of 45s.
I never ever used "clear" (<all>) in my Scilab work for 20 years. I
don't need it in Scilab,
if it does not apply to some explicitly named variables.
Except the execstr() => try/catch, other modifications = partial
vectorization are somewhat some hacks,
and the gain is poor, and back-compatibility is of concern. This is why
i did not attach them to my mail.
It is possible to improve a lot the speed of numderivative() in the case
of calling it for a whole set of points instead of only a single point
as currently done. But this would need to completely overhaul and
likely rewrite the code.
But this will not be a big gain when calling it through ode(), because
ode() calls the function with a scalar argument.
With a complete fine profiling, there is likely some room for internal
optimization of the existing code, but for a marginal gain (IMO less
than a factor ~1.4 in speed).
With 5.5.2, you can use add_profiling() and showprofile() to analyze the
code efficiency, as i did. This will show you the parts of the code that
take most of the execution time, so where to put your efforts to
optimize it.
Regards
Samuel
Le 19/11/2017 à 16:44, Hermes a écrit :
> Hi samuel,
> Such good news! to be able to see completely:"Scilab users - Mailing Lists
> Archives"
>
> My questions to your answer. Thanks for them:
> How can I reproduce this:
> "Then, mainly, vectorizing the function to derive in order to accept x with
> N columns instead of only 1, and changing numderivative () in order to be
> able to work with this new vectorized profile, we get 29 s."
>
> You can guide me with your answer, if possible with an example:
> "Improving numderivative () in order to be fully able to work with
> vectorized functions should be possible, but then: ...."
> regards
>
> I would very much like to be able to master numderivative. You could guide
> me to a website where I can read and study the vectorization in Scilab. I
> still do not feel comfortable with it.
> Hermes
>
>
>
> --
> Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20171119/acc339ab/attachment.htm>
More information about the users
mailing list