mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Clang-format tests, examples, libraries, benchmarks, etc.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
3252ecc7a4
commit
46e9cdb7fe
@@ -19,17 +19,11 @@ typedef Matrix<SCALAR, Eigen::Dynamic, 1> Vec;
|
||||
|
||||
using namespace std;
|
||||
|
||||
SCALAR E_VDW(const Vec &interactions1, const Vec &interactions2)
|
||||
{
|
||||
return (interactions2.cwise()/interactions1)
|
||||
.cwise().cube()
|
||||
.cwise().square()
|
||||
.cwise().square()
|
||||
.sum();
|
||||
SCALAR E_VDW(const Vec &interactions1, const Vec &interactions2) {
|
||||
return (interactions2.cwise() / interactions1).cwise().cube().cwise().square().cwise().square().sum();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int main() {
|
||||
//
|
||||
// 1 2 3 4 ... (interactions)
|
||||
// ka . . . . ...
|
||||
@@ -40,17 +34,17 @@ int main()
|
||||
// for
|
||||
// interaction)
|
||||
//
|
||||
Vec interactions1(SIZE), interactions2(SIZE); // SIZE is the number of vdw interactions in our system
|
||||
Vec interactions1(SIZE), interactions2(SIZE); // SIZE is the number of vdw interactions in our system
|
||||
// SetupCalculations()
|
||||
SCALAR rab = 1.0;
|
||||
SCALAR rab = 1.0;
|
||||
interactions1.setConstant(2.4);
|
||||
interactions2.setConstant(rab);
|
||||
|
||||
|
||||
// Energy()
|
||||
SCALAR energy = 0.0;
|
||||
for (unsigned int i = 0; i<REPEAT; ++i) {
|
||||
for (unsigned int i = 0; i < REPEAT; ++i) {
|
||||
energy += E_VDW(interactions1, interactions2);
|
||||
energy *= 1 + 1e-20 * i; // prevent compiler from optimizing the loop
|
||||
energy *= 1 + 1e-20 * i; // prevent compiler from optimizing the loop
|
||||
}
|
||||
cout << "energy = " << energy << endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user