|
|
Am 07.08.2016 um 01:57 schrieb clipka:
> You'll therefore have to find a different approach to implement your
> spherical harmonics -- pre-computing sample points of the polynomials
> and approximating the whole thing with splines won't work.
BTW, I suspect that evaluating the sample-based splines wouldn't even be
much more performant than evaluating the base polynomials on the fly.
However, I presume that a naive implementation of the final function
would cause unnecessary double-evaluation of the base polynomials.
Consider the following (simplified) example:
#declare fn1 = function(x) { ... }
#declare fn2 = function(x) { ... }
#declare fn3 = function(x) { ... }
#declare fnA = function(x) { fn1(x) + fn2(x) }
#declare fnB = function(x) { fn2(x) + fn3(x) }
#declare fnC = function(x) { fn3(x) + fn1(x) }
#declare fn = function(x)
{ A*fnA(x) + B*fnB(x) + C*fnC(x) }
Note how in this case each call to `fn` will evaluate all of the basic
functions twice.
One way to avoid this multiple evaluation of the basic functions is to
re-write the intermediate-level functions as taking not x as parameter,
but the results of the basic functions, like so:
#declare fn1 = function(x) { ... }
#declare fn2 = function(x) { ... }
#declare fn3 = function(x) { ... }
#declare fnA_ = function(fn1,fn2) { fn1 + fn2 }
#declare fnB_ = function(fn2,fn3) { fn2 + fn3 }
#declare fnC_ = function(fn3,fn1) { fn3 + fn1 }
#declare fn_ = function(fn1,fn2,fn3)
{ A*fnA_(fn1,fn2) + B*fnB_(fn2,fn3) + C*fnC(fn3,fn1) }
#declare fn = function(x) { fn_(fn1(x),fn2(x),fn3(x)) }
Not sure if this approach is applicable to your problem though, since I
only had a cursory glace at what the formulae in your code are actually
doing.
Post a reply to this message
|
|