[eigen] array functionality... |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: Eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: [eigen] array functionality...
- From: Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
- Date: Tue, 9 Mar 2010 12:05:42 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=qp2s9/pJ7WmFqOr2TEl3Ht8FOiAxG+ZrcZTnjscVdkQ=; b=ZcujQErYYXcTccBFYczvtbZs2warqDPRYzpgkSUOYqpAr1WSGM9e8WFFJyVG4TOA+V 03I2a9h8t+9tdsbzpD+4aOxuWcSAFkX0LoyQyvO+5jhDVhpKaR9/bq3MFFIXMN/YzJrI AVuotmUELqWkZc0Zx1ses1Nfg4ovqem+sGjr0=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=sa/7b25kUviSH94VlG1BcoAh84hrvw4kG3YVbmdWUWP2kITFPaNnflkfJ+lJJhLCio XpNZviOjHkDWfAbTk5yxPUivt6lHOUkKEXS6eQi9zBgeR9ja/bVptZ8wmscWxqvJW1Uj hlTbgQamJeiYHLiMECALwGKNl8iTHcUtZrq7Y=
Hi,
I want to quickly compute
sum_i alpha_i * std::exp( - gamma * (x - y_i)' * (x - y_i) )
Seems like a good candidate for Array, so I tried
ArrayXXd y;
ArrayXd x;
Array<double,1,Dynamic> alphas;
Array<double,1,Dynamic> norms =
x.replicate(1,y.cols()).colwise().squaredNorm(); // does not work,
needs a .matrix()
double val = (alphas * std::exp( -gamma * norms )).sum(); // does not
seem to be using SSE exp
Is it correct, that SSE exp is currently not used?
What do you think about allowing .colwise().squaredNorm() on arrays?
I need to verify this, but it feels as if the replicate implementation
is currently (at least on MSVC) slower than a hand crafted for loop
like:
for (int i=0; i<size; ++i)
norms(i) = (x - y.col()).matrix().squaredNorm();
Any hints would be welcome.
Regards,
Hauke