the big Array/Cwise rework as discussed on the mailing list. The new API

can be seen in Eigen/src/Core/Cwise.h.
This commit is contained in:
Benoit Jacob
2008-07-08 00:49:10 +00:00
parent c910c517b3
commit f5791eeb70
26 changed files with 465 additions and 389 deletions

View File

@@ -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();
}