@@ -78,14 +78,11 @@ Eigen::Matrix4Xf readPqr(const std::string &fName)
78
78
79
79
float checksum (const Grid3D &grid)
80
80
{
81
- float sum = grid.discStep * grid.grid .size ();
82
- for (int i = 0 ; i < 3 ; ++i) {
83
- sum += grid.originXYZ [i] + grid.shape [i];
84
- }
85
- for (const float &v : grid.grid ) {
86
- sum += v;
87
- }
88
- return sum;
81
+ using std::accumulate;
82
+ return grid.discStep * grid.grid .size ()
83
+ + accumulate (grid.originXYZ .begin (), grid.originXYZ .end (), 0 .0f )
84
+ + accumulate (grid.shape .begin (), grid.shape .end (), 0 )
85
+ + accumulate (grid.grid .begin (), grid.grid .end (), 0 .0f );
89
86
}
90
87
91
88
void printDistanceHist (const std::vector<float > &distances)
@@ -138,7 +135,6 @@ int main()
138
135
atoms.col (iat) = atoms.col (10 );
139
136
}
140
137
141
-
142
138
/* atoms= readPqr("short_helix.pqr");
143
139
atoms(3, 56) = 0.0f; //remove the attachment atom itself
144
140
source = atoms.col(56).head<3>();*/
@@ -152,7 +148,7 @@ int main()
152
148
Grid3D grid = minLinkerLength (atoms, source, linkerL, linkerD, dyeR,
153
149
discStep);
154
150
// savePqr("testMinL.pqr", grid);
155
- if (fabs (checksum (grid) - 667073 . 62500f ) > 0 .00001f ) {
151
+ if (fabs (checksum (grid) - 667076 . 87500f ) > 0 .00001f ) {
156
152
cout << " minLinkerLength() produced an unexpected result\n " ;
157
153
cout << " checksum = " << std::setprecision (5 ) << std::fixed
158
154
<< checksum (grid) << endl;
@@ -167,7 +163,7 @@ int main()
167
163
cout << " AV1 calculation took: " << dtMs << " ms" << endl;
168
164
// savePqr("testDensityAV1.pqr", grid);
169
165
170
- if (fabs (checksum (grid) - 50183 . 00000f ) > 0 .00001f ) {
166
+ if (fabs (checksum (grid) - 50182 . 99219f ) > 0 .00001f ) {
171
167
cout << " dyeDensity() AV1 produced an unexpected result\n " ;
172
168
cout << " checksum = " << std::setprecision (5 ) << std::fixed
173
169
<< checksum (grid) << endl;
@@ -194,7 +190,7 @@ int main()
194
190
// Takes 16 ms on a Core i7-4930K CPU
195
191
cout << " AV3 calculation took: " << dtMs << " ms" << endl;
196
192
// savePqr("testDensityAV3.pqr", grid);
197
- if (fabs (checksum (grid) - 49989 . 75391f ) > 0 .00001f ) {
193
+ if (fabs (checksum (grid) - 49991 . 96094f ) > 0 .00001f ) {
198
194
cout << " dyeDensity() AV3 produced an unexpected result\n " ;
199
195
cout << " checksum = " << std::setprecision (5 ) << std::fixed
200
196
<< checksum (grid) << endl;
@@ -216,7 +212,7 @@ int main()
216
212
// Takes 4.5 ms on a Core i7-4930K CPU
217
213
cout << " addWeights took: " << dtMs << " ms " << endl;
218
214
// savePqr("testContactDensityAV3.pqr", grid);
219
- if (fabs (checksum (grid) - 117905 . 71875f ) > 0 .00001f ) {
215
+ if (fabs (checksum (grid) - 117907 . 15625f ) > 0 .00001f ) {
220
216
cout << " addWeights() produced an unexpected result\n " ;
221
217
cout << " checksum = " << std::setprecision (5 ) << std::fixed
222
218
<< checksum (grid) << endl;
0 commit comments