|
![](/i/fill.gif) |
> I wonder if this is optimized if functions evaluator:
>
> select(
> x*Ey+y*Ex-R1*Ex,
> select(
> z+3*x.
> x*Ey+y*Ex-R1*Ex,
> 123
> ),
> 17
> )
>
> Note expression "x*Ey+y*Ex-R1*Ex" appear twice.
> How many times is it calculated ?
Thorsten says twice. However, there is a way to avoid that.
See the (untested) code below.
#declare Func1 =
function(x,y,z,Ex,Ey,Value){
select(
Value,
select( z+3*x, Value, 123 ),
17
)
}
#declare Func2 =
function(x,y,z,Ex,Ey){Func1(x,y,z,Ex,Ey,x*Ey+y*Ex-R1*Ex)}
I don't know in this case if the additional function call slows down more
than the calculation of the expression did, but it's worth trying out. In
cases where the same expression appears many times it can give a big
speed-up anyway.
Maybe you already knew this, but then, maybe you didn't, so...
Rune
--
3D images and anims, include files, tutorials and more:
Rune's World: http://rsj.mobilixnet.dk (updated Feb 16)
POV-Ray Users: http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Ring: http://webring.povray.co.uk
Post a reply to this message
|
![](/i/fill.gif) |