mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user