POV-Ray : Newsgroups : povray.advanced-users : function optimization question : Re: function optimization question Server Time
29 Jul 2024 20:12:58 EDT (-0400)
  Re: function optimization question  
From:
Date: 18 Mar 2002 03:49:53
Message: <4o9b9uk060bfb0orvu43ltcf2v6rsaamhp@4ax.com>
On Mon, 11 Mar 2002 03:17:07 -0500, "Slime" <noo### [at] hotmailcom> wrote:
>
> function{
>    f_noise3d(
>        x/(remember(1): sqrt(x^2+y^2+z^2)),
>        y/(recall:1),
>        z/(recall:1)
>    )
> }
>
> Where the 1 indicates that the remembered item labeled "1" should be
> recalled. The syntax I made up here is ugly, but is there any chance of this
> functionality appearing in the future?

It can appear tomorrow :-) if you just write:

 function{
    #local Function_With_One_Sqrt=function(x,y,z,sqrtxyz){
      f_noise3d(
          x/sqrtxyz,
          y/sqrtxyz,
          z/sqrtxyz
      )
    };
    Function_With_One_Sqrt(x,y,z,sqrt(x^2+y^2+z^2))
 }

The difference between your simple example and my case is very important.
While your subexpresssion is used three times in every function call, my
subexpression was used with apropriate condition in select(). I can't
precalculate it as subfunction with additional parameter becouse statisticaly
it is used only in 30% calls for example. Of course I can separate content of
select as sub function but it can slow down evaluation a lot when
subexpression is builded with hundreds of selects.

ABX


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.