c++ - How to raise double to array powers in Eigen -
i have simple problem should have simple answer well, far no luck.
i need raise double value array of integer powers, in c++ like
for (int = 0; < n; ++i) { y[i] = pow(delta, l[i]); }
but in eigen have tried number of variants on theme, without success.
i have eigen::arrayxi l_inte
maps stl vector l_int
.
this doesn't work:
eigen::pow(double, l_inte)
since pow()
function wants array first input, , raise array constant power.
one nasty workaround able working (this can't right way) this:
(log(delta)*l_doublee).exp()
which conversion
pow(delta,l) -> exp(l*log(delta))
and have convert integers doubles. can't performance either since pow(double, int) significantly faster pow(double, double) in general. although, maybe isn't true sse in eigen?
anyway, clarity here appreciated.
what multiplying each y[i]
l[i]
times?
y.fill(1); (arrayxi e = l; (e>0).any(); e -= 1) y = (e>0).select(delta*y, y);
note after every multiplication subtract 1 exponents , exit loop when of them 0 or less. since algorithm modifies array of exponents in order keep track of number of multiplications, copy in initialization clause of loop. if fine destroy l
along way, copy omitted.
Comments
Post a Comment