aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/vdw_new.cpp
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-07-08 00:49:10 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-07-08 00:49:10 +0000
commitf5791eeb7054b78ded6eb080e9712651da6c6a34 (patch)
tree414c138b050003fdc32e0cebcc6f39ea1e94dc7f /bench/vdw_new.cpp
parentc910c517b34b147894e7fa62cb9602cc19e0669b (diff)
the big Array/Cwise rework as discussed on the mailing list. The new API
can be seen in Eigen/src/Core/Cwise.h.
Diffstat (limited to 'bench/vdw_new.cpp')
-rw-r--r--bench/vdw_new.cpp39
1 files changed, 5 insertions, 34 deletions
diff --git a/bench/vdw_new.cpp b/bench/vdw_new.cpp
index b1237c4c7..a1bd422ae 100644
--- a/bench/vdw_new.cpp
+++ b/bench/vdw_new.cpp
@@ -1,35 +1,5 @@
-#include <Eigen/Core>
+#include <Eigen/Array>
-namespace Eigen {
-
-template<typename Scalar> struct pow12_op EIGEN_EMPTY_STRUCT {
- inline const Scalar operator() (const Scalar& a) const
- {
- Scalar b = a*a*a;
- Scalar c = b*b;
- return c*c;
- }
- template<typename PacketScalar>
- inline const PacketScalar packetOp(const PacketScalar& a) const
- {
- PacketScalar b = ei_pmul(a, ei_pmul(a, a));
- PacketScalar c = ei_pmul(b, b);
- return ei_pmul(c, c);
- }
-};
-
-template<typename Scalar>
-struct ei_functor_traits<pow12_op<Scalar> >
-{
- enum {
- Cost = 4 * NumTraits<Scalar>::MulCost,
- PacketAccess = int(ei_packet_traits<Scalar>::size) > 1
- };
-};
-
-} // namespace Eigen
-
-using Eigen::pow12_op;
USING_PART_OF_NAMESPACE_EIGEN
#ifndef SCALAR
@@ -50,9 +20,10 @@ using namespace std;
SCALAR E_VDW(const Vec &interactions1, const Vec &interactions2)
{
- return interactions2
- .cwiseQuotient(interactions1)
- .cwise(pow12_op<SCALAR>())
+ return (interactions2.cwise()/interactions1)
+ .cwise().cube()
+ .cwise().square()
+ .cwise().square()
.sum();
}