|
![](/i/fill.gif) |
Hello all, could you please advice on following problem. For example, I have two
functions
#declare frac = function (x) {
x - floor (x)
}
#declare menger = function (x, order) {
floor (3*frac(x*pow(3,order))) - floor (3*frac(x*pow(3,order))/2)*2
}
In procedural language like C++ to avoid recalculation of frac/pow I would write
in 2nd function
double tmp = frac(x*pow(3,order));
return floor (3*tmp) - floor (3*tmp/2)*2;
But how do I explain this to pov?
Ok, in this particular case I could use intermediate function
#declare menger2 = function (tmp) {
floor (3*tmp) - floor (3*tmp/2)*2
}
#declare menger = function (x, order) {
menger2(frac(x*pow(3,order)))
}
but
1) not sure if this can be done for arbitrary combination
2) wont stacking functions like that actually slow things down
Thanks.
Post a reply to this message
|
![](/i/fill.gif) |