|[eigen] How to raise double to array powers in Eigen|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: [eigen] How to raise double to array powers in Eigen
- From: Ian Bell <ian.h.bell@xxxxxxxxx>
- Date: Mon, 18 Aug 2014 00:23:25 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=KldMw5sIclLuEkvfwCWRuAZJNnRJlhVEIE2bx4NY8V8=; b=Ypp/Nh92jcwfVeVlHDRKC3XZuQ+kqOkLM17qoB4DEAeY8DJhMchf4JaayXNsPF/ucS abNSz6MKgySD0r61L9ITaGmybLX3RTQTdLYirfc6xpNnB1SKlkj9rPd1PhQxeY/NNhPi 2hEymIa31Vn9lvFvVF3MIh3AzLPCfyFtD9YECb8qJcMjPRHsQP9XbJU/rQd9BiFrhAbo 9urGXHrzsMmVLbDWrNTISOnbN8lfw1hfbSjAzD7kHijeMZUoNrZoQCZcf/HPchAA+JCK dqiV2RzXmja/b/5ttnuxRQtUd/FOWkQpMrfjg33ULrM1TGl2PrblS16rZcC0Gat8xsjm UGLw==
cross-posted to stack overflow...
I have a very simple problem that should have a simple answer as well, but so far no luck.
I need to raise a double value to an array of integer powers, in c++ this would look something like
for (int i = 0; i < N; ++i)
y[i] = pow(delta, l[i]);
But in Eigen I have tried a number of variants on this theme, without success.
I have an Eigen::ArrayXi l_intE which maps an STL vector l_int.
This doesn't work:
since the pow() function wants an array as the first input, and then to raise the array to a constant power.
One nasty workaround that I was able to get working (this can't be the right way) is to do this:
which does the conversion
pow(delta,L) -> exp(L*log(delta))
and I also have to convert the integers to doubles. This can't help performance either since pow(double, int) is significantly faster than pow(double, double) in general. Although, maybe that isn't true with SSE in Eigen?
Anyway, clarity here would be greatly appreciated.