// Ewald::FillErfcTable() void Ewald::FillErfcTable(double cutoffIn, double dxdr) { one_over_Dx_ = 1.0 / erfcTableDx_; unsigned int erfcTableSize = (unsigned int)(dxdr * one_over_Dx_ * cutoffIn * 1.5); Darray erfc_X, erfc_Y; erfc_X.reserve( erfcTableSize ); erfc_Y.reserve( erfcTableSize ); // Save X and Y values so we can calc the spline coefficients double xval = 0.0; for (unsigned int i = 0; i != erfcTableSize; i++) { double yval = erfc_func( xval ); erfc_X.push_back( xval ); erfc_Y.push_back( yval ); xval += erfcTableDx_; } Spline cspline; cspline.CubicSpline_Coeff(erfc_X, erfc_Y); erfc_X.clear(); // Store values in Spline table erfc_table_.reserve( erfcTableSize * 4 ); // Y B C D for (unsigned int i = 0; i != erfcTableSize; i++) { erfc_table_.push_back( erfc_Y[i] ); erfc_table_.push_back( cspline.B_coeff()[i] ); erfc_table_.push_back( cspline.C_coeff()[i] ); erfc_table_.push_back( cspline.D_coeff()[i] ); } // Memory saved Y values plus spline B, C, and D coefficient arrays. mprintf("\tMemory used by Erfc table and splines: %s\n", ByteString(erfc_table_.size() * sizeof(double), BYTE_DECIMAL).c_str()); }